Code-block card and inline-code chip rendering (opt-in) - #132
Draft
dylandeheer wants to merge 3 commits into
Draft
Code-block card and inline-code chip rendering (opt-in)#132dylandeheer wants to merge 3 commits into
dylandeheer wants to merge 3 commits into
Conversation
The theme can recolor every element except heading text (it inherits bodyText), and the heading config covers every metric except the face — so an embedder that wants serif display headings over a sans body has to fork. HeadingStyle.fontName picks a PostScript face for headings, honored exactly so the chosen weight survives; an unresolvable name falls back to the stock bold base font, like TaskCheckboxStyle's symbol fallback. MarkdownEditorTheme.headingText colors heading text while the `#` glyphs stay on headingMarker and inline constructs inside a heading keep their own ink. Emphasis inside a heading still composes on top of the configured face (traits added, family and per-level size kept). Both knobs default to nil, which keeps styling identical to before. Co-authored-by: Cursor <cursoragent@cursor.com>
Adds additive code typography and theming knobs: - CodeBlockStyle.fontName swaps the fenced-block face; nil (the default) keeps the syntax-highlighter service's font, and an unresolvable name degrades to it (mirrors HeadingStyle.fontName). - InlineCodeStyle.fontName overrides inline `code` spans independently; nil follows the block face, exactly as today. - MarkdownEditorTheme.codeBackground replaces the background behind fenced blocks and inline spans; nil keeps the service background. Code-block card chrome (corner radius, padding) is intentionally NOT included: the background today is a plain text attribute, and a card would need fragment-level drawing. Deferred. Co-authored-by: Cursor <cursoragent@cursor.com>
CodeBlockStyle.cornerRadius renders a fenced block as ONE continuous rounded card: each fragment paints its slice full-width, rounding corners only on the fragments holding the block's first and last characters (extend-and-clip keeps every fragment drawing strictly inside its own strip, so invalidation and scrolling stay per-fragment). CodeBlockStyle.cardVerticalPadding pins the hidden fence lines' height as the card's interior padding; fences revert to natural height while the caret reveals them. InlineCodeStyle.chipCornerRadius draws a small rounded chip hugging each inline code span with chipHorizontalPadding of breathing room, colored by theme.inlineCodeBackground (fallback codeBackground, then the highlighter background). Selection cuts out even-odd above both card and chips. All defaults preserve the historical .backgroundColor glyph-run fills exactly. Co-authored-by: Cursor <cursoragent@cursor.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.
What
Two opt-in rendering upgrades in the TextKit 2 layer, both defaulting to the historical
.backgroundColorglyph-run fills exactly:Code-block card —
CodeBlockStyle.cornerRadiusrenders a fenced block as ONE continuous rounded card spanning the whole block, wrapped lines included. Each fragment paints its slice full-width and rounds corners only on the fragments holding the block's first and last characters (extend-and-clip, so every fragment still draws strictly inside its own strip — invalidation and scrolling stay per-fragment). The styler tags the block with a.codeBlockCardattribute carrying the block range instead of a.backgroundColor, so no square fills fight the card.CodeBlockStyle.cardVerticalPaddingpins the hidden fence lines' height so they read as the card's interior padding; fences revert to their natural code line height while the caret reveals them.Inline-code chips —
InlineCodeStyle.chipCornerRadiusdraws a small rounded background hugging each inlinecodespan (per wrapped line, at the code font's own height rather than the whole line box) withchipHorizontalPaddingof breathing room.MarkdownEditorTheme.inlineCodeBackgroundcolors the chip (nil →codeBackground→ the syntax-highlighter background).Selection stays visible above both card and chips via the same even-odd cut-out the legacy code-block fill uses.
Why
Per-paragraph square fills read as disjoint highlight bands, not as a code block; designs that specify a rounded card with interior padding and chip-style inline code had no seam to express it.
Tests
CodeBlockCardTests— defaults preserved (both features), card tagging + background suppression, fence padding pin + caret reveal, chip tagging, theme slot. Full suite green.Stacks on the code typography knobs (#128); the last commit is this feature.
Made with Cursor