diff --git a/docs/content/4.plugins/1.built-in/rangi.md b/docs/content/4.plugins/1.built-in/rangi.md index f656f353..a69ca942 100644 --- a/docs/content/4.plugins/1.built-in/rangi.md +++ b/docs/content/4.plugins/1.built-in/rangi.md @@ -35,6 +35,8 @@ npm install rangi Use [`comark/plugins/shiki`](/plugins/built-in/shiki) when you need transformers, Twoslash, or the full VS Code grammar set. Use `rangi` for a faster, smaller highlighter with built-in light/dark themes. :: +Inline code highlighting with `{lang="…"}` is currently shiki only. Rangi highlights fenced blocks. + ## Usage ```typescript diff --git a/docs/content/4.plugins/1.built-in/shiki.md b/docs/content/4.plugins/1.built-in/shiki.md index 9ef4539b..c70cd860 100644 --- a/docs/content/4.plugins/1.built-in/shiki.md +++ b/docs/content/4.plugins/1.built-in/shiki.md @@ -196,6 +196,49 @@ const x: number = 42 ``` ```` +### Inline code + +Inline code is highlighted when it declares a language with the attributes syntax. `lang` wins over `language`: + +```markdown +The type is `Ref`{lang="ts-type"} and the component is ``{lang="vue-html"}. +``` + +Inline code uses the fast token path only, so `transformers` and `preStyles` are block-only and are not applied. The node gets the same `shiki` class a `
` gets, so the dual-theme CSS in [Styling](#styling) covers it without extra rules.
+
+Inline code naming a grammar that is not registered is left exactly as it was written, with no class and no spans. That is deliberate: `lang` is a real HTML attribute for natural language, so `` `Bonjour`{lang="fr"} `` must not be treated as code. A fenced block behaves differently and still falls back to an unhighlighted `.shiki` block, because a `
` is unambiguously code.
+
+Plain-text language names follow the same rule: `` `x`{lang="text"} ``, `txt` and `plain` are not registered grammars, so inline code naming one is left alone. The same name on a fence still produces a `.shiki` block.
+
+Set `inlineCode: false` to turn this off.
+
+### Grammar contexts
+
+Some inline snippets are fragments rather than whole statements, so the grammar needs seeding before it tokenizes them correctly. A grammar context maps a name you write in `{lang="…"}` onto a real grammar plus source that is tokenized and then discarded.
+
+Two ship by default, mirroring the `@nuxtjs/mdc` conventions:
+
+| Name | Grammar | Seed |
+|---|---|---|
+| `ts-type` | `typescript` | `let a:` |
+| `vue-html` | `vue` | `