metanorma-iso 1.9.1 → 1.9.5
Sign up to get free protection for your applications and to get access to all the features.
- 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 +49 -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 +451 -148
- data/lib/isodoc/iso/iso.international-standard.xsl +451 -148
- data/lib/isodoc/iso/metadata.rb +28 -16
- data/lib/isodoc/iso/presentation_xml_convert.rb +30 -22
- data/lib/metanorma/iso/processor.rb +1 -1
- data/lib/metanorma/iso/version.rb +1 -1
- data/spec/asciidoctor/base_spec.rb +2 -55
- data/spec/asciidoctor/blank_spec.rb +38 -0
- data/spec/asciidoctor/blocks_spec.rb +39 -0
- data/spec/asciidoctor/refs_spec.rb +1 -1
- data/spec/isodoc/inline_spec.rb +306 -245
- data/spec/isodoc/terms_spec.rb +30 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3710d3b53ba9f99228d2305a92fc2ae20f8aee71f555a06b3273a029df82dc9
|
4
|
+
data.tar.gz: 14d71fa2b1cac17b6097d6601bc05a36096cce50ae6dd0ace99cbee759fe8d47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9fd09732d19307285a7f4068b97be6c0bb5ca9a15028f10241c778e56eaf3d2d55093015d16f56c9cde30715d0c8842f345abd1bbeea0a208fd499c98fa303b2
|
7
|
+
data.tar.gz: b7abcda89ee9c7b390fbfef096b5403a1e507d9ed4e70071ccc3679c6cdc9c9c440c68b931634470407b85bc6acf562248713ff81d1ec25fc85d90d7bf8fd653
|
@@ -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>
|
@@ -1012,6 +1036,7 @@
|
|
1012
1036
|
<ref name="svgmap"/>
|
1013
1037
|
<ref name="inputform"/>
|
1014
1038
|
<ref name="toc"/>
|
1039
|
+
<ref name="passthrough"/>
|
1015
1040
|
</choice>
|
1016
1041
|
</define>
|
1017
1042
|
<define name="toc">
|
@@ -1019,6 +1044,14 @@
|
|
1019
1044
|
<ref name="ul"/>
|
1020
1045
|
</element>
|
1021
1046
|
</define>
|
1047
|
+
<define name="passthrough">
|
1048
|
+
<element name="passthrough">
|
1049
|
+
<optional>
|
1050
|
+
<attribute name="formats"/>
|
1051
|
+
</optional>
|
1052
|
+
<text/>
|
1053
|
+
</element>
|
1054
|
+
</define>
|
1022
1055
|
<define name="inputform">
|
1023
1056
|
<element name="form">
|
1024
1057
|
<attribute name="id">
|
@@ -1686,7 +1719,9 @@
|
|
1686
1719
|
<zeroOrMore>
|
1687
1720
|
<ref name="termgrammar"/>
|
1688
1721
|
</zeroOrMore>
|
1689
|
-
<
|
1722
|
+
<oneOrMore>
|
1723
|
+
<ref name="termdefinition"/>
|
1724
|
+
</oneOrMore>
|
1690
1725
|
<zeroOrMore>
|
1691
1726
|
<ref name="termnote"/>
|
1692
1727
|
</zeroOrMore>
|
@@ -1749,7 +1784,7 @@
|
|
1749
1784
|
</oneOrMore>
|
1750
1785
|
</element>
|
1751
1786
|
</define>
|
1752
|
-
<define name="
|
1787
|
+
<define name="termdefinition">
|
1753
1788
|
<element name="definition">
|
1754
1789
|
<oneOrMore>
|
1755
1790
|
<choice>
|
@@ -1758,6 +1793,9 @@
|
|
1758
1793
|
<ref name="formula"/>
|
1759
1794
|
</choice>
|
1760
1795
|
</oneOrMore>
|
1796
|
+
<zeroOrMore>
|
1797
|
+
<ref name="termsource"/>
|
1798
|
+
</zeroOrMore>
|
1761
1799
|
</element>
|
1762
1800
|
</define>
|
1763
1801
|
<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
|