mirror of https://github.com/tildeclub/site
Generate plain text versions of wiki articles, with links in footnotes
This commit is contained in:
parent
6ae86fb2a6
commit
8036feee67
|
@ -1 +1,2 @@
|
|||
*.html
|
||||
*.txt
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
SRC_MD_FILES != find source -name '*.md'
|
||||
DST_HTML_FILES := $(SRC_MD_FILES:source/%.md=%.html)
|
||||
|
||||
DST_TXT_FILES := $(SRC_MD_FILES:source/%.md=%.txt)
|
||||
PANDOC != command -v pandoc 2> /dev/null
|
||||
PHP != command -v php 2> /dev/null
|
||||
|
||||
all: dep-pandoc $(DST_HTML_FILES) index
|
||||
all: dep-pandoc $(DST_HTML_FILES) $(DST_TXT_FILES) index
|
||||
|
||||
index: dep-php index.html
|
||||
%.html: %.php
|
||||
|
@ -24,9 +24,20 @@ index: dep-php index.html
|
|||
--output $@ \
|
||||
$<
|
||||
|
||||
%.txt: source/%.md link_footnote.lua
|
||||
$(info building $@)
|
||||
@$(PANDOC) \
|
||||
--from markdown+backtick_code_blocks \
|
||||
--to plain \
|
||||
--lua-filter ./link_footnote.lua \
|
||||
--standalone \
|
||||
--output $@ \
|
||||
$<
|
||||
|
||||
clean:
|
||||
$(info removing generated files)
|
||||
-rm $(DST_HTML_FILES)
|
||||
-rm $(DST_TXT_FILES)
|
||||
|
||||
dep-pandoc::
|
||||
ifndef PANDOC
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
links = {}
|
||||
|
||||
function Link (el)
|
||||
table.insert(links,
|
||||
pandoc.Para({
|
||||
pandoc.Str("[" .. (#links + 1) .. "]"),
|
||||
pandoc.Space(),
|
||||
pandoc.Str(el.target),
|
||||
})
|
||||
)
|
||||
table.insert(el.content, pandoc.Str("[" .. #links .. "]"))
|
||||
return el.content
|
||||
end
|
||||
|
||||
function Pandoc (doc)
|
||||
table.insert(doc.blocks, pandoc.Div(links))
|
||||
return pandoc.Pandoc(doc.blocks, doc.meta)
|
||||
end
|
Loading…
Reference in New Issue