]> git.scottworley.com Git - paperdoorknob/blame - paperdoorknob.py
Handle Unicode characters ≈ and ◁
[paperdoorknob] / paperdoorknob.py
CommitLineData
92b11a10
SW
1# paperdoorknob: Print glowfic
2#
3# This program is free software: you can redistribute it and/or modify it
4# under the terms of the GNU General Public License as published by the
5# Free Software Foundation, version 3.
6
23f31879 7from args import spec_from_commandline_args
24b87bad 8from glowfic import Thread
23f31879 9from spec import Spec
92b11a10
SW
10
11
23f31879 12def process(spec: Spec) -> None:
67612898 13 spec.texout.write(br'''\documentclass{article}
30b145cc 14\usepackage{amssymb}
67612898
SW
15\usepackage{booktabs}
16\usepackage{graphicx}
17\usepackage{longtable}
18\usepackage{soul}
19\usepackage{varwidth}
20\usepackage{wrapstuff}
d2a41ff4 21''')
e10b5b6f 22 if spec.geometry is not None:
67612898 23 spec.texout.write(br'\usepackage[' +
e10b5b6f
SW
24 spec.geometry.encode('UTF-8') +
25 b']{geometry}\n')
67612898
SW
26 spec.texout.write(br'''\begin{document}
27\newcommand{\href}[2]{#2\footnote{\detokenize{#1}}}
9afdb32a 28\def\glowiconsize{%fmm}
5f230208
SW
29\newcommand{\glowicon}[1]{\includegraphics[
30 width=\glowiconsize,height=\glowiconsize,keepaspectratio
31]{#1}}
1fac41bf
SW
32\newcommand{\ifnotempty}[2]{\expandafter\ifx\expandafter\relax
33 \detokenize{#1}\relax\else #2\fi}
34%s
35''' % (spec.icon_size, spec.layout))
24b87bad 36 Thread(spec).emit()
23f31879 37 spec.texout.write(b'\\end{document}\n')
47cfa3cd
SW
38
39
92b11a10 40def main() -> None:
23f31879
SW
41 with spec_from_commandline_args() as spec:
42 process(spec)
92b11a10
SW
43
44
45if __name__ == '__main__':
46 main()