highlight.ts

Source

5 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

5 symbols 4 functions 1 modules 9 parameters 3 returns

Reference

fngetHighlighter(theme: string | ThemeRegistration, customLangs: LanguageRegistration[] = []): Promise<Highlighter>Get or create the Shiki highlighter.

Get or create the Shiki highlighter.

Signature

async function getHighlighter(theme: string | ThemeRegistration, customLangs: LanguageRegistration[] = []): Promise<Highlighter>

View source

Parameters

  • theme string | ThemeRegistration
  • customLangs LanguageRegistration[]

    optional · default: []

Returns

Promise<Highlighter>
fngetTextContent(node: Element | Root): stringExtract text content from a hast node.

Extract text content from a hast node.

Signature

function getTextContent(node: Element | Root): string

View source

Parameters

  • node Element | Root

Returns

string
modulehighlightSyntax highlighting with Shiki via rehype.

Syntax highlighting with Shiki via rehype.

View source

fnhighlightCode(html: string, theme: string | ThemeRegistration = "github-dark", langs: LanguageRegistration[] = []): Promise<string>Apply syntax highlighting to HTML using Shiki.

Apply syntax highlighting to HTML using Shiki.

Signature

export async function highlightCode(html: string, theme: string | ThemeRegistration = "github-dark", langs: LanguageRegistration[] = []): Promise<string>

View source

Parameters

  • html string
  • theme string | ThemeRegistration

    optional · default: "github-dark"

  • langs LanguageRegistration[]

    optional · default: []

Returns

Promise<string>
fnrehypeShikiHighlight(options: { theme: string | ThemeRegistration; langs?: LanguageRegistration[]; })Rehype plugin for syntax highlighting with Shiki.

Rehype plugin for syntax highlighting with Shiki.

Signature

function rehypeShikiHighlight(options: {
  theme: string | ThemeRegistration;
  langs?: LanguageRegistration[];
})

View source

Parameters

  • options { theme: string | ThemeRegistration; langs?: LanguageRegistration[] }
  • options.theme string | ThemeRegistration
  • options.langs? LanguageRegistration[]

    optional