Prism DOM
Syntax highlights an entire HTML string using Prism.js.
API
/** * Parses an HTML string and syntax highlights all code blocks using Prism.js. * * @param * @param * @param * code blocks. * @param * should show. * @param * language label should show. * * @return * value. */
Usage
$ npm install prism-dom
This module crawls the HTML string for two elements:
<code>
elements withclass
set tolanguage-<programming_language>
, i.e.<code class='language-javascript'>
. You can also uselang-
for short in place oflanguage
.<code>
elements whose direct parent element has itsclass
set tolanguage-<programming_language>
, i.e.<code class='language-javascript'>
. You can also uselang-
for short in place oflanguage
.
For a list of supported languages or CSS themes, refer to Prism.js.
Example:
const prismDOM = ; ;
Disclaimer
This is an experimental project driven by internal requirements.