]> git.scottworley.com Git - paperdoorknob/blame - paperdoorknob.py
Move per-thread processing stuff into Thread
[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
SW
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}
d2a41ff4 20''')
e10b5b6f 21 if spec.geometry is not None:
67612898 22 spec.texout.write(br'\usepackage[' +
e10b5b6f
SW
23 spec.geometry.encode('UTF-8') +
24 b']{geometry}\n')
67612898
SW
25 spec.texout.write(br'''\begin{document}
26\newcommand{\href}[2]{#2\footnote{\detokenize{#1}}}
9afdb32a 27\def\glowiconsize{%fmm}
5f230208
SW
28\newcommand{\glowicon}[1]{\includegraphics[
29 width=\glowiconsize,height=\glowiconsize,keepaspectratio
30]{#1}}
1fac41bf
SW
31\newcommand{\ifnotempty}[2]{\expandafter\ifx\expandafter\relax
32 \detokenize{#1}\relax\else #2\fi}
33%s
34''' % (spec.icon_size, spec.layout))
24b87bad 35 Thread(spec).emit()
23f31879 36 spec.texout.write(b'\\end{document}\n')
47cfa3cd
SW
37
38
92b11a10 39def main() -> None:
23f31879
SW
40 with spec_from_commandline_args() as spec:
41 process(spec)
92b11a10
SW
42
43
44if __name__ == '__main__':
45 main()