Repository navigation
Description
What happens
Found this while theming bb. A shell fence in a thread message comes out lexed as JavaScript: # install the plugin is a sign and three identifiers, and ./plugins/monokai is a string. Python, Rust, Go, C, Java and CSS fences are fine, which is what threw me at first.
Why
The fence language is read and mapped to a preset:
// apps/app/src/components/ui/markdown-code-highlight.ts
const preset = language === null ? undefined : PRESET_BY_LANGUAGE[language];
return highlight(code, preset);There's no shell key in the map, and no shell preset in sugar-high v1 to point one at. v1 ships eight: c, css, diff, go, java, json, python, rust. Same for yaml, sql, html, markdown, toml and dockerfile.
diff and json are the two of the eight the map doesn't use. If that's deliberate, ignore me.
Proposal
Streamdown for chat markdown. Its Shiki plugin takes the language:
// [email protected], dist/index.d.ts
interface HighlightOptions {
code: string
language: BundledLanguage
themes: [ThemeInput, ThemeInput]
}
highlight: (options: HighlightOptions, callback?: (result: HighlightResult) => void) => HighlightResult | nullIt colors through --shiki-dark and --sdm-c, so chat fences would land on the same theme as diffs and file previews instead of the separate --sh-* set.
I have a PoC of the swap in #1317, opened for render cost rather than for this. Not asking for it here, it's evidence the swap is tractable.
Smaller version if the migration isn't on the table: sugar-high v2 takes a lang string and ships 25 languages, shell among them.
-import { highlight } from 'sugar-high'
-import { c, css, go, java, python, rust } from 'sugar-high/presets'
+import { highlight } from 'sugar-high'
+import { lang } from 'sugar-high/lang'
-highlight(code, PRESET_BY_LANGUAGE[language])
+highlight(code, { lang: lang(language) })lang() returns undefined for h, hpp and less, which the map covers today. Either way v2 still colors through --sh-*, so chat and diffs stay on separate themes.
Refs
- https://github.com/vercel/streamdown
- perf(app): replace react-markdown with Streamdown (PoC) #1317
- Let a UI theme declare its own code theme #1239
- https://github.com/huozhi/sugar-high/blob/main/docs/API.md#lang-mapping
- https://github.com/huozhi/sugar-high/blob/main/docs/MIGRATION.md
Activity
SawyerHood commentedon Aug 18, 2026
Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1751.html
#is a sign, words are identifiers, and/plugins/monokaiis a regex-literal string.import { lang } from "sugar-high/lang"->highlight(code, { lang: lang(language) ?? EXTRA_ALIASES[language] }), with EXTRA_ALIASES covering h/hpp->c(pp), less->css, console->shell (verified: lang() maps sh/bash/zsh/shell->shell and 25 langs incl. yaml/toml/sql/diff/json; HTML still uses sh__token--* / --sh-* so the CSS is untouched; only this file imports sugar-high). Alternative minimal v1 patch: add a local shell preset (python-style#comment handlers + shell keywords) mapped fr…The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at
16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).Highlight shell and other chat fences with sugar-high v2 (#2175)