metanorma-standoc 2.1.1 → 2.1.2
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 +3 -1
- data/lib/metanorma/standoc/biblio.rng +32 -34
- data/lib/metanorma/standoc/blocks.rb +8 -3
- data/lib/metanorma/standoc/blocks_notes.rb +3 -0
- data/lib/metanorma/standoc/cleanup.rb +1 -0
- data/lib/metanorma/standoc/cleanup_footnotes.rb +14 -9
- data/lib/metanorma/standoc/cleanup_inline.rb +17 -0
- data/lib/metanorma/standoc/cleanup_terms.rb +3 -1
- data/lib/metanorma/standoc/cleanup_text.rb +9 -4
- data/lib/metanorma/standoc/converter.rb +2 -0
- data/lib/metanorma/standoc/isodoc.rng +9 -0
- data/lib/metanorma/standoc/lists.rb +8 -3
- data/lib/metanorma/standoc/macros.rb +28 -1
- data/lib/metanorma/standoc/macros_note.rb +1 -6
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +1 -1
- data/spec/metanorma/base_spec.rb +41 -5
- data/spec/metanorma/blocks_spec.rb +53 -1
- data/spec/metanorma/cleanup_sections_spec.rb +5 -5
- data/spec/metanorma/cleanup_spec.rb +5 -5
- data/spec/metanorma/cleanup_terms_spec.rb +1 -1
- data/spec/metanorma/inline_spec.rb +3 -3
- data/spec/metanorma/lists_spec.rb +10 -4
- data/spec/metanorma/macros_spec.rb +21 -12
- data/spec/metanorma/refs_spec.rb +1 -1
- data/spec/metanorma/table_spec.rb +24 -6
- data/spec/spec_helper.rb +1 -1
- data/spec/vcr_cassettes/bsi16341.yml +64 -64
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +83 -83
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec1.yml +10 -10
- data/spec/vcr_cassettes/hide_refs.yml +55 -55
- data/spec/vcr_cassettes/isobib_get_123.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_123_1.yml +25 -25
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +33 -33
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +12 -12
- data/spec/vcr_cassettes/isobib_get_124.yml +12 -12
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +14 -14
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +47 -49
- data/spec/vcr_cassettes/std-link.yml +12 -12
- metadata +7 -8
- data/docs/quickstart.adoc +0 -375
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 56e2b9105572c28858ffc12d075b16615ec8195836ad4bf7d7d2122fbf81dc05
|
4
|
+
data.tar.gz: 2594f703aeba2f78a5bf3df715709f78b3b6da1a751cb52fedd3ebce299eaf2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eeef127fe3ea160b49aa62cbb1aa665fb4e0cdb6d1712f646667394a41633c89864a294900c444abc1fceb7fbe2649bdfb2f539d1ccc66d3df89cd247ea31655
|
7
|
+
data.tar.gz: 2d1ded28e889db67a42275a5890a8e942b2b966e342e7bb7bc2b21129875394dff03ce1c1cd634b409ce72a68de0e4fd4eff518731cb3b8809c70d5c0c5f0449
|
@@ -171,7 +171,9 @@ module Metanorma
|
|
171
171
|
end
|
172
172
|
|
173
173
|
def doctype(node)
|
174
|
-
node.attr("doctype")&.gsub(/\s+/, "-")&.downcase
|
174
|
+
ret = node.attr("doctype")&.gsub(/\s+/, "-")&.downcase || "standard"
|
175
|
+
ret = "standard" if ret == "article"
|
176
|
+
ret
|
175
177
|
end
|
176
178
|
|
177
179
|
def front(node, xml)
|
@@ -614,12 +614,12 @@
|
|
614
614
|
<optional>
|
615
615
|
<ref name="fetched"/>
|
616
616
|
</optional>
|
617
|
-
<
|
618
|
-
<oneOrMore>
|
619
|
-
<ref name="btitle"/>
|
620
|
-
</oneOrMore>
|
617
|
+
<optional>
|
621
618
|
<ref name="formattedref"/>
|
622
|
-
</
|
619
|
+
</optional>
|
620
|
+
<oneOrMore>
|
621
|
+
<ref name="btitle"/>
|
622
|
+
</oneOrMore>
|
623
623
|
<zeroOrMore>
|
624
624
|
<ref name="bsource"/>
|
625
625
|
</zeroOrMore>
|
@@ -986,36 +986,34 @@
|
|
986
986
|
<ref name="SeriesType"/>
|
987
987
|
</attribute>
|
988
988
|
</optional>
|
989
|
-
<
|
989
|
+
<optional>
|
990
990
|
<ref name="formattedref"/>
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
</group>
|
1018
|
-
</choice>
|
991
|
+
</optional>
|
992
|
+
<ref name="btitle"/>
|
993
|
+
<optional>
|
994
|
+
<ref name="bplace"/>
|
995
|
+
</optional>
|
996
|
+
<optional>
|
997
|
+
<ref name="seriesorganization"/>
|
998
|
+
</optional>
|
999
|
+
<optional>
|
1000
|
+
<ref name="abbreviation"/>
|
1001
|
+
</optional>
|
1002
|
+
<optional>
|
1003
|
+
<ref name="seriesfrom"/>
|
1004
|
+
</optional>
|
1005
|
+
<optional>
|
1006
|
+
<ref name="seriesto"/>
|
1007
|
+
</optional>
|
1008
|
+
<optional>
|
1009
|
+
<ref name="seriesnumber"/>
|
1010
|
+
</optional>
|
1011
|
+
<optional>
|
1012
|
+
<ref name="seriespartnumber"/>
|
1013
|
+
</optional>
|
1014
|
+
<optional>
|
1015
|
+
<ref name="seriesrun"/>
|
1016
|
+
</optional>
|
1019
1017
|
</element>
|
1020
1018
|
</define>
|
1021
1019
|
<define name="SeriesType">
|
@@ -80,14 +80,17 @@ module Metanorma
|
|
80
80
|
|
81
81
|
def term_example(node)
|
82
82
|
noko do |xml|
|
83
|
-
xml.termexample **attr_code(id_attr(node)
|
83
|
+
xml.termexample **attr_code(id_attr(node)
|
84
|
+
.merge(
|
85
|
+
keepasterm: node.option?("termexample") ? "true" : nil,
|
86
|
+
)) do |ex|
|
84
87
|
wrap_in_para(node, ex)
|
85
88
|
end
|
86
89
|
end.join("\n")
|
87
90
|
end
|
88
91
|
|
89
92
|
def example(node)
|
90
|
-
return term_example(node) if in_terms?
|
93
|
+
return term_example(node) if in_terms? || node.option?("termexample")
|
91
94
|
|
92
95
|
role = node.role || node.attr("style")
|
93
96
|
%w(recommendation requirement permission).include?(role) and
|
@@ -237,10 +240,12 @@ module Metanorma
|
|
237
240
|
end
|
238
241
|
|
239
242
|
def pass(node)
|
243
|
+
c = HTMLEntities.new
|
240
244
|
noko do |xml|
|
241
245
|
xml.passthrough **attr_code(formats:
|
242
246
|
node.attr("format") || "metanorma") do |p|
|
243
|
-
p <<
|
247
|
+
p << c.encode(c.decode(node.content),
|
248
|
+
:basic, :hexadecimal)
|
244
249
|
end
|
245
250
|
end
|
246
251
|
end
|
@@ -8,6 +8,7 @@ module Metanorma
|
|
8
8
|
number: node.attr("number"),
|
9
9
|
subsequence: node.attr("subsequence"),
|
10
10
|
"keep-separate": node.attr("keep-separate"),
|
11
|
+
keepasterm: node.option?("termnote") ? "true" : nil,
|
11
12
|
)))
|
12
13
|
end
|
13
14
|
|
@@ -61,6 +62,8 @@ module Metanorma
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def note(node)
|
65
|
+
return termnote(node) if node.option?("termnote")
|
66
|
+
|
64
67
|
noko do |xml|
|
65
68
|
xml.note **note_attrs(node) do |c|
|
66
69
|
wrap_in_para(node, c)
|
@@ -5,12 +5,15 @@ require "json"
|
|
5
5
|
module Metanorma
|
6
6
|
module Standoc
|
7
7
|
module Cleanup
|
8
|
-
def footnote_content(
|
9
|
-
c =
|
8
|
+
def footnote_content(fnote)
|
9
|
+
c = if fnote.children.respond_to?(:to_xml)
|
10
|
+
fnote.children.to_xml
|
11
|
+
else fn.children
|
12
|
+
end
|
10
13
|
c.gsub(/ id="[^"]+"/, "")
|
11
14
|
end
|
12
15
|
|
13
|
-
# include footnotes inside figure if they are the only content
|
16
|
+
# include footnotes inside figure if they are the only content
|
14
17
|
# of the paras following
|
15
18
|
def figure_footnote_cleanup(xmldoc)
|
16
19
|
nomatches = false
|
@@ -18,7 +21,9 @@ module Metanorma
|
|
18
21
|
q = "//figure/following-sibling::*[1][self::p and *[1][self::fn]]"
|
19
22
|
nomatches = true
|
20
23
|
xmldoc.xpath(q).each do |s|
|
21
|
-
next if s.children.map
|
24
|
+
next if s.children.map do |c|
|
25
|
+
c.text? && /[[:alpha:]]/.match(c.text)
|
26
|
+
end.any?
|
22
27
|
|
23
28
|
s.previous_element << s.first_element_child.remove
|
24
29
|
s.remove
|
@@ -27,16 +32,16 @@ module Metanorma
|
|
27
32
|
end
|
28
33
|
end
|
29
34
|
|
30
|
-
def table_footnote_renumber1(
|
31
|
-
content = footnote_content(
|
35
|
+
def table_footnote_renumber1(fnote, i, seen)
|
36
|
+
content = footnote_content(fnote)
|
32
37
|
if seen[content] then outnum = seen[content]
|
33
38
|
else
|
34
39
|
i += 1
|
35
40
|
outnum = i
|
36
41
|
seen[content] = outnum
|
37
42
|
end
|
38
|
-
|
39
|
-
|
43
|
+
fnote["reference"] = (outnum - 1 + "a".ord).chr
|
44
|
+
fnote["table"] = true
|
40
45
|
[i, seen]
|
41
46
|
end
|
42
47
|
|
@@ -84,7 +89,7 @@ module Metanorma
|
|
84
89
|
|
85
90
|
def footnote_block_cleanup(xmldoc)
|
86
91
|
xmldoc.xpath("//footnoteblock").each do |f|
|
87
|
-
f.name =
|
92
|
+
f.name = "fn"
|
88
93
|
if id = xmldoc.at("//*[@id = '#{f.text}']")
|
89
94
|
f.children = id.remove.children
|
90
95
|
else
|
@@ -185,6 +185,23 @@ module Metanorma
|
|
185
185
|
Digest::MD5.hexdigest("#{elem.path}////#{elem.text}")
|
186
186
|
.sub(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, "_\\1-\\2-\\3-\\4-\\5")
|
187
187
|
end
|
188
|
+
|
189
|
+
def passthrough_cleanup(doc)
|
190
|
+
doc.xpath("//passthrough-inline").each do |p|
|
191
|
+
p.name = "passthrough"
|
192
|
+
p.children = select_odd_chars(p.children.to_xml)
|
193
|
+
end
|
194
|
+
doc.xpath("//identifier").each do |p|
|
195
|
+
p.children = select_odd_chars(p.children.to_xml)
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
private
|
200
|
+
|
201
|
+
# skip ZWNJ inserted to prevent regexes operating in asciidoctor
|
202
|
+
def select_odd_chars(text)
|
203
|
+
text.gsub(/(?!&)([[:punct:]])\u200c/, "\\1")
|
204
|
+
end
|
188
205
|
end
|
189
206
|
end
|
190
207
|
end
|
@@ -93,7 +93,9 @@ module Metanorma
|
|
93
93
|
def termnote_example_cleanup(xmldoc)
|
94
94
|
%w(note example).each do |w|
|
95
95
|
xmldoc.xpath("//term#{w}[not(ancestor::term)]").each do |x|
|
96
|
-
x
|
96
|
+
if x["keepasterm"] then x.delete("keepasterm")
|
97
|
+
else x.name = w
|
98
|
+
end
|
97
99
|
end
|
98
100
|
end
|
99
101
|
end
|
@@ -5,8 +5,11 @@ module Metanorma
|
|
5
5
|
text = result.flatten.map { |l| l.sub(/\s*\Z/, "") } * "\n"
|
6
6
|
!@keepasciimath and text = asciimath2mathml(text)
|
7
7
|
text = text.gsub(/\s+<fn /, "<fn ")
|
8
|
-
|
9
|
-
|
8
|
+
%w(passthrough passthrough-inline).each do |v|
|
9
|
+
text.gsub!(%r{<#{v}\s+formats="metanorma">([^<]*)
|
10
|
+
</#{v}>}mx) { HTMLEntities.new.decode($1) }
|
11
|
+
end
|
12
|
+
text
|
10
13
|
end
|
11
14
|
|
12
15
|
def smartquotes_cleanup(xmldoc)
|
@@ -33,7 +36,8 @@ module Metanorma
|
|
33
36
|
|
34
37
|
def uninterrupt_quotes_around_xml_skip(elem)
|
35
38
|
!(/\A['"]/.match?(elem.text) &&
|
36
|
-
elem.previous.ancestors("pre, tt, sourcecode, stem, figure, bibdata
|
39
|
+
elem.previous.ancestors("pre, tt, sourcecode, stem, figure, bibdata,
|
40
|
+
passthrough, identifer")
|
37
41
|
.empty? &&
|
38
42
|
((elem.previous.text.strip.empty? &&
|
39
43
|
!empty_tag_with_text_content?(elem.previous)) ||
|
@@ -70,7 +74,8 @@ module Metanorma
|
|
70
74
|
empty_tag_with_text_content?(x) and prev = "dummy"
|
71
75
|
next unless x.text?
|
72
76
|
|
73
|
-
x.ancestors("pre, tt, sourcecode, stem, figure, bibdata
|
77
|
+
x.ancestors("pre, tt, sourcecode, stem, figure, bibdata, passthrough,
|
78
|
+
identifier").empty? and
|
74
79
|
dumb2smart_quotes1(x, prev)
|
75
80
|
prev = x.text if x.ancestors("index").empty?
|
76
81
|
end
|
@@ -36,6 +36,7 @@ module Metanorma
|
|
36
36
|
inline_macro Metanorma::Standoc::DomainTermInlineMacro
|
37
37
|
inline_macro Metanorma::Standoc::InheritInlineMacro
|
38
38
|
inline_macro Metanorma::Standoc::HTML5RubyMacro
|
39
|
+
inline_macro Metanorma::Standoc::IdentifierInlineMacro
|
39
40
|
inline_macro Metanorma::Standoc::ConceptInlineMacro
|
40
41
|
inline_macro Metanorma::Standoc::AutonumberInlineMacro
|
41
42
|
inline_macro Metanorma::Standoc::VariantInlineMacro
|
@@ -63,6 +64,7 @@ module Metanorma
|
|
63
64
|
block Metanorma::Plugin::Lutaml::LutamlDiagramBlock
|
64
65
|
block Metanorma::Standoc::PseudocodeBlockMacro
|
65
66
|
preprocessor Metanorma::Standoc::EmbedIncludeProcessor
|
67
|
+
preprocessor Metanorma::Standoc::NamedEscapePreprocessor
|
66
68
|
end
|
67
69
|
|
68
70
|
include ::Asciidoctor::Converter
|
@@ -282,6 +282,9 @@
|
|
282
282
|
<ref name="MultilingualRenderingType"/>
|
283
283
|
</attribute>
|
284
284
|
</optional>
|
285
|
+
<optional>
|
286
|
+
<ref name="tname"/>
|
287
|
+
</optional>
|
285
288
|
<oneOrMore>
|
286
289
|
<ref name="ul_li"/>
|
287
290
|
</oneOrMore>
|
@@ -324,6 +327,9 @@
|
|
324
327
|
</choice>
|
325
328
|
</attribute>
|
326
329
|
</optional>
|
330
|
+
<optional>
|
331
|
+
<ref name="tname"/>
|
332
|
+
</optional>
|
327
333
|
<oneOrMore>
|
328
334
|
<ref name="li"/>
|
329
335
|
</oneOrMore>
|
@@ -360,6 +366,9 @@
|
|
360
366
|
<ref name="MultilingualRenderingType"/>
|
361
367
|
</attribute>
|
362
368
|
</optional>
|
369
|
+
<optional>
|
370
|
+
<ref name="tname"/>
|
371
|
+
</optional>
|
363
372
|
<oneOrMore>
|
364
373
|
<ref name="dt"/>
|
365
374
|
<ref name="dd"/>
|
@@ -38,9 +38,8 @@ module Metanorma
|
|
38
38
|
|
39
39
|
noko do |xml|
|
40
40
|
xml.ul **ul_attrs(node) do |xml_ul|
|
41
|
-
node
|
42
|
-
|
43
|
-
end
|
41
|
+
list_caption(node, xml_ul)
|
42
|
+
node.items.each { |item| ul_li(xml_ul, item) }
|
44
43
|
end
|
45
44
|
end.join("\n")
|
46
45
|
end
|
@@ -62,6 +61,7 @@ module Metanorma
|
|
62
61
|
def olist(node)
|
63
62
|
noko do |xml|
|
64
63
|
xml.ol **ol_attrs(node) do |xml_ol|
|
64
|
+
list_caption(node, xml_ol)
|
65
65
|
node.items.each { |item| li(xml_ol, item) }
|
66
66
|
end
|
67
67
|
end.join("\n")
|
@@ -98,6 +98,7 @@ module Metanorma
|
|
98
98
|
def dlist(node)
|
99
99
|
noko do |xml|
|
100
100
|
xml.dl **dl_attrs(node) do |xml_dl|
|
101
|
+
list_caption(node, xml_dl)
|
101
102
|
node.items.each do |terms, dd|
|
102
103
|
dt(terms, xml_dl)
|
103
104
|
dd(dd, xml_dl)
|
@@ -115,6 +116,10 @@ module Metanorma
|
|
115
116
|
end
|
116
117
|
end.join("\n")
|
117
118
|
end
|
119
|
+
|
120
|
+
def list_caption(node, out)
|
121
|
+
a = node.title and out.name { |n| n << a }
|
122
|
+
end
|
118
123
|
end
|
119
124
|
end
|
120
125
|
end
|
@@ -191,6 +191,7 @@ module Metanorma
|
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
194
|
+
# inject ZWNJ to prevent Asciidoctor from attempting regex substitutions
|
194
195
|
class PassInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
195
196
|
use_dsl
|
196
197
|
named :"pass-format"
|
@@ -198,7 +199,21 @@ module Metanorma
|
|
198
199
|
def process(parent, target, attrs)
|
199
200
|
format = target || "metanorma"
|
200
201
|
out = Asciidoctor::Inline.new(parent, :quoted, attrs[1]).convert
|
201
|
-
|
202
|
+
.gsub(/((?![<>&])[[:punct:]])/, "\\1‌")
|
203
|
+
%{<passthrough-inline formats="#{format}">#{out}</passthrough-inline>}
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
class IdentifierInlineMacro < Asciidoctor::Extensions::InlineMacroProcessor
|
208
|
+
use_dsl
|
209
|
+
named :identifier
|
210
|
+
parse_content_as :raw
|
211
|
+
using_format :short
|
212
|
+
|
213
|
+
def process(parent, _target, attrs)
|
214
|
+
out = Asciidoctor::Inline.new(parent, :quoted, attrs["text"]).convert
|
215
|
+
.gsub(/((?![<>&])[[:punct:]])/, "\\1‌")
|
216
|
+
%{<identifier>#{out}</identifier>}
|
202
217
|
end
|
203
218
|
end
|
204
219
|
|
@@ -213,5 +228,17 @@ module Metanorma
|
|
213
228
|
type: :xref, target: "_#{UUIDTools::UUID.random_create}")
|
214
229
|
end
|
215
230
|
end
|
231
|
+
|
232
|
+
class NamedEscapePreprocessor < Asciidoctor::Extensions::Preprocessor
|
233
|
+
def process(_document, reader)
|
234
|
+
c = HTMLEntities.new
|
235
|
+
lines = reader.readlines.map do |l|
|
236
|
+
l.split(/(&[A-Za-z][^;]*;)/).map do |s|
|
237
|
+
/^&[A-Za-z]/.match?(s) ? c.encode(c.decode(s), :hexadecimal) : s
|
238
|
+
end.join
|
239
|
+
end
|
240
|
+
::Asciidoctor::Reader.new lines
|
241
|
+
end
|
242
|
+
end
|
216
243
|
end
|
217
244
|
end
|
@@ -18,15 +18,10 @@ module Metanorma
|
|
18
18
|
(document.find_by context: :paragraph).each do |para|
|
19
19
|
next unless /^TODO: /.match? para.lines[0]
|
20
20
|
|
21
|
-
parent = para.parent
|
22
21
|
para.set_attr("name", "todo")
|
23
22
|
para.set_attr("caption", "TODO")
|
24
23
|
para.lines[0].sub!(/^TODO: /, "")
|
25
|
-
|
26
|
-
.new(parent, :admonition, attributes: para.attributes,
|
27
|
-
source: para.lines,
|
28
|
-
content_model: :compound)
|
29
|
-
parent.blocks[parent.blocks.index(para)] = todo
|
24
|
+
para.context = :admonition
|
30
25
|
end
|
31
26
|
end
|
32
27
|
end
|
data/metanorma-standoc.gemspec
CHANGED
@@ -46,7 +46,7 @@ Gem::Specification.new do |spec|
|
|
46
46
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
47
47
|
spec.add_development_dependency "guard", "~> 2.14"
|
48
48
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
49
|
-
spec.add_development_dependency "metanorma-iso"
|
49
|
+
spec.add_development_dependency "metanorma-iso", "~>2.1.2"
|
50
50
|
spec.add_development_dependency "rake", "~> 13.0"
|
51
51
|
spec.add_development_dependency "rspec", "~> 3.6"
|
52
52
|
spec.add_development_dependency "rubocop", "~> 1.5.2"
|
data/spec/metanorma/base_spec.rb
CHANGED
@@ -6,6 +6,42 @@ RSpec.describe Metanorma::Standoc do
|
|
6
6
|
expect(Metanorma::Standoc::VERSION).not_to be nil
|
7
7
|
end
|
8
8
|
|
9
|
+
it "processes named entities" do
|
10
|
+
FileUtils.rm_f "test.doc"
|
11
|
+
input = <<~INPUT
|
12
|
+
= Document title
|
13
|
+
Author
|
14
|
+
:docfile: test.adoc
|
15
|
+
:novalid:
|
16
|
+
:no-pdf:
|
17
|
+
|
18
|
+
Text × text
|
19
|
+
INPUT
|
20
|
+
output = <<~OUTPUT
|
21
|
+
<standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
|
22
|
+
<bibdata type='standard'>
|
23
|
+
<title language='en' format='text/plain'>Document title</title>
|
24
|
+
<language>en</language>
|
25
|
+
<script>Latn</script>
|
26
|
+
<status>
|
27
|
+
<stage>published</stage>
|
28
|
+
</status>
|
29
|
+
<copyright>
|
30
|
+
<from>#{Time.now.year}</from>
|
31
|
+
</copyright>
|
32
|
+
<ext>
|
33
|
+
<doctype>standard</doctype>
|
34
|
+
</ext>
|
35
|
+
</bibdata>
|
36
|
+
<sections>
|
37
|
+
<p id='_'>Text × text</p>
|
38
|
+
</sections>
|
39
|
+
</standard-document>
|
40
|
+
OUTPUT
|
41
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
42
|
+
.to be_equivalent_to xmlpp(output)
|
43
|
+
end
|
44
|
+
|
9
45
|
it "assigns default scripts to major languages" do
|
10
46
|
FileUtils.rm_f "test.doc"
|
11
47
|
input = <<~INPUT
|
@@ -29,7 +65,7 @@ RSpec.describe Metanorma::Standoc do
|
|
29
65
|
<from>#{Time.now.year}</from>
|
30
66
|
</copyright>
|
31
67
|
<ext>
|
32
|
-
<doctype>
|
68
|
+
<doctype>standard</doctype>
|
33
69
|
</ext>
|
34
70
|
</bibdata>
|
35
71
|
<sections> </sections>
|
@@ -125,7 +161,7 @@ RSpec.describe Metanorma::Standoc do
|
|
125
161
|
</owner>
|
126
162
|
</copyright>
|
127
163
|
<ext>
|
128
|
-
<doctype>
|
164
|
+
<doctype>standard</doctype>
|
129
165
|
</ext>
|
130
166
|
</bibdata>
|
131
167
|
<sections> </sections>
|
@@ -468,7 +504,7 @@ RSpec.describe Metanorma::Standoc do
|
|
468
504
|
<keyword>b</keyword>
|
469
505
|
<keyword>c</keyword>
|
470
506
|
<ext>
|
471
|
-
<doctype>
|
507
|
+
<doctype>standard</doctype>
|
472
508
|
<editorialgroup>
|
473
509
|
<technical-committee number="1" type="A">TC</technical-committee>
|
474
510
|
<technical-committee number="11" type="A1">TC1</technical-committee>
|
@@ -789,7 +825,7 @@ RSpec.describe Metanorma::Standoc do
|
|
789
825
|
<from>#{Time.now.year}</from>
|
790
826
|
</copyright>
|
791
827
|
<ext>
|
792
|
-
<doctype>
|
828
|
+
<doctype>standard</doctype>
|
793
829
|
</ext>
|
794
830
|
</bibdata>
|
795
831
|
<sections> </sections>
|
@@ -924,7 +960,7 @@ RSpec.describe Metanorma::Standoc do
|
|
924
960
|
</bibitem>
|
925
961
|
</relation>
|
926
962
|
<ext>
|
927
|
-
<doctype>
|
963
|
+
<doctype>standard</doctype>
|
928
964
|
</ext>
|
929
965
|
</bibdata>
|
930
966
|
<sections> </sections>
|
@@ -304,7 +304,7 @@ RSpec.describe Metanorma::Standoc do
|
|
304
304
|
<from>#{Date.today.year}</from>
|
305
305
|
</copyright>
|
306
306
|
<ext>
|
307
|
-
<doctype>
|
307
|
+
<doctype>standard</doctype>
|
308
308
|
</ext>
|
309
309
|
</bibdata>
|
310
310
|
<sections><p id="foreword">Foreword</p>
|
@@ -440,6 +440,32 @@ RSpec.describe Metanorma::Standoc do
|
|
440
440
|
.to be_equivalent_to xmlpp(output)
|
441
441
|
end
|
442
442
|
|
443
|
+
it "processes term notes outside of terms sections" do
|
444
|
+
input = <<~INPUT
|
445
|
+
#{ASCIIDOC_BLANK_HDR}
|
446
|
+
== Clause
|
447
|
+
|
448
|
+
[NOTE%termnote]
|
449
|
+
====
|
450
|
+
XYZ
|
451
|
+
====
|
452
|
+
INPUT
|
453
|
+
output = <<~OUTPUT
|
454
|
+
#{BLANK_HDR}
|
455
|
+
<sections>
|
456
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
457
|
+
<title>Clause</title>
|
458
|
+
<termnote id='_'>
|
459
|
+
<p id='_'>XYZ</p>
|
460
|
+
</termnote>
|
461
|
+
</clause>
|
462
|
+
</sections>
|
463
|
+
</standard-document>
|
464
|
+
OUTPUT
|
465
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
466
|
+
.to be_equivalent_to xmlpp(output)
|
467
|
+
end
|
468
|
+
|
443
469
|
it "processes term notes as plain notes in nonterm clauses" do
|
444
470
|
input = <<~INPUT
|
445
471
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -722,6 +748,32 @@ RSpec.describe Metanorma::Standoc do
|
|
722
748
|
.to be_equivalent_to xmlpp(output)
|
723
749
|
end
|
724
750
|
|
751
|
+
it "processes term examples outside of terms sections" do
|
752
|
+
input = <<~INPUT
|
753
|
+
#{ASCIIDOC_BLANK_HDR}
|
754
|
+
== Clause
|
755
|
+
|
756
|
+
[%termexample]
|
757
|
+
====
|
758
|
+
XYZ
|
759
|
+
====
|
760
|
+
INPUT
|
761
|
+
output = <<~OUTPUT
|
762
|
+
#{BLANK_HDR}
|
763
|
+
<sections>
|
764
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
765
|
+
<title>Clause</title>
|
766
|
+
<termexample id='_'>
|
767
|
+
<p id='_'>XYZ</p>
|
768
|
+
</termexample>
|
769
|
+
</clause>
|
770
|
+
</sections>
|
771
|
+
</standard-document>
|
772
|
+
OUTPUT
|
773
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(input, *OPTIONS))))
|
774
|
+
.to be_equivalent_to xmlpp(output)
|
775
|
+
end
|
776
|
+
|
725
777
|
it "processes term examples as plain examples in nonterm clauses" do
|
726
778
|
input = <<~INPUT
|
727
779
|
#{ASCIIDOC_BLANK_HDR}
|