1 # paperdoorknob: Print glowfic
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.
8 from bs4
import BeautifulSoup
10 from args
import spec_from_commandline_args
11 from glowfic
import chunkDOMs
15 def parse(content
: bytes) -> BeautifulSoup
:
16 return BeautifulSoup(content
, 'html.parser')
19 def process(spec
: Spec
) -> None:
20 spec
.texout
.write(b
'\\documentclass{article}\n\\usepackage{wrapfig}\n')
21 if spec
.geometry
is not None:
22 spec
.texout
.write(b
'\\usepackage[' +
23 spec
.geometry
.encode('UTF-8') +
25 spec
.texout
.write(b
'\\begin{document}\n')
26 html
= parse(spec
.htmlfilter(spec
.fetcher
.fetch(spec
.url
)))
27 for r
in chunkDOMs(html
):
29 spec
.texout
.write(spec
.texifier
.texify(r
))
30 spec
.texout
.write(b
'\\end{document}\n')
34 with spec_from_commandline_args() as spec
:
38 if __name__
== '__main__':