Basically you place you code examples in your HTML code in the <code-example> custom element with a language attribute for the language. Then, in the API handler you run the entire HTML blob through the highlightCode() function. This will use the existing @begin/parse5 package to parse the HTML. It will then traverse the DOM tree, find the <code-example> elements, do PrismJS magic on its contents and then places them back.
At the custom element expansion stage the highlighted code gets put in the <pre> & <code> and adds the correct class name based on the language attribute of the <code-example> element.