guanghu/docs/adr/0134-direct-shiki-language-registrations.md
冰朔 8739805f99
Some checks failed
Auto-update PR branches / Update open PR branches (push) Has been cancelled
CI / Frontend Static Quality Checks (push) Has been cancelled
CI / Frontend Tests & Coverage (push) Has been cancelled
CI / Rust Tests & Quality Checks (push) Has been cancelled
CI / Linux build verification (push) Has been cancelled
Release (Alpha) / Compute alpha version (push) Has been cancelled
Release (Alpha) / Build release artifacts (push) Has been cancelled
Release (Alpha) / GitHub Release (alpha) (push) Has been cancelled
Release (Alpha) / Update docs and release pages (push) Has been cancelled
Deploy docs / Build VitePress site (push) Has been cancelled
Deploy docs / Deploy to GitHub Pages (push) Has been cancelled
光湖开源源码快照 · Tolaria AGPL 分叉基线 · 独立更新链
2026-07-05 17:45:16 +08:00

2.0 KiB

type, id, title, status, date
type id title status date
ADR 0134 Direct Shiki language registrations for code blocks active 2026-05-29

Context

Tolaria uses @blocknote/code-block for rich-editor fenced-code highlighting. The bundled BlockNote highlighter covers the common web and systems languages already in the editor menu, but it does not include several common Shiki grammars such as PowerShell, VBScript, Dart, Dockerfile, Terraform/HCL, and TOML. Users still expect imported fences like powershell, ps1, vb, and vbscript to highlight, show a valid language picker state, and serialize back to a stable Markdown fence.

Decision

Tolaria keeps BlockNote's code-block integration and adds direct, lazy @shikijs/langs registrations for missing common languages and aliases.

Options considered

  • Keep only the BlockNote bundle: simplest, but leaves PowerShell/VBScript and other common fences unsupported.
  • Register selected @shikijs/langs grammars lazily (chosen): preserves BlockNote's schema and parser path while adding only the extra grammars users need.
  • Replace BlockNote's highlighter with a full custom Shiki bundle: more control, but a larger structural change than the current requirement needs.

Consequences

src/components/codeBlockOptions.ts remains the owner of the BlockNote highlighter configuration, but extra grammar modules are now imported directly from @shikijs/langs only when a matching fence or picker value needs highlighting. src/utils/codeBlockLanguageCatalog.ts owns the supported extra language labels and aliases, and src/utils/codeBlockLanguage.ts normalizes known imported aliases such as ps1 and vb to the canonical picker language.

The language menu grows, but unsupported aliases still fail safely by staying as plain explicit fence names. If Tolaria later needs a generated language bundle, export-time highlighting, or a substantially smaller menu, this ADR should be superseded by a custom Shiki packaging decision.