blob: b6542a1d8aca3c88e7d1b533a9c0d37af8304153 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
= Syntax Highlighting
[#install]
== Install a syntax highlighter
To add source highlighting to source blocks, you must have a suitable syntax highlighter available.
Asciidoctor PDF performs source highlighting during conversion, which means you must use a build-time syntax highlighter.
The build-time syntax highlighters that Asciidoctor PDF supports out of the box are Rouge, Pygments, and CodeRay.
Rouge is the preferred syntax highlighter.
The use of CodeRay is no longer recommended.
Refer to the table below for instructions on how to install one of these build-time syntax highlighters.
If you use Bundler to manage your gems in a [.path]_Gemfile_, add the entry listed in the *Bundler* column.
Otherwise, run the command in the *gem command* column.
[%autowidth,cols=1h;1h;1l;1l]
|===
|Library |gem name |Bundler |gem command
|Rouge
|rouge
|gem 'rouge'
|gem install rouge
|Pygments
|pygments.rb
|gem 'pygments.rb'
|gem install pygments.rb
|CodeRay
|coderay
|gem 'coderay'
|gem install coderay
|===
[#activate]
== Activate syntax highlighting
Once you've installed a syntax highlighter, you need to activate it for a given document by setting the `source-highlighter` attribute in the document header and assigning it the keyword value of the applicable library.
[,asciidoc]
----
= Document Title
:source-highlighter: rouge
----
|