Source Code Blocks
Developers are accustomed to seeing source code colorized to emphasize the code’s structure (i.e., keywords, types, delimiters, etc.). This technique is known as syntax highlighting. Since this technique is so prevalent, Asciidoctor integrates with a number of libraries to syntax highlight the source code blocks in your document. The list of integrated libraries includes Rouge, CodeRay, Pygments, and highlight.js.
Example 1 shows a listing block with the
source style and language
ruby applied to its content.
[source,ruby] ---- require 'sinatra' get '/hi' do "Hello World!" end ----
The result of Example 1 is rendered below.
require 'sinatra' get '/hi' do "Hello World!" end
You can use an include directive to insert source code into an AsciiDoc document directly from a file.
[source,ruby] ---- include::app.rb ----
If you specify custom substitutions on the source block using the