# you must go through a second phase of expansion. The $$ defers expansion
# until the second phase. Single $ can be expanded on the first phase.
.SECONDEXPANSION:
-$(builddirs): $$(patsubst $(SRC_DIR)%.md, $(BUILD_DIR)%, $$(shell find -L $$(patsubst $(BUILD_DIR)%, $(SRC_DIR)%, $$@) -name '*.md'))
+$(builddirs): $$(patsubst $(SRC_DIR)%.md, $(BUILD_DIR)%.html, $$(shell find -L $$(patsubst $(BUILD_DIR)%, $(SRC_DIR)%, $$@) -name '*.md'))
# For a given md file in src, make the corresponding html in build.
-$(BUILD_DIR)/%: $(SRC_DIR)/%.md
+$(BUILD_DIR)/%.html: $(SRC_DIR)/%.md
@mkdir -p $(dir $@)
@pandoc \
--to=html5 \
--standalone \
--defaults=./defaults.yml \
- --output=$@ $<
+ --output=$@ $< \
+ --lua-filter=scripts/links-to-html.lua
@echo "Building $@ from $<..."
# Clean up generated HTML files
--- /dev/null
+-- links-to-html.lua
+-- From https://stackoverflow.com/a/49396058
+function Link(el)
+ el.target = string.gsub(el.target, "%.md", ".html")
+ return el
+end
\ No newline at end of file