metanorma-standoc 2.8.5 → 2.8.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.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/anchor.rb +24 -14
- data/lib/metanorma/standoc/biblio.rng +24 -8
- data/lib/metanorma/standoc/blocks_image.rb +2 -1
- data/lib/metanorma/standoc/cleanup_image.rb +44 -21
- data/lib/metanorma/standoc/cleanup_section.rb +6 -10
- data/lib/metanorma/standoc/cleanup_section_names.rb +18 -11
- data/lib/metanorma/standoc/front.rb +1 -1
- data/lib/metanorma/standoc/isodoc.rng +67 -55
- data/lib/metanorma/standoc/macros_inline.rb +7 -1
- data/lib/metanorma/standoc/section.rb +21 -28
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +5 -9
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26ef7eeadddd66ca86125ae72f91a3e920057ad5ed1e8f0e1e5670f831355d0b
|
4
|
+
data.tar.gz: e1d1e42f6d4962d11ab86421fec3fc2877480e33fdac9aabcc4bd478fd3cc2df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a014a7cbc4f3665f07322713d0edad6dbd42301eb3b0e548a78efd116f7c6da4b7359db4f26e3cbc50315cdbdad99169997493fa792000b6f36e63c49c8ace1
|
7
|
+
data.tar.gz: 25f39be9f0df10ecdfaea29ecdf2e1cf8a50789f80fce1cf6fa71cd23beb1a69f6b890e2ca69527bc486091631281cce5926f3b3ec743bdbbfb24b9c7d195264
|
@@ -31,10 +31,11 @@ module Metanorma
|
|
31
31
|
|
32
32
|
def inline_anchor_xref_attrs(node)
|
33
33
|
text = concatenate_attributes_to_xref_text(node)
|
34
|
-
m = inline_anchor_xref_match(text)
|
35
34
|
t = node.target.gsub(/^#/, "").gsub(%r{(\.xml|\.adoc)(#.*$)}, "\\2")
|
36
|
-
|
37
|
-
|
35
|
+
attrs, text = inline_anchor_xref_match(text)
|
36
|
+
attrs.empty? and
|
37
|
+
return { target: t, type: "inline", text: text, style: @xrefstyle }
|
38
|
+
inline_anchor_xref_attrs1(attrs, t, text)
|
38
39
|
end
|
39
40
|
|
40
41
|
def concatenate_attributes_to_xref_text(node)
|
@@ -44,20 +45,29 @@ module Metanorma
|
|
44
45
|
end.map { |x| x.sub(/%+/, "%") }.join + (node.text || "")
|
45
46
|
end
|
46
47
|
|
47
|
-
def inline_anchor_xref_attrs1(
|
48
|
-
{ target: target, hidden:
|
49
|
-
type:
|
50
|
-
case:
|
51
|
-
|
52
|
-
|
53
|
-
|
48
|
+
def inline_anchor_xref_attrs1(attrs, target, text)
|
49
|
+
{ target: target, hidden: attrs["hidden"],
|
50
|
+
type: attrs.key?("fn") ? "footnote" : "inline",
|
51
|
+
case: %w(capital lowercase).detect { |x| attrs.key?(x) },
|
52
|
+
label: attrs["label"],
|
53
|
+
style: attrs["style"] || @xrefstyle,
|
54
|
+
droploc: attrs.key?("droploc") ? true : nil,
|
55
|
+
text: text }.compact
|
54
56
|
end
|
55
57
|
|
58
|
+
XREF_ATTRS = "hidden|style|droploc|capital|lowercase|label".freeze
|
59
|
+
|
56
60
|
def inline_anchor_xref_match(text)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
(
|
61
|
+
attrs = {}
|
62
|
+
while m = /^(#{XREF_ATTRS})(=[^%]+)?%(.*)$/o.match(text)
|
63
|
+
text = m[3]
|
64
|
+
attrs[m[1]] = m[2]&.sub(/^=/, "")
|
65
|
+
end
|
66
|
+
if m = /^(fn:?\s*)(\S.*)?$/.match(text)
|
67
|
+
text = m[2]
|
68
|
+
attrs["fn"] = ""
|
69
|
+
end
|
70
|
+
[attrs, text]
|
61
71
|
end
|
62
72
|
|
63
73
|
def inline_anchor_xref_text(match, text)
|
@@ -208,7 +208,9 @@
|
|
208
208
|
</define>
|
209
209
|
<define name="roledescription">
|
210
210
|
<element name="description">
|
211
|
-
<
|
211
|
+
<oneOrMore>
|
212
|
+
<ref name="TextElement"/>
|
213
|
+
</oneOrMore>
|
212
214
|
</element>
|
213
215
|
</define>
|
214
216
|
<define name="person">
|
@@ -333,7 +335,9 @@
|
|
333
335
|
</define>
|
334
336
|
<define name="affiliationdescription">
|
335
337
|
<element name="description">
|
336
|
-
<
|
338
|
+
<oneOrMore>
|
339
|
+
<ref name="TextElement"/>
|
340
|
+
</oneOrMore>
|
337
341
|
</element>
|
338
342
|
</define>
|
339
343
|
<define name="organization">
|
@@ -897,7 +901,9 @@
|
|
897
901
|
</define>
|
898
902
|
<define name="formattedref">
|
899
903
|
<element name="formattedref">
|
900
|
-
<
|
904
|
+
<oneOrMore>
|
905
|
+
<ref name="TextElement"/>
|
906
|
+
</oneOrMore>
|
901
907
|
</element>
|
902
908
|
</define>
|
903
909
|
<define name="license">
|
@@ -942,7 +948,9 @@
|
|
942
948
|
<optional>
|
943
949
|
<attribute name="type"/>
|
944
950
|
</optional>
|
945
|
-
<
|
951
|
+
<zeroOrMore>
|
952
|
+
<ref name="TextElement"/>
|
953
|
+
</zeroOrMore>
|
946
954
|
</define>
|
947
955
|
<!-- TitleType = ( "alternative" | "original" | "unofficial" | "subtitle" | "main" ) -->
|
948
956
|
<define name="TypedUri">
|
@@ -1042,7 +1050,9 @@
|
|
1042
1050
|
<optional>
|
1043
1051
|
<attribute name="script"/>
|
1044
1052
|
</optional>
|
1045
|
-
<
|
1053
|
+
<oneOrMore>
|
1054
|
+
<ref name="TextElement"/>
|
1055
|
+
</oneOrMore>
|
1046
1056
|
</element>
|
1047
1057
|
</define>
|
1048
1058
|
<define name="docnumber">
|
@@ -1267,12 +1277,16 @@
|
|
1267
1277
|
<optional>
|
1268
1278
|
<attribute name="type"/>
|
1269
1279
|
</optional>
|
1270
|
-
<
|
1280
|
+
<oneOrMore>
|
1281
|
+
<ref name="TextElement"/>
|
1282
|
+
</oneOrMore>
|
1271
1283
|
</element>
|
1272
1284
|
</define>
|
1273
1285
|
<define name="bibabstract">
|
1274
1286
|
<element name="abstract">
|
1275
|
-
<
|
1287
|
+
<oneOrMore>
|
1288
|
+
<ref name="TextElement"/>
|
1289
|
+
</oneOrMore>
|
1276
1290
|
</element>
|
1277
1291
|
</define>
|
1278
1292
|
<define name="copyright">
|
@@ -1377,7 +1391,9 @@
|
|
1377
1391
|
</attribute>
|
1378
1392
|
<optional>
|
1379
1393
|
<element name="description">
|
1380
|
-
<
|
1394
|
+
<oneOrMore>
|
1395
|
+
<ref name="TextElement"/>
|
1396
|
+
</oneOrMore>
|
1381
1397
|
</element>
|
1382
1398
|
</optional>
|
1383
1399
|
<element name="bibitem">
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require "vectory"
|
2
|
+
require "crass"
|
2
3
|
|
3
4
|
module Metanorma
|
4
5
|
module Standoc
|
@@ -30,8 +31,7 @@ module Metanorma
|
|
30
31
|
def svgmap_moveattrs1(svgmap, figure)
|
31
32
|
%w(unnumbered number subsequence keep-with-next
|
32
33
|
keep-lines-together tag multilingual-rendering).each do |a|
|
33
|
-
|
34
|
-
|
34
|
+
figure[a] || !svgmap[a] and next
|
35
35
|
figure[a] = svgmap[a]
|
36
36
|
svgmap.delete(a)
|
37
37
|
end
|
@@ -43,7 +43,7 @@ module Metanorma
|
|
43
43
|
s.children.remove
|
44
44
|
f = s1.at(".//figure") and s << f
|
45
45
|
s1.xpath(".//li").each do |li|
|
46
|
-
t = li
|
46
|
+
t = li.at(".//eref | .//link | .//xref") or next
|
47
47
|
href = t.xpath("./following-sibling::node()")
|
48
48
|
href.empty? or
|
49
49
|
s << %[<target href="#{svgmap_target(href)}">#{t.to_xml}</target>]
|
@@ -53,8 +53,7 @@ module Metanorma
|
|
53
53
|
|
54
54
|
def svgmap_target(nodeset)
|
55
55
|
nodeset.each do |n|
|
56
|
-
|
57
|
-
|
56
|
+
n.name == "link" or next
|
58
57
|
n.children = n["target"]
|
59
58
|
end
|
60
59
|
nodeset.text.sub(/^[,; ]/, "").strip
|
@@ -69,13 +68,17 @@ module Metanorma
|
|
69
68
|
end
|
70
69
|
end
|
71
70
|
end
|
72
|
-
|
71
|
+
svg_cleanup(xmldoc)
|
73
72
|
xmldoc
|
74
73
|
end
|
75
74
|
|
76
|
-
def
|
77
|
-
|
75
|
+
def svg_cleanup(xmldoc)
|
76
|
+
svg_uniqueids(xmldoc)
|
77
|
+
svg_classupdate(xmldoc)
|
78
|
+
end
|
78
79
|
|
80
|
+
def read_in_if_svg(img, localdir)
|
81
|
+
img["src"] or return false
|
79
82
|
path = Vectory::Utils.svgmap_rewrite0_path(img["src"], localdir)
|
80
83
|
File.file?(path) or return false
|
81
84
|
types = MIME::Types.type_for(path) or return false
|
@@ -85,6 +88,31 @@ module Metanorma
|
|
85
88
|
true
|
86
89
|
end
|
87
90
|
|
91
|
+
def svg_classupdate(xmldoc)
|
92
|
+
xmldoc.xpath("//m:svg[m:style]", "m" => SVG_NS)
|
93
|
+
.each_with_index do |s, i|
|
94
|
+
svg_classupdate1(s, s.at("./m:style", "m" => SVG_NS), i)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def svg_classupdate1(svg, style, idx)
|
99
|
+
tree = Crass.parse(style.text)
|
100
|
+
tree.each { |n| svg_suffix_css_style(n, idx) }
|
101
|
+
style.children = Crass::Parser.stringify(tree)
|
102
|
+
svg.xpath(".//*[@class]").each do |n|
|
103
|
+
n["class"] = n["class"].split(/\s+/)
|
104
|
+
.map { |x| "#{x}_inject_#{idx}" }.join(" ")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def svg_suffix_css_style(node, idx)
|
109
|
+
node[:node] == :style_rule && /\./.match?(node[:selector][:value]) or
|
110
|
+
return
|
111
|
+
v = node[:selector][:value]
|
112
|
+
.gsub(/([^.\s]*\.\S+)/, "\\1_inject_#{idx}")
|
113
|
+
node[:selector] = Crass.parse("#{v} {}").first[:selector]
|
114
|
+
end
|
115
|
+
|
88
116
|
IRI_TAG_PROPERTIES_MAP = {
|
89
117
|
clipPath: ["clip-path"],
|
90
118
|
"color-profile": nil,
|
@@ -111,13 +139,12 @@ module Metanorma
|
|
111
139
|
|
112
140
|
def svg_iri_properties(id_elems)
|
113
141
|
iri_tag_names = id_elems.each_with_object([]) do |e, m|
|
114
|
-
IRI_TAG_PROPERTIES_MAP.key?(e.name.to_sym) and m
|
142
|
+
IRI_TAG_PROPERTIES_MAP.key?(e.name.to_sym) and m << e.name
|
115
143
|
end.uniq
|
116
144
|
iri_properties = iri_tag_names.each_with_object([]) do |t, m|
|
117
145
|
(IRI_TAG_PROPERTIES_MAP[t.to_sym] || [t]).each { |t1| m = m << t1 }
|
118
146
|
end.uniq
|
119
|
-
return []
|
120
|
-
|
147
|
+
iri_properties.empty? and return []
|
121
148
|
iri_properties << "style"
|
122
149
|
end
|
123
150
|
|
@@ -132,8 +159,7 @@ module Metanorma
|
|
132
159
|
|
133
160
|
def svg_uniqueids2(svg, iri_properties, idx, ids)
|
134
161
|
svg.traverse do |e|
|
135
|
-
|
136
|
-
|
162
|
+
e.element? or next
|
137
163
|
if e.name == "style"
|
138
164
|
svg_styleupdate(e, idx, ids)
|
139
165
|
elsif !e.attributes.empty?
|
@@ -158,8 +184,7 @@ module Metanorma
|
|
158
184
|
|
159
185
|
def svg_attrupdate(elem, iri_properties, idx, ids)
|
160
186
|
iri_properties.each do |p|
|
161
|
-
|
162
|
-
|
187
|
+
elem[p] or next
|
163
188
|
elem[p] = svg_update_url(elem[p], idx, ids)
|
164
189
|
end
|
165
190
|
end
|
@@ -167,17 +192,15 @@ module Metanorma
|
|
167
192
|
def svg_linkupdate(elem, idx, ids)
|
168
193
|
%w(xlink:href href).each do |ref|
|
169
194
|
iri = elem[ref]&.strip
|
170
|
-
|
171
|
-
|
172
|
-
|
195
|
+
/^#/.match?(iri) or next
|
196
|
+
ids[iri.sub(/^#/, "")] or next
|
173
197
|
elem[ref] += "_inject_#{idx}"
|
174
198
|
end
|
175
199
|
end
|
176
200
|
|
177
201
|
def svg_idupdate(elem, idx, ids)
|
178
|
-
|
179
|
-
|
180
|
-
|
202
|
+
elem["id"] or return
|
203
|
+
ids[elem["id"]] or return
|
181
204
|
elem["id"] += "_inject_#{idx}"
|
182
205
|
end
|
183
206
|
end
|
@@ -97,8 +97,7 @@ module Metanorma
|
|
97
97
|
def make_annexes(xml)
|
98
98
|
xml.xpath("//*[@annex]").each do |y|
|
99
99
|
y.delete("annex")
|
100
|
-
|
101
|
-
|
100
|
+
y.name == "annex" || !y.ancestors("annex").empty? and next
|
102
101
|
y.wrap("<annex/>")
|
103
102
|
y.parent["id"] = "_#{UUIDTools::UUID.random_create}"
|
104
103
|
y.parent["obligation"] = y["obligation"]
|
@@ -117,8 +116,7 @@ module Metanorma
|
|
117
116
|
|
118
117
|
def sections_level_cleanup(xml)
|
119
118
|
m = maxlevel(xml)
|
120
|
-
|
121
|
-
|
119
|
+
m < 6 and return
|
122
120
|
m.downto(6).each do |l|
|
123
121
|
xml.xpath("//clause[@level = '#{l}']").each do |c|
|
124
122
|
c.delete("level")
|
@@ -173,7 +171,7 @@ module Metanorma
|
|
173
171
|
r["obligation"] = "normative" unless r["obligation"]
|
174
172
|
end
|
175
173
|
xml.xpath(Utils::SUBCLAUSE_XPATH).each do |r|
|
176
|
-
o = r
|
174
|
+
o = r.at("./ancestor::*/@obligation")&.text and r["obligation"] = o
|
177
175
|
end
|
178
176
|
end
|
179
177
|
|
@@ -183,8 +181,7 @@ module Metanorma
|
|
183
181
|
end
|
184
182
|
|
185
183
|
def preface_clausebefore_cleanup(xmldoc)
|
186
|
-
|
187
|
-
|
184
|
+
xmldoc.at("//preface") or return
|
188
185
|
ins = insert_before(xmldoc, "//preface")
|
189
186
|
xmldoc.xpath("//preface//*[@beforeclauses = 'true']").each do |x|
|
190
187
|
x.delete("beforeclauses")
|
@@ -232,9 +229,8 @@ module Metanorma
|
|
232
229
|
loop do
|
233
230
|
found = false
|
234
231
|
xmldoc.xpath("//floating-title").each do |t|
|
235
|
-
|
236
|
-
|
237
|
-
|
232
|
+
t.next_element.nil? or next
|
233
|
+
%w(sections annex preface).include? t.parent.name and next
|
238
234
|
t.parent.next = t
|
239
235
|
found = true
|
240
236
|
end
|
@@ -16,22 +16,32 @@ module Metanorma
|
|
16
16
|
text or return
|
17
17
|
doc.xpath(xpath).each_with_index do |node, i|
|
18
18
|
first && !i.zero? and next
|
19
|
+
node["keeptitle"] == "true" and next
|
19
20
|
title = get_or_make_title(node)
|
20
|
-
|
21
|
-
fn.each(&:remove)
|
22
|
-
title.children = text
|
23
|
-
fn.each { |n| title << n }
|
21
|
+
set_title_with_footnotes(title, text)
|
24
22
|
end
|
25
23
|
end
|
26
24
|
|
25
|
+
def set_title_with_footnotes(title, text)
|
26
|
+
fn = title.xpath("./fn | ./bookmark | ./index")
|
27
|
+
fn.each(&:remove)
|
28
|
+
title.children = text
|
29
|
+
fn.each { |n| title << n }
|
30
|
+
end
|
31
|
+
|
27
32
|
def sections_names_cleanup(xml)
|
28
33
|
replace_title(xml, "//clause[@type = 'scope']", @i18n&.scope)
|
34
|
+
sections_names_pref_cleanup(xml)
|
35
|
+
section_names_refs_cleanup(xml)
|
36
|
+
section_names_terms_cleanup(xml)
|
37
|
+
xml.xpath("//*[@keeptitle]").each { |s| s.delete("keeptitle") }
|
38
|
+
end
|
39
|
+
|
40
|
+
def sections_names_pref_cleanup(xml)
|
29
41
|
replace_title(xml, "//preface//abstract", @i18n&.abstract)
|
30
42
|
replace_title(xml, "//foreword", @i18n&.foreword)
|
31
43
|
replace_title(xml, "//introduction", @i18n&.introduction)
|
32
44
|
replace_title(xml, "//acknowledgements", @i18n&.acknowledgements)
|
33
|
-
section_names_refs_cleanup(xml)
|
34
|
-
section_names_terms_cleanup(xml)
|
35
45
|
end
|
36
46
|
|
37
47
|
def section_names_refs_cleanup(xml)
|
@@ -82,11 +92,8 @@ module Metanorma
|
|
82
92
|
@i18n&.termsdefsymbolsabbrev, true)
|
83
93
|
replace_title(xml, "//terms#{NO_SYMABBR} | //clause[.//terms]#{NO_SYMABBR}",
|
84
94
|
@i18n&.termsdefsymbolsabbrev, true)
|
85
|
-
replace_title(
|
86
|
-
|
87
|
-
"//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
|
88
|
-
@i18n&.termsdef, true
|
89
|
-
)
|
95
|
+
replace_title(xml, "//terms[not(.//definitions)] | //clause[.//terms][not(.//definitions)]",
|
96
|
+
@i18n&.termsdef, true)
|
90
97
|
end
|
91
98
|
|
92
99
|
# do not auto-name terms sections if there are terms subclauses
|
@@ -156,44 +156,7 @@
|
|
156
156
|
</define>
|
157
157
|
<define name="xref">
|
158
158
|
<element name="xref">
|
159
|
-
<
|
160
|
-
<data type="string">
|
161
|
-
<param name="pattern">\i\c*|\c+#\c+</param>
|
162
|
-
</data>
|
163
|
-
</attribute>
|
164
|
-
<optional>
|
165
|
-
<attribute name="to">
|
166
|
-
<data type="string">
|
167
|
-
<param name="pattern">\i\c*|\c+#\c+</param>
|
168
|
-
</data>
|
169
|
-
</attribute>
|
170
|
-
</optional>
|
171
|
-
<optional>
|
172
|
-
<attribute name="type">
|
173
|
-
<ref name="ReferenceFormat"/>
|
174
|
-
</attribute>
|
175
|
-
</optional>
|
176
|
-
<optional>
|
177
|
-
<attribute name="alt"/>
|
178
|
-
</optional>
|
179
|
-
<optional>
|
180
|
-
<attribute name="case">
|
181
|
-
<choice>
|
182
|
-
<value>capital</value>
|
183
|
-
<value>lowercase</value>
|
184
|
-
</choice>
|
185
|
-
</attribute>
|
186
|
-
</optional>
|
187
|
-
<optional>
|
188
|
-
<attribute name="droploc">
|
189
|
-
<data type="boolean"/>
|
190
|
-
</attribute>
|
191
|
-
</optional>
|
192
|
-
<optional>
|
193
|
-
<attribute name="style">
|
194
|
-
<ref name="XrefStyleType"/>
|
195
|
-
</attribute>
|
196
|
-
</optional>
|
159
|
+
<ref name="XrefAttributes"/>
|
197
160
|
<ref name="XrefBody"/>
|
198
161
|
</element>
|
199
162
|
</define>
|
@@ -407,23 +370,7 @@
|
|
407
370
|
</define>
|
408
371
|
<define name="figure">
|
409
372
|
<element name="figure">
|
410
|
-
<
|
411
|
-
<data type="ID"/>
|
412
|
-
</attribute>
|
413
|
-
<optional>
|
414
|
-
<attribute name="unnumbered">
|
415
|
-
<data type="boolean"/>
|
416
|
-
</attribute>
|
417
|
-
</optional>
|
418
|
-
<optional>
|
419
|
-
<attribute name="number"/>
|
420
|
-
</optional>
|
421
|
-
<optional>
|
422
|
-
<attribute name="subsequence"/>
|
423
|
-
</optional>
|
424
|
-
<optional>
|
425
|
-
<attribute name="class"/>
|
426
|
-
</optional>
|
373
|
+
<ref name="FigureAttributes"/>
|
427
374
|
<ref name="BlockAttributes"/>
|
428
375
|
<optional>
|
429
376
|
<ref name="tname"/>
|
@@ -2450,6 +2397,49 @@
|
|
2450
2397
|
</zeroOrMore>
|
2451
2398
|
</element>
|
2452
2399
|
</define>
|
2400
|
+
<define name="XrefAttributes">
|
2401
|
+
<attribute name="target">
|
2402
|
+
<data type="string">
|
2403
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
2404
|
+
</data>
|
2405
|
+
</attribute>
|
2406
|
+
<optional>
|
2407
|
+
<attribute name="to">
|
2408
|
+
<data type="string">
|
2409
|
+
<param name="pattern">\i\c*|\c+#\c+</param>
|
2410
|
+
</data>
|
2411
|
+
</attribute>
|
2412
|
+
</optional>
|
2413
|
+
<optional>
|
2414
|
+
<attribute name="type">
|
2415
|
+
<ref name="ReferenceFormat"/>
|
2416
|
+
</attribute>
|
2417
|
+
</optional>
|
2418
|
+
<optional>
|
2419
|
+
<attribute name="alt"/>
|
2420
|
+
</optional>
|
2421
|
+
<optional>
|
2422
|
+
<attribute name="case">
|
2423
|
+
<choice>
|
2424
|
+
<value>capital</value>
|
2425
|
+
<value>lowercase</value>
|
2426
|
+
</choice>
|
2427
|
+
</attribute>
|
2428
|
+
</optional>
|
2429
|
+
<optional>
|
2430
|
+
<attribute name="droploc">
|
2431
|
+
<data type="boolean"/>
|
2432
|
+
</attribute>
|
2433
|
+
</optional>
|
2434
|
+
<optional>
|
2435
|
+
<attribute name="style">
|
2436
|
+
<ref name="XrefStyleType"/>
|
2437
|
+
</attribute>
|
2438
|
+
</optional>
|
2439
|
+
<optional>
|
2440
|
+
<attribute name="label"/>
|
2441
|
+
</optional>
|
2442
|
+
</define>
|
2453
2443
|
<define name="XrefBody">
|
2454
2444
|
<zeroOrMore>
|
2455
2445
|
<ref name="XrefTarget"/>
|
@@ -2528,6 +2518,28 @@
|
|
2528
2518
|
<attribute name="columns"/>
|
2529
2519
|
</optional>
|
2530
2520
|
</define>
|
2521
|
+
<define name="FigureAttributes">
|
2522
|
+
<attribute name="id">
|
2523
|
+
<data type="ID"/>
|
2524
|
+
</attribute>
|
2525
|
+
<optional>
|
2526
|
+
<attribute name="unnumbered">
|
2527
|
+
<data type="boolean"/>
|
2528
|
+
</attribute>
|
2529
|
+
</optional>
|
2530
|
+
<optional>
|
2531
|
+
<attribute name="number"/>
|
2532
|
+
</optional>
|
2533
|
+
<optional>
|
2534
|
+
<attribute name="subsequence"/>
|
2535
|
+
</optional>
|
2536
|
+
<optional>
|
2537
|
+
<attribute name="class"/>
|
2538
|
+
</optional>
|
2539
|
+
<optional>
|
2540
|
+
<attribute name="width"/>
|
2541
|
+
</optional>
|
2542
|
+
</define>
|
2531
2543
|
<start>
|
2532
2544
|
<ref name="standard-document"/>
|
2533
2545
|
</start>
|
@@ -201,7 +201,13 @@ module Metanorma
|
|
201
201
|
using_format :short
|
202
202
|
|
203
203
|
def process(parent, _target, attrs)
|
204
|
-
|
204
|
+
t = attrs["text"]
|
205
|
+
t = if /,/.match?(t)
|
206
|
+
t.sub(/,/, "%")
|
207
|
+
else
|
208
|
+
"#{t}%"
|
209
|
+
end
|
210
|
+
create_anchor(parent, "hidden=#{t}",
|
205
211
|
type: :xref, target: "_#{UUIDTools::UUID.random_create}")
|
206
212
|
end
|
207
213
|
end
|
@@ -10,9 +10,8 @@ module Metanorma
|
|
10
10
|
@norm_ref = false
|
11
11
|
|
12
12
|
def sectiontype1(node)
|
13
|
-
|
14
|
-
|
15
|
-
node&.attr("heading")&.downcase ||
|
13
|
+
node.attr("style") == "abstract" and return "abstract"
|
14
|
+
node.attr("heading")&.downcase ||
|
16
15
|
node.title
|
17
16
|
.gsub(%r{<index>.*?</index>}m, "")
|
18
17
|
.gsub(%r{<fn[^>]*>.*?</fn>}m, "")
|
@@ -25,7 +24,7 @@ module Metanorma
|
|
25
24
|
ret = sectiontype1(node)
|
26
25
|
ret1 = preface_main_filter(sectiontype_streamline(ret), node)
|
27
26
|
ret1 == "symbols and abbreviated terms" and return ret1
|
28
|
-
!level || node.level == 1 or return nil
|
27
|
+
!level || node.level == 1 || node.attr("heading") or return nil
|
29
28
|
@seen_headers.include? ret and return nil
|
30
29
|
@seen_headers << ret unless ret1.nil?
|
31
30
|
@seen_headers_canonical << ret1 unless ret1.nil?
|
@@ -59,9 +58,12 @@ module Metanorma
|
|
59
58
|
["normative references", "terms and definitions", "scope",
|
60
59
|
"symbols and abbreviated terms", "clause", "bibliography"].freeze
|
61
60
|
|
62
|
-
def
|
63
|
-
|
61
|
+
def role_style(node, value)
|
62
|
+
node.role == value || node.attr("style") == value
|
63
|
+
end
|
64
64
|
|
65
|
+
def start_main_section(ret, node)
|
66
|
+
role_style(node, "preface") and return
|
65
67
|
@preface = false if self.class::MAIN_CLAUSE_NAMES.include?(ret)
|
66
68
|
@preface = false if self.class::PREFACE_CLAUSE_NAMES
|
67
69
|
.intersection(@seen_headers_canonical + [ret]).empty?
|
@@ -79,29 +81,20 @@ module Metanorma
|
|
79
81
|
end
|
80
82
|
|
81
83
|
def section_attributes(node)
|
82
|
-
ret =
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
tag: node&.attr("tag"),
|
94
|
-
"multilingual-rendering": node&.attr("multilingual-rendering"),
|
95
|
-
colophon: (if node.role == "colophon" ||
|
96
|
-
node.attr("style") == "colophon"
|
97
|
-
true
|
98
|
-
end),
|
99
|
-
preface: (if node.role == "preface" ||
|
100
|
-
node.attr("style") == "preface"
|
101
|
-
true
|
102
|
-
end) }
|
103
|
-
return ret unless node.attributes["change"]
|
84
|
+
ret =
|
85
|
+
{ id: Metanorma::Utils::anchor_or_uuid(node),
|
86
|
+
annex: role_style(node, "appendix") && node.level == 1 ? true : nil,
|
87
|
+
colophon: role_style(node, "colophon") ? true : nil,
|
88
|
+
preface: role_style(node, "preface") ? true : nil }
|
89
|
+
%w(language script number branch-number type tag keeptitle
|
90
|
+
multilingual-rendering).each do |k|
|
91
|
+
a = node.attr(k) and ret[k.to_sym] = a
|
92
|
+
end
|
93
|
+
section_attributes_change(node, ret).compact
|
94
|
+
end
|
104
95
|
|
96
|
+
def section_attributes_change(node, ret)
|
97
|
+
node.attributes["change"] or return ret
|
105
98
|
ret.merge(change: node.attributes["change"],
|
106
99
|
path: node.attributes["path"],
|
107
100
|
path_end: node.attributes["path_end"],
|
@@ -5,8 +5,6 @@ module Metanorma
|
|
5
5
|
# Intelligent term lookup xml modifier
|
6
6
|
class TermLookupCleanup
|
7
7
|
AUTO_GEN_ID_REGEXP = /\A_/.freeze
|
8
|
-
EXISTING_TERM_REGEXP = /\Aterm-/.freeze
|
9
|
-
EXISTING_SYMBOL_REGEXP = /\Asymbol-/.freeze
|
10
8
|
|
11
9
|
attr_reader :xmldoc, :lookup, :log
|
12
10
|
|
@@ -61,13 +59,12 @@ module Metanorma
|
|
61
59
|
def related_cleanup
|
62
60
|
xmldoc.xpath("//related").each do |n|
|
63
61
|
refterm = n.at("./refterm") or next
|
62
|
+
repl = "<preferred><expression>" \
|
63
|
+
"<name>#{refterm.children.to_xml}</name></expression></preferred>"
|
64
64
|
lookup = norm_ref_id_text(refterm.text.strip)
|
65
65
|
p = @lookup[:sec2prim][lookup] and refterm.children = @c.encode(p)
|
66
66
|
p || @lookup[:term][lookup] and
|
67
|
-
refterm.replace(
|
68
|
-
<preferred><expression><name>#{refterm.children.to_xml}</name></expression></preferred>
|
69
|
-
XML
|
70
|
-
)
|
67
|
+
refterm.replace(repl)
|
71
68
|
end
|
72
69
|
end
|
73
70
|
|
@@ -96,7 +93,7 @@ module Metanorma
|
|
96
93
|
def remove_missing_ref?(node)
|
97
94
|
node.at("../eref | ../termref") and return false
|
98
95
|
xref = node.at("../xref") or return true
|
99
|
-
xref["target"] && !xref["target"]
|
96
|
+
xref["target"] && !xref["target"].empty? and return false
|
100
97
|
xref.remove # if xref supplied by user, we won't delete
|
101
98
|
true
|
102
99
|
end
|
@@ -251,8 +248,7 @@ module Metanorma
|
|
251
248
|
end
|
252
249
|
|
253
250
|
def unique_text_id(text, prefix)
|
254
|
-
@idhash["#{prefix}-#{text}"] or
|
255
|
-
return "#{prefix}-#{text}"
|
251
|
+
@idhash["#{prefix}-#{text}"] or return "#{prefix}-#{text}"
|
256
252
|
(1..Float::INFINITY).lazy.each do |index|
|
257
253
|
@idhash["#{prefix}-#{text}-#{index}"] or
|
258
254
|
break("#{prefix}-#{text}-#{index}")
|
data/metanorma-standoc.gemspec
CHANGED
@@ -30,6 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
|
31
31
|
spec.add_dependency "addressable", "~> 2.8.0"
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
|
+
spec.add_dependency "crass", "~> 1.0.0"
|
33
34
|
spec.add_dependency "iev", "~> 0.3.0"
|
34
35
|
spec.add_dependency "isodoc", "~> 2.9.0"
|
35
36
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: metanorma-standoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.8.
|
4
|
+
version: 2.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: crass
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.0.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.0.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: iev
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|