Skip to content

tokenizeDataUris

tokenizeDataUris(tokens): void

Defined in: prism/utils/data-uri.js:54

Function that will highlight the body of data URIs. If you have 'data:image/svg+xml,<svg></svg>', then this will highlight <svg></svg> as XML for example.

Note that this function should be the first tokenization function that’s called. If matchBrackets or matchTags are called before this function is added as a tokenize listener, then tags and brackets created by this won’t be matched together.

To use this function with editors, add it as a tokenize listener.

createEditor(
"#editor",
{ ... },
editor => editor.on("tokenize", tokenizeDataUris),
// Other tokenizers after
matchBrackets()
)

To use this function with code blocks, call it inside tokenizeCallback.

renderCodeBlock({
language: "js",
code: "const foo = 'bar'",
tokenizeCallback(tokens) {
tokenizeDataUris(tokens)
// Other tokenizers after
}
})

TokenStream

Tokens to mutate.

void