diff --git a/docs/src/syntax-highlighting/index.css b/docs/src/syntax-highlighting/index.css index dd96fdc3417..1db244cd7ea 100644 --- a/docs/src/syntax-highlighting/index.css +++ b/docs/src/syntax-highlighting/index.css @@ -4,6 +4,7 @@ --syntax-constant: var(--color-blue); --syntax-entity: var(--color-violet); --syntax-parameter: var(--color-navy); + --syntax-parameter-background: var(--color-inline-highlight); --syntax-tag: var(--color-green); --syntax-keyword: var(--color-red); --syntax-string: var(--color-navy); @@ -33,6 +34,14 @@ --syntax-nullish: var(--color-blue); } +/* Highlight inline code parameters */ +[data-inline][data-syntax='parameter']:not([data-table-code]) { + color: var(--syntax-parameter); + background-color: var(--syntax-parameter-background); + border-radius: calc((0.5px + 0.2em)); + padding: 0.05em 0.2em; +} + /* Recover some of the syntax highlighting colors in tables */ [data-table-code] { --syntax-default: var(--color-foreground); diff --git a/docs/src/syntax-highlighting/rehypeInlineCode.mjs b/docs/src/syntax-highlighting/rehypeInlineCode.mjs index d7923531c3d..09a21c91f21 100644 --- a/docs/src/syntax-highlighting/rehypeInlineCode.mjs +++ b/docs/src/syntax-highlighting/rehypeInlineCode.mjs @@ -34,6 +34,11 @@ export function rehypeInlineCode() { } }); + // Mark inline code that contains a parameter token for code highlighting + if (node.children?.some((part) => part.properties?.style?.includes('--syntax-parameter'))) { + node.properties['data-syntax'] = 'parameter'; + } + // Tweak `` highlights to paint the bracket with the tag highlight color if (toString(node).match(/^<.+>$/)) { const keyNode = node.children?.find(