asciidoctor-external-callout 1.1.2 → 1.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +7 -0
- data/README.md +5 -6
- data/lib/asciidoctor-external-callout.rb +30 -7
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 92129f0b6fe96367004f4aa8e3f44b8bdf1182e56b07f296bb1d341a9568c7a1
|
4
|
+
data.tar.gz: c342a82f9630d128c38d1b87a802aa8a59791dc4666576cea6ced8ccea99aaae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c292169bea665e64331fbd2a9e473860d26845c953c8fa64666b10a262c205cd978dc786ec31584df864c04fa59c0301ad2d00e8db218dff033ecd9320baad1
|
7
|
+
data.tar.gz: 2d571d81ea89b61250050c64ecdf6f7b94b18ca60ce9653c294d1c95fdd8fe824807791d0e98e82fa9026571569dba93daaa5a26ce439be96517ea02e6ef1888
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
Record of bug fixes, enhancements, and changes.
|
4
4
|
|
5
|
+
## [1.1.3] – 2022-07-07-16
|
6
|
+
|
7
|
+
### Fixed
|
8
|
+
|
9
|
+
- The global and case-insensitive flags (ig) are now parsing correctly: using ii or gg will cause prevent the callout block from being processed. Thanks to Hakim Cassimally for finding the bug.
|
10
|
+
- Escaped slash characters were not being processed in the search. Thanks to Hakim Cassimally for finding the bug.
|
11
|
+
|
5
12
|
## [1.1.2] – 2022-07-07
|
6
13
|
|
7
14
|
### Fixed
|
data/README.md
CHANGED
@@ -53,22 +53,21 @@ Rather than tagging the code, you add a location token at the end of a list item
|
|
53
53
|
|
54
54
|
Two types of location token are supported:
|
55
55
|
|
56
|
-
|
56
|
+
**@_number_**
|
57
57
|
: This format takes a numeric value indicating the line in the source block where the callout should appear. The callouts will appear at the end of the line. Multiple callouts on the same line will have a single space between them.
|
58
58
|
|
59
|
-
|
60
|
-
@/_text_/
|
59
|
+
**@/_text_/**
|
61
60
|
: The text between the two slashes will be used in a regex search. A callout will be placed at the end of the first matching line.
|
62
61
|
If you have a large listing then it may be preferable to use the text search rather than counting all the lines. It may also be preferable to use a smaller listing, as a long listing might mean that your description is a bit too general. +
|
63
62
|
Using the text search method means that the location of the callout will move with the line; handy if you're referencing a source file that might get the occasional tweak outside your control.
|
64
63
|
|
65
|
-
|
64
|
+
**@/_text_/g**
|
66
65
|
: Works the same as the standard text search; the `g` flag means that callouts willl be added to _all_ the lines that match the search string, instead of just the first one.
|
67
66
|
|
68
|
-
|
67
|
+
**@/_text_/i**
|
69
68
|
: This is a case-insensitive search.
|
70
69
|
|
71
|
-
|
70
|
+
**@/_text_/gi**
|
72
71
|
: And of course, you can combine the two, though I'm not sure why you'd want to.
|
73
72
|
|
74
73
|
## Installation
|
@@ -18,8 +18,11 @@ Asciidoctor::Extensions::register do
|
|
18
18
|
CALLOUT_SOURCE_BLOCK_ROLE ||= 'external-callout-block'
|
19
19
|
CALLOUT_ORDERED_LIST_ROLE ||= 'external-callout-list'
|
20
20
|
|
21
|
-
LOCATION_TOKEN_RX ||= /@(\d+)|(@\/[^\/]+?\/
|
22
|
-
LOCATION_TOKEN_ARRAY_RX ||= /^(@\d+|@\/[^\/]+?\/
|
21
|
+
LOCATION_TOKEN_RX ||= /@(\d+)|(@\/(?:\\\/|[^\/])+?\/[ig]{0,2})/
|
22
|
+
LOCATION_TOKEN_ARRAY_RX ||= /^(@\d+|@\/(?:\\\/|[^\/]|)+?\/[ig]{0,2})((\s+@\d+)|(\s+@\/(?:\\\/|[^\/]|)+?\/[ig]{0,2}))*$/
|
23
|
+
|
24
|
+
SEARCH_STRING_RX ||= /\/((?:\\\/|[^\/])+?)\//
|
25
|
+
SEARCH_OPTIONS_RX ||= /\/(?:\\\/|[^\/])+?\/([ig]{0,2})/
|
23
26
|
|
24
27
|
tree_processor do
|
25
28
|
|
@@ -157,12 +160,11 @@ Asciidoctor::Extensions::register do
|
|
157
160
|
else
|
158
161
|
|
159
162
|
# Must be a string matcher then
|
163
|
+
search_options = get_search_options location
|
160
164
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
search_string = location[/\/([^\/]+?)\//, 1]
|
165
|
-
found_line_numbers = find_matching_lines(search_string, global_search, case_insensitive, owner_block)
|
165
|
+
search_string = location[SEARCH_STRING_RX, 1]
|
166
|
+
found_line_numbers = find_matching_lines(search_string, search_options[:global_search],
|
167
|
+
search_options[:case_insensitive], owner_block)
|
166
168
|
|
167
169
|
if !found_line_numbers.empty?
|
168
170
|
|
@@ -214,6 +216,27 @@ Asciidoctor::Extensions::register do
|
|
214
216
|
|
215
217
|
end
|
216
218
|
|
219
|
+
def get_search_options(location)
|
220
|
+
|
221
|
+
options = { :case_insensitive => false,
|
222
|
+
:global_search => false }
|
223
|
+
|
224
|
+
matches = location.match(SEARCH_OPTIONS_RX)
|
225
|
+
|
226
|
+
return options unless matches
|
227
|
+
|
228
|
+
# This is just for completeness, but make sure that
|
229
|
+
# none of the options are mentioned twice in the list
|
230
|
+
|
231
|
+
raise "Invalid search options: #{matches[1]}" if matches[1].match /^(.).*\1$/
|
232
|
+
|
233
|
+
options[:case_insensitive] = true if matches[1].include? 'i'
|
234
|
+
options[:global_search] = true if matches[1].include? 'g'
|
235
|
+
|
236
|
+
return options
|
237
|
+
|
238
|
+
end
|
239
|
+
|
217
240
|
class String
|
218
241
|
def is_numeric?
|
219
242
|
self.match(/^\d+$/)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asciidoctor-external-callout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ray Offiah
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-07-
|
11
|
+
date: 2022-07-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|