fix: skip hljs highlighting for markdown code fences#283
Merged
tomasz-tomczyk merged 2 commits intomainfrom Apr 16, 2026
Merged
fix: skip hljs highlighting for markdown code fences#283tomasz-tomczyk merged 2 commits intomainfrom
tomasz-tomczyk merged 2 commits intomainfrom
Conversation
…ting Adds a section with italic text, headings, bullet lists, and inline code to the v1 fixture. This section is absent in v2, producing a pure deletion marker in the document view — replicating the formatting interruption scenario from the original bug report. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
hljs's markdown grammar applies bold to headings (hljs-section), italic to emphasis (hljs-emphasis), and colored spans to backtick code — making markdown-within-markdown fences look half-rendered rather than showing plain source. Skip hljs for markdown/md fences so the content falls through to escapeHtml and renders as uniform monospace text. Other languages (Go, JS, Elixir, etc.) keep their syntax highlighting. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Merged
2 tasks
This was referenced Apr 28, 2026
tomasz-tomczyk
added a commit
that referenced
this pull request
Apr 29, 2026
* fix: patch hljs markdown grammar and re-enable for diff view Restores markdown syntax highlighting (PR #283 had disabled it because hljs's stock grammar mangled snake_case identifiers, bare ***/---/___ lines, code spans containing emphasis chars, and treated YAML frontmatter delimiters as setext heading underlines). Adds frontend/highlight-markdown-patch.js — a vendored grammar override re-registered after the upstream language file loads. Fixes: - hljs#4279: intraword underscores no longer trigger italic/bold (snake_case, flutter_eval, ⛔ stay plain) - hljs#3719: bare ***/---/___ lines render as horizontal rule, not bold - code spans (\`*foo*\`) consumed before emphasis matchers — no italic bleed - setext headings reject upper lines that are list items / blockquotes / ATX headers / ordered lists / indented code (per CommonMark §4.3), fixing YAML frontmatter false-positives Wired through copy-deps.js to append after languages bundle. Markdown files are now also pre-highlighted in diff view (preHighlightFile and the call-site gate in app.js). Removes the markdown skip guard from the markdown-it highlight callbacks. frontend/test-markdown-patch.mjs runs 30 vm-sandboxed assertions against the bundled grammar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: AA contrast for green hljs groups on addition rows in light theme axe-core flagged hljs-quote (#22863a) on .addition (#dafbe1) at 4.15:1 contrast — fails WCAG AA (needs 4.5:1). Same color is shared with hljs-name, hljs-selector-pseudo, hljs-selector-tag. Darken all four to fg-default (#1f2328) when nested inside .addition rows in light theme. Mirrors the existing .diff-word-del + hljs-* override pattern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Test <test@test.com>
tomasz-tomczyk
added a commit
that referenced
this pull request
Apr 29, 2026
* fix: patch hljs markdown grammar and re-enable for diff view Restores markdown syntax highlighting (PR #283 had disabled it because hljs's stock grammar mangled snake_case identifiers, bare ***/---/___ lines, code spans containing emphasis chars, and treated YAML frontmatter delimiters as setext heading underlines). Adds frontend/highlight-markdown-patch.js — a vendored grammar override re-registered after the upstream language file loads. Fixes: - hljs#4279: intraword underscores no longer trigger italic/bold (snake_case, flutter_eval, ⛔ stay plain) - hljs#3719: bare ***/---/___ lines render as horizontal rule, not bold - code spans (\`*foo*\`) consumed before emphasis matchers — no italic bleed - setext headings reject upper lines that are list items / blockquotes / ATX headers / ordered lists / indented code (per CommonMark §4.3), fixing YAML frontmatter false-positives Wired through copy-deps.js to append after languages bundle. Markdown files are now also pre-highlighted in diff view (preHighlightFile and the call-site gate in app.js). Removes the markdown skip guard from the markdown-it highlight callbacks. frontend/test-markdown-patch.mjs runs 30 vm-sandboxed assertions against the bundled grammar. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix: AA contrast for green hljs groups on addition rows in light theme axe-core flagged hljs-quote (#22863a) on .addition (#dafbe1) at 4.15:1 contrast — fails WCAG AA (needs 4.5:1). Same color is shared with hljs-name, hljs-selector-pseudo, hljs-selector-tag. Darken all four to fg-default (#1f2328) when nested inside .addition rows in light theme. Mirrors the existing .diff-word-del + hljs-* override pattern. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: Test <test@test.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.
Summary
markdown/mdcode fences — the markdown grammar applies bold headings, italic emphasis, and colored code spans, making markdown-within-markdown fences look half-rendered instead of plain sourcemake test-diffexercises this scenario with deletion markers interrupting the code blockTest plan
make test-diff, scroll to Code Standards section — markdown fence should render as plain monospace (no bold headings, no italic*text*)go test ./...passes🤖 Generated with Claude Code