Variable default

default: {
    Theme: typeof Theme;
    highlight: ((code, language, theme, renderer?) => string);
    init: ((moduleOverrides?) => Promise<void>);
    loadLanguage: ((input) => Promise<void>);
    process: ((code, language) => Highlights);
    render: ((highlights, theme, renderer?) => string);
}

Type declaration

  • Theme: typeof Theme
  • highlight: ((code, language, theme, renderer?) => string)
      • (code, language, theme, renderer?): string
      • Highlight code and render to the requested format.

        If you plan to highlight the same input multiple times, use process and render instead.

        Parameters

        • code: string

          The code to highlight.

        • language: string

          The name of the code's language.

          The language must have been loaded previously by calling loadLanguage.

        • theme: "abscs::abscs" | "aurora::aurora" | "blue_moon::blue_moon" | "boo::boo" | "catppuccin::frappe" | "catppuccin::latte" | "catppuccin::macchiato" | "catppuccin::mocha" | "darcula::darcula" | "dracula::dracula" | "everblush::everblush" | "everforest::dark" | "everforest::light" | "falcon::falcon" | "github::dark" | "github::dark_colorblind" | "github::dark_default" | "github::dark_dimmed" | "github::dark_high_contrast" | "github::dark_tritanopia" | "github::light" | "github::light_colorblind" | "github::light_default" | "github::light_high_contrast" | "github::light_tritanopia" | "gruvbox::dark" | "gruvbox::light" | "melange::melange" | "minimal::minimal" | "monochrome::monochrome" | "monokai::monokai" | "monokai::pro" | "monokai::ristretto" | "monokai::soda" | "moonfly::moonfly" | "moonlight::moonlight" | "neon::dark" | "neon::default" | "neon::doom" | "neon::light" | "nightfly::nightfly" | "nord::nord" | "oceanicnext::dark" | "oceanicnext::light" | "omni::omni" | "one::cool" | "one::dark" | "one::darker" | "one::deep" | "one::light" | "one::warm" | "one::warmer" | "oxocarbon::dark" | "oxocarbon::light" | "solarized::dark" | "solarized::light" | "tokyo::day" | "tokyo::moon" | "tokyo::night" | "tokyo::storm" | "vscode::dark" | "vscode::light" | "zephyr::zephyr" | Theme

          The name of the theme to use.

          All themes from the default collection are supported. The theme name is equivalent to its Rust path specifier, so for example the gruvbox dark theme is named gruvbox::dark. Alternatively, a custom theme can be specified.

        • renderer: string = 'HTML'

          The renderer to use.

          The renderer name is either HTML or Terminal in any casing. To specify a background color for the terminal renderer, append a hex color literal like terminal#282828 or Terminal#fff.

          By default, the HTML renderer will be used.

        Returns string

        The highlighted code as HTML code.

        See here for more information on the output.

  • init: ((moduleOverrides?) => Promise<void>)
      • (moduleOverrides?): Promise<void>
      • Initialize the Wasm module.

        This function must be called before any of the others

        Parameters

        • Optional moduleOverrides: any

        Returns Promise<void>

  • loadLanguage: ((input) => Promise<void>)
      • (input): Promise<void>
      • Load a language from a WebAssembly module.

        The module can be provided as a path to a file or as a buffer.

        Parameters

        • input: string | Uint8Array

        Returns Promise<void>

  • process: ((code, language) => Highlights)
      • (code, language): Highlights
      • Prepare code for rendering multiple times.

        Parameters

        • code: string

          The code to highlight.

        • language: string

          The name of the code's language.

          The language must have been loaded previously by calling loadLanguage.

        Returns Highlights

        Highlight information about the code to be used by render.

  • render: ((highlights, theme, renderer?) => string)
      • (highlights, theme, renderer?): string
      • Render code that was previously processed by calling process.

        Parameters

        • highlights: Highlights

          The processed highlight information to render.

        • theme: "abscs::abscs" | "aurora::aurora" | "blue_moon::blue_moon" | "boo::boo" | "catppuccin::frappe" | "catppuccin::latte" | "catppuccin::macchiato" | "catppuccin::mocha" | "darcula::darcula" | "dracula::dracula" | "everblush::everblush" | "everforest::dark" | "everforest::light" | "falcon::falcon" | "github::dark" | "github::dark_colorblind" | "github::dark_default" | "github::dark_dimmed" | "github::dark_high_contrast" | "github::dark_tritanopia" | "github::light" | "github::light_colorblind" | "github::light_default" | "github::light_high_contrast" | "github::light_tritanopia" | "gruvbox::dark" | "gruvbox::light" | "melange::melange" | "minimal::minimal" | "monochrome::monochrome" | "monokai::monokai" | "monokai::pro" | "monokai::ristretto" | "monokai::soda" | "moonfly::moonfly" | "moonlight::moonlight" | "neon::dark" | "neon::default" | "neon::doom" | "neon::light" | "nightfly::nightfly" | "nord::nord" | "oceanicnext::dark" | "oceanicnext::light" | "omni::omni" | "one::cool" | "one::dark" | "one::darker" | "one::deep" | "one::light" | "one::warm" | "one::warmer" | "oxocarbon::dark" | "oxocarbon::light" | "solarized::dark" | "solarized::light" | "tokyo::day" | "tokyo::moon" | "tokyo::night" | "tokyo::storm" | "vscode::dark" | "vscode::light" | "zephyr::zephyr" | Theme

          The name of the theme to use.

          All themes from the default collection are supported. The theme name is equivalent to its Rust path specifier, so for example the gruvbox dark theme is named gruvbox::dark. Alternatively, a custom theme can be specified.

        • renderer: string = 'HTML'

          The renderer to use.

          The renderer name is either HTML or Terminal in any casing. To specify a background color for the terminal renderer, append a hex color literal like terminal#282828 or Terminal#fff.

          By default, the HTML renderer will be used.

        Returns string

        The highlighted code in the requested format.

Generated using TypeDoc