Reject content that escapes the content root - #299
Merged
Merged
Conversation
A doc generated by this skill rendered full-bleed on tdoc.dev, and every check passed on the way out. One stray </div> closed .wrap at byte 4189 of a 37KB document, so the remaining 89% became siblings of the root and :where(body > .wrap) — which supplies the 720px column — stopped applying. Content measured 1261px wide at a 1280px viewport where the previous version measured 671px. Nothing else was wrong: the doc had a content root, its CSS was in contract, its figures were in bounds. Nesting was the only tell and nothing looked at it. The parser already counted content roots at body level; it now also records what it finds beside one. The check fires only when a root exists. A doc with no root at all is a supported shape — the template applies the column to body itself through :has() — and its headings are the document rather than escapees. ~/tdocs/hello is exactly that, and it was the single false positive in a sweep of every doc on this machine before that condition went in. Structural rather than stylistic, so it runs on both paths, beside the existing one-content-root rule that a document whose root wraps only its first paragraph would otherwise satisfy. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
PreviewOpen this: https://pr-299-tdoc-preview.jyshi1107.workers.dev/d/conway-life/v/2 This link is unique to this PR. New commits update the same URL. It is not tdoc.dev. Preview has no Durable Object — concurrent comments use the KV fallback. Data expires in 14 days. |
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.
A doc I generated rendered full-bleed on tdoc.dev, and every check passed on the way out.
One stray
</div>closed.wrapat byte 4189 of a 37KB document. The remaining 89% became siblings of the root, so:where(body > .wrap)— which supplies the 720px column — stopped applying to it. Measured against the previous version at the same viewport:Nothing else was wrong. The doc had a content root, its CSS was in contract, its figures were in bounds. The nesting was the only tell, and nothing looked at it.
The check
The parser already counted content roots at body level. It now also records the elements it finds beside one, and rejects them by name and count.
It fires only when a root exists. A doc with no root at all is a supported shape — the template applies the column to
bodyitself through:has()— and its headings are the document rather than escapees.~/tdocs/hellois exactly that, and it was the one false positive in a sweep of every doc on this machine before that condition went in. Zero after.<script>,<style>,<template>and<noscript>beside the root are not content and do not trip it.Tier
Structural, not stylistic, so it runs on both paths — beside the existing "exactly one content root" rule, which would otherwise be trivially satisfiable by a document whose root wraps only its first paragraph.
46 offline suites green; the new test covers the escaped case, the correctly nested case, and a
<template>sibling.🤖 Generated with Claude Code
https://claude.ai/code/session_01Xw9Mt3rV3ujnejPr41pqvz