asciidoctor-external-callout 1.1.4 → 1.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92129f0b6fe96367004f4aa8e3f44b8bdf1182e56b07f296bb1d341a9568c7a1
4
- data.tar.gz: c342a82f9630d128c38d1b87a802aa8a59791dc4666576cea6ced8ccea99aaae
3
+ metadata.gz: 988ee7db8d0166dee5024f3fb8d480d169b5e1b7ad5d520cdfa6d1732af8246c
4
+ data.tar.gz: d124ae287c1e1f8b3c046e58129da71ece998892b05cd3f31827fea2141098cf
5
5
  SHA512:
6
- metadata.gz: 6c292169bea665e64331fbd2a9e473860d26845c953c8fa64666b10a262c205cd978dc786ec31584df864c04fa59c0301ad2d00e8db218dff033ecd9320baad1
7
- data.tar.gz: 2d571d81ea89b61250050c64ecdf6f7b94b18ca60ce9653c294d1c95fdd8fe824807791d0e98e82fa9026571569dba93daaa5a26ce439be96517ea02e6ef1888
6
+ metadata.gz: '0782b1b464338a58aebc8134b9586100461fd84fc0a6e929a2aa7233c3c0ad21c461c8d0270e4159e098ef4e87971a2942a48e056dba9fdcdc1dcadbc078e54a'
7
+ data.tar.gz: a02cc9f11cbd93ce43d5c8031af3033aa1c28ec9422e49b873af70afd22ae245dc0331784638dc6fb72e5fe07c26946e971f9ed82bcbb1ec4442fe9e5690b171
data/.gitignore CHANGED
@@ -7,10 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /.idea
10
- **/sample.html
11
- **/sample_global_search.html
12
- **/callout-list-block-sample.html
13
- **/sample.pdf
10
+ /test/*.html
11
+ /test/*.pdf
14
12
  *.gem
15
13
  /Gemfile.lock
16
14
  /.asciidoctor
data/CHANGELOG.md CHANGED
@@ -2,10 +2,19 @@
2
2
 
3
3
  Record of bug fixes, enhancements, and changes.
4
4
 
5
- ## [1.1.3] – 2022-07-07-16
5
+ ## [1.2.1] – 2022-09-16
6
6
 
7
7
  ### Fixed
8
+ - Fixed detection of source blocks that are nested inside other blocks.
9
+
10
+ ## [1.2.0] – 2022-07-30
11
+
12
+ ### Added
13
+ - 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.
8
14
 
15
+ ## [1.1.3] – 2022-07-07-16
16
+
17
+ ### Fixed
9
18
  - 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
19
  - Escaped slash characters were not being processed in the search. Thanks to Hakim Cassimally for finding the bug.
11
20
 
data/README.md CHANGED
@@ -70,6 +70,14 @@ Using the text search method means that the location of the callout will move wi
70
70
  **@/_text_/gi**
71
71
  : And of course, you can combine the two, though I'm not sure why you'd want to.
72
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
+
73
81
  ## Installation
74
82
 
75
83
  Add this line to your application's Gemfile:
@@ -18,6 +18,8 @@ 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
+ STANDALONE_CALLOUT_LIST_STYLE ||= 'calloutlist'
22
+
21
23
  LOCATION_TOKEN_RX ||= /@(\d+)|(@\/(?:\\\/|[^\/])+?\/[ig]{0,2})/
22
24
  LOCATION_TOKEN_ARRAY_RX ||= /^(@\d+|@\/(?:\\\/|[^\/]|)+?\/[ig]{0,2})((\s+@\d+)|(\s+@\/(?:\\\/|[^\/]|)+?\/[ig]{0,2}))*$/
23
25
 
@@ -33,18 +35,30 @@ Asciidoctor::Extensions::register do
33
35
  # The makes sure it's the right kind of list.
34
36
  document.find_by context: :olist do |list|
35
37
 
36
- if external_callout_list? list
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.
37
41
 
38
- owner_block = owning_block list
42
+ if list.style.include? STANDALONE_CALLOUT_LIST_STYLE
39
43
 
40
- owner_block.subs.replace(owner_block.subs + [:callouts]).uniq
44
+ list.context = :colist
41
45
 
42
- process_callouts(list, owner_block)
46
+ else
43
47
 
44
- list.context = :colist
48
+ if external_callout_list? list
49
+
50
+ owner_block = owning_block document, list
45
51
 
46
- owner_block.add_role(CALLOUT_SOURCE_BLOCK_ROLE) unless owner_block.has_role?(CALLOUT_SOURCE_BLOCK_ROLE)
47
- list.add_role(CALLOUT_ORDERED_LIST_ROLE) unless list.has_role?(CALLOUT_ORDERED_LIST_ROLE)
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
48
62
 
49
63
  end
50
64
 
@@ -85,13 +99,13 @@ Asciidoctor::Extensions::register do
85
99
 
86
100
  # Have a look at the next level up
87
101
  # to find the block that our CO list belongs to
88
- def owning_block(list)
102
+ def owning_block(document, list)
89
103
 
90
- list_parent = list.parent
104
+ all_blocks = document.find_by
91
105
 
92
- raise "There is no block above the callout list" if list_parent == nil
106
+ raise "There are no available blocks" if all_blocks == nil
93
107
 
94
- index_back = list_parent.blocks.index { |x| x == list }
108
+ index_back = all_blocks.index { |x| x == list }
95
109
 
96
110
  # We should be able to find our own block, but in case we can't …
97
111
  raise "Error – could not locate our ordered list" if index_back == nil
@@ -101,11 +115,11 @@ Asciidoctor::Extensions::register do
101
115
  index_back = index_back - 1
102
116
 
103
117
  # We have found our matching block
104
- return list_parent.blocks[index_back] if list_parent.blocks[index_back].context == :listing
118
+ return all_blocks[index_back] if all_blocks[index_back].context == :listing
105
119
 
106
120
  # We have hit another callout list, but there was no list block first.
107
121
  # Assume we have an error
108
- raise "Callout list found while seeking listing block" if list_parent.blocks[index_back].context == :colist
122
+ raise "Callout list found while seeking listing block" if all_blocks[index_back].context == :colist
109
123
 
110
124
  end
111
125
 
data/lib/version.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  module Asciidoctor
4
4
  module External
5
5
  module Callout
6
- VERSION = "1.1.4"
6
+ VERSION = "1.2.1"
7
7
  end
8
8
  end
9
9
  end
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
4
+ version: 1.2.1
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-17 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor