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