Commit ee927fcb authored by Emanuele Aina's avatar Emanuele Aina Committed by Peter Senna Tschudin

hotdoc-html-2-pdf: Keep links clickable

The `links-as-notes=true` option has the undesiderable effect of making links
in the text not clickable.

Use a pandoc filter to keep links clickable and also add a footnote with the
URL, useful in case the document is printed.
Signed-off-by: Emanuele Aina's avatarEmanuele Aina <>
parent 7da77bb9
......@@ -145,7 +145,8 @@ def write(args, output):
raise e
cmd = ['/usr/bin/pandoc', tmp_path, '-V documentclass=article',
'--variable', 'links-as-notes=true',
'--variable', 'urlcolor=NavyBlue',
'--filter', os.path.join(program_dir, ''),
'--pdf-engine=xelatex', '--toc', '-o', args.output,
# because it's 2019 and the TeX engines still have no glyph fallback
'--variable', 'CJKmainfont=Noto Serif CJK KR', # this one seems a fair bet
import sys
from pandocfilters import toJSONFilter, Para, Link, Note, Str, stringify
def footnotify(key, value, format_, meta):
For each link add a footnote with the link URL, useful when the document is printed.
if key == "Link":
_, txt, (url, title_text) = value
empty_attrs = ["", [], []]
# Ignore bare links like <>; otherwise we run into a
# recursive problem where Pandoc tries to apply this same filter to the
# new link in the footnote. Also ignore URLs that begin with "#", since
# those point to sections within the document.
if stringify(txt) != url and not url.startswith("#"):
empty_attrs = ["", [], []]
footnote_link = Link(empty_attrs, [Str(url)], [url, ""])
return [Link(*value), Note([Para([footnote_link])])]
if __name__ == "__main__":
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment