summaryrefslogtreecommitdiff
path: root/docs/modules/syntax-highlighting/pages/coderay.adoc
blob: 7d12bdc3b96e34bb498370358785cb05f8ba4136 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
= CodeRay
:url-coderay: http://coderay.rubychan.de/
:url-coderay-gem: https://rubygems.org/gems/coderay

{url-coderay}[CodeRay^] is an encoding-aware, syntax highlighter that supports the languages listed below.

[%autowidth,cols="4*",grid=none,frame=none]
|===
| C
| C++
| Clojure
| CSS

| Delphi
| diff
| ERB
| Go

| Groovy
| HAML
| HTML
| Java

| JavaScript
| JSON
| Lua
| PHP

| Python
| Ruby
| Sass
| SQL

| Taskpaper
| XML
| YAML
|
|===

== Install CodeRay

To use CodeRay with Asciidoctor, you need the {url-coderay-gem}[coderay gem^].
You can use one of the following methods to install CodeRay.

Install using gem (all systems)::
+
 $ gem install coderay

Install using apt-get (Debian-based systems)::
+
 $ sudo apt-get install ruby-coderay

Install using dnf (Fedora-based systems)::
+
 $ sudo dnf install rubygem-coderay

== Activate CodeRay

Once you've installed the gem, assign the `coderay` value to the `source-highlighter` attribute in the document header to activate it.

[,asciidoc]
----
:source-highlighter: coderay
----

== CodeRay attributes

You can further customize the source block output with additional CodeRay attributes.

coderay-css::
Controls what method is used for applying CSS to the tokens.
Can be `class` or `style`.
Default: `class`.

coderay-linenums-mode::
Controls how line numbers are laid out.
Can be `table` or `inline`.
If line wrapping is enabled on preformatted blocks (i.e., `prewrap`), and you want to use line numbering on source blocks, you must set the value of this attribute to `inline` in order for the numbers to line up properly with their target lines.
Default: `table`.

.Customizing a source block with CodeRay line numbers
[source,asciidoc]
....
:source-highlighter: coderay
:coderay-linenums-mode: inline

[%linenums,ruby]
----
ORDERED_LIST_KEYWORDS = {
  'loweralpha' => 'a',
  'lowerroman' => 'i',
  'upperalpha' => 'A',
  'upperroman' => 'I'
   #'lowergreek' => 'a'
   #'arabic'     => '1'
   #'decimal'    => '1'
}
----
....

See the xref:html-backend:source-highlighting-stylesheets.adoc#coderay[CodeRay stylesheet section] to learn about the `coderay-css` attribute.

////
Note: I'm not getting this to work. Need to come back and do some quality assurance.
////