This program parses an html file and adds chroma classes to code within pre and code tags. Then you can add chroma themes with css.
Make sure you have golang installed (if not, follow this instructions) then run:
$ go run main.go <test_file.html>
with <test_file.html>
being an html file containing some code to highlight.
This is an example of a code snippet contained within an html file that this program adds chroma css classes
(...)
<pre><code class="language-c">
#include <stdio.h>
int main(void) {
char *hw = "Hello, world!\n";
printf("%s\n", hw);
return 0;
}
</code></pre>
(...)
To capture the code snippet it uses regular expression so it should be easier to adapt to other formats.
The main purpose of this program was to highlight code snippets on my blog. Checkout this post that I made to test it.