feat: add standalone HTML support - #147
Conversation
There was a problem hiding this comment.
All reported issues were addressed across 16 files
Tip: instead of fixing issues one by one fix them all with cubic
Re-trigger cubic
25cde7a to
341be1b
Compare
There was a problem hiding this comment.
All reported issues were addressed across 5 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
2 issues found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/formats/html.rs">
<violation number="1" location="src/formats/html.rs:179">
P1: For HTML-style `<div/>` chains, this condition undercounts nesting because non-void self-closing flags are ignored by the HTML tree builder. Track those elements as open, while handling foreign-content self-closing elements separately, so pathological depth is rejected before DOM construction.</violation>
<violation number="2" location="src/formats/html.rs:222">
P2: When malformed HTML relies on HTML5 heading repair, the preflight rejects it as too deep even though html5ever would produce sibling headings. Add the heading implied-closing rule (and the other HTML5 tree-builder closures) before applying the depth limit.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
2 issues found across 5 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/formats/detect.rs">
<violation number="1" location="src/formats/detect.rs:76">
P2: A UTF-16 doctype with more than 51 whitespace code units between `DOCTYPE` and `html` is not detected because the fixed prefix ends before the name. Scan the doctype marker state instead of truncating detection at 64 code units.</violation>
</file>
<file name="Cargo.toml">
<violation number="1" location="Cargo.toml:38">
P3: This change drops the trailing newline at the end of Cargo.toml (`strip = "symbols"` now ends the file with no newline). The target branch ends the file with a trailing newline. Restore the trailing newline to keep the file clean and avoid noisy diffs.</violation>
</file>
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
There was a problem hiding this comment.
All reported issues were addressed across 16 files (changes from recent commits).
Tip: Review your code locally with the cubic CLI to iterate faster.
Fix all with cubic | Re-trigger cubic
Cubic findings (PR 149 review run ed78d83a, shared HTML frontend):
1. The complexity preflight did not model HTML5's implicit <p> closure
on block-level start tags, so repeated <p><div> pairs accumulated
phantom nesting depth: documents html5ever repairs into shallow trees
were rejected and the depth accounting diverged from the DOM the
limits are meant to model. Close an innermost open <p> when a
block-level start tag arrives; deeper arrangements remain
over-counted, keeping the preflight fail-closed.
2. href="#" produced LinkTarget::Anchor(""), which the Markdown
renderer cannot resolve, so the link was dropped to plain text.
Preserve the empty fragment as a relative "#" URL instead.
Regressions: 200 <p><div> pairs now convert (depth 200 < limit), 300
pairs are still rejected before DOM construction, and a bare-hash link
renders as [top](#).
Cubic (PR 149, src/formats/html.rs:308) claimed dialog and summary do not implicitly close an open <p>; html5ever's in-body mode (tree_builder/rules.rs) proves they do. Keep both and complete the preflight list to the parser's full close_p_element_in_button_scope set: center, dir, listing, plaintext, and search were missing. table is retained: html5ever closes <p> for <table> outside quirks mode, and the preflight assumes standards mode.
|
@cubic-dev-ai ultrareview: focus on the HTML complexity preflight (implied-end-tag modeling for paragraphs, headings, anchors, lists), charset/detection handling, and the standalone HTML conversion path. |
@marcellmanfrin Couldn't start the ultrareview: PR author |
Scope
Adds standalone HTML support (
.html/.htm) for the HTML portion of #52. MHTML/MHT remains out of scope here and is handled separately in #149.Summary
Format::Html, extension mapping, UTF-8/UTF-16 content detection, charset sniffing, and tolerant HTML5 parsing viascraper/html5everReview follow-ups
The current head includes the earlier charset, detector-precedence, malformed-HTML repair, list, heading, foreign-content, and anchor-preflight fixes.
The latest Cubic findings discovered while reviewing #149 were reproduced against the previous #147 head and fixed here because they belong to the shared HTML frontend:
framesetdocuments no longer fail solely because they have no<body>; they convert to an empty document when there is no renderable body content<img src>values are preserved as image references, just like absolute and protocol-relative references; anydoc still does not fetch or load those resourcesTDD evidence
RED branch:
audit/html-cubic-frameset-relative-red, based on previous headc6b7bb18608d4bde426a71d9a5300070d8f653fc.GitHub Actions run
33300432395, job99227423622reproduced both findings:Malformed("HTML parser produced no body element")Validated functional SHA:
ce7948287c8b4a62666f851a5845beabb091ef38.The functional diff from the previous head is limited to
src/formats/html.rs,tests/html.rs, and the expected LibreOffice snapshot update.Fresh full validation
Temporary CI-only branch:
verify/html-cubic-frameset-relative-full-v2.CI-only commit:
56cf2e57fc02f17c20f1ede780524b99e4acaed2. Its sole parent is the validated functional SHAce7948287c8b4a62666f851a5845beabb091ef38; every job explicitly checks out that functional SHA detached.Authoritative GitHub Actions run:
33300809474— all 6 jobs passed.html,html_list,html_corpus, snapshots, and content-detection regressions: passed-D warnings, andcargo test --locked: passednpm ci, build, tests, and committed binding determinism: passednode --test wasm/test.mjs: passedsite-packagesmodule, and full unittest suite: passedReal validation fixture:
387c6f2d7223da224a8f55962b97eac947734c97fc84888e1e5619e93745837c32fca03d52dc62518bf4419e2a4b1be96160195cd99f613a2d3230f1bb1e817c6119ae4bb085acabe21149492020e159e431de4f7a169350b1b619f2add61c1a�,Ã, orÂmojibake markersThe current PR head is exactly the validated functional SHA above.