metanorma-iso 1.9.2 → 1.9.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@ module Asciidoctor
15
15
  end
16
16
 
17
17
  def appendix_parse(attrs, xml, node)
18
- attrs["inline-header".to_sym] = node.option? "inline-header"
18
+ attrs[:"inline-header"] = node.option? "inline-header"
19
19
  set_obligation(attrs, node)
20
20
  xml.appendix **attr_code(attrs) do |xml_section|
21
21
  xml_section.title { |name| name << node.title }
@@ -38,6 +38,12 @@ module Asciidoctor
38
38
 
39
39
  super
40
40
  end
41
+
42
+ def term_def_subclause_parse(attrs, xml, node)
43
+ node.role == "term" and
44
+ return term_def_subclause_parse1(attrs, xml, node)
45
+ super
46
+ end
41
47
  end
42
48
  end
43
49
  end
@@ -32,10 +32,10 @@ module Asciidoctor
32
32
  end
33
33
 
34
34
  ONE_SYMBOLS_WARNING = "Only one Symbols and Abbreviated "\
35
- "Terms section in the standard".freeze
35
+ "Terms section in the standard".freeze
36
36
 
37
37
  NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can "\
38
- "only contain a definition list".freeze
38
+ "only contain a definition list".freeze
39
39
 
40
40
  def symbols_validate(root)
41
41
  f = root.xpath("//definitions")
@@ -87,7 +87,7 @@ module Asciidoctor
87
87
  },
88
88
  {
89
89
  msg: "Normative References must be followed by "\
90
- "Terms and Definitions",
90
+ "Terms and Definitions",
91
91
  val: ["./self::terms | .//terms"],
92
92
  },
93
93
  ].freeze
@@ -127,17 +127,20 @@ module Asciidoctor
127
127
  end
128
128
  elem&.at("./self::clause") ||
129
129
  @log.add("Style", elem, "Document must contain clause after "\
130
- "Terms and Definitions")
130
+ "Terms and Definitions")
131
131
  elem&.at("./self::clause[@type = 'scope']") &&
132
- @log.add("Style", elem, "Scope must occur before Terms and Definitions")
132
+ @log.add("Style", elem,
133
+ "Scope must occur before Terms and Definitions")
133
134
  elem = names.shift
134
135
  while elem&.name == "clause"
135
136
  elem&.at("./self::clause[@type = 'scope']")
136
- @log.add("Style", elem, "Scope must occur before Terms and Definitions")
137
+ @log.add("Style", elem,
138
+ "Scope must occur before Terms and Definitions")
137
139
  elem = names.shift
138
140
  end
139
141
  %w(annex references).include? elem&.name or
140
- @log.add("Style", elem, "Only annexes and references can follow clauses")
142
+ @log.add("Style", elem,
143
+ "Only annexes and references can follow clauses")
141
144
  [names, elem]
142
145
  end
143
146
 
@@ -146,7 +149,8 @@ module Asciidoctor
146
149
  elem = names.shift
147
150
  end
148
151
  %w(annex references).include? elem&.name or
149
- @log.add("Style", elem, "Only annexes and references can follow terms and clauses")
152
+ @log.add("Style", elem,
153
+ "Only annexes and references can follow terms and clauses")
150
154
  [names, elem]
151
155
  end
152
156
 
@@ -155,25 +159,19 @@ module Asciidoctor
155
159
  elem = names.shift
156
160
  if elem.nil?
157
161
  @log.add("Style", nil, "Document must include (references) "\
158
- "Normative References")
162
+ "Normative References")
159
163
  end
160
164
  end
161
165
  elem&.at("./self::references[@normative = 'true']") ||
162
166
  @log.add("Style", nil, "Document must include (references) "\
163
- "Normative References")
167
+ "Normative References")
164
168
  elem = names&.shift
165
169
  elem&.at("./self::references[@normative = 'false']") ||
166
- @log.add("Style", elem, "Final section must be (references) Bibliography")
170
+ @log.add("Style", elem,
171
+ "Final section must be (references) Bibliography")
167
172
  names.empty? ||
168
- @log.add("Style", elem, "There are sections after the final Bibliography")
169
- end
170
-
171
- def style_warning(node, msg, text = nil)
172
- return if @novalid
173
-
174
- w = msg
175
- w += ": #{text}" if text
176
- @log.add("Style", node, w)
173
+ @log.add("Style", elem,
174
+ "There are sections after the final Bibliography")
177
175
  end
