metanorma-iso 1.9.0.1 → 1.9.4
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 +4 -4
- data/lib/asciidoctor/iso/cleanup.rb +3 -4
- data/lib/asciidoctor/iso/front_id.rb +7 -2
- data/lib/asciidoctor/iso/isodoc.rng +52 -11
- data/lib/asciidoctor/iso/isostandard.rng +4 -1
- data/lib/asciidoctor/iso/reqt.rng +15 -4
- data/lib/asciidoctor/iso/section.rb +7 -1
- data/lib/asciidoctor/iso/validate_section.rb +18 -20
- data/lib/asciidoctor/iso/validate_style.rb +17 -9
- data/lib/isodoc/iso/index.rb +48 -24
- data/lib/isodoc/iso/iso.amendment.xsl +387 -151
- data/lib/isodoc/iso/iso.international-standard.xsl +387 -151
- data/lib/isodoc/iso/metadata.rb +28 -16
- data/lib/isodoc/iso/presentation_xml_convert.rb +21 -12
- data/lib/metanorma/iso/processor.rb +1 -1
- data/lib/metanorma/iso/version.rb +1 -1
- data/spec/asciidoctor/base_spec.rb +2 -1
- data/spec/asciidoctor/blocks_spec.rb +41 -2
- data/spec/asciidoctor/cleanup_spec.rb +2 -2
- data/spec/asciidoctor/refs_spec.rb +1 -1
- data/spec/isodoc/inline_spec.rb +250 -219
- data/spec/isodoc/terms_spec.rb +30 -0
- 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: d361028b55729e120ba979ff911c432c4c540c92c5bb8046d9924fa908ac7420
|
4
|
+
data.tar.gz: 9cabc0515d30da042e63c0728bec5efca3d0600ce05bddf23aa4051cae29bc53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c570db53cb7e7d27f9bc10ab473ecc31f6d036dec343048f4992e79acc4bdd6a0be3aeaf26abdf56f21501d4af48475557641e81417a873ee5205e47330d20eb
|
7
|
+
data.tar.gz: 33da49640740fb46d457ddb28a68bbf4d7b64d01e604c003d5ef8846405173274df650ddb0f37833e203a224f344afe18d12f4db67a4c81682c3be50e6b3eee3
|
@@ -137,10 +137,9 @@ module Asciidoctor
|
|
137
137
|
xmldoc.xpath("//bibitem/note[@type = 'Unpublished-Status']").each do |n|
|
138
138
|
id = n.parent["id"]
|
139
139
|
e = xmldoc.at("//eref[@bibitemid = '#{id}']") or next
|
140
|
-
|
141
|
-
|
142
|
-
e.next
|
143
|
-
e.next.delete("type")
|
140
|
+
fn = n.children.to_xml
|
141
|
+
n&.elements&.first&.name == "p" or fn = "<p>#{fn}</p>"
|
142
|
+
e.next = "<fn>#{fn}</fn>"
|
144
143
|
end
|
145
144
|
end
|
146
145
|
|
@@ -193,12 +193,17 @@ module Asciidoctor
|
|
193
193
|
end
|
194
194
|
|
195
195
|
def get_stage(node)
|
196
|
-
|
196
|
+
a = node.attr("status")
|
197
|
+
a = node.attr("docstage") if a.nil? || a.empty?
|
198
|
+
a = "60" if a.nil? || a.empty?
|
199
|
+
a
|
197
200
|
end
|
198
201
|
|
199
202
|
def get_substage(node)
|
200
203
|
stage = get_stage(node)
|
201
|
-
node.attr("docsubstage")
|
204
|
+
ret = node.attr("docsubstage")
|
205
|
+
ret = (stage == "60" ? "60" : "00") if ret.nil? || ret.empty?
|
206
|
+
ret
|
202
207
|
end
|
203
208
|
|
204
209
|
def get_typeabbr(node, amd = false)
|
@@ -32,6 +32,18 @@
|
|
32
32
|
<ref name="DocumentType"/>
|
33
33
|
</element>
|
34
34
|
</define>
|
35
|
+
<define name="section-title">
|
36
|
+
<element name="title">
|
37
|
+
<zeroOrMore>
|
38
|
+
<ref name="TextElement"/>
|
39
|
+
</zeroOrMore>
|
40
|
+
</element>
|
41
|
+
<zeroOrMore>
|
42
|
+
<element name="variant-title">
|
43
|
+
<ref name="TypedTitleString"/>
|
44
|
+
</element>
|
45
|
+
</zeroOrMore>
|
46
|
+
</define>
|
35
47
|
<define name="hyperlink">
|
36
48
|
<element name="link">
|
37
49
|
<attribute name="target">
|
@@ -158,15 +170,17 @@
|
|
158
170
|
<data type="boolean"/>
|
159
171
|
</attribute>
|
160
172
|
</optional>
|
161
|
-
<
|
162
|
-
<
|
163
|
-
<
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
173
|
+
<optional>
|
174
|
+
<attribute name="type">
|
175
|
+
<choice>
|
176
|
+
<value>roman</value>
|
177
|
+
<value>alphabet</value>
|
178
|
+
<value>arabic</value>
|
179
|
+
<value>roman_upper</value>
|
180
|
+
<value>alphabet_upper</value>
|
181
|
+
</choice>
|
182
|
+
</attribute>
|
183
|
+
</optional>
|
170
184
|
<oneOrMore>
|
171
185
|
<ref name="li"/>
|
172
186
|
</oneOrMore>
|
@@ -976,6 +990,16 @@
|
|
976
990
|
<data type="boolean"/>
|
977
991
|
</attribute>
|
978
992
|
</optional>
|
993
|
+
<optional>
|
994
|
+
<attribute name="linkmention">
|
995
|
+
<data type="boolean"/>
|
996
|
+
</attribute>
|
997
|
+
</optional>
|
998
|
+
<optional>
|
999
|
+
<attribute name="linkref">
|
1000
|
+
<data type="boolean"/>
|
1001
|
+
</attribute>
|
1002
|
+
</optional>
|
979
1003
|
<optional>
|
980
1004
|
<element name="refterm">
|
981
1005
|
<zeroOrMore>
|
@@ -1011,8 +1035,14 @@
|
|
1011
1035
|
<ref name="imagemap"/>
|
1012
1036
|
<ref name="svgmap"/>
|
1013
1037
|
<ref name="inputform"/>
|
1038
|
+
<ref name="toc"/>
|
1014
1039
|
</choice>
|
1015
1040
|
</define>
|
1041
|
+
<define name="toc">
|
1042
|
+
<element name="toc">
|
1043
|
+
<ref name="ul"/>
|
1044
|
+
</element>
|
1045
|
+
</define>
|
1016
1046
|
<define name="inputform">
|
1017
1047
|
<element name="form">
|
1018
1048
|
<attribute name="id">
|
@@ -1254,6 +1284,12 @@
|
|
1254
1284
|
<optional>
|
1255
1285
|
<attribute name="type"/>
|
1256
1286
|
</optional>
|
1287
|
+
<optional>
|
1288
|
+
<attribute name="identifier"/>
|
1289
|
+
</optional>
|
1290
|
+
<optional>
|
1291
|
+
<attribute name="prefix"/>
|
1292
|
+
</optional>
|
1257
1293
|
<text/>
|
1258
1294
|
</define>
|
1259
1295
|
<define name="ics">
|
@@ -1674,7 +1710,9 @@
|
|
1674
1710
|
<zeroOrMore>
|
1675
1711
|
<ref name="termgrammar"/>
|
1676
1712
|
</zeroOrMore>
|
1677
|
-
<
|
1713
|
+
<oneOrMore>
|
1714
|
+
<ref name="termdefinition"/>
|
1715
|
+
</oneOrMore>
|
1678
1716
|
<zeroOrMore>
|
1679
1717
|
<ref name="termnote"/>
|
1680
1718
|
</zeroOrMore>
|
@@ -1737,7 +1775,7 @@
|
|
1737
1775
|
</oneOrMore>
|
1738
1776
|
</element>
|
1739
1777
|
</define>
|
1740
|
-
<define name="
|
1778
|
+
<define name="termdefinition">
|
1741
1779
|
<element name="definition">
|
1742
1780
|
<oneOrMore>
|
1743
1781
|
<choice>
|
@@ -1746,6 +1784,9 @@
|
|
1746
1784
|
<ref name="formula"/>
|
1747
1785
|
</choice>
|
1748
1786
|
</oneOrMore>
|
1787
|
+
<zeroOrMore>
|
1788
|
+
<ref name="termsource"/>
|
1789
|
+
</zeroOrMore>
|
1749
1790
|
</element>
|
1750
1791
|
</define>
|
1751
1792
|
<define name="termnote">
|
@@ -174,7 +174,7 @@
|
|
174
174
|
<optional>
|
175
175
|
<ref name="termdomain"/>
|
176
176
|
</optional>
|
177
|
-
<ref name="
|
177
|
+
<ref name="termdefinition"/>
|
178
178
|
<zeroOrMore>
|
179
179
|
<ref name="termnote"/>
|
180
180
|
</zeroOrMore>
|
@@ -184,6 +184,9 @@
|
|
184
184
|
<zeroOrMore>
|
185
185
|
<ref name="termsource"/>
|
186
186
|
</zeroOrMore>
|
187
|
+
<zeroOrMore>
|
188
|
+
<ref name="term"/>
|
189
|
+
</zeroOrMore>
|
187
190
|
</element>
|
188
191
|
</define>
|
189
192
|
<define name="annex">
|
@@ -64,9 +64,9 @@
|
|
64
64
|
<optional>
|
65
65
|
<ref name="label"/>
|
66
66
|
</optional>
|
67
|
-
<
|
67
|
+
<zeroOrMore>
|
68
68
|
<ref name="subject"/>
|
69
|
-
</
|
69
|
+
</zeroOrMore>
|
70
70
|
<zeroOrMore>
|
71
71
|
<ref name="reqinherit"/>
|
72
72
|
</zeroOrMore>
|
@@ -80,6 +80,7 @@
|
|
80
80
|
<ref name="verification"/>
|
81
81
|
<ref name="import"/>
|
82
82
|
<ref name="description"/>
|
83
|
+
<ref name="component"/>
|
83
84
|
</choice>
|
84
85
|
</zeroOrMore>
|
85
86
|
<optional>
|
@@ -105,12 +106,16 @@
|
|
105
106
|
</define>
|
106
107
|
<define name="subject">
|
107
108
|
<element name="subject">
|
108
|
-
<
|
109
|
+
<oneOrMore>
|
110
|
+
<ref name="TextElement"/>
|
111
|
+
</oneOrMore>
|
109
112
|
</element>
|
110
113
|
</define>
|
111
114
|
<define name="reqinherit">
|
112
115
|
<element name="inherit">
|
113
|
-
<
|
116
|
+
<oneOrMore>
|
117
|
+
<ref name="TextElement"/>
|
118
|
+
</oneOrMore>
|
114
119
|
</element>
|
115
120
|
</define>
|
116
121
|
<define name="measurementtarget">
|
@@ -138,6 +143,12 @@
|
|
138
143
|
<ref name="RequirementSubpart"/>
|
139
144
|
</element>
|
140
145
|
</define>
|
146
|
+
<define name="component">
|
147
|
+
<element name="component">
|
148
|
+
<attribute name="class"/>
|
149
|
+
<ref name="RequirementSubpart"/>
|
150
|
+
</element>
|
151
|
+
</define>
|
141
152
|
<define name="reqt_references">
|
142
153
|
<element name="references">
|
143
154
|
<oneOrMore>
|
@@ -15,7 +15,7 @@ module Asciidoctor
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def appendix_parse(attrs, xml, node)
|
18
|
-
attrs["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
|
-
|
35
|
+
"Terms section in the standard".freeze
|
36
36
|
|
37
37
|
NON_DL_SYMBOLS_WARNING = "Symbols and Abbreviated Terms can "\
|
38
|
-
|
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
|
-
|
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
|
-
|
130
|
+
"Terms and Definitions")
|
131
131
|
elem&.at("./self::clause[@type = 'scope']") &&
|
132
|
-
@log.add("Style", elem,
|
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,
|
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,
|
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,
|
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
|
-
|
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
|
-
|
167
|
+
"Normative References")
|
164
168
|
elem = names&.shift
|
165
169
|
elem&.at("./self::references[@normative = 'false']") ||
|
166
|
-
@log.add("Style", elem,
|
170
|
+
@log.add("Style", elem,
|
171
|
+
"Final section must be (references) Bibliography")
|
167
172
|
names.empty? ||
|
168
|
-
@log.add("Style", elem,
|
169
|
-
|
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(
|
74
|
-
(m =
|
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,
|
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 =
|
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
|
-
|
136
|
-
|
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
|
-
|
150
|
-
|
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
|
data/lib/isodoc/iso/index.rb
CHANGED
@@ -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
|
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")),
|
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({})
|
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(
|
35
|
-
HTMLEntities.new.decode(Nokogiri::XML.fragment(
|
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],
|
44
|
-
|
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],
|
57
|
-
|
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],
|
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({})
|
72
|
-
|
73
|
-
|
74
|
-
|
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(
|
100
|
-
terms.each_with_object(
|
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(
|
114
|
-
HTMLEntities.new.encode(
|
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(
|
134
|
-
|
135
|
-
|
136
|
-
|
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
|