fix: patch hljs markdown grammar and re-enable for fenced blocks#139
Merged
tomasz-tomczyk merged 2 commits intomainfrom Apr 29, 2026
Merged
fix: patch hljs markdown grammar and re-enable for fenced blocks#139tomasz-tomczyk merged 2 commits intomainfrom
tomasz-tomczyk merged 2 commits intomainfrom
Conversation
Ports the hljs markdown grammar fix from tomasz-tomczyk/crit#388 to keep the review page in parity. Hosted reviews now syntax-highlight nested ```markdown fences without the cascading visual bugs that caused PR #283 (in crit) to disable markdown highlighting. Adds assets/js/highlight-markdown-patch.js — exports registerMarkdownPatch(hljs) which re-registers the markdown language with four fixes: - hljs#4279: intraword underscores no longer trigger italic/bold - hljs#3719: bare ***/---/___ lines render as horizontal rule, not bold - code spans consumed before emphasis matchers (no italic bleed) - setext headings reject upper lines that aren't paragraphs (per CommonMark §4.3) — fixes YAML frontmatter false-positives The patch is registered at the top of document-renderer.js, immediately after `import hljs from "highlight.js"` and before any hljs.highlight() call. esbuild bundles document-renderer.js as a chunk only loaded on /r/:token, so the patch is applied exactly once per review-page mount. Also removes the `lang === 'markdown'` skip guard from the markdown-it highlight() callback, mirroring the same change in crit/. assets/test-markdown-patch.mjs runs 30 vm-sandboxed assertions covering all four bug classes plus regressions. Run with `node assets/test-markdown-patch.mjs`. See also: tomasz-tomczyk/crit#388 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #139 +/- ##
=======================================
Coverage 77.21% 77.21%
=======================================
Files 52 52
Lines 1567 1567
=======================================
Hits 1210 1210
Misses 357 357
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Mirrors tomasz-tomczyk/crit fix — hljs-quote/name/selector-pseudo/ selector-tag (#22863a) on .addition (#dafbe1) fails WCAG AA at 4.15:1. Darken to fg-default (#1f2328) when nested inside .addition rows in light theme. See also: tomasz-tomczyk/crit#388 Co-Authored-By: Claude Opus 4.7 (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.
Summary
Ports the hljs markdown grammar fix from tomasz-tomczyk/crit#388 so hosted reviews stay in parity with the local CLI. The review page now syntax-highlights nested
```markdownfences cleanly instead of producing cascading visual bugs (snake_case italicized, bold bleed across code spans, YAML frontmatter delimiters parsed as setext headings).assets/js/highlight-markdown-patch.jsexportsregisterMarkdownPatch(hljs)which re-registers the markdown language with four fixes:***/---/___lines render as horizontal ruleThe patch is registered at the top of
document-renderer.js, immediately afterimport hljs from "highlight.js"and before anyhljs.highlight()call. esbuild bundlesdocument-renderer.jsas a chunk only loaded on/r/:token, so the patch is applied exactly once per review-page mount.assets/test-markdown-patch.mjsruns 30 vm-sandboxed assertions covering all four bug classes plus regression checks.Review
Test plan
node assets/test-markdown-patch.mjs— 30/30 passingmix precommit— 471 tests, 0 failures (compile, format, sobelow, deps.audit, test all green)mix assets.build— succeededNotes
registerMarkdownPatch(hljs)) instead of crit/'s IIFE since crit-web importshighlight.jsfrom npm via esbuild rather than concatenating CDN bundles.highlight.js ^11.11.1aligned with crit/'s@highlightjs/cdn-assets ^11.11.1.See also: tomasz-tomczyk/crit#388
🤖 Generated with Claude Code