X-Git-Url: http://git.scottworley.com/paperdoorknob/blobdiff_plain/c594c8bf593ab97e863827b7a22f2148bcb174b6..551bb1c9f85382a90abc89ac622bd363dccd36a7:/paperdoorknob.py diff --git a/paperdoorknob.py b/paperdoorknob.py index 4e7cdf6..0fd1fde 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{#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)