]> git.scottworley.com Git - paperdoorknob/blob - paperdoorknob.py
Handle Unicode characters ≈ and ◁
[paperdoorknob] / paperdoorknob.py
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
7 from args import spec_from_commandline_args
8 from glowfic import Thread
9 from spec import Spec
10
11
12 def process(spec: Spec) -> None:
13 spec.texout.write(br'''\documentclass{article}
14 \usepackage{amssymb}
15 \usepackage{booktabs}
16 \usepackage{graphicx}
17 \usepackage{longtable}
18 \usepackage{soul}
19 \usepackage{varwidth}
20 \usepackage{wrapstuff}
21 ''')
22 if spec.geometry is not None:
23 spec.texout.write(br'\usepackage[' +
24 spec.geometry.encode('UTF-8') +
25 b']{geometry}\n')
26 spec.texout.write(br'''\begin{document}
27 \newcommand{\href}[2]{#2\footnote{\detokenize{#1}}}
28 \def\glowiconsize{%fmm}
29 \newcommand{\glowicon}[1]{\includegraphics[
30 width=\glowiconsize,height=\glowiconsize,keepaspectratio
31 ]{#1}}
32 \newcommand{\ifnotempty}[2]{\expandafter\ifx\expandafter\relax
33 \detokenize{#1}\relax\else #2\fi}
34 %s
35 ''' % (spec.icon_size, spec.layout))
36 Thread(spec).emit()
37 spec.texout.write(b'\\end{document}\n')
38
39
40 def main() -> None:
41 with spec_from_commandline_args() as spec:
42 process(spec)
43
44
45 if __name__ == '__main__':
46 main()