Skip to content

Keep the ids a document links to - #5

Merged
blambeau merged 2 commits into
masterfrom
keep-document-ids
Oct 28, 2026
Merged

blambeau merged 2 commits into
masterfrom
keep-document-ids

Conversation

@blambeau

Copy link
Copy Markdown
Contributor

The sanitizer allowed class and nothing else on a generic element, so every id was stripped before the converter ran. An <a href="#x"> survived — href is allowed on a — and pointed at nothing, which made any document carrying its own table of contents come out with every entry dead. Hand the same HTML to weasyprint directly and it writes a named destination; hand it through here and it writes none.

id carries no script and no navigation of its own. DOM clobbering is a browser concern, and this HTML only ever reaches a document converter.

Measured on a 16-page card exported from Klaro: 7 link annotations and no destination table before, 43 annotations and 22 named destinations after — one per heading.

blambeau and others added 2 commits October 28, 2026 18:56
The sanitizer allowed `class` and nothing else on a generic element, so
every `id` was stripped before the converter ran. An `<a href="#x">`
survived — `href` is allowed on `a` — and pointed at nothing, which made
any document carrying its own table of contents come out with every
entry dead. Hand the same HTML to weasyprint directly and it writes a
named destination; hand it through here and it writes none.

`id` carries no script and no navigation of its own. DOM clobbering is a
browser concern, and this HTML only ever reaches a document converter.

Measured on a 16-page card exported from Klaro: 7 link annotations and
no destination table before, 43 annotations and 22 named destinations
after — one per heading.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`dir` was stripped like every other generic attribute, so a renderer
that marks its output `dir="auto"` — markdown-it-bidi does, and Klaro
ships it — had the mark removed and Arabic or Hebrew came out laid out
as if it were English: flush left, in a paragraph that should run right
to left. `bdo` was already an allowed tag and means nothing at all
without `dir`.

Like `id`, it carries no script and no navigation; it only says which
way a paragraph runs.

Rendered a mixed Arabic / Hebrew / English document through the service
before and after: the two right-to-left paragraphs move to the right
margin, the English one stays where it was.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@blambeau
blambeau merged commit 6ef54e1 into master Oct 28, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant