...
 
Commits (2)
  • Emanuele Aina's avatar
    hotdoc-html-2-pdf: Set up fonts to better handle unicode data · 7da77bb9
    Emanuele Aina authored
    It's 2019 and *TeX still lacks proper glyph fallback, so we get the following
    errors on `make pdf`:
    
        ./hotdoc-html-2-pdf build/html/appdev-debugging.html build/pdf/appdev-debugging.pdf --remote-prefix "https://developer.apertis.org" --line-numbers
        [WARNING] Missing character: There is no ▸ in font [lmmono10-regular]:!
        [WARNING] Missing character: There is no ▸ in font [lmmono10-regular]:!
        ./hotdoc-html-2-pdf build/html/programming-guide-tooling.html build/pdf/programming-guide-tooling.pdf --remote-prefix "https://developer.apertis.org" --line-numbers
        [WARNING] Missing character: There is no 李 in font [lmmono10-regular]:!
        [WARNING] Missing character: There is no 健 in font [lmmono10-regular]:!
        [WARNING] Missing character: There is no 秋 in font [lmmono10-regular]:!
        ./hotdoc-html-2-pdf build/html/vm-config.html build/pdf/vm-config.pdf --remote-prefix "https://developer.apertis.org" --line-numbers
        [WARNING] Missing character: There is no ▸ in font [lmmono10-regular]:!
        ./hotdoc-html-2-pdf build/html/vm-management.html build/pdf/vm-management.pdf --remote-prefix "https://developer.apertis.org" --line-numbers
        [WARNING] Missing character: There is no ▸ in font [lmmono10-regular]:!
        [WARNING] Missing character: There is no ▸ in font [lmmono10-regular]:!
        ./hotdoc-html-2-pdf build/html/vm-setup.html build/pdf/vm-setup.pdf --remote-prefix "https://developer.apertis.org" --line-numbers
        [WARNING] Missing character: There is no ▸ in font [lmmono10-regular]:!
        [WARNING] Missing character: There is no ▸ in font [lmmono10-regular]:!
    
    Address those by:
    * setting up a CJK font so we don't erase team members
    * setting up a monospace font which has large Unicode coverage without
      requiring fallbacks, so a `▸` in a code snippets doesn't end up in a
      unrendered character
    Signed-off-by: Emanuele Aina's avatarEmanuele Aina <emanuele.aina@collabora.com>
    7da77bb9
  • Emanuele Aina's avatar
    hotdoc-html-2-pdf: Keep links clickable · ee927fcb
    Emanuele Aina authored
    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 <emanuele.aina@collabora.com>
    ee927fcb
......@@ -145,8 +145,13 @@ 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, 'pandoc-add-link-footnotes.py'),
'--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
'--variable', 'monofont=FreeMono', # has a good Unicode coverage without requiring fallbacks
'--variable', 'monofontoptions=Scale=0.75', # make the very wide FreeMono font a bit smaller
'--include-in-header='+os.path.join(latex_dir, 'apertis_logo.latex')]
if args.line_numbers:
......
#!/usr/bin/python3
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 <http://example.com>; 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__":
toJSONFilter(footnotify)