Repository navigation
Feat/extension seam - #100
Merged
Merged
Conversation
The engine grew a steady stream of non-CommonMark inline constructs hard-wired into the parser, styler, tokenizer, and HTML renderer. Adding one (`%%` comments, etc.) meant ~15 edits across ~9 files, and a bug in one construct could hide in code shared with another. This introduces an extension seam. A `MarkdownExtension` supplies only a `SpanSyntax` (open/close delimiter pair + matching flags), content attributes, and an HTML wrapper; register instances via `MarkdownEditorConfiguration.extensions`. Extensions never emit ranges — the parser derives all span geometry — so a misbehaving extension can at worst restyle its own span, never a neighbor. Marker mute/shrink, caret reveal, incremental restyle, table cells, and rich copy are handled generically. All parse caches (block-token memo, document memo, DocumentParseState, table-image cache) key on the registry fingerprint, so registered extensions can change at runtime without stale results. `==highlight==` and `~~strikethrough~~`, formerly built into the core grammar, are now `HighlightExtension` / `StrikethroughExtension` in Sources/MarkdownEngine/Extensions/ — the core parses pure markdown, and unregistered syntax stays literal text. This is a breaking change: register both to restore the previous behavior. A golden corpus (one HTML-snapshot fixture per construct, baseline recorded pre-seam) proves the extraction changed nothing — byte-identical output with the extensions registered, literal `==`/`~~` without, every other construct untouched. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
luca-chen198
force-pushed
the
feat/extension-seam
branch
from
July 15, 2026 11:28
24e2358 to
358d84d
Compare
The extension seam is about constructs in general, not only inline spans — the CONTRIBUTING constraint, README feature list, and CHANGELOG entry now say 'construct' and leave the concrete form open (block support lands next). Extensions get their own feature bullet in the README. Also repairs the CHANGELOG: the rebase onto main had left the seam entries inside 0.9.0 and pushed 0.9.0's own Added items under Changed; 0.9.0 is byte-identical to main again and the seam entries sit under Unreleased. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Inline spans were only half the story: block-shaped constructs (callouts, containers, admonitions) still required threading a new case through the parser, styler, tokenizer, and renderer. This generalizes MarkdownExtension to contribute an inline form, a fenced block form (BlockSyntax), or both. A fenced extension block mirrors ``` semantics exactly: a line starting with the fence opens it, the next fence line closes it, unclosed runs to the end of the document. Built-ins always classify first, so an extension can never take text away from core markdown. The incremental machinery is fence-aware end to end: hasBlockDelimiter consults registered fences, the splice window bails on trailing extension blocks, every parse cache keys on the registry fingerprint, and an edit touching a fence line triggers the full-document restyle the same way the backtick census does. ContainerExtension (`::: … :::`) is the first block extension and the contributor template; it is not registered by default. The review pass on this change also surfaced and fixed a pre-existing incremental-parse gap: backspace-joining two paragraphs could leave the splice with two adjacent paragraph blocks where a full parse merges them, causing transient styling divergence until the next edit. The trailing guard now falls back to the full reparse in that case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
No description provided.