asciidoctor-external-callout 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/CHANGELOG.md +16 -0
- data/README.md +13 -6
- data/lib/asciidoctor-external-callout.rb +53 -16
- 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: 9071bcc8bd5b3d881297e12f8a9f27cb9220dd4633584f35aa537a33b2a1ffcc
|
4
|
+
data.tar.gz: 6e1e73370eb5ee7df1c5128f0178975ba30852c69b450fb0cb02e5ca105db3a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a62d43ad6fee410aa7d71862f71bb28ad67e12a44d102fce91ea5130c19b9ac14b5fbe905278eb9aaf6a2d39e347f99f8caadf68ae3c737119086ab17902455a
|
7
|
+
data.tar.gz: 2a0671db148dd4c7e855fbd5e00a87c885167a31716fa387810e1cacc0368c9b4d0af3131b5b26fbf23834c40c74a4dd5fe579f13638524e37755f598a4dc668
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,22 @@
|
|
2
2
|
|
3
3
|
Record of bug fixes, enhancements, and changes.
|
4
4
|
|
5
|
+
## [1.2.0] – 2022-07-30
|
6
|
+
|
7
|
+
### Added
|
8
|
+
- If you add the role `[calloutlist]` to an ordered list then it will be styled to look like a callout list. This allows you to add callouts to annotated images etc.
|
9
|
+
|
10
|
+
## [1.1.3] – 2022-07-07-16
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- 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.
|
14
|
+
- Escaped slash characters were not being processed in the search. Thanks to Hakim Cassimally for finding the bug.
|
15
|
+
|
16
|
+
## [1.1.2] – 2022-07-07
|
17
|
+
|
18
|
+
### Fixed
|
19
|
+
- Code fix to stop the constants from reloading every time the extension is run. (Tidying up for execution inside the Asciidoc plugin)
|
20
|
+
|
5
21
|
## [1.1.1] – 2022-06-23
|
6
22
|
|
7
23
|
### Fixed
|
data/README.md
CHANGED
@@ -53,24 +53,31 @@ 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
|
|
73
|
+
## Standalone callout lists
|
74
|
+
You can create a standalone callout list by adding the `calloutlist` role to an ordered list. This simply styles the list to make it look like a list of callouts so you can use it as a reference to annoted images etc.
|
75
|
+
```asciidoc
|
76
|
+
[calloutlist]
|
77
|
+
. This list can be used to add references to annotated images
|
78
|
+
. The list will look like a standard callout list.
|
79
|
+
```
|
80
|
+
|
74
81
|
## Installation
|
75
82
|
|
76
83
|
Add this line to your application's Gemfile:
|
@@ -15,11 +15,16 @@ include Asciidoctor
|
|
15
15
|
|
16
16
|
Asciidoctor::Extensions::register do
|
17
17
|
|
18
|
-
CALLOUT_SOURCE_BLOCK_ROLE
|
19
|
-
CALLOUT_ORDERED_LIST_ROLE
|
18
|
+
CALLOUT_SOURCE_BLOCK_ROLE ||= 'external-callout-block'
|
19
|
+
CALLOUT_ORDERED_LIST_ROLE ||= 'external-callout-list'
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
STANDALONE_CALLOUT_LIST_STYLE ||= 'calloutlist'
|
22
|
+
|
23
|
+
LOCATION_TOKEN_RX ||= /@(\d+)|(@\/(?:\\\/|[^\/])+?\/[ig]{0,2})/
|
24
|
+
LOCATION_TOKEN_ARRAY_RX ||= /^(@\d+|@\/(?:\\\/|[^\/]|)+?\/[ig]{0,2})((\s+@\d+)|(\s+@\/(?:\\\/|[^\/]|)+?\/[ig]{0,2}))*$/
|
25
|
+
|
26
|
+
SEARCH_STRING_RX ||= /\/((?:\\\/|[^\/])+?)\//
|
27
|
+
SEARCH_OPTIONS_RX ||= /\/(?:\\\/|[^\/])+?\/([ig]{0,2})/
|
23
28
|
|
24
29
|
tree_processor do
|
25
30
|
|
@@ -30,18 +35,30 @@ Asciidoctor::Extensions::register do
|
|
30
35
|
# The makes sure it's the right kind of list.
|
31
36
|
document.find_by context: :olist do |list|
|
32
37
|
|
33
|
-
if
|
38
|
+
# if there is as calloutlist style attached to the block
|
39
|
+
# then simply style the block as a colist. This will allow folk
|
40
|
+
# to create callout blocks that can be attached to annotated images etc.
|
41
|
+
|
42
|
+
if list.style.include? STANDALONE_CALLOUT_LIST_STYLE
|
34
43
|
|
35
|
-
|
44
|
+
list.context = :colist
|
36
45
|
|
37
|
-
|
46
|
+
else
|
38
47
|
|
39
|
-
|
48
|
+
if external_callout_list? list
|
40
49
|
|
41
|
-
|
50
|
+
owner_block = owning_block list
|
42
51
|
|
43
|
-
|
44
|
-
|
52
|
+
owner_block.subs.replace(owner_block.subs + [:callouts]).uniq
|
53
|
+
|
54
|
+
process_callouts(list, owner_block)
|
55
|
+
|
56
|
+
list.context = :colist
|
57
|
+
|
58
|
+
owner_block.add_role(CALLOUT_SOURCE_BLOCK_ROLE) unless owner_block.has_role?(CALLOUT_SOURCE_BLOCK_ROLE)
|
59
|
+
list.add_role(CALLOUT_ORDERED_LIST_ROLE) unless list.has_role?(CALLOUT_ORDERED_LIST_ROLE)
|
60
|
+
|
61
|
+
end
|
45
62
|
|
46
63
|
end
|
47
64
|
|
@@ -157,12 +174,11 @@ Asciidoctor::Extensions::register do
|
|
157
174
|
else
|
158
175
|
|
159
176
|
# Must be a string matcher then
|
177
|
+
search_options = get_search_options location
|
160
178
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
search_string = location[/\/([^\/]+?)\//, 1]
|
165
|
-
found_line_numbers = find_matching_lines(search_string, global_search, case_insensitive, owner_block)
|
179
|
+
search_string = location[SEARCH_STRING_RX, 1]
|
180
|
+
found_line_numbers = find_matching_lines(search_string, search_options[:global_search],
|
181
|
+
search_options[:case_insensitive], owner_block)
|
166
182
|
|
167
183
|
if !found_line_numbers.empty?
|
168
184
|
|
@@ -214,6 +230,27 @@ Asciidoctor::Extensions::register do
|
|
214
230
|
|
215
231
|
end
|
216
232
|
|
233
|
+
def get_search_options(location)
|
234
|
+
|
235
|
+
options = { :case_insensitive => false,
|
236
|
+
:global_search => false }
|
237
|
+
|
238
|
+
matches = location.match(SEARCH_OPTIONS_RX)
|
239
|
+
|
240
|
+
return options unless matches
|
241
|
+
|
242
|
+
# This is just for completeness, but make sure that
|
243
|
+
# none of the options are mentioned twice in the list
|
244
|
+
|
245
|
+
raise "Invalid search options: #{matches[1]}" if matches[1].match /^(.).*\1$/
|
246
|
+
|
247
|
+
options[:case_insensitive] = true if matches[1].include? 'i'
|
248
|
+
options[:global_search] = true if matches[1].include? 'g'
|
249
|
+
|
250
|
+
return options
|
251
|
+
|
252
|
+
end
|
253
|
+
|
217
254
|
class String
|
218
255
|
def is_numeric?
|
219
256
|
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.
|
4
|
+
version: 1.2.0
|
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-
|
11
|
+
date: 2022-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: asciidoctor
|