memory-leaks

Still reachable: lots of words in many pages.
git clone https://git.kevinlegouguec.net/memory-leaks
Log | Files | Refs | README | LICENSE

commit a4401b352150205d2f6ee7e3dc99c1145e399c60
parent 23685fe090d986d3322903a003b91f7b1dfd1a3a
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Wed, 29 Apr 2020 00:40:14 +0200

Fix links to internal pages

Replace .md/.org extension with .html.

The output of "make" is now ugly as sin.

Diffstat:
Mrepo/www/Makefile | 6+++++-
Mrepo/www/TODO | 1-
Arepo/www/convert-internal-links.lua | 21+++++++++++++++++++++
Mrepo/www/generate-index.py | 5++++-
4 files changed, 30 insertions(+), 3 deletions(-)

diff --git 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 @@ -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 @@ -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 @@ -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)