metanorma-iso 1.10.2 → 1.10.6

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.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +3 -33
  3. data/.github/workflows/ubuntu.yml +1 -1
  4. data/Gemfile +1 -1
  5. data/lib/asciidoctor/iso/base.rb +1 -1
  6. data/lib/asciidoctor/iso/basicdoc.rng +1 -11
  7. data/lib/asciidoctor/iso/biblio.rng +0 -2
  8. data/lib/asciidoctor/iso/front.rb +17 -4
  9. data/lib/asciidoctor/iso/front_id.rb +20 -17
  10. data/lib/asciidoctor/iso/isodoc.rng +61 -19
  11. data/lib/asciidoctor/iso/isostandard-amd.rng +1 -1
  12. data/lib/asciidoctor/iso/isostandard.rng +15 -3
  13. data/lib/asciidoctor/iso/reqt.rng +1 -1
  14. data/lib/asciidoctor/iso/section.rb +1 -1
  15. data/lib/asciidoctor/iso/validate.rb +1 -1
  16. data/lib/asciidoctor/iso/validate_image.rb +1 -1
  17. data/lib/asciidoctor/iso/validate_section.rb +1 -1
  18. data/lib/isodoc/iso/base_convert.rb +14 -31
  19. data/lib/isodoc/iso/html/isodoc.scss +0 -1
  20. data/lib/isodoc/iso/html/style-human.scss +36 -9
  21. data/lib/isodoc/iso/html/style-iso.scss +31 -6
  22. data/lib/isodoc/iso/html/wordstyle.scss +10 -8
  23. data/lib/isodoc/iso/html_convert.rb +81 -22
  24. data/lib/isodoc/iso/index.rb +53 -45
  25. data/lib/isodoc/iso/iso.amendment.xsl +406 -122
  26. data/lib/isodoc/iso/iso.international-standard.xsl +406 -122
  27. data/lib/isodoc/iso/isosts_convert.rb +6 -2
  28. data/lib/isodoc/iso/metadata.rb +27 -22
  29. data/lib/isodoc/iso/presentation_xml_convert.rb +60 -25
  30. data/lib/isodoc/iso/sts_convert.rb +3 -2
  31. data/lib/isodoc/iso/word_convert.rb +0 -2
  32. data/lib/metanorma/iso/processor.rb +2 -2
  33. data/lib/metanorma/iso/version.rb +1 -1
  34. data/metanorma-iso.gemspec +3 -3
  35. data/spec/asciidoctor/base_spec.rb +398 -546
  36. data/spec/asciidoctor/blocks_spec.rb +4 -4
  37. data/spec/asciidoctor/cleanup_spec.rb +15 -12
  38. data/spec/asciidoctor/refs_spec.rb +87 -84
  39. data/spec/isodoc/amd_spec.rb +261 -250
  40. data/spec/isodoc/i18n_spec.rb +7 -7
  41. data/spec/isodoc/inline_spec.rb +242 -216
  42. data/spec/isodoc/iso_spec.rb +3 -1
  43. data/spec/isodoc/postproc_spec.rb +111 -28
  44. data/spec/isodoc/section_spec.rb +4 -4
  45. data/spec/isodoc/terms_spec.rb +34 -41
  46. data/spec/isodoc/xref_spec.rb +3 -3
  47. data/spec/metanorma/processor_spec.rb +110 -14
  48. data/spec/vcr_cassettes/docrels.yml +37 -427
  49. metadata +11 -16
  50. data/lib/isodoc/iso/html/htmlstyle.css +0 -47
  51. data/lib/isodoc/iso/html/isodoc.css +0 -1328
  52. data/lib/isodoc/iso/html/style-human.css +0 -979
  53. data/lib/isodoc/iso/html/style-iso.css +0 -1007
  54. data/lib/isodoc/iso/html/wordstyle.css +0 -1699
