Code block styling and syntax highlighting#4
Merged
genmon merged 2 commits intoinanimate-tech:mainfrom Apr 10, 2026
Merged
Conversation
Fenced code blocks (``` ... ```) now get a background color and monospace font via the existing markdown decoration system, matching the inline code style. Fence delimiters are dimmed, inline markdown patterns are suppressed inside code blocks, and the max-width constraint is lifted for code content.
Integrates sugar-high (~1KB gzipped, zero deps) for syntax highlighting inside fenced code blocks. Tokens are applied as ProseMirror inline decorations (sh-keyword, sh-string, sh-comment, etc.) with colours for both light and dark themes. Built-in language presets for JS/TS/JSX (default), Python, Rust, Go, C/C++, Java, and CSS. Unrecognised languages fall back to the default JS-oriented tokenizer which handles most C-family syntax reasonably.
Contributor
|
Looks great, thank you! |
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.
Fenced code blocks (``` ... ```) now render with a background colour, monospace font, and syntax highlighting — bringing them in line with how inline
codeis already styled. Fixes #3.What changed
background/font and suppressing inline markdown patterns (bold, italic, etc.) inside code blocks.
themes are covered.
Why sugar-high?
The editor renders markdown as plain text with ProseMirror decorations — there are no structured CodeBlock nodes in the schema. This rules out the usual ProseMirror/TipTap syntax highlighting extensions (@tiptap/extension-code-block-lowlight, prosemirror-highlight, etc.) which all expect a dedicated code block node type.
sugar-highis a good fit because:If you later move to a richer document schema with actual code block nodes, we could swap in lowlight or Shiki, but sugar-high fits the current decoration-based architecture well.