Repository navigation
Conversation
Borrow stored parts and share decoded section ranges without double-counting the byte budget. Use weak sibling links with flat DOM ownership for constant-time insert/remove operations. Add failing-first regression coverage and reproducible release time/RSS benchmarks.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CHM manuals currently fail format detection, so they cannot use anydoc's file/bytes APIs or shared document model. This draft adds a native CHM frontend across Rust, Node.js, Python, WebAssembly, and the CLI.
Refs #200.
Implementation
.chm, then routeFormat::Chmthrough the existing dispatcher, sharedDocumentmodel, and Markdown serializer.lzxd0.2.7, with its MIT license and source notice undersrc/formats/chm/lzx/. The published dependency does not expose consumed input bytes; the local adaptation returns this for each frame so SpanInfo decoding does not guess boundaries or replay the stream. It preserves unfinished blocks and dictionary/tree state, handles padding and E8 positions across resets, and rejects invalid match offsets.@charsetand the referring page's encoding.html5everparsing into the existingElementtree and shared converter. Weak sibling links provide constant-time insertion/removal during HTML recovery; a flat arena owns nodes and avoids recursive sibling-chain destruction. Resolve HTMLbase hreffor links/images/stylesheets while retaining actual topic paths for anchor definitions. Preserve the topic title when the body contains only subheadings.AssetSink. Shared HTML anchors and tight-list spacing use the existing serializer.Discussion points / current boundaries
html5everis the only new registry dependency;encoding_rswas already present.Document.assets; Markdown follows the existing alt-text behavior.Validation
Regression tests were exercised failing before the corresponding fixes. Nine small, original CHM fixtures are reproducible with
python3 tests/fixture-src/chm.py. They cover legacy URLs/CSS/LCIDs, HTML bases, topic titles, and a real Huffman-compressed four-frame SpanInfo stream with dictionary dependencies and resets. The external manual and full output are excluded from Git.cargo test --locked: 397 passed, two external-corpus tests ignored by default. Existing snapshots are unchanged; new fixtures have new snapshots.--all-targets --all-features -- -D warnings), and wasm-target Clippy passed. Cargo packaging includes the private decoder sources and license.bench/convert.py --formats chmaccepts all nine original fixtures.bench/chm.pymeasures per-process peak RSS and conversion/wall time on macOS/Linux, with external input paths and no converted contents saved.ANYDOC_CHM_SAMPLE=/path/to/manual.chm cargo test --test chm local_chm_manual -- --ignored --nocapture.Performance validation
Release builds on the same 10-core, 24 GiB Mac, with serial fresh-process comparisons against the previous implementation (three runs, medians; OS caches warm after the first conversions):
Large-manual conversion time is effectively unchanged within observed variation; peak RSS fell by about 86 MiB. Synthetic sibling-insertion recovery scales approximately linearly after the change. The manual's 30,929,290-byte Markdown is byte-identical (SHA-256 verified), and all four extracted assets retain their hashes. The private manual and benchmark outputs are not committed.
CSS still uses the shared HTML style matcher. Existing Node document-object materialization, synchronous WASM calls, and the Rust example's second parse for
--assetsremain framework-level follow-ups outside this CHM-specific optimization.Opening as a draft to discuss the reader/decompression strategy, private decoder adaptation, HTML adapter, TOC behavior, and memory tradeoff before treating this as ready for merge.
Summary by cubic
Adds native CHM (Compiled HTML Help) conversion. CHM files are now detected by their ITSF signature or
.chmextension and convert through the shared document model across Rust, Node.js, Python, WebAssembly, and the CLI.lzxdadaptation, sharing decoded section ranges across entries so the byte budget is counted once; covers both ResetTable and SpanInfo-only stream framing.encoding_rsand adapts recovered HTML into the shared element tree withhtml5ever; HTML sibling mutation is constant-time via flat DOM ownership with weak sibling links..hhcTOC hierarchy as a nested list, converts each topic once in TOC order, and appends unlisted topics in stable path order.AssetSink; topic and TOC links use each file's selected encoding.Known boundaries
Written for commit 186ff3f. Summary will update on new commits.