How to enable syntax highlighting for ASCIIDoctor

Syntax highlighting of Python code by ASCIIDoctor
Syntax highlighting of Python code by ASCIIDoctor

Adding source code to ASCIIDoc documents is easy, as described here. ASCIIDoctor can be used to easily convert them to HTML5 documents using the html5 backend (which is the default). However, the source code is not rendered with syntax highlighting.

To enable syntax highlighting:

$ gem install coderay
  • Set CodeRay as the syntax highlighter, by adding this attribute at the top of your ASCIIDoc document:
:source-highlighter: coderay

Tried with: CodeRay 1.1.0, ASCIIDoctor 1.5.2 and Ubuntu 14.04

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s