Skip to content

highlight

Unofficial

Highlights a string of code using the given grammar.

Import:

import type { highlight } from '@obsidian-typings/obsidian-public-latest';

Signature:

function highlight(text: string, grammar: Grammar, language: string): string

Parameters:

ParameterTypeDescription
textstringThe code string to highlight.
grammarGrammarThe grammar to use for tokenization.
languagestringThe language identifier.

Returns: string — The highlighted HTML string.


Links to this page: