metanorma-standoc 2.2.3.1 → 2.2.5
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 +2 -1
- data/lib/metanorma/standoc/biblio.rng +32 -1
- data/lib/metanorma/standoc/blocks.rb +2 -1
- data/lib/metanorma/standoc/cleanup_biblio.rb +111 -23
- data/lib/metanorma/standoc/cleanup_boilerplate.rb +2 -2
- data/lib/metanorma/standoc/front.rb +1 -0
- data/lib/metanorma/standoc/isodoc.rng +9 -0
- data/lib/metanorma/standoc/macros_plantuml.rb +23 -10
- data/lib/metanorma/standoc/render.rb +1 -0
- data/lib/metanorma/standoc/term_lookup_cleanup.rb +32 -13
- data/lib/metanorma/standoc/utils.rb +3 -3
- data/lib/metanorma/standoc/validate.rb +12 -3
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +2 -2
- data/spec/metanorma/base_spec.rb +10 -1
- data/spec/metanorma/biblio_spec.rb +47 -17
- data/spec/metanorma/blocks_spec.rb +2 -2
- data/spec/metanorma/cleanup_sections_spec.rb +2 -1
- data/spec/metanorma/inline_spec.rb +10 -9
- data/spec/metanorma/isobib_cache_spec.rb +2 -2
- data/spec/metanorma/macros_concept_spec.rb +1 -1
- data/spec/metanorma/macros_spec.rb +2 -2
- data/spec/metanorma/refs_spec.rb +25 -25
- data/spec/metanorma/validate_spec.rb +33 -0
- data/spec/vcr_cassettes/bsi16341.yml +38 -38
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +64 -64
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +13 -13
- data/spec/vcr_cassettes/hide_refs.yml +53 -53
- data/spec/vcr_cassettes/isobib_get_123.yml +11 -11
- data/spec/vcr_cassettes/isobib_get_123_1.yml +22 -22
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +54 -54
- data/spec/vcr_cassettes/isobib_get_123_2.yml +24 -24
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_124.yml +11 -11
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +22 -24
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +55 -55
- data/spec/vcr_cassettes/std-link.yml +13 -13
- metadata +6 -10
- data/spec/requirements/default/blocks_spec.rb +0 -250
- data/spec/requirements/default/cleanup_spec.rb +0 -173
- data/spec/requirements/modspec/cleanup_spec.rb +0 -333
- data/spec/requirements/modspec/validate_spec.rb +0 -330
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12bb8cacaa61b510652a691e358e62e0e2e4f4ea1ac37dcff09f394b097051a9
|
4
|
+
data.tar.gz: 714fa0c071097b0817e3b95c5066fbd181634f1b7f09cff04e2c1e5eb45b385a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a45f4013300b1c263e7f99ff50605e3576157afaacb4710c7a1f9b14c2e1ac6a624737be9a87e6a4ca3205756451b9a7cacde8df4bc8491d508121d5e821772
|
7
|
+
data.tar.gz: 0c5bdb3f7a121998082b101488352bba31cad34abedf1f7fb1845cf25438c671545e3c65d09ec6a5bf06a075c8f311edbe4f61d210f470b1da009c71c8ea7627
|
@@ -100,7 +100,8 @@ module Metanorma
|
|
100
100
|
@lang = (node.attr("language") || "en")
|
101
101
|
@script = (node.attr("script") ||
|
102
102
|
Metanorma::Utils.default_script(node.attr("language")))
|
103
|
-
@
|
103
|
+
@locale = node.attr("locale")
|
104
|
+
@isodoc = isodoc(@lang, @script, @locale, node.attr("i18nyaml"))
|
104
105
|
@i18n = @isodoc.i18n
|
105
106
|
end
|
106
107
|
|
@@ -73,8 +73,14 @@
|
|
73
73
|
<text/>
|
74
74
|
</element>
|
75
75
|
</define>
|
76
|
-
<define name="
|
76
|
+
<define name="locale">
|
77
77
|
<a:documentation>ISO-639</a:documentation>
|
78
|
+
<element name="locale">
|
79
|
+
<text/>
|
80
|
+
</element>
|
81
|
+
</define>
|
82
|
+
<define name="script">
|
83
|
+
<a:documentation>ISO-3166</a:documentation>
|
78
84
|
<element name="script">
|
79
85
|
<text/>
|
80
86
|
</element>
|
@@ -93,6 +99,9 @@
|
|
93
99
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
94
100
|
<attribute name="language"/>
|
95
101
|
</optional>
|
102
|
+
<optional>
|
103
|
+
<attribute name="locale"/>
|
104
|
+
</optional>
|
96
105
|
<optional>
|
97
106
|
<attribute name="script"/>
|
98
107
|
</optional>
|
@@ -136,6 +145,9 @@
|
|
136
145
|
<!-- multiple languages and scripts possible: comma delimit them if so -->
|
137
146
|
<attribute name="language"/>
|
138
147
|
</optional>
|
148
|
+
<optional>
|
149
|
+
<attribute name="locale"/>
|
150
|
+
</optional>
|
139
151
|
<optional>
|
140
152
|
<attribute name="script"/>
|
141
153
|
</optional>
|
@@ -650,6 +662,9 @@
|
|
650
662
|
<zeroOrMore>
|
651
663
|
<ref name="language"/>
|
652
664
|
</zeroOrMore>
|
665
|
+
<zeroOrMore>
|
666
|
+
<ref name="locale"/>
|
667
|
+
</zeroOrMore>
|
653
668
|
<zeroOrMore>
|
654
669
|
<ref name="script"/>
|
655
670
|
</zeroOrMore>
|
@@ -741,6 +756,9 @@
|
|
741
756
|
<zeroOrMore>
|
742
757
|
<ref name="language"/>
|
743
758
|
</zeroOrMore>
|
759
|
+
<zeroOrMore>
|
760
|
+
<ref name="locale"/>
|
761
|
+
</zeroOrMore>
|
744
762
|
<zeroOrMore>
|
745
763
|
<ref name="script"/>
|
746
764
|
</zeroOrMore>
|
@@ -854,6 +872,15 @@
|
|
854
872
|
<optional>
|
855
873
|
<attribute name="type"/>
|
856
874
|
</optional>
|
875
|
+
<optional>
|
876
|
+
<attribute name="language"/>
|
877
|
+
</optional>
|
878
|
+
<optional>
|
879
|
+
<attribute name="locale"/>
|
880
|
+
</optional>
|
881
|
+
<optional>
|
882
|
+
<attribute name="script"/>
|
883
|
+
</optional>
|
857
884
|
<data type="anyURI"/>
|
858
885
|
</define>
|
859
886
|
<define name="DateType">
|
@@ -882,6 +909,7 @@
|
|
882
909
|
<value>vote-started</value>
|
883
910
|
<value>vote-ended</value>
|
884
911
|
<value>announced</value>
|
912
|
+
<value>stable-until</value>
|
885
913
|
</choice>
|
886
914
|
</define>
|
887
915
|
<define name="bdate">
|
@@ -930,6 +958,9 @@
|
|
930
958
|
<optional>
|
931
959
|
<attribute name="language"/>
|
932
960
|
</optional>
|
961
|
+
<optional>
|
962
|
+
<attribute name="locale"/>
|
963
|
+
</optional>
|
933
964
|
<optional>
|
934
965
|
<attribute name="script"/>
|
935
966
|
</optional>
|
@@ -110,7 +110,10 @@ module Metanorma
|
|
110
110
|
|
111
111
|
def formattedref_spans(xmldoc)
|
112
112
|
xmldoc.xpath("//bibitem[formattedref//span]").each do |b|
|
113
|
-
|
113
|
+
spans = spans_preprocess(extract_content(b))
|
114
|
+
ret = spans_to_bibitem(spans)
|
115
|
+
spans[:type] and b["type"] = spans[:type]
|
116
|
+
b << ret
|
114
117
|
end
|
115
118
|
end
|
116
119
|
|
@@ -120,13 +123,19 @@ module Metanorma
|
|
120
123
|
|
121
124
|
def extract_spans(bib)
|
122
125
|
bib.xpath("./formattedref//span").each_with_object([]) do |s, m|
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
(s["class"] == "type" and s.remove) or s.replace(s.children)
|
126
|
+
next if s.at("./ancestor::span")
|
127
|
+
|
128
|
+
extract_spans1(s, m)
|
127
129
|
end
|
128
130
|
end
|
129
131
|
|
132
|
+
def extract_spans1(span, acc)
|
133
|
+
keys = span["class"].split(".", 2)
|
134
|
+
acc << { key: keys[0], type: keys[1],
|
135
|
+
val: span.children.to_xml }
|
136
|
+
(span["class"] == "type" and span.remove) or span.replace(span.children)
|
137
|
+
end
|
138
|
+
|
130
139
|
def extract_docid(bib)
|
131
140
|
bib.xpath("./docidentifier").each_with_object([]) do |d, m|
|
132
141
|
m << { key: "docid", type: d["type"], val: d.text }
|
@@ -134,21 +143,61 @@ module Metanorma
|
|
134
143
|
end
|
135
144
|
end
|
136
145
|
|
146
|
+
def empty_span_hash
|
147
|
+
{ contrib: [], docid: [], uri: [], date: [], extent: {}, in: {} }
|
148
|
+
end
|
149
|
+
|
137
150
|
def spans_preprocess(spans)
|
138
|
-
ret =
|
139
|
-
spans.each
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
+
ret = empty_span_hash
|
152
|
+
spans.each { |s| span_preprocess1(s, ret) }
|
153
|
+
host_rearrange(ret)
|
154
|
+
end
|
155
|
+
|
156
|
+
def span_preprocess1(span, ret)
|
157
|
+
case span[:key]
|
158
|
+
when "uri", "docid"
|
159
|
+
ret[span[:key].to_sym] << { type: span[:type], val: span[:val] }
|
160
|
+
when "date"
|
161
|
+
ret[span[:key].to_sym] << { type: span[:type] || "published",
|
162
|
+
val: span[:val] }
|
163
|
+
when "pages", "volume", "issue"
|
164
|
+
ret[:extent][span[:key].to_sym] ||= []
|
165
|
+
ret[:extent][span[:key].to_sym] << span[:val]
|
166
|
+
when "pubplace", "title", "type", "series"
|
167
|
+
ret[span[:key].to_sym] = span[:val]
|
168
|
+
when "in_title"
|
169
|
+
ret[:in][:title] = span[:val]
|
170
|
+
when "publisher"
|
171
|
+
ret[:contrib] << { role: "publisher", entity: "organization",
|
172
|
+
name: span[:val] }
|
173
|
+
when "surname", "initials", "givenname", "formatted-initials"
|
174
|
+
ret[:contrib] = spans_preprocess_contrib(span, ret[:contrib])
|
175
|
+
when "organization"
|
176
|
+
ret[:contrib] = spans_preprocess_org(span, ret[:contrib])
|
177
|
+
when "in_surname", "in_initials", "in_givenname",
|
178
|
+
"in_formatted-initials"
|
179
|
+
ret[:in][:contrib] ||= []
|
180
|
+
span[:key].sub!(/^in_/, "")
|
181
|
+
ret[:in][:contrib] =
|
182
|
+
spans_preprocess_contrib(span, ret[:in][:contrib])
|
183
|
+
when "in_organization"
|
184
|
+
ret[:in][:contrib] ||= []
|
185
|
+
span[:key].sub!(/^in_/, "")
|
186
|
+
ret[:in][:contrib] =
|
187
|
+
spans_preprocess_org(span, ret[:in][:contrib])
|
151
188
|
end
|
189
|
+
end
|
190
|
+
|
191
|
+
def host_rearrange(ret)
|
192
|
+
ret[:in][:title] or return ret
|
193
|
+
ret[:in].merge!(empty_span_hash, { type: "misc" }) { |_, old, _| old }
|
194
|
+
|
195
|
+
%i(series).each do |k|
|
196
|
+
ret[:in][k] = ret[k]
|
197
|
+
ret.delete(k)
|
198
|
+
end
|
199
|
+
/^in/.match?(ret[:type]) and ret[:in][:type] =
|
200
|
+
ret[:type].sub(/^in/, "")
|
152
201
|
ret
|
153
202
|
end
|
154
203
|
|
@@ -169,16 +218,55 @@ module Metanorma
|
|
169
218
|
contrib[-1][:role] != (span[:type] || "author")
|
170
219
|
end
|
171
220
|
|
172
|
-
def
|
221
|
+
def spans_preprocess_org(span, contrib)
|
222
|
+
contrib << { role: span[:type] || "author", entity: "organization",
|
223
|
+
name: span[:val] }
|
224
|
+
contrib
|
225
|
+
end
|
226
|
+
|
227
|
+
def spans_to_bibitem(spans)
|
173
228
|
ret = ""
|
174
229
|
spans[:title] and ret += "<title>#{spans[:title]}</title>"
|
230
|
+
ret += spans_to_bibitem_docid(spans)
|
231
|
+
spans[:contrib].each { |s| ret += span_to_contrib(s) }
|
232
|
+
spans[:series] and
|
233
|
+
ret += "<series><title>#{spans[:series]}</title></series>"
|
234
|
+
spans[:pubplace] and ret += "<place>#{spans[:pubplace]}</place>"
|
235
|
+
ret += spans_to_bibitem_host(spans)
|
236
|
+
ret + spans_to_bibitem_extent(spans[:extent])
|
237
|
+
end
|
238
|
+
|
239
|
+
def spans_to_bibitem_host(spans)
|
240
|
+
return "" if spans[:in].empty?
|
241
|
+
|
242
|
+
ret =
|
243
|
+
"<relation type='includedIn'><bibitem type='#{spans[:in][:type]}'>"
|
244
|
+
spans[:in].delete(:type)
|
245
|
+
ret + "#{spans_to_bibitem(spans[:in])}</bibitem></relation>"
|
246
|
+
end
|
247
|
+
|
248
|
+
def spans_to_bibitem_docid(spans)
|
249
|
+
ret = ""
|
175
250
|
spans[:uri].each { |s| ret += span_to_docid(s, "uri") }
|
176
251
|
spans[:docid].each { |s| ret += span_to_docid(s, "docidentifier") }
|
177
252
|
spans[:date].each { |s| ret += span_to_docid(s, "date") }
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
253
|
+
ret
|
254
|
+
end
|
255
|
+
|
256
|
+
def spans_to_bibitem_extent(spans)
|
257
|
+
ret = ""
|
258
|
+
{ volume: "volume", issue: "issue", pages: "page" }.each do |k, v|
|
259
|
+
spans[k]&.each { |s| ret += span_to_extent(s, v) }
|
260
|
+
end
|
261
|
+
ret
|
262
|
+
end
|
263
|
+
|
264
|
+
def span_to_extent(span, key)
|
265
|
+
values = span.split(/[-–]/)
|
266
|
+
ret = "<extent type='#{key}'><referenceFrom>#{values[0]}</referenceFrom>"
|
267
|
+
values[1] and
|
268
|
+
ret += "<referenceTo>#{values[1]}</referenceTo>"
|
269
|
+
"#{ret}</extent>"
|
182
270
|
end
|
183
271
|
|
184
272
|
def span_to_docid(span, key)
|
@@ -4,7 +4,7 @@ module Metanorma
|
|
4
4
|
def external_terms_boilerplate(sources)
|
5
5
|
@i18n.l10n(
|
6
6
|
@i18n.external_terms_boilerplate.gsub(/%/, sources || "???"),
|
7
|
-
@lang, @script
|
7
|
+
@lang, @script, @locale
|
8
8
|
)
|
9
9
|
end
|
10
10
|
|
@@ -64,7 +64,7 @@ module Metanorma
|
|
64
64
|
x = xmldoc.dup
|
65
65
|
x.root.add_namespace(nil, self.class::XML_NAMESPACE)
|
66
66
|
xml = Nokogiri::XML(x.to_xml)
|
67
|
-
@isodoc ||= isodoc(@lang, @script)
|
67
|
+
@isodoc ||= isodoc(@lang, @script, @locale)
|
68
68
|
@isodoc.info(xml, nil)
|
69
69
|
@isodoc
|
70
70
|
end
|
@@ -205,6 +205,15 @@
|
|
205
205
|
<data type="boolean"/>
|
206
206
|
</attribute>
|
207
207
|
</optional>
|
208
|
+
<optional>
|
209
|
+
<attribute name="style">
|
210
|
+
<choice>
|
211
|
+
<value>basic</value>
|
212
|
+
<value>full</value>
|
213
|
+
<value>short</value>
|
214
|
+
</choice>
|
215
|
+
</attribute>
|
216
|
+
</optional>
|
208
217
|
<ref name="XrefBody"/>
|
209
218
|
</element>
|
210
219
|
</define>
|
@@ -1,21 +1,22 @@
|
|
1
1
|
module Metanorma
|
2
2
|
module Standoc
|
3
3
|
class PlantUMLBlockMacroBackend
|
4
|
-
# https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
|
5
4
|
def self.plantuml_installed?
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
5
|
+
unless which("plantuml")
|
6
|
+
raise "PlantUML not installed"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.plantuml_bin
|
11
|
+
if Gem.win_platform? || which("plantumlc")
|
12
|
+
"plantumlc"
|
13
|
+
else
|
14
|
+
"plantuml"
|
13
15
|
end
|
14
|
-
raise "PlantUML not installed"
|
15
16
|
end
|
16
17
|
|
17
18
|
def self.run(umlfile, outfile)
|
18
|
-
system "
|
19
|
+
system "#{plantuml_bin} #{umlfile.path}" or (warn $? and return false)
|
19
20
|
i = 0
|
20
21
|
until !Gem.win_platform? || File.exist?(outfile) || i == 15
|
21
22
|
sleep(1)
|
@@ -84,6 +85,18 @@ module Metanorma
|
|
84
85
|
memo
|
85
86
|
end
|
86
87
|
end
|
88
|
+
|
89
|
+
# https://stackoverflow.com/questions/2108727/which-in-ruby-checking-if-program-exists-in-path-from-ruby
|
90
|
+
def self.which(cmd)
|
91
|
+
exts = ENV["PATHEXT"] ? ENV["PATHEXT"].split(";") : [""]
|
92
|
+
ENV["PATH"].split(File::PATH_SEPARATOR).each do |path|
|
93
|
+
exts.each do |ext|
|
94
|
+
exe = File.join(path, "#{cmd}#{ext}")
|
95
|
+
return exe if File.executable?(exe) && !File.directory?(exe)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
nil
|
99
|
+
end
|
87
100
|
end
|
88
101
|
|
89
102
|
class PlantUMLBlockMacro < Asciidoctor::Extensions::BlockProcessor
|
@@ -42,7 +42,8 @@ module Metanorma
|
|
42
42
|
refterm = n.at("./refterm") or next
|
43
43
|
p = @termlookup[:secondary2primary][refterm.text] and
|
44
44
|
refterm.children = p
|
45
|
-
refterm.replace("<preferred><expression
|
45
|
+
refterm.replace("<preferred><expression>"\
|
46
|
+
"<name>#{refterm.children.to_xml}"\
|
46
47
|
"</name></expression></preferred>")
|
47
48
|
end
|
48
49
|
end
|
@@ -69,33 +70,51 @@ module Metanorma
|
|
69
70
|
|
70
71
|
def remove_missing_ref(node, target)
|
71
72
|
if node.at("./parent::concept[@type = 'symbol']")
|
73
|
+
log.add("AsciiDoc Input", node,
|
74
|
+
remove_missing_ref_msg(node, target, :symbol))
|
72
75
|
remove_missing_ref_symbol(node, target)
|
73
76
|
else
|
77
|
+
log.add("AsciiDoc Input", node,
|
78
|
+
remove_missing_ref_msg(node, target, :term))
|
74
79
|
remove_missing_ref_term(node, target)
|
75
80
|
end
|
76
81
|
end
|
77
82
|
|
83
|
+
def remove_missing_ref_msg(node, target, type)
|
84
|
+
type == :symbol and return <<~LOG
|
85
|
+
Error: Symbol reference in `symbol[#{target}]` missing: "#{target}" is not defined in document
|
86
|
+
LOG
|
87
|
+
ret = <<~LOG
|
88
|
+
Error: Term reference to `#{target}` missing: "#{target}" is not defined in document
|
89
|
+
LOG
|
90
|
+
remove_missing_ref_msg1(node, target, ret)
|
91
|
+
end
|
92
|
+
|
93
|
+
def remove_missing_ref_msg1(node, target, ret)
|
94
|
+
target2 = "_#{target.downcase.gsub(/-/, '_')}"
|
95
|
+
if node.document.at("//*[@id = '#{target}']")&.name == "terms" ||
|
96
|
+
node.document.at("//*[@id = '#{target2}']")&.name == "terms"
|
97
|
+
ret.strip!
|
98
|
+
ret += ". Did you mean to point to a subterm?"
|
99
|
+
end
|
100
|
+
ret
|
101
|
+
end
|
102
|
+
|
78
103
|
def remove_missing_ref_term(node, target)
|
79
|
-
log.add("AsciiDoc Input", node,
|
80
|
-
%(Error: Term reference to `#{target}` missing: \
|
81
|
-
"#{target}" is not defined in document))
|
82
104
|
node.name = "strong"
|
83
|
-
node
|
84
|
-
display = node
|
85
|
-
display = [] if display.nil? || display
|
105
|
+
node.at("../xrefrender")&.remove
|
106
|
+
display = node.at("../renderterm")&.remove&.children
|
107
|
+
display = [] if display.nil? || display.to_xml == node.text
|
86
108
|
d = display.empty? ? "" : ", display <tt>#{display.to_xml}</tt>"
|
87
109
|
node.children = "term <tt>#{node.text}</tt>#{d} "\
|
88
110
|
"not resolved via ID <tt>#{target}</tt>"
|
89
111
|
end
|
90
112
|
|
91
113
|
def remove_missing_ref_symbol(node, target)
|
92
|
-
log.add("AsciiDoc Input", node,
|
93
|
-
%(Error: Symbol reference in `symbol[#{target}]` missing: \
|
94
|
-
"#{target}" is not defined in document))
|
95
114
|
node.name = "strong"
|
96
|
-
node
|
97
|
-
display = node
|
98
|
-
display = [] if display.nil? || display
|
115
|
+
node.at("../xrefrender")&.remove
|
116
|
+
display = node.at("../renderterm")&.remove&.children
|
117
|
+
display = [] if display.nil? || display.to_xml == node.text
|
99
118
|
d = display.empty? ? "" : ", display <tt>#{display.to_xml}</tt>"
|
100
119
|
node.children = "symbol <tt>#{node.text}</tt>#{d} "\
|
101
120
|
"not resolved via ID <tt>#{target}</tt>"
|
@@ -36,10 +36,10 @@ module Metanorma
|
|
36
36
|
SUBCLAUSE_XPATH = "//clause[not(parent::sections)]"\
|
37
37
|
"[not(ancestor::boilerplate)]".freeze
|
38
38
|
|
39
|
-
def isodoc(lang, script, i18nyaml = nil)
|
39
|
+
def isodoc(lang, script, locale, i18nyaml = nil)
|
40
40
|
conv = presentation_xml_converter(EmptyAttr.new)
|
41
|
-
i18n = conv.i18n_init(lang, script, i18nyaml)
|
42
|
-
conv.metadata_init(lang, script, i18n)
|
41
|
+
i18n = conv.i18n_init(lang, script, locale, i18nyaml)
|
42
|
+
conv.metadata_init(lang, script, locale, i18n)
|
43
43
|
conv
|
44
44
|
end
|
45
45
|
|
@@ -77,15 +77,24 @@ module Metanorma
|
|
77
77
|
next if doc.at("//term[@id = '#{x['target']}']")
|
78
78
|
next if doc.at("//definitions//dt[@id = '#{x['target']}']")
|
79
79
|
|
80
|
-
@log.add("Anchors", x,
|
81
|
-
"#{tag.capitalize} #{x&.at("../#{refterm}")&.text} is "\
|
82
|
-
"pointing to #{x['target']}, which is not a term or symbol")
|
80
|
+
@log.add("Anchors", x, concept_validate_msg(doc, tag, refterm, x))
|
83
81
|
found = true
|
84
82
|
end
|
85
83
|
found and
|
86
84
|
@fatalerror << "#{tag.capitalize} not cross-referencing term or symbol"
|
87
85
|
end
|
88
86
|
|
87
|
+
def concept_validate_msg(doc, tag, refterm, xref)
|
88
|
+
ret = <<~LOG
|
89
|
+
#{tag.capitalize} #{xref.at("../#{refterm}")&.text} is pointing to #{xref['target']}, which is not a term or symbol
|
90
|
+
LOG
|
91
|
+
if doc.at("//*[@id = '#{xref['target']}']")&.name == "terms"
|
92
|
+
ret = ret.strip
|
93
|
+
ret += ". Did you mean to point to a subterm?"
|
94
|
+
end
|
95
|
+
ret
|
96
|
+
end
|
97
|
+
|
89
98
|
def repeat_id_validate1(ids, elem)
|
90
99
|
if ids[elem["id"]]
|
91
100
|
@log.add("Anchors", elem, "Anchor #{elem['id']} has already been "\
|
data/metanorma-standoc.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
|
28
28
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
29
29
|
spec.add_dependency "iev", "~> 0.3.0"
|
30
|
-
spec.add_dependency "isodoc", "~> 2.
|
30
|
+
spec.add_dependency "isodoc", "~> 2.3.1"
|
31
31
|
spec.add_dependency "metanorma"
|
32
32
|
spec.add_dependency "metanorma-plugin-datastruct", "~> 0.2.0"
|
33
33
|
spec.add_dependency "metanorma-plugin-lutaml"
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |spec|
|
|
37
37
|
spec.add_dependency "concurrent-ruby"
|
38
38
|
spec.add_dependency "latexmath"
|
39
39
|
spec.add_dependency "mathml2asciimath"
|
40
|
-
spec.add_dependency "mn-requirements", "~> 0.1.
|
40
|
+
spec.add_dependency "mn-requirements", "~> 0.1.4"
|
41
41
|
spec.add_dependency "pngcheck"
|
42
42
|
spec.add_dependency "relaton-cli", "~> 1.13.0"
|
43
43
|
spec.add_dependency "relaton-iev", "~> 1.1.0"
|
data/spec/metanorma/base_spec.rb
CHANGED
@@ -6,6 +6,13 @@ RSpec.describe Metanorma::Standoc do
|
|
6
6
|
expect(Metanorma::Standoc::VERSION).not_to be nil
|
7
7
|
end
|
8
8
|
|
9
|
+
it "applies Asciidoctor substitutions" do
|
10
|
+
expect(Metanorma::Utils.asciidoc_sub("A -- B"))
|
11
|
+
.to eq "A — B"
|
12
|
+
expect(Metanorma::Utils.asciidoc_sub("*A* stem:[x]"))
|
13
|
+
.to eq "<strong>A</strong> <stem type=\"AsciiMath\">x</stem>"
|
14
|
+
end
|
15
|
+
|
9
16
|
it "processes named entities" do
|
10
17
|
FileUtils.rm_f "test.doc"
|
11
18
|
input = <<~INPUT
|
@@ -554,6 +561,7 @@ RSpec.describe Metanorma::Standoc do
|
|
554
561
|
:tc-docnumber: 2000
|
555
562
|
:language: el
|
556
563
|
:script: Grek
|
564
|
+
:locale: CY
|
557
565
|
:publisher: IEC;IETF;ISO
|
558
566
|
:uri: A
|
559
567
|
:xml-uri: B
|
@@ -689,6 +697,7 @@ RSpec.describe Metanorma::Standoc do
|
|
689
697
|
<revision-date>2000-01</revision-date>
|
690
698
|
</version>
|
691
699
|
<language>el</language>
|
700
|
+
<locale>CY</locale>
|
692
701
|
<script>Grek</script>
|
693
702
|
<abstract><p>This is the abstract of the document</p>
|
694
703
|
<p>This is the second paragraph of the abstract of the document.</p></abstract>
|
@@ -780,7 +789,7 @@ RSpec.describe Metanorma::Standoc do
|
|
780
789
|
|
781
790
|
INPUT
|
782
791
|
output = <<~OUTPUT
|
783
|
-
|
792
|
+
<standard-document xmlns="https://www.metanorma.org/ns/standoc" type="semantic" version="#{Metanorma::Standoc::VERSION}">
|
784
793
|
<bibdata type='standard'>
|
785
794
|
<title language='en' format='text/plain'>Document title</title>
|
786
795
|
<contributor>
|