metanorma-standoc 2.2.3.1 → 2.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/metanorma/standoc/base.rb +2 -1
- data/lib/metanorma/standoc/biblio.rng +32 -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/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/cleanup_sections_spec.rb +2 -1
- data/spec/metanorma/macros_concept_spec.rb +1 -1
- 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: 8dfe44699d10166a0388cc7ebad8484584eaad6f13ec9777b4ad70484fcd8002
|
4
|
+
data.tar.gz: 13d5367c69704b000b00f676b81c5285ef5dba303db110e1463504c45c0f84f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d3f9d03a2e32b41e7a2851eb5ca735800708c90ea21b472b11953a2130e1bdfff63b16d98585b6506857802642f5182fd09add53e022ab32af9e9c6115b7cb7
|
7
|
+
data.tar.gz: 69f79d44f92bc8a2f40769febf4707cf75cdea9be62691b0d39219eb06a7a0dc489896c4914db99244f47f50bf5dd4fb1b64c64848783a53378d4f604ae9dc7a
|
@@ -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
|
@@ -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>
|
@@ -896,12 +896,12 @@ RSpec.describe Metanorma::Standoc do
|
|
896
896
|
[bibliography]
|
897
897
|
=== Normative References
|
898
898
|
|
899
|
-
* [[[A, B]]], span:surname[Wozniak], span:initials[S.] & span:givenname[Steve] span:surname[Jobs]. span:
|
899
|
+
* [[[A, B]]], span:surname[Wozniak], span:initials[S.] & span:givenname[Steve] span:surname[Jobs]. span:date.issued[1991]. span:date[1996]. span:title[_Work_]. span:in_surname.editor[Gates], span:in_initials.editor[W. H] & span:in_organization[UNICEF], span:in_title[Collected Essays]. _span:series[Bibliographers Anonymous]_. span:docid.ISO[ISO 1234]. span:pubplace[Geneva]: span:publisher[International Standardization Organization]. span:uri.citation[http://www.example.com]. span:volume[4] span:issue[2–3] span:pages[12-13] span:pages[19]. span:type[inbook]
|
900
900
|
INPUT
|
901
901
|
output = <<~OUTPUT
|
902
902
|
#{BLANK_HDR}
|
903
903
|
<sections> </sections>
|
904
|
-
|
904
|
+
<bibliography>
|
905
905
|
<references id='_' normative='true' obligation='informative'>
|
906
906
|
<title>Normative references</title>
|
907
907
|
<p id='_'>
|
@@ -911,14 +911,15 @@ RSpec.describe Metanorma::Standoc do
|
|
911
911
|
references, the latest edition of the referenced document (including any
|
912
912
|
amendments) applies.
|
913
913
|
</p>
|
914
|
-
<bibitem id='A' type=
|
914
|
+
<bibitem id='A' type='inbook'>
|
915
915
|
<formattedref format='application/x-isodoc+xml'>
|
916
|
-
Wozniak, S. & Steve Jobs. 1996.
|
916
|
+
Wozniak, S. & Steve Jobs. 1991. 1996.
|
917
917
|
<em>Work</em>
|
918
|
-
.
|
919
|
-
|
918
|
+
. Gates, W. H & UNICEF, Collected Essays.
|
919
|
+
<em>Bibliographers Anonymous</em>
|
920
|
+
. ISO 1234. Geneva: International Standardization Organization.
|
920
921
|
<link target='http://www.example.com'/>
|
921
|
-
.
|
922
|
+
. 4 2–3 12-13 19.
|
922
923
|
</formattedref>
|
923
924
|
<title>
|
924
925
|
<em>Work</em>
|
@@ -928,6 +929,7 @@ RSpec.describe Metanorma::Standoc do
|
|
928
929
|
</uri>
|
929
930
|
<docidentifier>B</docidentifier>
|
930
931
|
<docidentifier type='ISO'>ISO 1234</docidentifier>
|
932
|
+
<date type='issued'>1991</date>
|
931
933
|
<date type='published'>1996</date>
|
932
934
|
<contributor>
|
933
935
|
<role type='author'/>
|
@@ -947,22 +949,50 @@ RSpec.describe Metanorma::Standoc do
|
|
947
949
|
</name>
|
948
950
|
</person>
|
949
951
|
</contributor>
|
950
|
-
<contributor>
|
951
|
-
<role type='editor'/>
|
952
|
-
<person>
|
953
|
-
<name>
|
954
|
-
<formatted-initials>W. H</formatted-initials>
|
955
|
-
<surname>Gates</surname>
|
956
|
-
</name>
|
957
|
-
</person>
|
958
|
-
</contributor>
|
959
952
|
<contributor>
|
960
953
|
<role type='publisher'/>
|
961
954
|
<organization>
|
962
955
|
<name>International Standardization Organization</name>
|
963
956
|
</organization>
|
964
957
|
</contributor>
|
965
|
-
<place
|
958
|
+
<place>Geneva</place>
|
959
|
+
<relation type='includedIn'>
|
960
|
+
<bibitem type='book'>
|
961
|
+
<title>Collected Essays</title>
|
962
|
+
<contributor>
|
963
|
+
<role type='editor'/>
|
964
|
+
<person>
|
965
|
+
<name>
|
966
|
+
<formatted-initials>W. H</formatted-initials>
|
967
|
+
<surname>Gates</surname>
|
968
|
+
</name>
|
969
|
+
</person>
|
970
|
+
</contributor>
|
971
|
+
<contributor>
|
972
|
+
<role type='author'/>
|
973
|
+
<organization>
|
974
|
+
<name>UNICEF</name>
|
975
|
+
</organization>
|
976
|
+
</contributor>
|
977
|
+
<series>
|
978
|
+
<title>Bibliographers Anonymous</title>
|
979
|
+
</series>
|
980
|
+
</bibitem>
|
981
|
+
</relation>
|
982
|
+
<extent type='volume'>
|
983
|
+
<referenceFrom>4</referenceFrom>
|
984
|
+
</extent>
|
985
|
+
<extent type='issue'>
|
986
|
+
<referenceFrom>2</referenceFrom>
|
987
|
+
<referenceTo>3</referenceTo>
|
988
|
+
</extent>
|
989
|
+
<extent type='page'>
|
990
|
+
<referenceFrom>12</referenceFrom>
|
991
|
+
<referenceTo>13</referenceTo>
|
992
|
+
</extent>
|
993
|
+
<extent type='page'>
|
994
|
+
<referenceFrom>19</referenceFrom>
|
995
|
+
</extent>
|
966
996
|
</bibitem>
|
967
997
|
</references>
|
968
998
|
</bibliography>
|
@@ -3,6 +3,7 @@ require "relaton_iec"
|
|
3
3
|
require "fileutils"
|
4
4
|
|
5
5
|
RSpec.describe Metanorma::Standoc do
|
6
|
+
=begin
|
6
7
|
it "appends any initial user-supplied text to boilerplate in terms and definitions" do
|
7
8
|
input = <<~INPUT
|
8
9
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -1354,7 +1355,7 @@ RSpec.describe Metanorma::Standoc do
|
|
1354
1355
|
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
1355
1356
|
.to be_equivalent_to xmlpp(output)
|
1356
1357
|
end
|
1357
|
-
|
1358
|
+
=end
|
1358
1359
|
it "processes section names, internationalisation file" do
|
1359
1360
|
input = <<~INPUT
|
1360
1361
|
#{ASCIIDOC_BLANK_HDR.sub(/:nodoc:/, ":no-pdf:\n:i18nyaml: spec/assets/i18n.yaml")}
|