metanorma-standoc 2.7.5 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/base.rb +5 -7
- data/lib/metanorma/standoc/basicdoc.rng +91 -8
- data/lib/metanorma/standoc/biblio-standoc.rng +44 -1
- data/lib/metanorma/standoc/biblio.rng +11 -0
- data/lib/metanorma/standoc/cleanup.rb +2 -0
- data/lib/metanorma/standoc/cleanup_amend.rb +2 -1
- data/lib/metanorma/standoc/cleanup_bibdata.rb +118 -7
- data/lib/metanorma/standoc/cleanup_image.rb +5 -3
- data/lib/metanorma/standoc/cleanup_xref.rb +22 -2
- data/lib/metanorma/standoc/front_organisation.rb +4 -0
- data/lib/metanorma/standoc/inline.rb +1 -1
- data/lib/metanorma/standoc/isodoc.rng +10 -64
- data/lib/metanorma/standoc/reqt.rng +0 -16
- data/lib/metanorma/standoc/validate.rb +5 -5
- data/lib/metanorma/standoc/version.rb +1 -1
- data/lib/metanorma-standoc.rb +1 -0
- data/metanorma-standoc.gemspec +3 -2
- metadata +20 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed917e2185484c68d9c76b23b7bf977ee03da83204d3ceae22fd4fc893b8dae0
|
4
|
+
data.tar.gz: c1c7af6fd9cb9a958093cb698beb2523d16bee5cdc4b4a06140092690753f44b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 491207a21d304b30840b19398d547a1eb5e55037bd93c3c39397a9d31a725cde2de5e88348e984958639415f8ea38dcd6091fb5888825775934609e83c79cf53
|
7
|
+
data.tar.gz: aa771efa57e60c94ac9e8e65dc0fd00a6c9280a812ea1ecbc212cecb25547be7b492111a6fdcbfa0118ad855ca775772fbedfc1d83c92fd3d3fff68b89a8f950
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require "date"
|
2
2
|
require "nokogiri"
|
3
3
|
require "htmlentities"
|
4
|
-
require "json"
|
5
4
|
require "pathname"
|
6
5
|
require "isodoc"
|
7
6
|
require "relaton"
|
8
7
|
require "fileutils"
|
9
8
|
require "metanorma-utils"
|
10
|
-
require "isodoc/xslfo_convert"
|
11
9
|
require_relative "render"
|
12
10
|
require_relative "localbib"
|
13
11
|
require "mn-requirements"
|
@@ -80,8 +78,8 @@ module Metanorma
|
|
80
78
|
end
|
81
79
|
|
82
80
|
def init_reqt(node)
|
83
|
-
@default_requirement_model =
|
84
|
-
|
81
|
+
@default_requirement_model = node.attr("requirements-model") ||
|
82
|
+
default_requirement_model
|
85
83
|
@reqt_models = requirements_processor
|
86
84
|
.new({ default: @default_requirement_model })
|
87
85
|
end
|
@@ -117,9 +115,9 @@ module Metanorma
|
|
117
115
|
end
|
118
116
|
|
119
117
|
def init_i18n(node)
|
120
|
-
@lang =
|
121
|
-
@script =
|
122
|
-
|
118
|
+
@lang = node.attr("language") || "en"
|
119
|
+
@script = node.attr("script") ||
|
120
|
+
Metanorma::Utils.default_script(node.attr("language"))
|
123
121
|
@locale = node.attr("locale")
|
124
122
|
@isodoc = isodoc(@lang, @script, @locale, node.attr("i18nyaml"))
|
125
123
|
@i18n = @isodoc.i18n
|
@@ -95,8 +95,89 @@
|
|
95
95
|
<ref name="pagebreak"/>
|
96
96
|
<ref name="hr"/>
|
97
97
|
<ref name="bookmark"/>
|
98
|
+
<ref name="amend"/>
|
98
99
|
</choice>
|
99
100
|
</define>
|
101
|
+
<define name="amend">
|
102
|
+
<element name="amend">
|
103
|
+
<ref name="AmendType"/>
|
104
|
+
</element>
|
105
|
+
</define>
|
106
|
+
<define name="AmendType">
|
107
|
+
<optional>
|
108
|
+
<attribute name="id">
|
109
|
+
<data type="ID"/>
|
110
|
+
</attribute>
|
111
|
+
</optional>
|
112
|
+
<attribute name="change">
|
113
|
+
<choice>
|
114
|
+
<value>add</value>
|
115
|
+
<value>modify</value>
|
116
|
+
<value>delete</value>
|
117
|
+
<value>replace</value>
|
118
|
+
</choice>
|
119
|
+
</attribute>
|
120
|
+
<optional>
|
121
|
+
<attribute name="path"/>
|
122
|
+
</optional>
|
123
|
+
<optional>
|
124
|
+
<attribute name="path_end"/>
|
125
|
+
</optional>
|
126
|
+
<optional>
|
127
|
+
<attribute name="title"/>
|
128
|
+
</optional>
|
129
|
+
<optional>
|
130
|
+
<element name="location">
|
131
|
+
<zeroOrMore>
|
132
|
+
<choice>
|
133
|
+
<ref name="locality"/>
|
134
|
+
<ref name="localityStack"/>
|
135
|
+
</choice>
|
136
|
+
</zeroOrMore>
|
137
|
+
</element>
|
138
|
+
</optional>
|
139
|
+
<optional>
|
140
|
+
<element name="description">
|
141
|
+
<zeroOrMore>
|
142
|
+
<ref name="BasicBlock"/>
|
143
|
+
</zeroOrMore>
|
144
|
+
</element>
|
145
|
+
</optional>
|
146
|
+
<optional>
|
147
|
+
<element name="newcontent">
|
148
|
+
<optional>
|
149
|
+
<attribute name="id">
|
150
|
+
<data type="ID"/>
|
151
|
+
</attribute>
|
152
|
+
</optional>
|
153
|
+
<zeroOrMore>
|
154
|
+
<ref name="BasicBlock"/>
|
155
|
+
</zeroOrMore>
|
156
|
+
</element>
|
157
|
+
</optional>
|
158
|
+
<zeroOrMore>
|
159
|
+
<ref name="classification"/>
|
160
|
+
</zeroOrMore>
|
161
|
+
<zeroOrMore>
|
162
|
+
<ref name="contributor"/>
|
163
|
+
</zeroOrMore>
|
164
|
+
</define>
|
165
|
+
<define name="classification">
|
166
|
+
<element name="classification">
|
167
|
+
<ref name="classification_tag"/>
|
168
|
+
<ref name="classification_value"/>
|
169
|
+
</element>
|
170
|
+
</define>
|
171
|
+
<define name="classification_tag">
|
172
|
+
<element name="tag">
|
173
|
+
<text/>
|
174
|
+
</element>
|
175
|
+
</define>
|
176
|
+
<define name="classification_value">
|
177
|
+
<element name="value">
|
178
|
+
<text/>
|
179
|
+
</element>
|
180
|
+
</define>
|
100
181
|
<define name="paragraph">
|
101
182
|
<element name="p">
|
102
183
|
<ref name="ParagraphType"/>
|
@@ -939,18 +1020,12 @@
|
|
939
1020
|
</optional>
|
940
1021
|
<optional>
|
941
1022
|
<attribute name="width">
|
942
|
-
<
|
943
|
-
<data type="int"/>
|
944
|
-
<value>auto</value>
|
945
|
-
</choice>
|
1023
|
+
<ref name="ImageSize"/>
|
946
1024
|
</attribute>
|
947
1025
|
</optional>
|
948
1026
|
<optional>
|
949
1027
|
<attribute name="height">
|
950
|
-
<
|
951
|
-
<data type="int"/>
|
952
|
-
<value>auto</value>
|
953
|
-
</choice>
|
1028
|
+
<ref name="ImageSize"/>
|
954
1029
|
</attribute>
|
955
1030
|
</optional>
|
956
1031
|
<optional>
|
@@ -965,6 +1040,14 @@
|
|
965
1040
|
</attribute>
|
966
1041
|
</optional>
|
967
1042
|
</define>
|
1043
|
+
<define name="ImageSize">
|
1044
|
+
<choice>
|
1045
|
+
<data type="string">
|
1046
|
+
<param name="pattern">\d+([.]\d+)?(%?)</param>
|
1047
|
+
</data>
|
1048
|
+
<value>auto</value>
|
1049
|
+
</choice>
|
1050
|
+
</define>
|
968
1051
|
<define name="video">
|
969
1052
|
<element name="video">
|
970
1053
|
<attribute name="id">
|
@@ -9,11 +9,42 @@
|
|
9
9
|
-->
|
10
10
|
<include href="biblio.rng">
|
11
11
|
<define name="BibData">
|
12
|
-
<ref name="
|
12
|
+
<ref name="StandardBibliographicItem"/>
|
13
13
|
<optional>
|
14
14
|
<ref name="ext"/>
|
15
15
|
</optional>
|
16
16
|
</define>
|
17
|
+
<define name="docrelation">
|
18
|
+
<element name="relation">
|
19
|
+
<attribute name="type">
|
20
|
+
<ref name="DocRelationType"/>
|
21
|
+
</attribute>
|
22
|
+
<optional>
|
23
|
+
<element name="description">
|
24
|
+
<ref name="FormattedString"/>
|
25
|
+
</element>
|
26
|
+
</optional>
|
27
|
+
<element name="bibitem">
|
28
|
+
<ref name="StandardReducedBibliographicItem"/>
|
29
|
+
</element>
|
30
|
+
<choice>
|
31
|
+
<zeroOrMore>
|
32
|
+
<ref name="locality"/>
|
33
|
+
</zeroOrMore>
|
34
|
+
<zeroOrMore>
|
35
|
+
<ref name="localityStack"/>
|
36
|
+
</zeroOrMore>
|
37
|
+
</choice>
|
38
|
+
<choice>
|
39
|
+
<zeroOrMore>
|
40
|
+
<ref name="sourceLocality"/>
|
41
|
+
</zeroOrMore>
|
42
|
+
<zeroOrMore>
|
43
|
+
<ref name="sourceLocalityStack"/>
|
44
|
+
</zeroOrMore>
|
45
|
+
</choice>
|
46
|
+
</element>
|
47
|
+
</define>
|
17
48
|
</include>
|
18
49
|
<define name="ext">
|
19
50
|
<element name="ext">
|
@@ -161,4 +192,16 @@
|
|
161
192
|
</optional>
|
162
193
|
</element>
|
163
194
|
</define>
|
195
|
+
<define name="StandardBibliographicItem">
|
196
|
+
<ref name="BibliographicItem"/>
|
197
|
+
<zeroOrMore>
|
198
|
+
<ref name="amend"/>
|
199
|
+
</zeroOrMore>
|
200
|
+
</define>
|
201
|
+
<define name="StandardReducedBibliographicItem">
|
202
|
+
<ref name="ReducedBibliographicItem"/>
|
203
|
+
<zeroOrMore>
|
204
|
+
<ref name="amend"/>
|
205
|
+
</zeroOrMore>
|
206
|
+
</define>
|
164
207
|
</grammar>
|
@@ -241,6 +241,9 @@
|
|
241
241
|
</element>
|
242
242
|
</define>
|
243
243
|
<define name="FullNameType">
|
244
|
+
<optional>
|
245
|
+
<ref name="name_abbreviation"/>
|
246
|
+
</optional>
|
244
247
|
<choice>
|
245
248
|
<group>
|
246
249
|
<zeroOrMore>
|
@@ -266,6 +269,11 @@
|
|
266
269
|
<ref name="variantname"/>
|
267
270
|
</zeroOrMore>
|
268
271
|
</define>
|
272
|
+
<define name="name_abbreviation">
|
273
|
+
<element name="abbreviation">
|
274
|
+
<ref name="LocalizedString"/>
|
275
|
+
</element>
|
276
|
+
</define>
|
269
277
|
<define name="prefix">
|
270
278
|
<element name="prefix">
|
271
279
|
<ref name="LocalizedString"/>
|
@@ -870,6 +878,9 @@
|
|
870
878
|
<optional>
|
871
879
|
<ref name="validity"/>
|
872
880
|
</optional>
|
881
|
+
<optional>
|
882
|
+
<ref name="depiction"/>
|
883
|
+
</optional>
|
873
884
|
</define>
|
874
885
|
<define name="btitle">
|
875
886
|
<element name="title">
|
@@ -71,6 +71,8 @@ module Metanorma
|
|
71
71
|
mathml_cleanup(xmldoc)
|
72
72
|
script_cleanup(xmldoc)
|
73
73
|
docidentifier_cleanup(xmldoc) # feeds: bibdata_cleanup
|
74
|
+
ext_contributor_cleanup(xmldoc) # feeds: bibdata_cleanup
|
75
|
+
ext_dochistory_cleanup(xmldoc) # feeds: bibdata_cleanup
|
74
76
|
bibdata_cleanup(xmldoc)
|
75
77
|
svgmap_cleanup(xmldoc) # feeds: img_cleanup
|
76
78
|
boilerplate_cleanup(xmldoc)
|
@@ -19,9 +19,10 @@ module Metanorma
|
|
19
19
|
def create_amend1(clause, amend)
|
20
20
|
create_amend2(clause, amend)
|
21
21
|
d = amend.at("./description")
|
22
|
-
d.xpath(".//autonumber").
|
22
|
+
autonum = d.xpath(".//autonumber").map(&:remove)
|
23
23
|
d.xpath(".//p[normalize-space(.)='']").each(&:remove)
|
24
24
|
move_attrs_to_amend(clause, amend)
|
25
|
+
autonum.each { |a| amend << a }
|
25
26
|
amend
|
26
27
|
end
|
27
28
|
|
@@ -46,17 +46,16 @@ module Metanorma
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def indirect_eref_to_xref(eref, ident)
|
49
|
-
loc = eref.at("./localityStack[locality[@type = 'anchor']]")
|
50
|
-
|
51
|
-
|
49
|
+
loc = eref.at("./localityStack[locality[@type = 'anchor']]") ||
|
50
|
+
eref.at("./locality[@type = 'anchor']")
|
51
|
+
loc = loc&.remove&.text || ident
|
52
52
|
eref.name = "xref"
|
53
53
|
eref.delete("bibitemid")
|
54
54
|
eref.delete("citeas")
|
55
55
|
eref["target"] = loc
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
56
|
+
eref.document.at("//*[@id = '#{loc}']") and return
|
57
|
+
eref.children = %(** Missing target #{loc})
|
58
|
+
eref["target"] = ident
|
60
59
|
end
|
61
60
|
|
62
61
|
def resolve_local_indirect_erefs(xmldoc, refs, prefix)
|
@@ -122,6 +121,118 @@ module Metanorma
|
|
122
121
|
.each { |x| x << ident.text }
|
123
122
|
end
|
124
123
|
end
|
124
|
+
|
125
|
+
def ext_contributor_cleanup(xmldoc)
|
126
|
+
t = xmldoc.xpath("//metanorma-extension/clause/title").detect do |x|
|
127
|
+
x.text.strip.casecmp("contributor metadata").zero?
|
128
|
+
end or return
|
129
|
+
a = t.at("../sourcecode") or return
|
130
|
+
ins = xmldoc.at("//bibdata/contributor[last()]")
|
131
|
+
yaml = YAML.safe_load(a.text, permitted_classes: [Date])
|
132
|
+
ext_contributors_process(yaml, ins)
|
133
|
+
end
|
134
|
+
|
135
|
+
def yaml2relaton(yaml, amend = nil)
|
136
|
+
r = RelatonBib.parse_yaml(yaml.to_yaml, [Date], symbolize_names: true)
|
137
|
+
h = RelatonBib::HashConverter.hash_to_bib(r)
|
138
|
+
b = RelatonBib::BibliographicItem.new(**h).to_xml
|
139
|
+
amend and b.sub!("</bibitem>", "#{amend}</bibitem>")
|
140
|
+
b
|
141
|
+
end
|
142
|
+
|
143
|
+
def ext_contributors_process(yaml, ins)
|
144
|
+
yaml.is_a?(Hash) && !yaml["contributor"] and yaml = [yaml]
|
145
|
+
yaml.is_a?(Array) and yaml = { "contributor" => yaml }
|
146
|
+
r = yaml2relaton(yaml)
|
147
|
+
Nokogiri::XML(r).xpath("//contributor").reverse
|
148
|
+
.each do |c|
|
149
|
+
ins.next = c
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
def bib_relation_insert_pt(xmldoc)
|
154
|
+
ins = nil
|
155
|
+
%w(relation copyright status abstract script language note version
|
156
|
+
edition contributor).each do |x|
|
157
|
+
ins = xmldoc.at("//bibdata/#{x}[last()]") and break
|
158
|
+
end
|
159
|
+
ins
|
160
|
+
end
|
161
|
+
|
162
|
+
def ext_dochistory_cleanup(xmldoc)
|
163
|
+
t = xmldoc.xpath("//metanorma-extension/clause/title").detect do |x|
|
164
|
+
x.text.strip.casecmp("document history").zero?
|
165
|
+
end or return
|
166
|
+
a = t.at("../sourcecode") or return
|
167
|
+
ins = bib_relation_insert_pt(xmldoc) or return
|
168
|
+
docid = xmldoc.at("//bibdata/docidentifier")
|
169
|
+
yaml = YAML.safe_load(a.text, permitted_classes: [Date])
|
170
|
+
ext_dochistory_process(yaml, ins, docid)
|
171
|
+
end
|
172
|
+
|
173
|
+
def ext_dochistory_process(yaml, ins, docid)
|
174
|
+
yaml.is_a?(Hash) and yaml = [yaml]
|
175
|
+
yaml.reverse.each do |y|
|
176
|
+
type = y["relation.type"] || "updatedBy"
|
177
|
+
docid and
|
178
|
+
y["docid"] ||= [{ "type" => docid["type"], "id" => docid.text }]
|
179
|
+
r = yaml2relaton(y, amend_hash2mn(y["amend"]))
|
180
|
+
ins.next = "<relation type='#{type}'>#{r}</relation>"
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def amend_hash2mn(yaml)
|
185
|
+
yaml.nil? and return ""
|
186
|
+
yaml.is_a?(Hash) and yaml = [yaml]
|
187
|
+
yaml.map { |x| amend_hash2mn1(x) }.join("\n")
|
188
|
+
end
|
189
|
+
|
190
|
+
def amend_attrs(yaml)
|
191
|
+
ret = ""
|
192
|
+
yaml["change"] ||= "modify"
|
193
|
+
%w(change path path_end title).each do |x|
|
194
|
+
a = yaml[x] and ret += " #{x}='#{a}'"
|
195
|
+
end
|
196
|
+
ret = "<amend#{ret}>"
|
197
|
+
end
|
198
|
+
|
199
|
+
def amend_hash2mn1(yaml)
|
200
|
+
ret = amend_attrs(yaml)
|
201
|
+
ret += amend_description(yaml)
|
202
|
+
ret += amend_location(yaml)
|
203
|
+
ret += amend_classification(yaml)
|
204
|
+
"#{ret}</amend>"
|
205
|
+
end
|
206
|
+
|
207
|
+
def amend_location(yaml)
|
208
|
+
a = yaml["location"] or return ""
|
209
|
+
a.is_a?(Array) or a = [a]
|
210
|
+
ret = a.map do |x|
|
211
|
+
elem = Nokogiri::XML("<location>#{x}</location>").root
|
212
|
+
extract_localities(elem)
|
213
|
+
elem.children.to_xml
|
214
|
+
end.join("\n")
|
215
|
+
"<location>#{ret}</location>"
|
216
|
+
end
|
217
|
+
|
218
|
+
def amend_description(yaml)
|
219
|
+
a = yaml["description"] or return ""
|
220
|
+
out = adoc2xml(a, backend.to_sym)
|
221
|
+
"<description>#{out.children.to_xml}</description>"
|
222
|
+
end
|
223
|
+
|
224
|
+
def amend_classification(yaml)
|
225
|
+
a = yaml["classification"] or return ""
|
226
|
+
a.is_a?(Array) or a = [a]
|
227
|
+
a.map { |x| amend_classification1(x) }.join("\n")
|
228
|
+
end
|
229
|
+
|
230
|
+
def amend_classification1(yaml)
|
231
|
+
yaml.is_a?(Hash) or yaml = { "tag" => "default", "value" => yaml }
|
232
|
+
<<~OUT
|
233
|
+
<classification><tag>#{yaml['tag']}</tag><value>#{yaml['value']}</value></classification>
|
234
|
+
OUT
|
235
|
+
end
|
125
236
|
end
|
126
237
|
end
|
127
238
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "vectory"
|
2
|
+
|
1
3
|
module Metanorma
|
2
4
|
module Standoc
|
3
5
|
module Cleanup
|
@@ -5,7 +7,7 @@ module Metanorma
|
|
5
7
|
svg_uniqueids(xmldoc)
|
6
8
|
svgmap_moveattrs(xmldoc)
|
7
9
|
svgmap_populate(xmldoc)
|
8
|
-
|
10
|
+
Vectory::SvgMapping.new(xmldoc, @localdir).call
|
9
11
|
end
|
10
12
|
|
11
13
|
def guid?(str)
|
@@ -64,7 +66,7 @@ module Metanorma
|
|
64
66
|
xmldoc.xpath("//image").each do |i|
|
65
67
|
# do not datauri encode SVG, we need to deduplicate its IDs
|
66
68
|
unless read_in_if_svg(i, @localdir)
|
67
|
-
i["src"] =
|
69
|
+
i["src"] = Vectory::Utils::datauri(i["src"], @localdir)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
end
|
@@ -75,7 +77,7 @@ module Metanorma
|
|
75
77
|
def read_in_if_svg(img, localdir)
|
76
78
|
return false unless img["src"]
|
77
79
|
|
78
|
-
path =
|
80
|
+
path = Vectory::Utils.svgmap_rewrite0_path(img["src"], localdir)
|
79
81
|
File.file?(path) or return false
|
80
82
|
types = MIME::Types.type_for(path) or return false
|
81
83
|
types.first == "image/svg+xml" or return false
|
@@ -2,8 +2,10 @@ module Metanorma
|
|
2
2
|
module Standoc
|
3
3
|
module Cleanup
|
4
4
|
# extending localities to cover ISO referencing
|
5
|
+
CONN_REGEX_STR = "(?<conn>and|or|from|to)!".freeze
|
6
|
+
|
5
7
|
LOCALITY_REGEX_STR = <<~REGEXP.freeze
|
6
|
-
^((
|
8
|
+
^((#{CONN_REGEX_STR})?
|
7
9
|
(?<locality>section|clause|part|paragraph|chapter|page|line|
|
8
10
|
table|annex|figure|example|note|formula|list|time|anchor|
|
9
11
|
locality:[^ \\t\\n\\r:,;=]+)(\\s+|=)
|
@@ -15,6 +17,15 @@ module Metanorma
|
|
15
17
|
LOCALITY_RE = Regexp.new(LOCALITY_REGEX_STR.gsub(/\s/, ""),
|
16
18
|
Regexp::IGNORECASE | Regexp::MULTILINE)
|
17
19
|
|
20
|
+
LOCALITY_REGEX_VALUE_ONLY_STR = <<~REGEXP.freeze
|
21
|
+
^(?<conn0>(#{CONN_REGEX_STR}))
|
22
|
+
(?!whole|title|locality:)
|
23
|
+
(?<value>[^=,;:\\t\\n\\r]+)
|
24
|
+
(?<punct>[,;\\t\\n\\r]|$)
|
25
|
+
REGEXP
|
26
|
+
LOCALITY_VAL_ONLY_RE = Regexp.new(LOCALITY_REGEX_VALUE_ONLY_STR
|
27
|
+
.gsub(/\s/, ""), Regexp::IGNORECASE | Regexp::MULTILINE)
|
28
|
+
|
18
29
|
def tq(text)
|
19
30
|
text.sub(/^"/, "").sub(/"$/, "")
|
20
31
|
end
|
@@ -33,13 +44,22 @@ module Metanorma
|
|
33
44
|
b = elem.add_child("<localityStack/>").first if LOCALITY_RE.match text
|
34
45
|
while (m = LOCALITY_RE.match text)
|
35
46
|
add_locality(b, m)
|
36
|
-
text = m
|
47
|
+
text = extract_localities_update_text(m)
|
37
48
|
b = elem.add_child("<localityStack/>").first if m[:punct] == ";"
|
38
49
|
end
|
39
50
|
fill_in_eref_connectives(elem)
|
40
51
|
elem.add_child(text) if text
|
41
52
|
end
|
42
53
|
|
54
|
+
# clause=3;and!5 => clause=3;and!clause=5
|
55
|
+
def extract_localities_update_text(match)
|
56
|
+
ret = match[:text]
|
57
|
+
if LOCALITY_VAL_ONLY_RE.match?(ret) && match[:punct] == ";"
|
58
|
+
ret.sub!(%r{^(#{CONN_REGEX_STR})}o, "\\1#{match[:locality]}=")
|
59
|
+
end
|
60
|
+
ret
|
61
|
+
end
|
62
|
+
|
43
63
|
def add_locality(stack, match)
|
44
64
|
stack.children.empty? && match[:conn] and
|
45
65
|
stack["connective"] = match[:conn]
|
@@ -124,7 +124,7 @@ module Metanorma
|
|
124
124
|
if Gem.win_platform? && /^\/[a-zA-Z]:/.match?(uri)
|
125
125
|
uri = uri[1..-1]
|
126
126
|
end
|
127
|
-
types = if /^data:/.match?(uri) then
|
127
|
+
types = if /^data:/.match?(uri) then Vectory::Utils::datauri2mime(uri)
|
128
128
|
else MIME::Types.type_for(uri)
|
129
129
|
end
|
130
130
|
type = types.first.to_s
|
@@ -17,10 +17,19 @@
|
|
17
17
|
these elements; we just want one namespace for any child grammars
|
18
18
|
of this.
|
19
19
|
-->
|
20
|
-
<!-- VERSION v1.2.
|
20
|
+
<!-- VERSION v1.2.12 -->
|
21
21
|
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
|
22
22
|
<include href="reqt.rng"/>
|
23
23
|
<include href="basicdoc.rng">
|
24
|
+
<define name="amend">
|
25
|
+
<element name="amend">
|
26
|
+
<ref name="BlockAttributes"/>
|
27
|
+
<ref name="AmendType"/>
|
28
|
+
<zeroOrMore>
|
29
|
+
<ref name="autonumber"/>
|
30
|
+
</zeroOrMore>
|
31
|
+
</element>
|
32
|
+
</define>
|
24
33
|
<define name="admonition">
|
25
34
|
<element name="admonition">
|
26
35
|
<attribute name="type">
|
@@ -2319,69 +2328,6 @@
|
|
2319
2328
|
<ref name="CitationType"/>
|
2320
2329
|
</element>
|
2321
2330
|
</define>
|
2322
|
-
<define name="amend">
|
2323
|
-
<element name="amend">
|
2324
|
-
<optional>
|
2325
|
-
<attribute name="id">
|
2326
|
-
<data type="ID"/>
|
2327
|
-
</attribute>
|
2328
|
-
</optional>
|
2329
|
-
<attribute name="change">
|
2330
|
-
<choice>
|
2331
|
-
<value>add</value>
|
2332
|
-
<value>modify</value>
|
2333
|
-
<value>delete</value>
|
2334
|
-
<value>replace</value>
|
2335
|
-
</choice>
|
2336
|
-
</attribute>
|
2337
|
-
<optional>
|
2338
|
-
<attribute name="path"/>
|
2339
|
-
</optional>
|
2340
|
-
<optional>
|
2341
|
-
<attribute name="path_end"/>
|
2342
|
-
</optional>
|
2343
|
-
<optional>
|
2344
|
-
<attribute name="title"/>
|
2345
|
-
</optional>
|
2346
|
-
<ref name="BlockAttributes"/>
|
2347
|
-
<optional>
|
2348
|
-
<element name="location">
|
2349
|
-
<zeroOrMore>
|
2350
|
-
<ref name="locality"/>
|
2351
|
-
</zeroOrMore>
|
2352
|
-
</element>
|
2353
|
-
</optional>
|
2354
|
-
<zeroOrMore>
|
2355
|
-
<ref name="autonumber"/>
|
2356
|
-
</zeroOrMore>
|
2357
|
-
<optional>
|
2358
|
-
<element name="description">
|
2359
|
-
<zeroOrMore>
|
2360
|
-
<ref name="BasicBlock"/>
|
2361
|
-
</zeroOrMore>
|
2362
|
-
</element>
|
2363
|
-
</optional>
|
2364
|
-
<optional>
|
2365
|
-
<element name="newcontent">
|
2366
|
-
<optional>
|
2367
|
-
<attribute name="id">
|
2368
|
-
<data type="ID"/>
|
2369
|
-
</attribute>
|
2370
|
-
</optional>
|
2371
|
-
<zeroOrMore>
|
2372
|
-
<ref name="BasicBlock"/>
|
2373
|
-
</zeroOrMore>
|
2374
|
-
</element>
|
2375
|
-
</optional>
|
2376
|
-
<optional>
|
2377
|
-
<element name="description">
|
2378
|
-
<zeroOrMore>
|
2379
|
-
<ref name="BasicBlock"/>
|
2380
|
-
</zeroOrMore>
|
2381
|
-
</element>
|
2382
|
-
</optional>
|
2383
|
-
</element>
|
2384
|
-
</define>
|
2385
2331
|
<define name="autonumber">
|
2386
2332
|
<element name="autonumber">
|
2387
2333
|
<attribute name="type">
|
@@ -207,20 +207,4 @@
|
|
207
207
|
<value>permission</value>
|
208
208
|
</choice>
|
209
209
|
</define>
|
210
|
-
<define name="classification">
|
211
|
-
<element name="classification">
|
212
|
-
<ref name="classification_tag"/>
|
213
|
-
<ref name="classification_value"/>
|
214
|
-
</element>
|
215
|
-
</define>
|
216
|
-
<define name="classification_tag">
|
217
|
-
<element name="tag">
|
218
|
-
<text/>
|
219
|
-
</element>
|
220
|
-
</define>
|
221
|
-
<define name="classification_value">
|
222
|
-
<element name="value">
|
223
|
-
<text/>
|
224
|
-
</element>
|
225
|
-
</define>
|
226
210
|
</grammar>
|
@@ -144,8 +144,8 @@ module Metanorma
|
|
144
144
|
|
145
145
|
def image_exists(doc)
|
146
146
|
doc.xpath("//image").each do |i|
|
147
|
-
|
148
|
-
|
147
|
+
Vectory::Utils::url?(i["src"]) and next
|
148
|
+
Vectory::Utils::datauri?(i["src"]) and next
|
149
149
|
expand_path(i["src"]) and next
|
150
150
|
@log.add("Images", i.parent,
|
151
151
|
"Image not found: #{i['src']}", severity: 0)
|
@@ -161,9 +161,9 @@ module Metanorma
|
|
161
161
|
|
162
162
|
def png_validate(doc)
|
163
163
|
doc.xpath("//image[@mimetype = 'image/png']").each do |i|
|
164
|
-
|
165
|
-
decoded = if
|
166
|
-
|
164
|
+
Vectory::Utils::url?(i["src"]) and next
|
165
|
+
decoded = if Vectory::Utils::datauri?(i["src"])
|
166
|
+
Vectory::Utils::decode_datauri(i["src"])[:data]
|
167
167
|
else
|
168
168
|
path = expand_path(i["src"]) or next
|
169
169
|
File.binread(path)
|
data/lib/metanorma-standoc.rb
CHANGED
data/metanorma-standoc.gemspec
CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.add_dependency "addressable", "~> 2.8.0"
|
32
32
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
33
33
|
spec.add_dependency "iev", "~> 0.3.0"
|
34
|
-
spec.add_dependency "isodoc", "~> 2.
|
34
|
+
spec.add_dependency "isodoc", "~> 2.8.0"
|
35
35
|
spec.add_dependency "metanorma", ">= 1.6.0"
|
36
36
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
|
37
37
|
spec.add_dependency "metanorma-plugin-glossarist", "~> 0.1.1"
|
@@ -41,9 +41,10 @@ Gem::Specification.new do |spec|
|
|
41
41
|
spec.add_dependency "asciimath2unitsml", "~> 0.4.0"
|
42
42
|
spec.add_dependency "concurrent-ruby"
|
43
43
|
spec.add_dependency "pngcheck"
|
44
|
-
spec.add_dependency "relaton-cli", "~> 1.
|
44
|
+
spec.add_dependency "relaton-cli", "~> 1.18.0"
|
45
45
|
spec.add_dependency "relaton-iev", "~> 1.1.5"
|
46
46
|
spec.add_dependency "unicode2latex", "~> 0.0.1"
|
47
|
+
spec.add_dependency "vectory", "~> 0.6"
|
47
48
|
|
48
49
|
spec.add_development_dependency "debug"
|
49
50
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
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.
|
4
|
+
version: 2.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ribose Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.8.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.8.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: metanorma
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,14 +184,14 @@ dependencies:
|
|
184
184
|
requirements:
|
185
185
|
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version: 1.
|
187
|
+
version: 1.18.0
|
188
188
|
type: :runtime
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
192
|
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version: 1.
|
194
|
+
version: 1.18.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: relaton-iev
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -220,6 +220,20 @@ dependencies:
|
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
222
|
version: 0.0.1
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: vectory
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - "~>"
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0.6'
|
230
|
+
type: :runtime
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - "~>"
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0.6'
|
223
237
|
- !ruby/object:Gem::Dependency
|
224
238
|
name: debug
|
225
239
|
requirement: !ruby/object:Gem::Requirement
|