Skip to content

highlightTokens

const highlightTokens: (tokens) => string

Defined in: prism/core.d.ts:139

This function takes in a TokenStream and returns a string of HTML code.

This HTML differs slightly from the HTML that’s produced by PrismJS. Firstly, it can safely be split into lines with something like html.split('\n'). This is because all span elements are closed and immediately opened again on a line break, which ensures no context is lost when splitting by lines. Secondly, behavior identical to the Highlight Keywords plugin is present by default.

TokenStream

The tokens you want to highlight.

string