X-Git-Url: http://git.scottworley.com/paperdoorknob/blobdiff_plain/c594c8bf593ab97e863827b7a22f2148bcb174b6..62043b2bafbcb57beae7559235bd6984b6275b55:/paperdoorknob.py diff --git a/paperdoorknob.py b/paperdoorknob.py index 4e7cdf6..72ec1a5 100644 --- a/paperdoorknob.py +++ b/paperdoorknob.py @@ -34,11 +34,17 @@ def process(spec: Spec) -> None: spec.texout.write(b'\\usepackage[' + spec.geometry.encode('UTF-8') + b']{geometry}\n') - spec.texout.write(b'\\begin{document}\n') + spec.texout.write(b'''\\begin{document} +\\newcommand{\\href}[2]{#2\\footnote{\\detokenize{#1}}} +''') url = flatURL(spec.url) - html = parse(spec.htmlfilter(spec.fetcher.fetch(url))) - num_chunks = ilen(chunkDOMs(html)) - for i, r in enumerate(chunkDOMs(html)): + spec.log('Fetching HTML...\r') + html = spec.fetcher.fetch(url) + spec.log('Parsing HTML...\r') + dom = parse(spec.htmlfilter(html)) + spec.log('Counting chunks...\r') + num_chunks = ilen(chunkDOMs(dom)) + for i, r in enumerate(chunkDOMs(dom)): percent = 100.0 * i / num_chunks spec.log(f'Processing chunk {i} of {num_chunks} ({percent:.1f}%)\r') spec.domfilter(r)