- url = flatURL(spec.url)
- spec.log('Fetching HTML...\r')
- html = spec.fetcher.fetch(url)
- spec.log('Parsing HTML...\r')
- dom = parse(spec.htmlfilter(html))
- thread = Thread(dom)
- spec.log('Counting chunks...\r')
- num_chunks = ilen(thread.chunkDOMs())
- title = thread.title() or "chunk"
- for i, r in enumerate(thread.chunkDOMs()):
- percent = 100.0 * i / num_chunks
- spec.log(f'Processing {title} {i} of {num_chunks} ({percent:.1f}%)\r')
- spec.domfilter(r)
- chunk = makeChunk(r, spec.images)
- spec.texout.write(spec.texfilter(renderChunk(spec.texifier, chunk)))
- spec.log('')