asciidoctor-autoterm 1.0.0 → 1.0.2

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: 9aa205a2201907e6e79efdf5e15b67116c0fe00c074927580f305487a930e817
4
- data.tar.gz: 73962f910b8e86becb9233012a7507d914e50508413567edd3896f59d1c95028
3
+ metadata.gz: dcc5c6113c38d85b30990827bb540723c544fca19945081ed308c27ba1a2e7ef
4
+ data.tar.gz: cf29b08297c9ddcfbd6c3bd28513dd9264c6d35671ca032ff9cf9a675a0250a9
5
5
  SHA512:
6
- metadata.gz: 1c708dde292c21e8149e81029ac501ebb53ea9da26c0aa159de5c4271360b01fefa00a1ca307b0588bd64c702e84135bd3e002ee7b3a6666bd79c2e24f22c000
7
- data.tar.gz: 8453acb552ee6b80382c0f95b48645eb1347b45203612efd766b60fcf138588ab32dca730b7d831a5832b0ff662ea147bde3e9e5d8b8473453baa04c0d7e5b29
6
+ metadata.gz: 8808d90bc9f42c396a2d61fb5d0f5c92d48d378f00b304366a20045865f3fd375beb9c43111ed8816bdf670f8ee3a9d74184373284ae22f4d345545b9e341a15
7
+ data.tar.gz: 1f13bed6c62613fc01bc66b9c65f67deea1e72721415eefdee58fa054eec8278f8c1a1afb9f6f121b7397ebebc5dd9fa4ccf5e226f2656a64d29b391b4c49078
@@ -13,10 +13,26 @@ class TermIndex < Asciidoctor::Converter.for('pdf')
13
13
  convert_terminology_entries(terms_by_full_name_with_abbr_and_definition) unless terms_by_full_name_with_abbr_and_definition.empty?
14
14
  nil
15
15
  else
16
+ repair_index_term_parens
16
17
  super
17
18
  end
18
19
  end
19
20
 
21
+ def repair_index_term_parens
22
+ # AsciiDoc matches the first )) in ((Full Term (Abbr))), so the stored term
23
+ # name loses its closing ). term.name is a FormattedString (String subclass
24
+ # with a fragments array). Append ) to the last fragment's text.
25
+ @index.categories.each do |category|
26
+ category.terms.each do |term_obj|
27
+ if term_obj.name.to_s =~ /\([^)]+$/
28
+ fixed_fragments = term_obj.name.fragments.map(&:dup)
29
+ fixed_fragments.last[:text] = "#{fixed_fragments.last[:text]})"
30
+ term_obj.instance_variable_set(:@name, FormattedString.new(fixed_fragments))
31
+ end
32
+ end
33
+ end
34
+ end
35
+
20
36
  def convert_terminology_entries(terms_by_full_name_with_abbr_and_definition)
21
37
  sorted_terms = terms_by_full_name_with_abbr_and_definition.sort_by do |full_term, details|
22
38
  abbr = details[:abbr]
@@ -114,7 +130,10 @@ class TermIndex < Asciidoctor::Converter.for('pdf')
114
130
  category.terms.each do |term_obj|
115
131
  term_name = term_obj.name
116
132
 
117
- if term_name =~ /(.*?)\s+\((.*?)\)/
133
+ # AsciiDoc's ((Full Term (Abbr))) indexterm syntax matches the FIRST ))
134
+ # encountered, so nested parens like (Abbr) lose their closing ).
135
+ # The regex matches (Abbr with or without a closing ) to handle both.
136
+ if term_name =~ /(.*?)\s+\(([^)]+)\)?$/
118
137
  full_name = $1.strip
119
138
  abbr = $2.strip
120
139
  else
@@ -1,5 +1,5 @@
1
1
  module Asciidoctor
2
2
  module Autoterm
3
- VERSION = '1.0.0'
3
+ VERSION = '1.0.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asciidoctor-autoterm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - baiyibai