asciidoctor-rouge 0.3.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.adoc +1 -1
- data/asciidoctor-rouge.gemspec +2 -2
- data/lib/asciidoctor/rouge/callouts_substitutor.rb +4 -2
- data/lib/asciidoctor/rouge/treeprocessor.rb +23 -7
- data/lib/asciidoctor/rouge/version.rb +1 -1
- metadata +13 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2caf58ed658bc1fb15cc640aad7ba7c8c782aea88c475f457f0121219a85fd1
|
4
|
+
data.tar.gz: 542083c67d842f909970791f283fe30b7335533d0ed89525d3fab45ae8f8bfa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84df699e7fde56a7a03770d22fd158fb3f0f06b833a22b8b99ab1cb984e75fb7779caa71240ed06f9371275ab12eaf850808f9579544f59b5e42faaebd68181c
|
7
|
+
data.tar.gz: caa3e9ddd3fd96f33b7eb02ad6c325e8f8cc2a18e3086d26c1e92ceacd5c7026b1c3bb7c55e15b223c91d8656372111b1cbaf122110001dde4148d0b3e5fa284
|
data/README.adoc
CHANGED
data/asciidoctor-rouge.gemspec
CHANGED
@@ -15,8 +15,8 @@ Gem::Specification.new do |s|
|
|
15
15
|
|
16
16
|
s.required_ruby_version = '>= 2.1'
|
17
17
|
|
18
|
-
s.add_runtime_dependency 'asciidoctor', '
|
19
|
-
s.add_runtime_dependency 'rouge', '
|
18
|
+
s.add_runtime_dependency 'asciidoctor', '>= 1.5.6', '< 2.1'
|
19
|
+
s.add_runtime_dependency 'rouge', '>= 2.2', '< 4'
|
20
20
|
|
21
21
|
s.add_development_dependency 'corefines', '~> 1.11'
|
22
22
|
s.add_development_dependency 'kramdown', '~> 1.16'
|
@@ -65,9 +65,11 @@ module Asciidoctor::Rouge
|
|
65
65
|
|
66
66
|
@callout_rx = if node.attr? 'line-comment'
|
67
67
|
comment_rx = ::Regexp.escape(node.attr('line-comment'))
|
68
|
-
|
68
|
+
# Copied from Asciidoctor::CalloutExtractRxt (0db74cd)
|
69
|
+
/(?:#{comment_rx} )?(\\)?<()(\d+|\.)>(?=(?: ?\\?<(?:\d+|\.)>)*$)/
|
69
70
|
else
|
70
|
-
|
71
|
+
# Copied from Asciidoctor::CalloutExtractRx (0db74cd)
|
72
|
+
%r((?:(?://|#|--|;;) ?)?(\\)?<!?(|--)(\d+|\.)\2>(?=(?: ?\\?<!?\2(?:\d+|\.)\2>)*$))
|
71
73
|
end
|
72
74
|
end
|
73
75
|
|
@@ -71,9 +71,6 @@ module Asciidoctor::Rouge
|
|
71
71
|
subs = block.subs # Array<Symbol>
|
72
72
|
opts = {}
|
73
73
|
|
74
|
-
# Don't escape special characters, Rouge will take care of it.
|
75
|
-
subs.delete(:specialcharacters)
|
76
|
-
|
77
74
|
if subs.delete(:macros)
|
78
75
|
passthroughs = @passthroughs_sub.create(block)
|
79
76
|
source = passthroughs.extract(source)
|
@@ -84,8 +81,13 @@ module Asciidoctor::Rouge
|
|
84
81
|
source = callouts.extract(source)
|
85
82
|
end
|
86
83
|
|
87
|
-
|
88
|
-
|
84
|
+
# Apply subs before :specialcharacters, keep subs after :specialcharacters.
|
85
|
+
# We don't escape special characters, Rouge will take care of it.
|
86
|
+
# See https://github.com/asciidoctor/asciidoctor/blob/v1.5.7.1/lib/asciidoctor/substitutors.rb#L1618-L1622
|
87
|
+
if (subs_before = subs.slice!(0, subs.index(:specialcharacters) || -1))
|
88
|
+
subs.delete(:specialcharacters)
|
89
|
+
source = block.apply_subs(source, subs_before)
|
90
|
+
end
|
89
91
|
|
90
92
|
lang = block.attr('language', 'plaintext', false)
|
91
93
|
lexer = find_lexer(lang)
|
@@ -100,8 +102,7 @@ module Asciidoctor::Rouge
|
|
100
102
|
end
|
101
103
|
|
102
104
|
if block.attr?('highlight', nil, false)
|
103
|
-
|
104
|
-
opts[:highlighted_lines] = block.resolve_highlight_lines(highlight)
|
105
|
+
opts[:highlighted_lines] = resolve_lines_to_highlight(block, source)
|
105
106
|
end
|
106
107
|
|
107
108
|
opts[:callout_markers] = callouts.method(:convert_line) if callouts
|
@@ -132,5 +133,20 @@ module Asciidoctor::Rouge
|
|
132
133
|
@formatter.format(tokens)
|
133
134
|
end
|
134
135
|
end
|
136
|
+
|
137
|
+
# @param block [Asciidoctor::Block] the listing block.
|
138
|
+
# @param source [String] the source of the *block*.
|
139
|
+
# @return [Array<Integer>] an array of line numbers to highlight.
|
140
|
+
def resolve_lines_to_highlight(block, source)
|
141
|
+
highlight = block.attr('highlight', '', false)
|
142
|
+
|
143
|
+
# Asciidoctor < 1.5.8
|
144
|
+
if block.respond_to?(:resolve_highlight_lines)
|
145
|
+
block.resolve_highlight_lines(highlight)
|
146
|
+
# Asciidoctor >= 1.5.8
|
147
|
+
else
|
148
|
+
block.resolve_lines_to_highlight(source, highlight)
|
149
|
+
end
|
150
|
+
end
|
135
151
|
end
|
136
152
|
end
|
metadata
CHANGED
@@ -1,34 +1,40 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-rouge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakub Jirutka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.5.6
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '2.1'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 1.5.6
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.1'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rouge
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '2.2'
|
34
40
|
- - "<"
|
@@ -38,7 +44,7 @@ dependencies:
|
|
38
44
|
prerelease: false
|
39
45
|
version_requirements: !ruby/object:Gem::Requirement
|
40
46
|
requirements:
|
41
|
-
- - "
|
47
|
+
- - ">="
|
42
48
|
- !ruby/object:Gem::Version
|
43
49
|
version: '2.2'
|
44
50
|
- - "<"
|
@@ -180,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
186
|
version: '0'
|
181
187
|
requirements: []
|
182
188
|
rubyforge_project:
|
183
|
-
rubygems_version: 2.7.
|
189
|
+
rubygems_version: 2.7.8
|
184
190
|
signing_key:
|
185
191
|
specification_version: 4
|
186
192
|
summary: Rouge code highlighter support for Asciidoctor
|