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
, flatURL
, makeChunk
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}
21 \\usepackage{booktabs}
22 \\usepackage{graphicx}
23 \\usepackage{longtable}
25 \\usepackage{varwidth}
26 \\usepackage{wrapstuff}
28 if spec
.geometry
is not None:
29 spec
.texout
.write(b
'\\usepackage[' +
30 spec
.geometry
.encode('UTF-8') +
32 spec
.texout
.write(b
'\\begin{document}\n')
33 url
= flatURL(spec
.url
)
34 html
= parse(spec
.htmlfilter(spec
.fetcher
.fetch(url
)))
35 for r
in chunkDOMs(html
):
37 chunk
= makeChunk(r
, spec
.images
)
38 spec
.texout
.write(spec
.texfilter(spec
.layout
.renderChunk(chunk
)))
39 spec
.texout
.write(b
'\\end{document}\n')
43 with spec_from_commandline_args() as spec
:
47 if __name__
== '__main__':