@@ -140,7 +140,7 @@ span.title {
140
140
 
141
141
  /* TYPOGRAPHY */
142
142
 
143
- h1 {
143
+ h1, .h1 {
144
144
  font-weight: 900;
145
145
  }
146
146
 
@@ -148,18 +148,19 @@ h2,
148
148
  h3,
149
149
  h4,
150
150
  h5,
151
- h6 {
151
+ h6,
152
+ .h2, .h3, .h4, .h5, .h6{
152
153
  font-weight: 700;
153
154
  }
154
155
 
155
- h1 {
156
+ h1, .h1 {
156
157
  font-size: 1.5em;
157
158
  line-height: 2em;
158
159
  margin-top: 2em;
159
160
  margin-bottom: 1em;
160
161
  }
161
162
 
162
- h2 {
163
+ h2, .h2 {
163
164
  font-size: 1.2em;
164
165
  line-height: 1.5em;
165
166
  margin-top: 2em;
@@ -171,7 +172,8 @@ h2,
171
172
  h3,
172
173
  h4,
173
174
  h5,
174
- h6 {
175
+ h6,
176
+ .h1, .h2, .h3, .h4, .h5, .h6 {
175
177
  line-height: 1.2;
176
178
  }
177
179
 
@@ -179,7 +181,7 @@ h6 {
179
181
 
180
182
  {% if doctype == "Amendment" or doctype == "Technical Corrigendum" %}
181
183
 
182
- h1, h2, h3, h4, h5, h6 {
184
+ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
183
185
  font-weight: normal;
184
186
  font-size: initial;
185
187
  font-style: italic;
@@ -190,7 +192,7 @@ h1, h2, h3, h4, h5, h6 {
190
192
 
191
193
  {% endif %}
192
194
 
193
- h2 p {
195
+ h2 p, .h2 p {
194
196
  display: inline;
195
197
  }
196
198
 
@@ -218,7 +220,7 @@ a {
218
220
  text-decoration-color: black;
219
221
  }
220
222
 
221
- h2 p {
223
+ h2 p, .h2 p {
222
224
  display: inline;
223
225
  }
224
226
 
@@ -252,7 +254,6 @@ p.AltTerms {
252
254
  }
253
255
 
254
256
  p.Terms {
255
- font-weight: bold;
256
257
  margin-top: 0em;
257
258
  }
258
259
 
@@ -693,3 +694,29 @@ span.keyword {
693
694
  .admonition p {
694
695
  margin: 0;
695
696
  }
697
+
698
+ /* Collapse TOC */
699
+
700
+ .collapse-group {
701
+ display: flex;
702
+ align-items: center;
703
+ position: relative;
704
+ }
705
+
706
+ .collapse-button {
707
+ position: absolute;
708
+ right: 0;
709
+ display: inline-block;
710
+ height: 20px;
711
+ width: 20px;
712
+ cursor: pointer;
713
+ background-image: url('data:image/svg+xml,<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="rgba(0,0,0,.54)" d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"></path></svg>');
714
+ }
715
+
716
+ .collapse {
717
+ display: none;
718
+ }
719
+
720
+ .expand {
721
+ transform: rotateZ(-180deg);
722
+ }
@@ -112,27 +112,27 @@ span.partlabel {
112
112
 
113
113
  /* TYPOGRAPHY */
114
114
 
115
- h1 {
115
+ h1, .h1 {
116
116
  font-size: 1.5em;
117
117
  line-height: 2em;
118
118
  margin-top: 2em;
119
119
  margin-bottom: 1em;
120
120
  }
121
121
 
122
- h2 {
122
+ h2, .h2 {
123
123
  font-size: 1.2em;
124
124
  line-height: 1.5em;
125
125
  margin-top: 2em;
126
126
  margin-bottom: 1em;
127
127
  }
128
128
 
129
- h1, h2, h3, h4, h5, h6 {
129
+ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
130
130
  line-height: 1.2;
131
131
  }
132
132
 
133
133
  {% if doctype == "Amendment" or doctype == "Technical Corrigendum" %}
134
134
 
135
- h1, h2, h3, h4, h5, h6 {
135
+ h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
136
136
  font-weight: normal;
137
137
  font-size: initial;
138
138
  font-style: italic;
@@ -164,7 +164,7 @@ a {
164
164
  text-decoration-color: black;
165
165
  }
166
166
 
167
- h2 p {
167
+ h2 p, .h2 p {
168
168
  display: inline;
169
169
  }
170
170
 
@@ -193,7 +193,6 @@ p.AltTerms {
193
193
  }
194
194
 
195
195
  p.Terms {
196
- font-weight: bold;
197
196
  margin-top: 0em;
198
197
  }
199
198
 
@@ -710,3 +709,29 @@ font-weight: 600;
710
709
  .Admonition p, .admonition p {
711
710
  margin: 0;
712
711
  }
712
+
713
+ /* Collapse TOC */
714
+
715
+ .collapse-group {
716
+ display: flex;
717
+ align-items: center;
718
+ position: relative;
719
+ }
720
+
721
+ .collapse-button {
722
+ position: absolute;
723
+ right: 0;
724
+ display: inline-block;
725
+ height: 20px;
726
+ width: 20px;
727
+ cursor: pointer;
728
+ background-image: url('data:image/svg+xml,<svg focusable="false" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="rgba(0,0,0,.54)" d="M16.59 8.59L12 13.17 7.41 8.59 6 10l6 6 6-6z"></path></svg>');
729
+ }
730
+
731
+ .collapse {
732
+ display: none;
733
+ }
734
+
735
+ .expand {
736
+ transform: rotateZ(-180deg);
737
+ }
@@ -269,7 +269,7 @@ p.MsoListParagraphCxSpLast, li.MsoListParagraphCxSpLast, div.MsoListParagraphCxS
269
269
  div.figure, p.figure
270
270
  {text-align: center;}
271
271
 
272
- h1
272
+ h1, .h1
273
273
  {mso-style-priority:1;
274
274
  mso-style-unhide:no;
275
275
  mso-style-qformat:yes;
@@ -284,8 +284,6 @@ h1
284
284
  line-height:13.5pt;
285
285
  mso-pagination:widow-orphan;
286
286
  page-break-after:avoid;
287
- mso-outline-level:1;
288
- mso-list:l1 level1 lfo6;
289
287
  mso-hyphenate:none;
290
288
  tab-stops:20.0pt list 21.6pt left 28.0pt;
291
289
  {% if doctype == "Amendment" or doctype == "Technical Corrigendum" %}
@@ -303,6 +301,10 @@ h1
303
301
  mso-ansi-language:EN-GB;
304
302
  mso-fareast-language:JA;
305
303
  mso-bidi-font-weight:normal;}
304
+ h1 {
305
+ mso-outline-level:1;
306
+ mso-list:l1 level1 lfo6;
307
+ }
306
308
  h1.ForewordTitle {
307
309
  font-size:13.0pt;
308
310
  font-style: normal ;
@@ -336,7 +338,7 @@ h1.Annex
336
338
  mso-ansi-language:EN-GB;
337
339
  mso-fareast-language:JA;
338
340
  mso-bidi-font-weight:normal;}
339
- .h2Annex, h2
341
+ .h2Annex, h2, .h2
340
342
  {mso-style-priority:2;
341
343
  mso-style-unhide:no;
342
344
  mso-style-qformat:yes;
@@ -372,7 +374,7 @@ h2
372
374
  { mso-list:l1 level2 lfo6;
373
375
  mso-outline-level:2;
374
376
  }
375
- .h3Annex, h3
377
+ .h3Annex, h3, .h3
376
378
  {mso-style-priority:3;
377
379
  mso-style-unhide:no;
378
380
  mso-style-qformat:yes;
@@ -407,7 +409,7 @@ h2
407
409
  h3 {mso-list:l1 level3 lfo6;
408
410
  mso-outline-level:3;
409
411
  }
410
- .h4Annex, h4
412
+ .h4Annex, h4, .h4
411
413
  {mso-style-priority:4;
412
414
  mso-style-unhide:no;
413
415
  mso-style-qformat:yes;
@@ -440,7 +442,7 @@ h3 {mso-list:l1 level3 lfo6;
440
442
  h4 {mso-list:l1 level4 lfo6;
441
443
  mso-outline-level:4;
442
444
  }
443
- .h5Annex, h5
445
+ .h5Annex, h5, .h5
444
446
  {mso-style-priority:5;
445
447
  mso-style-unhide:no;
446
448
  mso-style-qformat:yes;
@@ -473,7 +475,7 @@ h4 {mso-list:l1 level4 lfo6;
473
475
  h5 {mso-list:l1 level5 lfo6;
474
476
  mso-outline-level:5;
475
477
  }
476
- h6
478
+ h6, .h6
477
479
  {mso-style-priority:6;
478
480
  mso-style-unhide:no;
479
481
  mso-style-qformat:yes;
@@ -10,39 +10,98 @@ module IsoDoc
10
10
  super
11
11
  end
12
12
 
13
- def googlefonts()
14
- <<~HEAD.freeze
15
- <link href="https://fonts.googleapis.com/css?family=Space+Mono:400,400i,700,700i&display=swap" rel="stylesheet">
16
- <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
17
- HEAD
18
- end
13
+ def googlefonts
14
+ <<~HEAD.freeze
15
+ <link href="https://fonts.googleapis.com/css?family=Space+Mono:400,400i,700,700i&display=swap" rel="stylesheet">
16
+ <link href="https://fonts.googleapis.com/css?family=Lato:400,400i,700,900" rel="stylesheet">
17
+ HEAD
18
+ end
19
19
 
20
20
  def default_fonts(options)
21
21
  {
22
- bodyfont: (options[:script] == "Hans" ? '"Source Han Sans",serif' :
23
- options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'),
24
- headerfont: (options[:script] == "Hans" ? '"Source Han Sans",sans-serif' :
25
- options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'),
26
- monospacefont: (options[:alt] ? '"Space Mono",monospace' :
27
- '"Courier New",monospace'),
28
- normalfontsize: "1.0em",
29
- smallerfontsize: "0.9em",
30
- footnotefontsize: "0.9em",
31
- monospacefontsize: "0.8em",
22
+ bodyfont: (if options[:script] == "Hans"
23
+ '"Source Han Sans",serif'
24
+ else
25
+ options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'
26
+ end),
27
+ headerfont: (if options[:script] == "Hans"
28
+ '"Source Han Sans",sans-serif'
29
+ else
30
+ options[:alt] ? '"Lato",sans-serif' : '"Cambria",serif'
31
+ end),
32
+ monospacefont: (if options[:alt]
33
+ '"Space Mono",monospace'
34
+ else
35
+ '"Courier New",monospace'
36
+ end),
37
+ normalfontsize: "1.0em",
38
+ smallerfontsize: "0.9em",
39
+ footnotefontsize: "0.9em",
40
+ monospacefontsize: "0.8em",
32
41
  }
33
42
  end
34
43
 
35
44
  def default_file_locations(options)
36
45
  {
37
- htmlstylesheet: (options[:alt] ? html_doc_path("style-human.scss") :
38
- html_doc_path("style-iso.scss")),
39
- htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
40
- htmlintropage: html_doc_path("html_iso_intro.html"),
46
+ htmlstylesheet: (if options[:alt]
47
+ html_doc_path("style-human.scss")
48
+ else
49
+ html_doc_path("style-iso.scss")
50
+ end),
51
+ htmlcoverpage: html_doc_path("html_iso_titlepage.html"),
52
+ htmlintropage: html_doc_path("html_iso_intro.html"),
41
53
  }
42
54
  end
43
55
 
44
- def footnote_reference_format(a)
45
- a.content = a.content + ")"
56
+ def footnote_reference_format(link)
57
+ link.content += ")"
58
+ end
59
+
60
+ def html_toc_entry(level, header)
61
+ if level == "h1" && header.parent.at(".//h2[not(@class = 'TermNum')]"\
62
+ "[not(@class = 'noTOC')][text()]")
63
+ <<~HDR
64
+ <li class="#{level}"><div class="collapse-group"><a href="##{header['id']}">#{header_strip(header)}</a></li>
65
+ <div class="collapse-button"></div></div>
66
+ HDR
67
+ else
68
+ %(<li class="#{level}"><a href="##{header['id']}">\
69
+ #{header_strip(header)}</a></li>)
70
+ end
71
+ end
72
+
73
+ def html_toc(docxml)
74
+ super
75
+ docxml.xpath("//div[@id = 'toc']/ul[li[@class = 'h2']]").each do |u|
76
+ html_toc1(u)
77
+ end
78
+ docxml
79
+ end
80
+
81
+ def html_toc1(ulist)
82
+ u2 = nil
83
+ ulist.xpath("./li").each do |l|
84
+ if l["class"] != "h2"
85
+ u2 = nil
86
+ elsif u2 then u2.add_child(l.remove)
87
+ else
88
+ u2 = l.replace("<ul class='content collapse'>#{l}</ul>").first
89
+ p = u2.previous_element and p << u2
90
+ end
91
+ end
92
+ end
93
+
94
+ def inject_script(doc)
95
+ scr = <<~HEAD.freeze
96
+ <script>
97
+ $(".collapse-button").click(function () {
98
+ $(this).toggleClass('expand'); // expand: the class to change the collapse button shape
99
+ // collapse: the class to collapse/expand the li elements with the h2 class
100
+ $(this).closest('li').children(".content").toggleClass('collapse');})
101
+ </script>
102
+ HEAD
103
+ a = super.split(%r{</body>})
104
+ "#{a[0]}#{scr}</body>#{a[1]}"
46
105
  end
47
106
 
48
107
  def table_th_center(docxml)
@@ -5,32 +5,36 @@ module IsoDoc
5
5
  %(id="_#{UUIDTools::UUID.random_create}")
6
6
  end
7
7
 
8
- def index(docxml)
9
- unless docxml.at(ns("//index"))
10
- docxml.xpath(ns("//indexsect")).each(&:remove)
11
- return
8
+ def index(xml)
9
+ if xml.at(ns("//index"))
10
+ i = xml.at(ns("//indexsect")) ||
11
+ xml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}"\
12
+ "</title></indexsect>").first
13
+ index = sort_indexterms(xml.xpath(ns("//index")),
14
+ xml.xpath(ns("//index-xref[@also = 'false']")),
15
+ xml.xpath(ns("//index-xref[@also = 'true']")))
16
+ index1(xml, i, index)
17
+ else xml.xpath(ns("//indexsect")).each(&:remove)
12
18
  end
13
- i = docxml.at(ns("//indexsect")) ||
14
- docxml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}</title></indexsect>").first
15
- index = sort_indexterms(docxml.xpath(ns("//index")),
16
- docxml.xpath(ns("//index-xref[@also = 'false']")),
17
- docxml.xpath(ns("//index-xref[@also = 'true']")))
18
- index1(docxml, i, index)
19
19
  end
20
20
 
21
- def index1(docxml, i, index)
22
- c = i.add_child("<ul></ul>").first
21
+ def index1(docxml, indexsect, index)
22
+ c = indexsect.add_child("<ul></ul>").first
23
23
  index.keys.sort.each do |k|
24
- # c = i.add_child "<clause #{add_id}><title>#{k}</title><ul></ul></clause>"
25
24
  words = index[k].keys.each_with_object({}) do |w, v|
26
25
  v[sortable(w).downcase] = w
27
26
  end
28
27
  words.keys.localize(@lang.to_sym).sort.to_a.each do |w|
29
- # c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
30
28
  c.add_child index_entries(words, index[k], w)
31
29
  end
32
30
  end
33
- docxml.xpath(ns("//indexsect//xref")).each { |x| x.children.remove }
31
+ index1_cleanup(docxml)
32
+ end
33
+
34
+ def index1_cleanup(docxml)
35
+ docxml.xpath(ns("//indexsect//xref")).each do |x|
36
+ x.children.remove
37
+ end
34
38
  @xrefs.bookmark_anchor_names(docxml)
35
39
  end
36
40
 
@@ -56,7 +60,7 @@ module IsoDoc
56
60
  end
57
61
  ret += "</ul>"
58
62
  end
59
- ret + "</li>"
63
+ "#{ret}</li>"
60
64
  end
61
65
 
62
66
  def index_entries2(words, index, secondary)
@@ -75,30 +79,29 @@ module IsoDoc
75
79
  end
76
80
  ret += "</ul>"
77
81
  end
78
- ret + "</li>"
82
+ "#{ret}</li>"
79
83
  end
80
84
 
81
85
  def index_entries_head(head, entries, opt)
82
86
  ret = "<li>#{head}"
83
87
  xref = entries&.dig(:xref)&.join(", ")
84
- see_sort = entries&.dig(:see)&.each_with_object({}) do |w, v|
85
- v[sortable(w).downcase] = w
86
- end
87
- see = see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map do |k|
88
- see_sort[k]
89
- end&.join(", ")
90
- also_sort = entries&.dig(:also)&.each_with_object({}) do |w, v|
91
- v[sortable(w).downcase] = w
92
- end
93
- also = also_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map do |k|
94
- also_sort[k]
95
- end&.join(", ")
88
+ see = index_entries_see(entries, :see)
89
+ also = index_entries_see(entries, :also)
96
90
  ret += "#{opt[:xref_lbl]} #{xref}" if xref
97
91
  ret += "#{opt[:see_lbl]} #{see}" if see
98
92
  ret += "#{opt[:also_lbl]} #{also}" if also
99
93
  ret
100
94
  end
101
95
 
96
+ def index_entries_see(entries, label)
97
+ see_sort = entries&.dig(label)&.each_with_object({}) do |w, v|
98
+ v[sortable(w).downcase] = w
99
+ end
100
+ see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map do |k|
101
+ see_sort[k]
102
+ end&.join(", ")
103
+ end
104
+
102
105
  def see_lbl
103
106
  @lang == "en" ? @i18n.see : "<em>#{@i18n.see}</em>"
104
107
  end
@@ -119,13 +122,8 @@ module IsoDoc
119
122
 
120
123
  def extract_indexsee(val, terms, label)
121
124
  terms.each_with_object(val) do |t, v|
122
- term = t&.at(ns("./primary"))&.children&.to_xml
123
- term2 = t&.at(ns("./secondary"))&.children&.to_xml
124
- term3 = t&.at(ns("./tertiary"))&.children&.to_xml
125
- v[term] ||= {}
126
- v[term][term2] ||= {}
127
- v[term][term2][term3] ||= {}
128
- v[term][term2][term3][label] ||= []
125
+ term, term2, term3 = extract_indexterms_init(t)
126
+ term_hash_init(v, term, term2, term3, label)
129
127
  v[term][term2][term3][label] << t&.at(ns("./target"))&.children&.to_xml
130
128
  t.remove
131
129
  end
@@ -138,22 +136,32 @@ module IsoDoc
138
136
  end
139
137
  end
140
138
 
141
- # attributes are decoded into UTF-8, elements in extract_indexsee are still in entities
139
+ # attributes are decoded into UTF-8,
140
+ # elements in extract_indexsee are still in entities
142
141
  def extract_indexterms(terms)
143
142
  terms.each_with_object({}) do |t, v|
144
- term = t&.at(ns("./primary"))&.children&.to_xml
145
- term2 = t&.at(ns("./secondary"))&.children&.to_xml
146
- term3 = t&.at(ns("./tertiary"))&.children&.to_xml
143
+ term, term2, term3 = extract_indexterms_init(t)
147
144
  index2bookmark(t)
148
- v[term] ||= {}
149
- v[term][term2] ||= {}
150
- v[term][term2][term3] ||= {}
151
- v[term][term2][term3][:xref] ||= []
145
+ term_hash_init(v, term, term2, term3, :xref)
152
146
  to = t["to"] ? "to='#{t['to']}' " : ""
153
- v[term][term2][term3][:xref] << "<xref target='#{t['id']}' #{to}pagenumber='true'/>"
147
+ v[term][term2][term3][:xref] << "<xref target='#{t['id']}' "\
148
+ "#{to}pagenumber='true'/>"
149
+ end
150
+ end
151
+
152
+ def extract_indexterms_init(term)
153
+ %w(primary secondary tertiary).each_with_object([]) do |x, m|
154
+ m << term&.at(ns("./#{x}"))&.children&.to_xml
154
155
  end
155
156
  end
156
157
 
158
+ def term_hash_init(hash, term, term2, term3, label)
159
+ hash[term] ||= {}
160
+ hash[term][term2] ||= {}
161
+ hash[term][term2][term3] ||= {}
162
+ hash[term][term2][term3][label] ||= []
163
+ end
164
+
157
165
  def index2bookmark(node)
158
166
  node.name = "bookmark"
159
167
  node.children.each(&:remove)