Canonical form owes the author fidelity: strip only editor-injected state - #29
Open
namedgraph wants to merge 1 commit into
Open
Canonical form owes the author fidelity: strip only editor-injected state#29namedgraph wants to merge 1 commit into
namedgraph wants to merge 1 commit into
Conversation
…ributes round-trip Canonicalization conflated two jobs: removing the editor's own ephemera (its duty) and enforcing a class-free storage doctrine on authored content (a host policy, inherited from a retired draft). The second half made every save destructive for content the doctrine didn't cover: one click-in/ click-out stripped all class/id/aria-*/hidden attributes, upon which the attributeless-wrapper rules dissolved the remains into bare paragraphs. C2 now strips only the editor's injections (contenteditable, draggable, tabindex="-1") plus @Style, which no editing gesture can author; C2b subtracts the editor's own class tokens instead of deleting the attribute. cm:authored-attributes() backs the C6/C7 meaninglessness tests, so an element keeping any authored attribute is never unwrapped as browser junk, and C8 keeps empty a[@id] anchors. S1 exempts button - inert markup once S2 strips its handlers, legitimately stored by content components. A host with a stricter storage policy overrides these templates at higher import precedence. Canonical fixtures updated to the fidelity contract; 05 and 11 gain coverage for anchor preservation and button survival. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S1UnYpbW5aYLj7LbwtyUo1
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.
Problem
Canonicalization conflated two jobs: removing the editor's own ephemera (its duty) and enforcing a class-free storage doctrine on authored content (a host policy, inherited from a since-retired draft of the LDH v6 document format). The second half fails the basic contract an editor owes its data — load, touch nothing, blur, and the document should come back identical. Instead, C2 stripped every authored
class/id/style/aria-*/data-*, upon which the attributeless-wrapper rules (C6/C7) dissolved the newly bare wrappers, and S1 droppedbuttonelements outright. In LinkedDataHub this destroyed a styled documentation page through nothing but a click-in/click-out: all 23 classes, 11 ids (anchor targets), everyaria-*/hidden, 3 buttons and 7 spans gone, 15 of 16 divs digested into paragraphs.Change
contenteditable,draggable,tabindex="-1"— plus@style, which no editing gesture can author (browsers mint styled spans during editing and paste, so inline style stays in the browser-mess family withfont/u).rdfa-editor-*,dragging,drop-*,rdfa-invalid) instead of deleting the attribute; authored tokens survive, an emptied attribute drops.cm:authored-attributes()backs the meaninglessness tests: C6 (span unwrap) and C7a/C7b (div→p / div unwrap) now treat any surviving authored attribute as meaning, mirroring how unknown elements are already preserved-and-linted rather than deleted. C8 keeps emptya[@id]— an anchor target, not junk.button: inert markup once S2 strips itson*handlers, and legitimately stored by content components (e.g. ARIA tab strips).form/input/select/textarea/script/iframe/… stay banned.ldh-editor.xslalready uses.Tests
Canonical fixtures updated to the fidelity contract (region-root host attributes and authored attributes now survive;
07-attr-stripexercises the new split directly). Fixture05gains empty-anchor coverage,11gains standalone-button coverage. All extractor, lint and canonical suites pass; both SEF flavors compile.A useful property this buys downstream: an unedited region canonicalizes to exactly what was loaded, so hosts can implement a save dirty-check as a string comparison (LinkedDataHub now does).
🤖 Generated with Claude Code
https://claude.ai/code/session_01S1UnYpbW5aYLj7LbwtyUo1