Highlight JS is a well known javascript library that is able to
highlight source code in a HTML page.
If you need to generate a static HTML that contains highlighted source
code, and if you use Saxon 10 and Java 11 at least, you now have a XPath
extension function that do this. It embeds highlight.js library, and so,
rendering is the same as the one done in browser. But your page is
generated and do not require JavaScript, and so can be used as source in
multiple renderers, as FlyingSaucer[0] or forks.