A string with the code to be highlighted.
The name of the language definition passed to grammar
.
Optional
options: HighlightOptionsAn object containing the tokens to use.
Usually a language definition like Prism.languages.markup
.
The highlighted HTML.
This is the most high-level function in Prism’s API.
It queries all the elements that have a .language-xxxx
class and then calls Prism#highlightElement on
each one of them.
The following hooks will be run:
before-highlightall
before-all-elements-highlight
Highlights the code inside a single element.
The following hooks will be run:
before-sanity-check
before-highlight
async
is true
.before-insert
after-highlight
complete
Some the above hooks will be skipped if the element doesn’t contain any text or there is no grammar loaded for the element’s language.
The element containing the code.
It must have a class of language-xxxx
to be processed, where xxxx
is a valid language identifier.
This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input and the language definitions to use, and returns an array with the tokenized code.
When the language definition includes nested tokens, the function is called recursively on each of these tokens.
This method could be useful in other contexts as well, as a very crude parser.
A string with the code to be highlighted.
An object containing the tokens to use.
Usually a language definition like Prism.languages.markup
.
An array of strings and tokens, a token stream.
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:
before-tokenize
after-tokenize
wrap
: On each Token.