summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKévin Le Gouguec <kevin.legouguec@gmail.com>2020-04-29 00:40:14 +0200
committerKévin Le Gouguec <kevin.legouguec@gmail.com>2020-04-29 00:40:14 +0200
commita4401b352150205d2f6ee7e3dc99c1145e399c60 (patch)
tree92829d81f4eda39f02f248c6ac87d0db5f7f76ef
parent23685fe090d986d3322903a003b91f7b1dfd1a3a (diff)
downloadmemory-leaks-a4401b352150205d2f6ee7e3dc99c1145e399c60.tar.xz
Fix links to internal pages
Replace .md/.org extension with .html. The output of "make" is now ugly as sin.
-rw-r--r--repo/www/Makefile6
-rw-r--r--repo/www/TODO1
-rw-r--r--repo/www/convert-internal-links.lua21
-rwxr-xr-xrepo/www/generate-index.py5
4 files changed, 30 insertions, 3 deletions
diff --git a/repo/www/Makefile b/repo/www/Makefile
index cdc7ee2..db656f2 100644
--- a/repo/www/Makefile
+++ b/repo/www/Makefile
@@ -43,7 +43,10 @@ $(html_folders) $(cache):
$(pages) $(subindices): $(title)
$(pages): $(OUT_DIR)/%.html:
- pandoc -s $< -o $@ -T "$$(cat $(title))" -M title="$*"
+ TEXT_FILES="$(TEXT_FILES)" \
+ pandoc -s $< -o $@ \
+ -T "$$(cat $(title))" -M title="$*" \
+ --lua-filter convert-internal-links.lua
top_index = $(OUT_DIR)/index.html
subindices = $(filter-out $(top_index),$(indices))
@@ -54,6 +57,7 @@ $(subindices): index_options = --site-title="$$(cat $(title))"
# ⚠ When tweaking this rule, check whether it still works for the
# top-level index.html.
$(indices): $(OUT_DIR)/%index.html:
+ TEXT_FILES="$(TEXT_FILES)" \
./generate-index.py $(index_options) $(site_tree) "$(patsubst %/,%,$*)" $@
clean:
diff --git a/repo/www/TODO b/repo/www/TODO
index 4ac72db..dd1e670 100644
--- a/repo/www/TODO
+++ b/repo/www/TODO
@@ -1,5 +1,4 @@
- compute "leak count" on toplevel index
-- lua filter to s/.md/.html on links
- autogenerate nav
- autogenerate breadcrumbs
- get stylin'
diff --git a/repo/www/convert-internal-links.lua b/repo/www/convert-internal-links.lua
new file mode 100644
index 0000000..b0817dd
--- /dev/null
+++ b/repo/www/convert-internal-links.lua
@@ -0,0 +1,21 @@
+EXTENSIONS = {}
+
+string.gsub(
+ os.getenv("TEXT_FILES"),
+ "[^%s]+",
+ function (ext) EXTENSIONS[#EXTENSIONS+1] = ext end
+)
+
+function Link(link)
+ if link.target:match("^[%w]+://")
+ then
+ return link
+ end
+
+ for _, ext in pairs(EXTENSIONS)
+ do
+ link.target = link.target:gsub("%."..ext.."$", ".html")
+ end
+
+ return link
+end
diff --git a/repo/www/generate-index.py b/repo/www/generate-index.py
index 1fb00e6..4353819 100755
--- a/repo/www/generate-index.py
+++ b/repo/www/generate-index.py
@@ -97,7 +97,10 @@ def format_index(target, directories, files):
def convert_page(content, output, site_title):
- pandoc = ('pandoc', '-s', '-o', output)
+ pandoc = (
+ 'pandoc', '-s', '--lua-filter', 'convert-internal-links.lua',
+ '-o', output
+ )
if site_title is not None:
pandoc += ('-T', site_title)