Skip to content

Code font and background knobs - #128

Draft
dylandeheer wants to merge 2 commits into
nodes-app:mainfrom
GetWeeve:feature/code-font-theming
Draft

Code font and background knobs#128
dylandeheer wants to merge 2 commits into
nodes-app:mainfrom
GetWeeve:feature/code-font-theming

Conversation

@dylandeheer

Copy link
Copy Markdown

Motivation

Code always renders in the syntax-highlighter service's font over the service's background. Embedders that bundle a specific mono face (e.g. Geist Mono) or theme the code background can't express that without replacing the whole highlighter service.

What's added

  • CodeBlockStyle.fontName: String? — PostScript face for fenced blocks. nil (the default) keeps the service font; an unresolvable name degrades to it (mirrors HeadingStyle.fontName's fallback).
  • InlineCodeStyle.fontName: String? — overrides inline `code` spans independently. nil follows the block face, exactly as today.
  • MarkdownEditorTheme.codeBackground: NSColor? — background behind fenced blocks and inline spans. nil keeps the service background.

Code-block card chrome (corner radius, padding) is intentionally not included: today's background is a plain text attribute; a card needs fragment-level drawing and feels like its own design conversation.

Tests

Tests/MarkdownEngineTests/CodeFontThemingTests.swift (5 tests): nil keeps the service font in blocks and inline; block face applies to both by default; inline face overrides independently; unresolvable names fall back; the background slot replaces the service background in blocks and inline while nil keeps it.

swift build / swift test green locally (the two ScrollingHeaderController animation-timing failures are pre-existing/environmental).

Notes

Stacks on #121 (branched from feature/heading-font-and-color; the diff over #121 is this feature only).

Made with Cursor

dylandeheer and others added 2 commits August 3, 2026 22:59
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>
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