memory-leaks

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

commit b5205f3253e745083f55f40f4a5e64cb2da39aac
parent 205b6d12ff5673bd8ae59f827f07b69771b9dfee
Author: Kévin Le Gouguec <kevin.legouguec@gmail.com>
Date:   Tue, 18 Aug 2020 22:30:19 +0200

Pass filters to generation scripts explicitly

Diffstat:
Mrepo/www/Makefile | 3+++
Mrepo/www/generate-index.py | 6+++++-
Mrepo/www/generate-page.py | 5+++++
Mrepo/www/helpers.py | 5+++--
4 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/repo/www/Makefile b/repo/www/Makefile @@ -14,6 +14,7 @@ text_patterns = $(foreach ext,$(TEXT_FILES),'$(TOP_DIR)/**.$(ext)') text_folders = $(call dirnames,$(shell git ls-files $(text_patterns))) top_readme = $(shell git ls-files $(addprefix $(TOP_DIR)/README.,$(TEXT_FILES))) html_template = template.html +lua_filters = convert-internal-links.lua all: site @@ -53,6 +54,7 @@ $(pages) $(indices): $(html_template) $(pages): $(OUT_DIR)/%.html: $(call v,PAGE,$*) TEXT_FILES="$(TEXT_FILES)" \ ./generate-page.py --site-title="$$(cat $(title))" --title="$*" \ + $(foreach f,$(lua_filters),--lua-filter $(f)) \ --template=$(html_template) $< $@ top_index = $(OUT_DIR)/index.html @@ -66,6 +68,7 @@ $(subindices): index_options = --site-title="$$(cat $(title))" $(indices): $(OUT_DIR)/%index.html: $(call v,INDEX,$*) TEXT_FILES="$(TEXT_FILES)" \ ./generate-index.py $(index_options) --template=$(html_template) \ + $(foreach f,$(lua_filters),--lua-filter $(f)) \ $(site_tree) "$(patsubst %/,%,$*)" $@ clean: diff --git a/repo/www/generate-index.py b/repo/www/generate-index.py @@ -21,6 +21,10 @@ def parse_arguments(): '--site-title', help='Prefix to add to <title>.' ) parser.add_argument( + '--lua-filter', dest='filters', action='append', + help='Lua filter to run the page through.' + ) + parser.add_argument( 'site_tree', help='JSON file describing the page tree.' ) parser.add_argument( @@ -111,7 +115,7 @@ def main(arguments): page.flush() pandoc(page.name, arguments.output, arguments.template, - site_title=arguments.site_title) + arguments.filters, site_title=arguments.site_title) if __name__ == '__main__': diff --git a/repo/www/generate-page.py b/repo/www/generate-page.py @@ -14,6 +14,10 @@ def parse_arguments(): '--site-title', help='Prefix to add to <title>.' ) parser.add_argument( + '--lua-filter', dest='filters', action='append', + help='Lua filter to run the page through.' + ) + parser.add_argument( '--title', help='Page title.' ) parser.add_argument( @@ -30,6 +34,7 @@ def main(arguments): arguments.page, arguments.output, arguments.template, + arguments.filters, title=arguments.title, site_title=arguments.site_title ) diff --git a/repo/www/helpers.py b/repo/www/helpers.py @@ -1,5 +1,6 @@ from collections import defaultdict from dataclasses import dataclass, field +from itertools import chain from os import path from subprocess import run from typing import Iterator @@ -55,10 +56,10 @@ def deserialize_directories(directories): } -def pandoc(page, output, template, title=None, site_title=None): +def pandoc(page, output, template, filters, title=None, site_title=None): cmd = ( 'pandoc', '-s', page, '-o', output, '--template', template, - '--lua-filter', 'convert-internal-links.lua' + *chain(*(('--lua-filter', f) for f in filters)) ) if title is not None: