fix(themes): an imported theme's bold and italic colours reach the editor (#676) - #678
Merged
Merged
Conversation
…itor (#676) A VS Code theme colours TextMate scopes; Monaco's markdown tokenizer emits names of its own. `markup.bold` was handed to `defineTheme` unchanged and matched nothing, so every emphasis rule an imported theme ships has been inert. Headings and lists took colour only because they tokenize as `keyword`, which themes define under that same name. Rename the four scopes Monaco can actually receive — bold, italic, inline code, link — keeping the original rule beside the alias, and split scopes written as one comma-separated string, which were missing for the same reason.
This was referenced Aug 19, 2026
Closed
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 this is
Addresses #676, asked by @Fallgrim, whose note-taking depends on telling bold and italic apart at a glance: they had tried several VS Code themes and found that headings took colour while
**bold**,*italic*and`code`never did, and concluded the editor could not style them.After this, importing a theme that defines
markup.bold/markup.italic/markup.inline.raw/markup.underline.linkcolours those spans in the editor. Measured with a probe theme (markup.bold.markdown: #ff0000,markup.italic.markdown: #008000, neither carrying afontStyle), reading computed style off the rendered token spans:**bold text**mtk1 mtkb— default foreground, boldmtk4 mtkb—rgb(255, 0, 0), bold*italic text*mtk1 mtki— default foreground, italicmtk8 mtki—rgb(0, 128, 0), italicThe weight and slant survive because a theme entry without a
fontStyleproduces a rule without one, which Monaco reads asFontStyle.NotSetand merges withacceptOverwrite— the base theme'sstrong: boldandemphasis: italicstay standing. Spelling itregularinstead would have flattened text the theme was only asked to colour.Mechanism
parseAndApplyVscodeThemecopied eachtokenColorsentry's scope straight into a Monaco rule'stoken. Monaco resolves those against a trie of the names its grammars emit, andbasic-languages/markdown/markdown.jsemitsstrong,emphasis,variablefor inline code andstring.link— nevermarkup.bold. So the rules were parsed, inserted under a token nothing produces, and never matched. Nothing failed and nothing logged; the theme just arrived partly applied.Headings, lists and table pipes were the exception because they tokenize as
keyword, which is also a TextMate scope themes define — the coincidence that made this look like "themes can only colour headings".Scope
Only the four scopes Monaco can receive are renamed.
~~strikethrough~~,==highlight==and++insert++are absent from the tokenizer entirely — it never leaveslinecontentfor them — so no rename reaches them; the preview renders all three (comrak'sstrikethrough,highlight,insertextensions), and closing that gap means owning a fork of the monarch grammar. Worth its own issue, not this change.The built-in
app-theme-light/app-theme-darkstill shiprules: [], so out of the box the editor colours markdown exactly as before — this only unblocks imported themes. Giving the built-ins their own emphasis colours would change the default look for every user and is a design decision, not a defect.Also left alone: the reporter's second ask, a place to add custom CSS. That is a feature request and belongs in its own issue.
The scope-splitting is in because it is the same defect one layer up: an entry written
"scope": "comment, markup.bold"became a single token containing a comma and coloured nothing at all. Splitting it activates rules those themes always intended, which is a visible change for themes that use that spelling — and the direction the issue asks for.Tests
scripts/markdownTokenColours.test.ts, five behaviour tests againstmonacoTokenRules, which this change extracts fromparseAndApplyVscodeThemeso the rule construction can be run without a DOM or a Monaco instance. Drop the alias push and keep the tests: four of the five go red. The fifth is the "unusable entry is dropped" case, which is about the pre-existing guard rather than the fix.Verification
The before/after table was measured in Chromium against the dev server, with
window.__TAURI_INTERNALS__stubbed so the frontend boots outside Tauri, applying the probe theme throughparseAndApplyVscodeThemedirectly. Not measured: the import-a-theme-file path itself, which goes through Tauri and is unchanged here, and how any specific published theme spells its scopes — the prefix match coversmarkup.boldandmarkup.bold.markdown, but a theme that colours emphasis under some other scope entirely still will not arrive.