Based on Doxygen 1.8.13 and HighLightJS 9.11.0
To make the @snippet
code be syntax highlighted by highlight.js, there are few steps to do:
-
Generate the default .html templates by doing:
doxygen.exe -w html header.html footer.html customdoxygen.css
-
Download highlight.js from here specifying which languages you need.
Inside the zip you will find highlight.pack.js and a list of styles (I'll use style/github.css in this case)
-
Edit header.html adding this before
</head>
:<!--HIGHLIGHT.JS INSTALL BEGIN--> <link rel="stylesheet" href="$relpath^github.css"> <script src="$relpath^highlight.pack.js"></script> <script> $(function() { hljs.configure({useBR: false}); $(".fragment").each(function(i,node) { $(node).removeClass("fragment"); hljs.highlightBlock(node); }); }); </script> <!--HIGHLIGHT.JS INSTALL END-->
-
Edit Doxygen by adding:
HTML_HEADER = header.html HTML_EXTRA_FILES = highlight.pack.js github.css
-
Be sure to have all the files checked and it's ready to be compiled.
Result:
-
How you setup a
@snippet
tag code in source: -
How you setup the real snippet code:
-
How it will appear in doxygen: (github.css style)
Notes:
-
The inline comments in lua are a little buggy, so I had to use the in-section comments
--[[...]]
instead. -
Sometimes, I had to indent the whole code with an extra initial tab/space character to show the initial tags well colored
-
The CDN-hosted of highlightjs packages are here: