Prism API - v1.29.0
    Preparing search index...

    Function highlight

    • Low-level function, only use if you know what you’re doing. It accepts a string of text as input and the language definitions to use, and returns a string with the HTML produced.

      The following hooks will be run:

      1. before-tokenize
      2. after-tokenize
      3. wrap: On each Token.

      Parameters

      • this: Prism
      • text: string

        A string with the code to be highlighted.

      • language: string

        The name of the language definition passed to grammar.

      • Optionaloptions: HighlightOptions

        An object containing the tokens to use.

        Usually a language definition like Prism.languages.markup.

      Returns string

      The highlighted HTML.

      Prism.highlight('var foo = true;', 'javascript');