Skip to content

Commit

Permalink
Fix internal links in EPUB. Added a few .md files
Browse files Browse the repository at this point in the history
  • Loading branch information
johanwiden committed Sep 2, 2022
1 parent 69264a3 commit 355e57e
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 5 deletions.
76 changes: 76 additions & 0 deletions fix-epub-links.sed
@@ -0,0 +1,76 @@
# sed script to change internal links in markdown file,
# to links pandoc can use when generating EPUB from markdown.
# Currently, the transformed links do not work in the web server,
# so the script should change a file that is not used in the web server.
# Usage:
# sed -i -f fix-epub-links.sed full.md
# Note:
# The links with format like (#numbers), are there for a reason.
# The (#foo) format is used when the [foo] format is ambiguous.
#
# arrays.md
s/\(\[\(Arrays and vectors\)\]\)(data-structures.html)/\1[\2]/
# databases.md
s/\(\[CLOS\]\)(clos.html)/\1[Fundamentals of CLOS]/
s/\(\[clos\]\)(clos.html)/\1[Fundamentals of CLOS]/
# data-structures.md
s/\(\[pattern matching\]\)(pattern_matching.html)/\1[Pattern Matching]/
s/\(\[strings\]\)(strings.html)/\1(#strings)/
s/\(\[CLOS section\]\)(clos.html)/\1[Fundamentals of CLOS]/
# debugging.md
s/\(\[error handling\]\)(error_handling.html)/\1[Error and exception handling]/
s/\(\[testing\]\)(testing.html)/\1[Testing the code]/
# editor-support.md
s/\(\["\(Using Emacs as an IDE\)"\]\)(emacs-ide.html)/\1[\2]/
s/\(\[\(Using VSCode with Alive\)\]\)(vscode-alive.html)/\1[\2]/
s/\(\[read our LispWorks review here\]\)(lispworks.html)/\1[LispWorks review]/
# error_handling.md
s/\(\[debugging section\]\)(debugging.html)/\1[Debugging]/
# getting-started.md
s/\(\[editor-support\]\)(editor-support.html)/\1[Editor support]/
# index.md
s/\(\[\(License\)\]\)(license.html)/\1[\2]/
s/\(\[Getting started\]\)(getting-started.html)/\1[Getting started with Common Lisp]/
s/\(\[\(Editor support\)\]\)(editor-support.html)/\1[\2]/
s/\(\[\(Using Emacs as an IDE\)\]\)(emacs-ide.html)/\1[\2]/
s/\(\[The LispWorks IDE\]\)(lispworks.html)/\1[LispWorks review]/
s/\(\[Functions\]\)(functions.html)/\1(#functions)/
s/\(\[Data Structures\]\)(data-structures.html)/\1[Data structures]/
s/\(\[Strings\]\)(strings.html)/\1(#strings)/
s/\(\[\(Regular Expressions\)\]\)(regexp.html)/\1[\2]/
s/\(\[Numbers\]\)(numbers.html)/\1(#numbers)/
s/\(\[Loops, iteration, mapping\]\)(iteration.html)/\1[Loop, iteration, mapping]/
s/\(\[Multidimensional Arrays\]\)(arrays.html)/\1[Multidimensional arrays]/
s/\(\[\(Dates and Times\)\]\)(dates_and_times.html)/\1[\2]/
s/\(\[\(Pattern Matching\)\]\)(pattern_matching.html)/\1[\2]/
s/\(\[\(Input\/Output\)\]\)(io.html)/\1[\2]/
s/\(\[\(Files and Directories\)\]\)(files.html)/\1[\2]/
s/\(\[Error and condition handling\]\)(error_handling.html)/\1[Error and exception handling]/
s/\(\[\(Packages\)\]\)(packages.html)/\1[\2]/
s/\(\[Macros and Backquote\]\)(macros.html)/\1[Macros]/
s/\(\[CLOS (the Common Lisp Object System)\]\)(clos.html)/\1[Fundamentals of CLOS]/
s/\(\[\(Type System\)\]\)(type.html)/\1[\2]/
s/\(\[Sockets\]\)(sockets.html)/\1[TCP\/UDP programming with sockets]/
s/\(\[\(Interfacing with your OS\)\]\)(os.html)/\1[\2]/
s/\(\[\(Foreign Function Interfaces\)\]\)(ffi.html)/\1[\2]/
s/\(\[\(Threads\)\]\)(process.html)/\1[\2]/
s/\(\[\(Defining Systems\)\]\)(systems.html)/\1[\2]/
s/\(\[\(Using the Win32 API\)\]\)(win32.html)/\1[\2]/
s/\(\[\(Debugging\)\]\)(debugging.html)/\1[\2]/
s/\(\[Performance Tuning\]\)(performance.html)/\1[Performance Tuning and Tips]/
s/\(\[Scripting. Building executables\]\)(scripting.html)/\1[Scripting. Command line arguments. Executables.]/
s/\(\[Testing and Continuous Integration\]\)(testing.html)/\1[Testing the code]/
s/\(\[Databases\]\)(databases.html)/\1[Database Access and Persistence]/
s/\(\[GUI programming\]\)(gui.html)/\1[GUI toolkits]/
s/\(\[\(Web development\)\]\)(web.html)/\1[\2]/
s/\(\[\(Web Scraping\)\]\)(web-scraping.html)/\1[\2]/
s/\(\[\(WebSockets\)\]\)(websockets.html)/\1[\2]/
s/\(\[\(Miscellaneous\)\]\)(misc.html)/\1[\2]/
# iteration.md
s/\(\[data-structures chapter\]\)(data-structures.html)/\1[Data structures]/
# scripting.md
s/\(\[error and condition handling\]\)(error_handling.html)/\1[Error and exception handling]/
# strings.md
s/\(\[regexp\]\)(regexp.html)/\1[Regular Expressions]/
# web.md
s/\(\[databases section\]\)(databases.html)/\1[Database Access and Persistence]/
2 changes: 1 addition & 1 deletion getting-started.md
@@ -1,5 +1,5 @@
---
title: Getting started
title: Getting started with Common Lisp
---

We'll begin with presenting easy steps to install a development environment and to start a new Common Lisp project.
Expand Down
2 changes: 1 addition & 1 deletion lispworks.md
@@ -1,5 +1,5 @@
---
title: LispWorks
title: LispWorks review
---

[LispWorks](http://www.lispworks.com/) is a Common Lisp implementation that
Expand Down
9 changes: 7 additions & 2 deletions make-cookbook.lisp
Expand Up @@ -12,6 +12,8 @@

(defparameter chapters
(list
"index.md"
"license.md"
"foreword.md"
"getting-started.md"
"editor-support.md"
Expand All @@ -36,9 +38,10 @@
"type.md"
"sockets.md"
"os.md"
"ffi.md"
"process.md"
"systems.md"
;; "win32.md"
"win32.md"
"debugging.md"
"performance.md"
"scripting.md"
Expand All @@ -48,7 +51,7 @@
"web.md"
"web-scraping.md"
"websockets.md"
;; "misc.md"
"misc.md"
;; "awesome-cl.md"
"contributors.md"
))
Expand All @@ -68,6 +71,8 @@
(uiop:run-program (format nil "sed -i \"s/---/ /g\" ~a" *full-markdown*))
;; Exclude regions that don't export correctly, like embedded videos.
(uiop:run-program (format nil "sed -i \"/<\!-- epub-exclude-start -->/,/<\!-- epub-exclude-end -->/d\" ~a" *full-markdown*))
;; Make internal links work in the generated EPUB.
(uiop:run-program (format nil "sed -i -f fix-epub-links.sed ~a" *full-markdown*))
)

(defun to-epub ()
Expand Down
2 changes: 1 addition & 1 deletion testing.md
@@ -1,5 +1,5 @@
---
title: Testing
title: Testing the code
---

So you want to easily test the code you're writing? The following
Expand Down

0 comments on commit 355e57e

Please sign in to comment.