@asciidoctor/core
    Preparing search index...

    Class SyntaxHighlighterBase

    Base class for syntax highlighter adapters.

    Subclasses should override the methods they need. Two usage patterns:

    1. Server-side highlighting: override handlesHighlighting() → true and highlight().
    2. Client-side highlighting: override hasDocinfo() → true and docinfo().

    Both patterns may also override format().

    Index

    Constructors

    Properties

    _preClass: string
    name: string

    Methods

    • Generates docinfo markup to insert at the specified location in the output document.

      Parameters

      • location: string

        the location slot ('head' or 'footer')

      • doc: Document

        the Document in which this highlighter is used

      • opts: { cdn_base_url?: string; linkcss?: boolean; self_closing_tag_slash?: string }

        options

        • Optionalcdn_base_url?: string

          base URL for CDN assets

        • Optionallinkcss?: boolean

          link stylesheet instead of embedding

        • Optionalself_closing_tag_slash?: string

          '/' for self-closing tags

      Returns string

      the markup to insert

    • Formats the highlighted source for inclusion in an HTML document.

      Parameters

      • node: Block

        the source Block being processed

      • lang: string

        the source language (e.g. 'ruby')

      • opts: { nowrap?: boolean; transform?: Function }

        options

        • Optionalnowrap?: boolean

          disable line wrapping

        • Optionaltransform?: Function

          called with (pre, code) attribute objects before building tags

      Returns string | Promise<string>

      the highlighted source wrapped in <pre><code> tags. Subclasses may return a plain string — the caller always awaits the result.

    • Indicates whether highlighting is handled server-side by this highlighter.

      Returns boolean

      false by default; subclasses return true to enable highlight

    • Indicates whether this highlighter has docinfo markup to insert at the specified location.

      Parameters

      • location: string

        the location slot ('head' or 'footer')

      Returns boolean

      false by default; subclasses return true to enable docinfo

    • Highlights the specified source when this source block is being converted.

      If the source contains callout marks, the caller assumes the source remains on the same lines and no closing tags are added to the end of each line. If the source gets shifted by one or more lines, return a tuple of the highlighted source and the line offset.

      Parameters

      • node: Block

        the source Block to highlight

      • source: string

        the raw source text

      • lang: string

        the source language (e.g. 'ruby')

      • opts: {
            callouts?: any;
            css_mode?: string;
            highlight_lines?: number[];
            number_lines?: string;
            start_line_number?: number;
            style?: string;
        }

        options

        • Optionalcallouts?: any

          callouts indexed by line number

        • Optionalcss_mode?: string

          CSS mode ('class' or 'inline')

        • Optionalhighlight_lines?: number[]

          1-based line numbers to emphasize

        • Optionalnumber_lines?: string

          'table' or 'inline' if lines should be numbered

        • Optionalstart_line_number?: number

          starting line number (default: 1)

        • Optionalstyle?: string

          theme name

      Returns string | [string, number]

      the highlighted source, or a tuple with a line offset

    • Indicates whether this highlighter wants to write a stylesheet to disk.

      Parameters

      • doc: Document

        the Document in which this highlighter is being used

      Returns boolean

      false by default; subclasses return true to enable writeStylesheetToDisk

    • Writes the stylesheet to disk.

      Parameters

      • doc: Document

        the Document in which this highlighter is used

      • toDir: string

        the absolute path of the output directory

      Returns void