Color code blocks when the site is built #30

Merged
jcoffey-dev merged 1 commits from docs/code-highlighting into main 2026-10-15 03:42:48 +00:00
14 changed files with 330 additions and 7 deletions

No files matched your search

+4 -2
View File
@@ -85,8 +85,10 @@ pages are written:
What doesn't come across is listed in `IMPORT-REPORT.md`, page by page:
snippet includes (`--8<--`), template tags (the macros plugin),
abbreviations, icons and emoji (`:material-check:`), Mermaid diagrams (shown
as code), code highlighting and annotations, and the theme's overrides and
extra CSS and JavaScript: the site's own look replaces the theme.
as code), code annotations, and the theme's overrides and extra CSS and
JavaScript: the site's own look replaces the theme. Code blocks are colored
as pymdownx.highlight colors them, with the same class names, and
`hl_lines` marks lines; line numbers (`linenums`) aren't drawn.
MkDocs passes any HTML in a page through as it is; HotDog sanitizes it, so
an inline `<svg>`, a `<script>` or a `style=""` is removed, and the report
+19
View File
@@ -256,6 +256,25 @@ background, text, hero and closing-band colors (each with a dark-mode
value), the font (Inter, system, serif, rounded or Recursive, which ships
with the starter under the SIL Open Font License), corners and the logo.
## Code colors
A fenced code block that names its language (` ```go `, ` ```yaml `, any
name, alias or file extension chroma knows) is colored when the site is
built, so the page needs no script for it. The markup is
pymdownx.highlight's: `<div class="highlight">` around the block and
Pygments' short class names on the pieces (`.k` a keyword, `.s` a string,
`.c1` a comment), so a stylesheet written for MkDocs or Pygments colors it
too. `hl_lines="2 4-5"` in the fence's info marks those lines
(`<span class="hll">`). A block with no language, `text`, or a language
chroma doesn't know is left as it always was.
The starter's stylesheet and the docs pack's have the colors: each is a hue
from the palette (`--code-keyword`, `--code-string`, `--code-number`,
`--code-function`, `--code-type`, `--code-tag`, `--code-mark`) mixed into the
code block's own text color, so the same hues read on a light block and a
dark one. A theme without these rules shows the code as before.
`markdown.highlight: false` in `site.yaml` turns the coloring off.
## The footer
`site.yaml`'s `copyright:` names who holds the copyright the footer shows
+2
View File
@@ -3,6 +3,7 @@ module git.coffeylabs.org/coffey-labs/hotdog-cms
go 1.26.0
require (
github.com/alecthomas/chroma/v2 v2.27.0
github.com/fsnotify/fsnotify v1.10.1
github.com/microcosm-cc/bluemonday v1.0.27
github.com/yuin/goldmark v1.8.6
@@ -14,6 +15,7 @@ require (
require (
github.com/aymerick/douceur v0.2.0 // indirect
github.com/dlclark/regexp2/v2 v2.2.1 // indirect
github.com/gorilla/css v1.0.1 // indirect
golang.org/x/sys v0.48.0 // indirect
)
+10
View File
@@ -1,9 +1,19 @@
github.com/alecthomas/assert/v2 v2.11.0 h1:2Q9r3ki8+JYXvGsDyBXwH3LcJ+WK5D0gc5E8vS6K3D0=
github.com/alecthomas/assert/v2 v2.11.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
github.com/alecthomas/chroma/v2 v2.27.0 h1:FodwmyOBgJULFYmDqibcp9pvfDLWdtPRh9v/r5BXYZs=
github.com/alecthomas/chroma/v2 v2.27.0/go.mod h1:NjJ3ciIgrqBNeIkWZ4e46nseoLDslxU1LmfCoL+wcY8=
github.com/alecthomas/repr v0.5.2 h1:SU73FTI9D1P5UNtvseffFSGmdNci/O6RsqzeXJtP0Qs=
github.com/alecthomas/repr v0.5.2/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
github.com/dlclark/regexp2/v2 v2.2.1 h1:mf4KkFUj0gJuarK8P+LgiS+Lit7m9N1yAwEfPbee7R0=
github.com/dlclark/regexp2/v2 v2.2.1/go.mod h1:avUrQvPaLz2DrFNHJF0taWAFFX2C1GMSSoeiqFjcBmU=
github.com/fsnotify/fsnotify v1.10.1 h1:b0/UzAf9yR5rhf3RPm9gf3ehBPpf0oZKIjtpKrx59Ho=
github.com/fsnotify/fsnotify v1.10.1/go.mod h1:TLheqan6HD6GBK6PrDWyDPBaEV8LspOxvPSjC+bVfgo=
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM=
github.com/hexops/gotextdiff v1.0.3/go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg=
github.com/microcosm-cc/bluemonday v1.0.27 h1:MpEUotklkwCSLeH+Qdx1VJgNqLlpY2KXwXFM08ygZfk=
github.com/microcosm-cc/bluemonday v1.0.27/go.mod h1:jFi9vgW+H7c3V0lb6nR74Ib/DIB5OBs92Dimizgw2cA=
github.com/yuin/goldmark v1.8.6 h1:d0VcaP1sx9GkFVkoW+KtggpGi2KZ965i14b0+bDQST4=
+1
View File
@@ -136,6 +136,7 @@ var mkdocsUnderstood = map[string]bool{
"tables": true, "toc": true, "pymdownx.details": true, "pymdownx.keys": true, "pymdownx.tabbed": true,
"pymdownx.tasklist": true, "pymdownx.superfences": true, "pymdownx.betterem": true, "fenced_code": true,
"pymdownx.tilde": true, "sane_lists": true, "meta": true, "pymdownx.magiclink": true,
"pymdownx.highlight": true, "codehilite": true,
}
// mkdocsSource maps a file under docs_dir to its source under content/:
+6
View File
@@ -106,11 +106,17 @@ type MarkdownConfig struct {
// the key's own capitalized: {hash: "#"} shows ++hash++ as #. MkDocs'
// pymdownx.keys calls it key_map.
Keys map[string]string `yaml:"keys"`
// Highlight colors code blocks that name their language (```go) when the
// site is built (highlight.go). On unless set to false.
Highlight *bool `yaml:"highlight"`
}
// AutolinkOn reports whether bare URLs become links.
func (m MarkdownConfig) AutolinkOn() bool { return m.Autolink == nil || *m.Autolink }
// HighlightOn reports whether code blocks are colored.
func (m MarkdownConfig) HighlightOn() bool { return m.Highlight == nil || *m.Highlight }
// Redirect sends one old address somewhere else.
type Redirect struct {
From string `yaml:"from" json:"from"`
+4 -4
View File
@@ -52,7 +52,7 @@ func TestTabs(t *testing.T) {
got := render(t, MarkdownConfig{}, "=== \"Linux\"\n ```sh\n a\n ```\n\n===+ \"macOS\"\n Two.\n\n===! \"Other\"\n New set.\n\n=== \"More\"\n Same set.\n")
for _, want := range []string{
`<div class="tabbed-set tabbed-alternate" data-tabs="1:2"><input id="__tabbed_1_1" name="__tabbed_1" type="radio"><input checked="checked" id="__tabbed_1_2" name="__tabbed_1" type="radio"><div class="tabbed-labels"><label for="__tabbed_1_1">Linux</label><label for="__tabbed_1_2">macOS</label></div>`,
"<div class=\"tabbed-block\">\n<pre><code class=\"language-sh\">a\n</code></pre>\n</div>",
"<div class=\"tabbed-block\">\n<div class=\"highlight\"><pre><code class=\"language-sh\">a\n</code></pre></div>\n</div>",
`data-tabs="2:2"><input checked="checked" id="__tabbed_2_1"`,
} {
if !strings.Contains(got, want) {
@@ -101,7 +101,7 @@ func TestTrailingAttributesAndDefinitions(t *testing.T) {
}
func TestMarkdownInHTML(t *testing.T) {
src := "<div class=\"grid\" markdown>\n **Bold** inside.\n\n - one\n</div>\n\n```html\n<div markdown>\nleft alone in code\n</div>\n```\n"
src := "<div class=\"grid\" markdown>\n **Bold** inside.\n\n - one\n</div>\n\n```text\n<div markdown>\nleft alone in code\n</div>\n```\n"
got := render(t, MarkdownConfig{TrustHTML: true}, src)
for _, want := range []string{"<div class=\"grid\">\n<p><strong>Bold</strong> inside.</p>\n<ul>\n<li>one</li>\n</ul>\n</div>", "&lt;div markdown&gt;"} {
if !strings.Contains(got, want) {
@@ -184,8 +184,8 @@ func TestAdmonitionTitleMarkdown(t *testing.T) {
func TestCodeTitle(t *testing.T) {
got := render(t, MarkdownConfig{}, "```json title=\"servers.json\"\n{\"a\": 1}\n```\n\n```sh\nls\n```\n")
for _, want := range []string{
"<div class=\"highlight\"><span class=\"filename\">servers.json</span><pre><code class=\"language-json\">{&quot;a&quot;: 1}\n</code></pre>\n</div>",
"<pre><code class=\"language-sh\">ls\n</code></pre>",
"<div class=\"highlight\"><span class=\"filename\">servers.json</span><pre><code class=\"language-json\"><span class=\"p\">{</span><span class=\"nt\">&quot;a&quot;</span><span class=\"p\">:</span> <span class=\"mi\">1</span><span class=\"p\">}</span>\n</code></pre>\n</div>",
"<div class=\"highlight\"><pre><code class=\"language-sh\">ls\n</code></pre></div>",
} {
if !strings.Contains(got, want) {
t.Errorf("missing %q in\n%s", want, got)
+181
View File
@@ -0,0 +1,181 @@
package site
// Code highlighting, done when the site is built, so a page needs no script
// for it. A fenced block whose info names a language chroma knows,
//
// ```go
//
// comes out as pymdownx.highlight writes it, with Pygments' class names,
// so a stylesheet written for MkDocs colors it too:
//
// <div class="highlight"><pre><code class="language-go"><span class="kd">func</span> …
//
// The colors are the site's stylesheet's to choose (the starter's and the
// docs pack's have them); without any, the code reads as it did before.
// A block with no language, or one chroma doesn't know, is left as it was.
//
// hl_lines="2 4-5" in the info marks lines, as pymdownx.highlight does:
// each is wrapped in <span class="hll">.
import (
"regexp"
"strconv"
"strings"
"github.com/alecthomas/chroma/v2"
"github.com/alecthomas/chroma/v2/lexers"
"github.com/yuin/goldmark"
"github.com/yuin/goldmark/ast"
"github.com/yuin/goldmark/renderer"
"github.com/yuin/goldmark/renderer/html"
"github.com/yuin/goldmark/util"
)
type codeHighlight struct{}
func (codeHighlight) Extend(m goldmark.Markdown) {
// Ahead of goldmark's own renderer (1000), which still draws the blocks
// this one leaves alone.
m.Renderer().AddOptions(renderer.WithNodeRenderers(util.Prioritized(codeRenderer{}, 200)))
}
type codeRenderer struct{}
func (codeRenderer) RegisterFuncs(reg renderer.NodeRendererFuncRegisterer) {
reg.Register(ast.KindFencedCodeBlock, renderFencedCode)
}
// plainFenced is goldmark's own renderer for a fenced block, for the blocks
// that aren't highlighted, so they come out exactly as they always have.
var plainFenced = func() renderer.NodeRendererFunc {
var g grabFenced
html.NewRenderer().RegisterFuncs(&g)
return g.f
}()
type grabFenced struct{ f renderer.NodeRendererFunc }
func (g *grabFenced) Register(k ast.NodeKind, f renderer.NodeRendererFunc) {
if k == ast.KindFencedCodeBlock {
g.f = f
}
}
var hlLinesRe = regexp.MustCompile(`\bhl_lines=(?:"([^"]*)"|'([^']*)')`)
func renderFencedCode(w util.BufWriter, src []byte, node ast.Node, entering bool) (ast.WalkStatus, error) {
n := node.(*ast.FencedCodeBlock)
var info []byte
if n.Info != nil {
info = n.Info.Segment.Value(src)
}
lang := strings.ToLower(string(n.Language(src)))
marked := markedLines(info)
lexer := codeLexer(lang)
if lexer == nil && len(marked) > 0 {
lexer = lexers.Fallback
}
if lexer == nil {
return plainFenced(w, src, node, entering)
}
if !entering {
return ast.WalkContinue, nil
}
var code strings.Builder
for i := 0; i < n.Lines().Len(); i++ {
l := n.Lines().At(i)
code.Write(l.Value(src))
}
it, err := chroma.Coalesce(lexer).Tokenise(&chroma.TokeniseOptions{State: "root", EnsureLF: true}, code.String())
if err != nil {
// chroma gave up on it; the block is still worth showing.
return plainFenced(w, src, node, entering)
}
_, titled := n.Parent().(*codeTitle)
if !titled {
w.WriteString(`<div class="highlight">`)
}
w.WriteString(`<pre><code`)
if lang != "" {
w.WriteString(` class="language-`)
w.Write(util.EscapeHTML([]byte(lang)))
w.WriteString(`"`)
}
w.WriteString(">")
for i, line := range chroma.SplitTokensIntoLines(it.Tokens()) {
if marked[i+1] {
w.WriteString(`<span class="hll">`)
}
for _, t := range line {
if cls := tokenClass(t.Type); cls != "" {
w.WriteString(`<span class="` + cls + `">`)
w.Write(util.EscapeHTML([]byte(t.Value)))
w.WriteString("</span>")
} else {
w.Write(util.EscapeHTML([]byte(t.Value)))
}
}
if marked[i+1] {
w.WriteString("</span>")
}
}
w.WriteString("</code></pre>")
if !titled {
w.WriteString("</div>")
}
w.WriteString("\n")
return ast.WalkSkipChildren, nil
}
// codeLexer finds the lexer for a fence's language, by name, alias or file
// extension. Plain text gets none: there's nothing in it to color.
func codeLexer(lang string) chroma.Lexer {
if lang == "" {
return nil
}
l := lexers.Get(lang)
if l == nil || l.Config().Name == "plaintext" {
return nil
}
return l
}
// tokenClass is the Pygments class for a token, or its parent's when it has
// none of its own; plain text has none.
func tokenClass(t chroma.TokenType) string {
for ; t != 0; t = t.Parent() {
if cls, ok := chroma.StandardTypes[t]; ok {
if cls == "w" {
return "" // whitespace: nothing to color
}
return cls
}
}
return ""
}
// markedLines reads hl_lines="2 4-5" into the line numbers it names.
func markedLines(info []byte) map[int]bool {
m := hlLinesRe.FindSubmatch(info)
if m == nil {
return nil
}
out := map[int]bool{}
for _, f := range strings.Fields(string(m[1]) + string(m[2])) {
from, to, ok := strings.Cut(f, "-")
a, err := strconv.Atoi(from)
if err != nil {
continue
}
b := a
if ok {
if b, err = strconv.Atoi(to); err != nil {
continue
}
}
for i := a; i <= b && i-a < 10000; i++ {
out[i] = true
}
}
return out
}
+60
View File
@@ -0,0 +1,60 @@
package site
import (
"strings"
"testing"
)
func TestHighlight(t *testing.T) {
got := render(t, MarkdownConfig{}, "```go\nfunc main() { return \"<hi>\" } // done\n```\n")
for _, want := range []string{
`<div class="highlight"><pre><code class="language-go"><span class="kd">func</span> <span class="nf">main</span>`,
`<span class="s">&quot;&lt;hi&gt;&quot;</span>`,
`<span class="c1">// done</span>` + "\n</code></pre></div>",
} {
if !strings.Contains(got, want) {
t.Errorf("missing %q in\n%s", want, got)
}
}
}
func TestHighlightLeavesPlainBlocks(t *testing.T) {
for _, src := range []string{"```\na < b\n```\n", "```nosuchlanguage\na < b\n```\n", "```text\na < b\n```\n", " a < b\n"} {
got := render(t, MarkdownConfig{}, src)
if strings.Contains(got, "highlight") || strings.Contains(got, "<span") || !strings.Contains(got, "a &lt; b\n</code></pre>") {
t.Errorf("%q: want the block as it was, got\n%s", src, got)
}
}
off := false
if got := render(t, MarkdownConfig{Highlight: &off}, "```go\nfunc f() {}\n```\n"); got != "<pre><code class=\"language-go\">func f() {}\n</code></pre>\n" {
t.Errorf("highlight: false still colored:\n%s", got)
}
}
func TestHighlightWithTitleAndLines(t *testing.T) {
got := render(t, MarkdownConfig{}, "```yaml title=\"site.yaml\" hl_lines=\"2 4-5\"\na: 1\nb: 2\nc: 3\nd: 4\ne: 5\n```\n")
if strings.Count(got, `class="highlight"`) != 1 || !strings.HasPrefix(got, `<div class="highlight"><span class="filename">site.yaml</span><pre><code class="language-yaml">`) {
t.Errorf("want one highlight box, the file name over the code:\n%s", got)
}
if n := strings.Count(got, `<span class="hll">`); n != 3 {
t.Errorf("want lines 2, 4 and 5 marked, got %d:\n%s", n, got)
}
if !strings.Contains(got, "\n</span><span class=\"hll\"><span class=\"nt\">b</span>") && !strings.Contains(got, `<span class="hll"><span class="nt">b</span>`) {
t.Errorf("line 2 isn't the marked one:\n%s", got)
}
// Marking lines works on a block in no language too.
if got := render(t, MarkdownConfig{}, "``` hl_lines=\"1\"\nplain\n```\n"); !strings.Contains(got, "<span class=\"hll\">plain\n</span>") {
t.Errorf("unmarked plain line:\n%s", got)
}
}
// With unsafe_html the output passes the sanitizer, which must keep the
// classes the colors hang on.
func TestHighlightSurvivesSanitizer(t *testing.T) {
got := render(t, MarkdownConfig{UnsafeHTML: true}, "```bash\necho \"hi\" # say it\n```\n")
for _, want := range []string{`<div class="highlight">`, `<span class="nb">echo</span>`, `<span class="c1"># say it</span>`} {
if !strings.Contains(got, want) {
t.Errorf("missing %q in\n%s", want, got)
}
}
}
+3
View File
@@ -42,6 +42,9 @@ func NewMarkdown(c MarkdownConfig, host string) *Markdown {
if c.AutolinkOn() {
exts = append(exts, extension.Linkify)
}
if c.HighlightOn() {
exts = append(exts, codeHighlight{})
}
rendererOpts := []goldmark.Option{
goldmark.WithExtensions(exts...),
goldmark.WithParserOptions(parser.WithAutoHeadingID(), parser.WithAttribute()),
+7
View File
@@ -16,3 +16,10 @@ host, as on a docs subdomain. The docs collection gets a search index
(`/docs/search.json`, with each page's headings so a result can go to its
section); a pack can't carry scripts, so adding a search box is up to the
site. hotdogcms.org/docs is built with this pack.
Code blocks that name their language (` ```yaml `) are colored when the
site is built, and the pack's stylesheet has the colors: each one a hue
mixed into the code's own text color, so they read on light code blocks and
dark ones. A theme that wants other hues sets `--code-keyword`,
`--code-string`, `--code-number`, `--code-function`, `--code-type`,
`--code-tag` and `--code-mark` (behind lines marked with `hl_lines`).
+14
View File
@@ -164,3 +164,17 @@ dd { margin: .2em 0 0 1.4em; color: var(--text); }
/* A code block's file name (```json title="servers.json"). */
.highlight > .filename { display: block; margin-top: 1.2em; padding: 6px 14px; font: 600 .85em var(--font-mono, monospace); color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; }
.highlight > .filename + pre { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
/* Code colors. Blocks that name their language (```go) are colored when the
site is built, with Pygments' class names. Each color is a hue mixed into
the code's own text color, so it reads on a light block and a dark one,
on any theme. A theme can set the hues (--code-keyword and the rest). */
.highlight :is(.k, .kd, .kn, .kp, .kr, .ow, .cp, .cpf, .nd) { color: color-mix(in srgb, var(--code-keyword, #a855f7) 60%, currentColor); }
.highlight :is(.s, .sa, .sb, .sc, .dl, .sd, .s1, .s2, .sh, .sx, .sr, .ss, .l, .ld, .gi) { color: color-mix(in srgb, var(--code-string, #16a34a) 60%, currentColor); }
.highlight :is(.m, .mb, .mf, .mh, .mi, .il, .mo, .se, .si, .no, .kc, .na) { color: color-mix(in srgb, var(--code-number, #ea7a12) 60%, currentColor); }
.highlight :is(.nf, .fm, .nc, .nn, .ne, .gh, .gu) { color: color-mix(in srgb, var(--code-function, #2f7ff0) 60%, currentColor); }
.highlight :is(.kt, .nb, .bp) { color: color-mix(in srgb, var(--code-type, #0d9488) 60%, currentColor); }
.highlight :is(.nt, .nv, .vc, .vg, .vi, .vm, .gd, .gr, .gt) { color: color-mix(in srgb, var(--code-tag, #e0457b) 60%, currentColor); }
.highlight :is(.c, .ch, .cm, .c1, .cs, .gp, .go) { color: color-mix(in srgb, currentColor 68%, transparent); }
.highlight :is(.c, .ch, .cm, .c1, .cs, .ge) { font-style: italic; }
.highlight :is(.gh, .gu, .gs) { font-weight: 700; }
.highlight .hll { display: block; background: color-mix(in srgb, var(--code-mark, #f5c542) 22%, transparent); }
+1 -1
View File
@@ -1,5 +1,5 @@
name: docs
version: 1.4.0
version: 1.5.0
title: Documentation
description: A documentation section with a sidebar of parts and pages (as deep as you like), a breadcrumb, an on-this-page list, a page for each part, and previous and next links, in the order you set.
license: MIT
+18
View File
@@ -21,6 +21,10 @@
--accent-soft: #fbeadf;
--band: #1d2b3a;
--band-text: #f5f1ea;
/* Code colors: hues, mixed with the code's text color where they're used,
so the same ones serve light mode and dark. */
--code-keyword: #a855f7; --code-string: #16a34a; --code-number: #ea7a12;
--code-function: #2f7ff0; --code-type: #0d9488; --code-tag: #e0457b; --code-mark: #f5c542;
--radius: 14px;
--font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
--font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
@@ -256,3 +260,17 @@ dd { margin: .2em 0 0 1.4em; color: var(--text); }
/* A code block's file name (```json title="servers.json"). */
.highlight > .filename { display: block; margin-top: 1.2em; padding: 6px 14px; font: 600 .85em var(--font-mono, monospace); color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 10px 10px 0 0; }
.highlight > .filename + pre { margin-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
/* Code colors. Blocks that name their language (```go) are colored when the
site is built, with Pygments' class names. Each color is a hue mixed into
the code's own text color, so it reads on a light block and a dark one,
and follows the band color the Look panel sets. */
.highlight :is(.k, .kd, .kn, .kp, .kr, .ow, .cp, .cpf, .nd) { color: color-mix(in srgb, var(--code-keyword) 60%, currentColor); }
.highlight :is(.s, .sa, .sb, .sc, .dl, .sd, .s1, .s2, .sh, .sx, .sr, .ss, .l, .ld, .gi) { color: color-mix(in srgb, var(--code-string) 60%, currentColor); }
.highlight :is(.m, .mb, .mf, .mh, .mi, .il, .mo, .se, .si, .no, .kc, .na) { color: color-mix(in srgb, var(--code-number) 60%, currentColor); }
.highlight :is(.nf, .fm, .nc, .nn, .ne, .gh, .gu) { color: color-mix(in srgb, var(--code-function) 60%, currentColor); }
.highlight :is(.kt, .nb, .bp) { color: color-mix(in srgb, var(--code-type) 60%, currentColor); }
.highlight :is(.nt, .nv, .vc, .vg, .vi, .vm, .gd, .gr, .gt) { color: color-mix(in srgb, var(--code-tag) 60%, currentColor); }
.highlight :is(.c, .ch, .cm, .c1, .cs, .gp, .go) { color: color-mix(in srgb, currentColor 68%, transparent); }
.highlight :is(.c, .ch, .cm, .c1, .cs, .ge) { font-style: italic; }
.highlight :is(.gh, .gu, .gs) { font-weight: 700; }
.highlight .hll { display: block; margin: 0 -18px; padding: 0 18px; background: color-mix(in srgb, var(--code-mark) 22%, transparent); }