Ace API Reference
    Preparing search index...
    • Applies syntax highlighting to an HTML element containing code.

      Automatically detects the language from CSS class names (e.g., 'lang-javascript') or uses the specified mode. Transforms the element's content into syntax-highlighted HTML with CSS styling and preserves any existing child elements by repositioning them after highlighting.

      Parameters

      • el: HTMLElement

        The HTML element containing code to highlight

      • opts: StaticHighlightOptions

        Highlighting options

      • Optionalcallback: Function

        Optional callback executed after highlighting is complete

      Returns boolean

      Returns false if no valid mode is found, otherwise true

    Index

    Methods

    • Transforms a given input code snippet into HTML using the given mode

      Parameters

      • input: string

        Code snippet

      • mode: string | Ace.SyntaxMode

        String specifying the mode to load such as ace/mode/javascript or, a mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode').

      • theme: string | Ace.Theme

        String specifying the theme to load such as ace/theme/twilight or, a theme loaded from /ace/theme.

      • lineStart: number

        A number indicating the first line number. Defaults to 1.

      • disableGutter: boolean

        Specifies whether or not to disable the gutter. true disables the gutter, false enables the gutter. Defaults to false.

      • Optionalcallback: Function

        When specifying the mode or theme as a string, this method has no return value and you must specify a callback function. The callback will receive the rendered object containing the properties html and css.

      Returns any

      An object containing the properties html and css.

    • Transforms a given input code snippet into HTML using the given mode

      Parameters

      • input: string

        Code snippet

      • mode: string | Ace.SyntaxMode

        Mode loaded from /ace/mode (use 'ServerSideHiglighter.getMode')

      • theme: Ace.Theme
      • lineStart: any
      • disableGutter: boolean

      Returns any

      An object containing: html, css