You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Rouge/README.md
+33-3
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,7 @@ Testing how to employ custom [Rouge] lexers in [Asciidoctor] projects.
14
14
-[Challenges](#challenges)
15
15
-[Info](#info)
16
16
-[Custom Lexers with Rougify via CLI](#custom-lexers-with-rougify-via-cli)
17
+
-[Custom Lexers via Rouge API](#custom-lexers-via-rouge-api)
17
18
-[Custom Lexers with Asciidoctor](#custom-lexers-with-asciidoctor)
18
19
-[Links](#links)
19
20
-[Rouge](#rouge)
@@ -64,14 +65,39 @@ To highlight an Alan source file using a custom Rouge lexer from the command lin
64
65
$ rougify sample.alan --require ./alan3.rb
65
66
```
66
67
68
+
From rougify help:
69
+
70
+
```
71
+
$ rougify help highlight
72
+
usage: rougify highlight <filename> [options...]
73
+
rougify highlight [options...]
74
+
75
+
[...]
76
+
77
+
--require|-r <filename> require a filename or library before
78
+
highlighting
79
+
```
80
+
81
+
82
+
## Custom Lexers via Rouge API
83
+
84
+
I'm still not entirely sure how to instruct the Rouge API to require a custom lexer, but here's how the command line parameter `--require` is being handled by [`lib/rouge/cli.rb`][cli.rb] (L235):
85
+
86
+
```ruby
87
+
when'-r', '--require'
88
+
opts[:requires] << argv.shift
89
+
```
90
+
67
91
## Custom Lexers with Asciidoctor
68
92
69
93
As for Asciidoctor, there doesn't seem to be a way to enforce the `--require` option on Rouge.
70
-
My best guess right now is we might need to write a custom Rouge extension and override Asciidoctor's native API for Rouge:
94
+
My best guess right now is that we might need to either:
95
+
96
+
1. Write a [custom syntax highlighter adapter] for Rouge, and override Asciidoctor's native API for Rouge:
0 commit comments