'--domfilters',
help='Which DOM filters to use (default: %(default)s)',
default=','.join(f[0] for f in DOMFilters))
+ parser.add_argument(
+ '--geometry',
+ help='''Page size and margin control
+See https://faculty.bard.edu/bloch/geometry.pdf for details
+(default: %(default)s)''',
+ default='paperwidth=5.5in,paperheight=8.5in,nohead,' +
+ 'tmargin=15mm,hmargin=15mm,bmargin=17mm,foot=4mm')
parser.add_argument(
'--htmlfilters',
help='Which HTML filters to use (default: %(default)s)',
lambda x: ApplyHTMLFilters(args.htmlfilters, x),
lambda x: ApplyDOMFilters(args.domfilters, x),
PandocTexifier(args.pandoc or 'pandoc'),
+ args.geometry,
texout)
def process(spec: Spec) -> None:
- spec.texout.write(b'\\documentclass{article}\n\\begin{document}\n')
+ spec.texout.write(b'\\documentclass{article}\n')
+ if spec.geometry is not None:
+ spec.texout.write(b'\\usepackage[' +
+ spec.geometry.encode('UTF-8') +
+ b']{geometry}\n')
+ spec.texout.write(b'\\begin{document}\n')
html = parse(spec.htmlfilter(spec.fetcher.fetch(spec.url)))
for r in replies(html):
spec.domfilter(r)
lambda x: x,
lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
PandocTexifier('pandoc'),
+ 'margin=20mm',
buf)
paperdoorknob.process(spec)
assert buf.getvalue() == b'''\\documentclass{article}
+\\usepackage[margin=20mm]{geometry}
\\begin{document}
This is glowfic
You \\emph{sure}?
lambda x: x,
lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
texifier,
+ None,
buf)
paperdoorknob.process(spec)
lambda x: x,
lambda x: ApplyDOMFilters('NoEdit,NoFooter', x),
PandocTexifier('pandoc'),
+ None,
out)
paperdoorknob.process(spec)
subprocess.run(['pdflatex', 'test.tex'],
htmlfilter: Callable[[bytes], bytes]
domfilter: Callable[[Tag], None]
texifier: Texifier
+ geometry: str | None
texout: IO[bytes]