How config asciidoc Source code highlighter?

Re: How config asciidoc Source code highlighter?

kuu yee,

If you want to do source highlighting via JavaScript (client-side), which I recommend, there's nothing you have to configure in the Awestruct AsciiDoc integration to make that happen. All you need to do is include highlight.js and a highlight.js stylesheet in the page template.

NOTE: Asciicoctor adds these headers when it produces HTML files, but remember that we are running Asciidoctor in embedded mode in Awestruct, so we don't get the HTML head and body tags.

You can see AsciiDoc with source code highlighting in action using highight.js on asciidoctor.org. Here's where I include the highlight.js assets:

You'll notice above that line I include instructions for how I built the highlight.js file. I recommend making a custom build since the project hasn't been released in a long time and has tons of new features that aren't in 1.7.3.

The alternative is to use CodeRay. If you want to use CodeRay, then you'd configure Asciidoctor in _config/site.yml using the new template engine configuration mechanism in Awestruct 0.5.0. Here's an example:

asciidoctor:

:attributes:

source-highlighter: coderay

coderay-css: style

If you want to style the tokens using CSS, then change coderay-css to class and include the CodeRay stylesheet in the header. In haml, that would be: