Skip to main content

scale_token_limit_to_source

Function scale_token_limit_to_source 

Source
pub fn scale_token_limit_to_source(source_bytes: usize)
Expand description

Scale the runaway-token backstop to the SOURCE size — cumulatively, over every file the conversion opens. The DEFAULT_TOKEN_LIMIT baseline is sized for arXiv-scale inputs; a book-scale source legitimately expands past it (witness: a 131 MB flat-index compilation died at the then-400M ceiling mid-digestion with no loop in sight, at a measured ~3+ tokens/byte and paper-class documents measured up to ~160 tokens/byte; l3doc’s crossref pass over source2e’s .dtxs ~1000/byte). ×1000/byte keeps the ceiling finite — a true infinite loop still trips, and opens no new files while it spins — while never LOWERING the baseline for small documents. The bytes are summed over the main source AND everything it \inputs/\DocIncludes (every Mouth::open_file): source2e.tex is a 15 KB driver over ~40 .dtx files (~2 MB), so the driver-only sizing never engaged. An explicit LATEXML_TOKEN_LIMIT or --token-limit (fix_token_limit) wins unchanged (including 0 = disabled).