Skip to content

Preserve markup during syntax highlighting - #4

Merged
samuel-williams-shopify merged 6 commits into
mainfrom
preserve-code-markup
Aug 15, 2026
Merged

Preserve markup during syntax highlighting#4
samuel-williams-shopify merged 6 commits into
mainfrom
preserve-code-markup

Conversation

@samuel-williams-shopify

@samuel-williams-shopify samuel-williams-shopify commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

The compatibility upgrader previously copied element.textContent into <syntax-code>, discarding existing semantic markup before highlighting.

This restores the range-based behavior from jQuery.Syntax without changing language parsers:

  • move the original child nodes into <syntax-code>
  • extract nested elements as source-aligned matches
  • insert those matches into the existing syntax tree
  • recreate authored elements while retaining syntax highlighting inside them
  • ensure authored links take precedence over generated documentation links

Coverage includes links, nested markup, markup spanning multiple highlighted tokens and lines, direct <syntax-code> usage, and re-rendering after a language change.

Checks:

  • pnpm test (858 tests pass)
  • git diff --check

@samuel-williams-shopify samuel-williams-shopify changed the title Preserve markup during automatic upgrade Preserve markup during syntax highlighting Aug 15, 2026
@samuel-williams-shopify
samuel-williams-shopify merged commit d8d137a into main Aug 15, 2026
6 checks passed
@samuel-williams-shopify
samuel-williams-shopify deleted the preserve-code-markup branch August 15, 2026 23:18
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