Official Node.js library.
The Node.js library is responsible for processing snippets that meet the established conditions.
The snippets must be inside the HTML
<pre><code>...</code></pre> (code) or
<pre><samp>...</samp></pre> (output) tags.
Also, as in the rest of the libraries, the HTML
<samp> tags must include the
language-NAME class, as indicated on the getting-started/quickstart#snippet-preparation page.
This library accepts any HTML structure, such as an article, and returns the same article with the processed snippets, keeping the rest intact.
It is installed using npm or Yarn.
Import the library and call the
photon function with the snippet to process as the first argument.
The function call returns a promise that fulfills with the result or is rejected with an error.
Promises + require
setup function to provide the API key.
Async/await + import
The API key can also be provided through the
options object to the
Function that accepts as single argument an object with configuration parameters. These parameters affect all calls to the
apiKey: The API key to use for all calls to the
Function that accepts as the first argument a snippet or an HTML fragment/document with snippets inside it, nested at any level.
As a second argument,
highlight accepts an object with configuration parameters. These parameters only affect this call to the
apiKey: The API key to use in this specific call.
If you do not provide an API key to the
setup function, you must provide it to the