178
176
 
179
177
  NORM_ISO_WARN = "non-ISO/IEC reference not expected as normative".freeze
@@ -70,18 +70,18 @@ module Asciidoctor
70
70
  style(node, extract_text(node))
71
71
  end
72
72
 
73
- def style_regex(re, warning, n, text)
74
- (m = re.match(text)) && style_warning(n, warning, m[:num])
73
+ def style_regex(regex, warning, n, text)
74
+ (m = regex.match(text)) && style_warning(n, warning, m[:num])
75
75
  end
76
76
 
77
77
  # style check with a regex on a token
78
78
  # and a negative match on its preceding token
79
- def style_two_regex_not_prev(n, text, re, re_prev, warning)
79
+ def style_two_regex_not_prev(n, text, regex, re_prev, warning)
80
80
  return if text.nil?
81
81
 
82
82
  arr = Tokenizer::WhitespaceTokenizer.new.tokenize(text)
83
83
  arr.each_index do |i|
84
- m = re.match arr[i]
84
+ m = regex.match arr[i]
85
85
  m_prev = i.zero? ? nil : re_prev.match(arr[i - 1])
86
86
  if !m.nil? && m_prev.nil?
87
87
  style_warning(n, warning, m[:num])
@@ -132,22 +132,22 @@ module Asciidoctor
132
132
 
133
133
  # leaving out as problematic: N J K C S T H h d B o E
134
134
  SI_UNIT = "(m|cm|mm|km|μm|nm|g|kg|mgmol|cd|rad|sr|Hz|Hz|MHz|Pa|hPa|kJ|"\
135
- "V|kV|W|MW|kW|F|μF|Ω|Wb|°C|lm|lx|Bq|Gy|Sv|kat|l|t|eV|u|Np|Bd|"\
136
- "bit|kB|MB|Hart|nat|Sh|var)".freeze
135
+ "V|kV|W|MW|kW|F|μF|Ω|Wb|°C|lm|lx|Bq|Gy|Sv|kat|l|t|eV|u|Np|Bd|"\
136
+ "bit|kB|MB|Hart|nat|Sh|var)".freeze
137
137
 
138
138
  # ISO/IEC DIR 2, 9.3
139
139
  def style_units(node, text)
140
140
  style_regex(/\b(?<num>[0-9][0-9,]*\s+[\u00b0\u2032\u2033])/,
141
141
  "space between number and degrees/minutes/seconds",
142
142
  node, text)
143
- style_regex(/\b(?<num>[0-9][0-9,]*#{SI_UNIT})\b/,
143
+ style_regex(/\b(?<num>[0-9][0-9,]*#{SI_UNIT})\b/o,
144
144
  "no space between number and SI unit", node, text)
145
145
  style_non_std_units(node, text)
146
146
  end
147
147
 
148
148
  NONSTD_UNITS = {
149
- "sec": "s", "mins": "min", "hrs": "h", "hr": "h", "cc": "cm^3",
150
- "lit": "l", "amp": "A", "amps": "A", "rpm": "r/min"
149
+ sec: "s", mins: "min", hrs: "h", hr: "h", cc: "cm^3",
150
+ lit: "l", amp: "A", amps: "A", rpm: "r/min"
151
151
  }.freeze
152
152
 
153
153
  # ISO/IEC DIR 2, 9.3
@@ -157,6 +157,14 @@ module Asciidoctor
157
157
  "non-standard unit (should be #{v})", node, text)
158
158
  end
159
159
  end
160
+
161
+ def style_warning(node, msg, text = nil)
162
+ return if @novalid
163
+
164
+ w = msg
165
+ w += ": #{text}" if text
166
+ @log.add("Style", node, w)
167
+ end
160
168
  end
161
169
  end
162
170
  end
@@ -1,4 +1,3 @@
1
- @charset "UTF-8";
2
1
  p.Sourcecode, li.Sourcecode, div.Sourcecode, pre.Sourcecode {
3
2
  mso-style-unhide: no;
4
3
  mso-style-qformat: yes;
@@ -208,7 +207,7 @@ p.AnnexTableTitle, li.AnnexTableTitle, div.AnnexTableTitle {
208
207
  mso-style-name: "Annex Table Title";
209
208
  mso-style-unhide: no;
210
209
  mso-style-qformat: yes;
211
- mso-style-parent: "Παράγραφος λίστας";
210
+ mso-style-parent: "List Paragraph";
212
211
  mso-style-link: "Annex Table Title Char";
213
212
  margin-top: 0cm;
214
213
  margin-right: 0cm;
@@ -197,7 +197,7 @@ p.AnnexTableTitle, li.AnnexTableTitle, div.AnnexTableTitle
197
197
  {mso-style-name:"Annex Table Title";
198
198
  mso-style-unhide:no;
199
199
  mso-style-qformat:yes;
200
- mso-style-parent:"Παράγραφος λίστας";
200
+ mso-style-parent:"List Paragraph";
201
201
  mso-style-link:"Annex Table Title Char";
202
202
  margin-top:0cm;
203
203
  margin-right:0cm;
@@ -130,7 +130,7 @@ p.MsoBlockText, li.MsoBlockText, div.MsoBlockText {
130
130
  p.MsoList, li.MsoList, div.MsoList {
131
131
  mso-style-priority: 4;
132
132
  mso-style-unhide: no;
133
- mso-style-parent: "MsoListParagraph";
133
+ mso-style-parent: "List Paragraph";
134
134
  margin-top: 0cm;
135
135
  margin-right: 0cm;
136
136
  margin-bottom: 6.0pt;
@@ -151,7 +151,7 @@ p.MsoList, li.MsoList, div.MsoList {
151
151
  p.MsoListCxSpFirst, li.MsoListCxSpFirst, div.MsoListCxSpFirst {
152
152
  mso-style-priority: 4;
153
153
  mso-style-unhide: no;
154
- mso-style-parent: "MsoListParagraph";
154
+ mso-style-parent: "List Paragraph";
155
155
  mso-style-type: export-only;
156
156
  margin-top: 0cm;
157
157
  margin-right: 0cm;
@@ -173,7 +173,7 @@ p.MsoListCxSpFirst, li.MsoListCxSpFirst, div.MsoListCxSpFirst {
173
173
  p.MsoListCxSpMiddle, li.MsoListCxSpMiddle, div.MsoListCxSpMiddle {
174
174
  mso-style-priority: 4;
175
175
  mso-style-unhide: no;
176
- mso-style-parent: "MsoListParagraph";
176
+ mso-style-parent: "List Paragraph";
177
177
  mso-style-type: export-only;
178
178
  margin-top: 0cm;
179
179
  margin-right: 0cm;
@@ -195,7 +195,7 @@ p.MsoListCxSpMiddle, li.MsoListCxSpMiddle, div.MsoListCxSpMiddle {
195
195
  p.MsoListCxSpLast, li.MsoListCxSpLast, div.MsoListCxSpLast {
196
196
  mso-style-priority: 4;
197
197
  mso-style-unhide: no;
198
- mso-style-parent: "MsoListParagraph";
198
+ mso-style-parent: "List Paragraph";
199
199
  mso-style-type: export-only;
200
200
  margin-top: 0cm;
201
201
  margin-right: 0cm;
@@ -217,6 +217,7 @@ p.MsoListCxSpLast, li.MsoListCxSpLast, div.MsoListCxSpLast {
217
217
  p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph {
218
218
  mso-style-priority: 34;
219
219
  mso-style-unhide: no;
220
+ mso-style-name: "List Paragraph";
220
221
  mso-style-qformat: yes;
221
222
  margin-top: 0cm;
222
223
  margin-right: 0cm;
@@ -292,6 +293,7 @@ h1 {
292
293
  mso-style-priority: 1;
293
294
  mso-style-unhide: no;
294
295
  mso-style-qformat: yes;
296
+ mso-style-name: "Heading 1";
295
297
  mso-style-link: "Heading 1 Char";
296
298
  mso-style-next: Normal;
297
299
  margin-top: 13.5pt;
@@ -360,6 +362,7 @@ h1.Annex {
360
362
  mso-style-priority: 2;
361
363
  mso-style-unhide: no;
362
364
  mso-style-qformat: yes;
365
+ mso-style-name: "Heading 2";
363
366
  mso-style-parent: "Heading 1";
364
367
  mso-style-link: "Heading 2 Char";
365
368
  mso-style-next: Normal;
@@ -396,6 +399,7 @@ h2 {
396
399
  mso-style-priority: 3;
397
400
  mso-style-unhide: no;
398
401
  mso-style-qformat: yes;
402
+ mso-style-name: "Heading 3";
399
403
  mso-style-parent: "Heading 1";
400
404
  mso-style-link: "Heading 3 Char";
401
405
  mso-style-next: Normal;
@@ -432,6 +436,7 @@ h3 {
432
436
  mso-style-priority: 4;
433
437
  mso-style-unhide: no;
434
438
  mso-style-qformat: yes;
439
+ mso-style-name: "Heading 4";
435
440
  mso-style-parent: "Heading 3";
436
441
  mso-style-link: "Heading 4 Char";
437
442
  mso-style-next: Normal;
@@ -466,6 +471,7 @@ h4 {
466
471
  mso-style-priority: 5;
467
472
  mso-style-unhide: no;
468
473
  mso-style-qformat: yes;
474
+ mso-style-name: "Heading 5";
469
475
  mso-style-parent: "Heading 4";
470
476
  mso-style-link: "Heading 5 Char";
471
477
  mso-style-next: Normal;
@@ -500,6 +506,7 @@ h6 {
500
506
  mso-style-priority: 6;
501
507
  mso-style-unhide: no;
502
508
  mso-style-qformat: yes;
509
+ mso-style-name: "Heading 6";
503
510
  mso-style-parent: "Heading 5";
504
511
  mso-style-link: "Heading 6 Char";
505
512
  mso-style-next: Normal;
@@ -533,6 +540,7 @@ h6 {
533
540
  p.MsoToc1, li.MsoToc1, div.MsoToc1 {
534
541
  mso-style-priority: 39;
535
542
  mso-style-unhide: no;
543
+ mso-style-name: "TOC 1";
536
544
  mso-style-next: Normal;
537
545
  margin-top: 6.0pt;
538
546
  margin-right: 25.0pt;
@@ -555,6 +563,7 @@ p.MsoToc2, li.MsoToc2, div.MsoToc2 {
555
563
  mso-style-noshow: yes;
556
564
  mso-style-priority: 39;
557
565
  mso-style-unhide: no;
566
+ mso-style-name: "TOC 2";
558
567
  mso-style-parent: "TOC 1";
559
568
  mso-style-next: Normal;
560
569
  margin-top: 0cm;
@@ -578,6 +587,7 @@ p.MsoToc3, li.MsoToc3, div.MsoToc3 {
578
587
  mso-style-noshow: yes;
579
588
  mso-style-priority: 39;
580
589
  mso-style-unhide: no;
590
+ mso-style-name: "TOC 3";
581
591
  mso-style-parent: "TOC 2";
582
592
  mso-style-next: Normal;
583
593
  margin-top: 0cm;
@@ -683,6 +693,7 @@ p.MsoFooterLandscape, li.MsoFooterLandscape, div.MsoFooterLandscape {
683
693
 
684
694
  span.MsoFootnoteReference {
685
695
  mso-style-priority: 99;
696
+ mso-style-name: "Footnote Reference";
686
697
  vertical-align: super; }
687
698
 
688
699
  p.MsoCaption, li.MsoCaption, div.MsoCaption {
@@ -1084,6 +1095,7 @@ span.BodyTextChar, span.Char3 {
1084
1095
  p.MsoCommentText, li.MsoCommentText, div.MsoCommentText {
1085
1096
  mso-style-noshow: yes;
1086
1097
  mso-style-priority: 99;
1098
+ mso-style-name: "Comment Text";
1087
1099
  mso-style-link: "Comment Text Char";
1088
1100
  margin-top: 0cm;
1089
1101
  margin-right: 0cm;
@@ -118,7 +118,7 @@ p.MsoBlockText, li.MsoBlockText, div.MsoBlockText
118
118
  p.MsoList, li.MsoList, div.MsoList
119
119
  {mso-style-priority:4;
120
120
  mso-style-unhide:no;
121
- mso-style-parent:"MsoListParagraph";
121
+ mso-style-parent:"List Paragraph";
122
122
  margin-top:0cm;
123
123
  margin-right:0cm;
124
124
  margin-bottom:6.0pt;
@@ -138,7 +138,7 @@ p.MsoList, li.MsoList, div.MsoList
138
138
  p.MsoListCxSpFirst, li.MsoListCxSpFirst, div.MsoListCxSpFirst
139
139
  {mso-style-priority:4;
140
140
  mso-style-unhide:no;
141
- mso-style-parent:"MsoListParagraph";
141
+ mso-style-parent:"List Paragraph";
142
142
  mso-style-type:export-only;
143
143
  margin-top:0cm;
144
144
  margin-right:0cm;
@@ -159,7 +159,7 @@ p.MsoListCxSpFirst, li.MsoListCxSpFirst, div.MsoListCxSpFirst
159
159
  p.MsoListCxSpMiddle, li.MsoListCxSpMiddle, div.MsoListCxSpMiddle
160
160
  {mso-style-priority:4;
161
161
  mso-style-unhide:no;
162
- mso-style-parent:"MsoListParagraph";
162
+ mso-style-parent:"List Paragraph";
163
163
  mso-style-type:export-only;
164
164
  margin-top:0cm;
165
165
  margin-right:0cm;
@@ -180,7 +180,7 @@ p.MsoListCxSpMiddle, li.MsoListCxSpMiddle, div.MsoListCxSpMiddle
180
180
  p.MsoListCxSpLast, li.MsoListCxSpLast, div.MsoListCxSpLast
181
181
  {mso-style-priority:4;
182
182
  mso-style-unhide:no;
183
- mso-style-parent:"MsoListParagraph";
183
+ mso-style-parent:"List Paragraph";
184
184
  mso-style-type:export-only;
185
185
  margin-top:0cm;
186
186
  margin-right:0cm;
@@ -201,6 +201,7 @@ p.MsoListCxSpLast, li.MsoListCxSpLast, div.MsoListCxSpLast
201
201
  p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
202
202
  {mso-style-priority:34;
203
203
  mso-style-unhide:no;
204
+ mso-style-name:"List Paragraph";
204
205
  mso-style-qformat:yes;
205
206
  margin-top:0cm;
206
207
  margin-right:0cm;
@@ -272,6 +273,7 @@ h1
272
273
  {mso-style-priority:1;
273
274
  mso-style-unhide:no;
274
275
  mso-style-qformat:yes;
276
+ mso-style-name:"Heading 1";
275
277
  mso-style-link:"Heading 1 Char";
276
278
  mso-style-next:Normal;
277
279
  margin-top:13.5pt;
@@ -338,6 +340,7 @@ h1.Annex
338
340
  {mso-style-priority:2;
339
341
  mso-style-unhide:no;
340
342
  mso-style-qformat:yes;
343
+ mso-style-name:"Heading 2";
341
344
  mso-style-parent:"Heading 1";
342
345
  mso-style-link:"Heading 2 Char";
343
346
  mso-style-next:Normal;
@@ -373,6 +376,7 @@ h2
373
376
  {mso-style-priority:3;
374
377
  mso-style-unhide:no;
375
378
  mso-style-qformat:yes;
379
+ mso-style-name:"Heading 3";
376
380
  mso-style-parent:"Heading 1";
377
381
  mso-style-link:"Heading 3 Char";
378
382
  mso-style-next:Normal;
@@ -407,6 +411,7 @@ h3 {mso-list:l1 level3 lfo6;
407
411
  {mso-style-priority:4;
408
412
  mso-style-unhide:no;
409
413
  mso-style-qformat:yes;
414
+ mso-style-name:"Heading 4";
410
415
  mso-style-parent:"Heading 3";
411
416
  mso-style-link:"Heading 4 Char";
412
417
  mso-style-next:Normal;
@@ -439,6 +444,7 @@ h4 {mso-list:l1 level4 lfo6;
439
444
  {mso-style-priority:5;
440
445
  mso-style-unhide:no;
441
446
  mso-style-qformat:yes;
447
+ mso-style-name:"Heading 5";
442
448
  mso-style-parent:"Heading 4";
443
449
  mso-style-link:"Heading 5 Char";
444
450
  mso-style-next:Normal;
@@ -471,6 +477,7 @@ h6
471
477
  {mso-style-priority:6;
472
478
  mso-style-unhide:no;
473
479
  mso-style-qformat:yes;
480
+ mso-style-name:"Heading 6";
474
481
  mso-style-parent:"Heading 5";
475
482
  mso-style-link:"Heading 6 Char";
476
483
  mso-style-next:Normal;
@@ -502,6 +509,7 @@ h6 {mso-list:l1 level6 lfo6;
502
509
  p.MsoToc1, li.MsoToc1, div.MsoToc1
503
510
  {mso-style-priority:39;
504
511
  mso-style-unhide:no;
512
+ mso-style-name:"TOC 1";
505
513
  mso-style-next:Normal;
506
514
  margin-top:6.0pt;
507
515
  margin-right:25.0pt;
@@ -523,6 +531,7 @@ p.MsoToc2, li.MsoToc2, div.MsoToc2
523
531
  {mso-style-noshow:yes;
524
532
  mso-style-priority:39;
525
533
  mso-style-unhide:no;
534
+ mso-style-name:"TOC 2";
526
535
  mso-style-parent:"TOC 1";
527
536
  mso-style-next:Normal;
528
537
  margin-top:0cm;
@@ -545,6 +554,7 @@ p.MsoToc3, li.MsoToc3, div.MsoToc3
545
554
  {mso-style-noshow:yes;
546
555
  mso-style-priority:39;
547
556
  mso-style-unhide:no;
557
+ mso-style-name:"TOC 3";
548
558
  mso-style-parent:"TOC 2";
549
559
  mso-style-next:Normal;
550
560
  margin-top:0cm;
@@ -645,6 +655,7 @@ p.MsoFooterLandscape, li.MsoFooterLandscape, div.MsoFooterLandscape
645
655
  mso-ansi-language:EN-GB;}
646
656
  span.MsoFootnoteReference
647
657
  {mso-style-priority:99;
658
+ mso-style-name:"Footnote Reference";
648
659
  vertical-align:super;}
649
660
  p.MsoCaption, li.MsoCaption, div.MsoCaption
650
661
  {mso-style-priority:35;
@@ -1022,6 +1033,7 @@ span.BodyTextChar, span.Char3
1022
1033
  p.MsoCommentText, li.MsoCommentText, div.MsoCommentText
1023
1034
  {mso-style-noshow:yes;
1024
1035
  mso-style-priority:99;
1036
+ mso-style-name:"Comment Text";
1025
1037
  mso-style-link:"Comment Text Char";
1026
1038
  margin-top:0cm;
1027
1039
  margin-right:0cm;
@@ -7,12 +7,13 @@ module IsoDoc
7
7
 
8
8
  def index(docxml)
9
9
  unless docxml.at(ns("//index"))
10
- docxml.xpath(ns("//indexsect")).each { |i| i.remove }
10
+ docxml.xpath(ns("//indexsect")).each(&:remove)
11
11
  return
12
12
  end
13
13
  i = docxml.at(ns("//indexsect")) ||
14
14
  docxml.root.add_child("<indexsect #{add_id}><title>#{@i18n.index}</title></indexsect>").first
15
- index = sort_indexterms(docxml.xpath(ns("//index")), docxml.xpath(ns("//index-xref[@also = 'false']")),
15
+ index = sort_indexterms(docxml.xpath(ns("//index")),
16
+ docxml.xpath(ns("//index-xref[@also = 'false']")),
16
17
  docxml.xpath(ns("//index-xref[@also = 'true']")))
17
18
  index1(docxml, i, index)
18
19
  end
@@ -20,10 +21,12 @@ module IsoDoc
20
21
  def index1(docxml, i, index)
21
22
  c = i.add_child("<ul></ul>").first
22
23
  index.keys.sort.each do |k|
23
- #c = i.add_child "<clause #{add_id}><title>#{k}</title><ul></ul></clause>"
24
- words = index[k].keys.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
24
+ # c = i.add_child "<clause #{add_id}><title>#{k}</title><ul></ul></clause>"
25
+ words = index[k].keys.each_with_object({}) do |w, v|
26
+ v[sortable(w).downcase] = w
27
+ end
25
28
  words.keys.localize(@lang.to_sym).sort.to_a.each do |w|
26
- #c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
29
+ # c.first.at(ns("./ul")).add_child index_entries(words, index[k], w)
27
30
  c.add_child index_entries(words, index[k], w)
28
31
  end
29
32
  end
@@ -31,8 +34,8 @@ module IsoDoc
31
34
  @xrefs.bookmark_anchor_names(docxml)
32
35
  end
33
36
 
34
- def sortable(s)
35
- HTMLEntities.new.decode(Nokogiri::XML.fragment(s).text)
37
+ def sortable(str)
38
+ HTMLEntities.new.decode(Nokogiri::XML.fragment(str).text)
36
39
  end
37
40
 
38
41
  def index_entries_opt
@@ -40,8 +43,12 @@ module IsoDoc
40
43
  end
41
44
 
42
45
  def index_entries(words, index, primary)
43
- ret = index_entries_head(words[primary], index.dig(words[primary], nil, nil), index_entries_opt)
44
- words2 = index[words[primary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
46
+ ret = index_entries_head(words[primary],
47
+ index.dig(words[primary], nil, nil),
48
+ index_entries_opt)
49
+ words2 = index[words[primary]]&.keys&.reject do |k|
50
+ k.nil?
51
+ end&.each_with_object({}) { |w, v| v[w.downcase] = w }
45
52
  unless words2.empty?
46
53
  ret += "<ul>"
47
54
  words2.keys.localize(@lang.to_sym).sort.to_a.each do |w|
@@ -53,12 +60,18 @@ module IsoDoc
53
60
  end
54
61
 
55
62
  def index_entries2(words, index, secondary)
56
- ret = index_entries_head(words[secondary], index.dig(words[secondary], nil), index_entries_opt)
57
- words3 = index[words[secondary]]&.keys&.reject { |k| k.nil?}&.each_with_object({}) { |w, v| v[w.downcase] = w }
63
+ ret = index_entries_head(words[secondary],
64
+ index.dig(words[secondary], nil),
65
+ index_entries_opt)
66
+ words3 = index[words[secondary]]&.keys&.reject do |k|
67
+ k.nil?
68
+ end&.each_with_object({}) { |w, v| v[w.downcase] = w }
58
69
  unless words3.empty?
59
70
  ret += "<ul>"
60
71
  words3.keys.localize(@lang.to_sym).sort.to_a.each do |w|
61
- ret += (index_entries_head(words3[w], index[words[secondary]][words3[w]], index_entries_opt) + "</li>")
72
+ ret += (index_entries_head(words3[w],
73
+ index[words[secondary]][words3[w]],
74
+ index_entries_opt) + "</li>")
62
75
  end
63
76
  ret += "</ul>"
64
77
  end
@@ -68,10 +81,18 @@ module IsoDoc
68
81
  def index_entries_head(head, entries, opt)
69
82
  ret = "<li>#{head}"
70
83
  xref = entries&.dig(:xref)&.join(", ")
71
- see_sort = entries&.dig(:see)&.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
72
- see = see_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map { |k| see_sort[k] }&.join(", ")
73
- also_sort = entries&.dig(:also)&.each_with_object({}) { |w, v| v[sortable(w).downcase] = w }
74
- also = also_sort&.keys&.localize(@lang.to_sym)&.sort&.to_a&.map { |k| also_sort[k] }&.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(", ")
75
96
  ret += "#{opt[:xref_lbl]} #{xref}" if xref
76
97
  ret += "#{opt[:see_lbl]} #{see}" if see
77
98
  ret += "#{opt[:also_lbl]} #{also}" if also
@@ -96,8 +117,8 @@ module IsoDoc
96
117
  end
97
118
  end
98
119
 
99
- def extract_indexsee(v, terms, label)
100
- terms.each_with_object(v) do |t, v|
120
+ def extract_indexsee(val, terms, label)
121
+ terms.each_with_object(val) do |t, v|
101
122
  term = t&.at(ns("./primary"))&.children&.to_xml
102
123
  term2 = t&.at(ns("./secondary"))&.children&.to_xml
103
124
  term3 = t&.at(ns("./tertiary"))&.children&.to_xml
@@ -110,8 +131,11 @@ module IsoDoc
110
131
  end
111
132
  end
112
133
 
113
- def xml_encode_attr(s)
114
- HTMLEntities.new.encode(s, :basic, :hexadecimal).gsub(/\&#x([^;]+);/) { |x| "&#x#{$1.upcase};" }
134
+ def xml_encode_attr(str)
135
+ HTMLEntities.new.encode(str, :basic, :hexadecimal)
136
+ .gsub(/&#x([^;]+);/) do |_x|
137
+ "&#x#{$1.upcase};"
138
+ end
115
139
  end
116
140
 
117
141
  # attributes are decoded into UTF-8, elements in extract_indexsee are still in entities
@@ -130,10 +154,10 @@ module IsoDoc
130
154
  end
131
155
  end
132
156
 
133
- def index2bookmark(t)
134
- t.name = "bookmark"
135
- t.children.each { |x| x.remove }
136
- t["id"] = "_#{UUIDTools::UUID.random_create}"
157
+ def index2bookmark(node)
158
+ node.name = "bookmark"
159
+ node.children.each(&:remove)
160
+ node["id"] = "_#{UUIDTools::UUID.random_create}"
137
161
  end
138
162
  end
139
163
  end