metanorma-standoc 1.7.3 → 1.8.5
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/.github/workflows/rake.yml +11 -41
- data/.rubocop.yml +1 -1
- data/lib/asciidoctor/standoc/base.rb +34 -45
- data/lib/asciidoctor/standoc/basicdoc.rng +5 -3
- data/lib/asciidoctor/standoc/blocks.rb +20 -11
- data/lib/asciidoctor/standoc/blocks_notes.rb +2 -2
- data/lib/asciidoctor/standoc/cleanup.rb +29 -77
- data/lib/asciidoctor/standoc/cleanup_block.rb +39 -27
- data/lib/asciidoctor/standoc/cleanup_boilerplate.rb +56 -0
- data/lib/asciidoctor/standoc/cleanup_inline.rb +26 -29
- data/lib/asciidoctor/standoc/cleanup_maths.rb +123 -0
- data/lib/asciidoctor/standoc/cleanup_ref.rb +4 -98
- data/lib/asciidoctor/standoc/cleanup_ref_dl.rb +94 -0
- data/lib/asciidoctor/standoc/cleanup_section.rb +5 -0
- data/lib/asciidoctor/standoc/cleanup_terms.rb +2 -2
- data/lib/asciidoctor/standoc/converter.rb +0 -1
- data/lib/asciidoctor/standoc/front.rb +2 -2
- data/lib/asciidoctor/standoc/inline.rb +8 -16
- data/lib/asciidoctor/standoc/isodoc.rng +108 -2
- data/lib/asciidoctor/standoc/lists.rb +2 -2
- data/lib/asciidoctor/standoc/macros_plantuml.rb +1 -1
- data/lib/asciidoctor/standoc/ref_sect.rb +2 -2
- data/lib/asciidoctor/standoc/reqt.rb +6 -1
- data/lib/asciidoctor/standoc/section.rb +12 -80
- data/lib/asciidoctor/standoc/table.rb +1 -1
- data/lib/asciidoctor/standoc/terms.rb +125 -0
- data/lib/asciidoctor/standoc/utils.rb +2 -120
- data/lib/asciidoctor/standoc/validate.rb +16 -1
- data/lib/metanorma/standoc/version.rb +1 -1
- data/metanorma-standoc.gemspec +4 -4
- data/spec/{asciidoctor-standoc → asciidoctor}/base_spec.rb +30 -1
- data/spec/{asciidoctor-standoc → asciidoctor}/blocks_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/cleanup_sections_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/cleanup_spec.rb +408 -6
- data/spec/{asciidoctor-standoc → asciidoctor}/datamodel/attributes_table_preprocessor_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/datamodel/diagram_preprocessor_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/inline_spec.rb +2 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/isobib_cache_spec.rb +4 -4
- data/spec/{asciidoctor-standoc → asciidoctor}/lists_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/macros_json2text_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/macros_lutaml_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/macros_plantuml_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/macros_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/macros_yaml2text_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/refs_dl_spec.rb +13 -1
- data/spec/{asciidoctor-standoc → asciidoctor}/refs_spec.rb +175 -153
- data/spec/{asciidoctor-standoc → asciidoctor}/section_spec.rb +22 -3
- data/spec/{asciidoctor-standoc → asciidoctor}/table_spec.rb +0 -0
- data/spec/{asciidoctor-standoc → asciidoctor}/validate_spec.rb +20 -0
- data/spec/fixtures/action_schemaexpg1.svg +122 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/vcr_cassettes/dated_iso_ref_joint_iso_iec.yml +47 -47
- data/spec/vcr_cassettes/isobib_get_123.yml +14 -14
- data/spec/vcr_cassettes/isobib_get_123_1.yml +27 -27
- data/spec/vcr_cassettes/isobib_get_123_1_fr.yml +36 -36
- data/spec/vcr_cassettes/isobib_get_123_2001.yml +13 -13
- data/spec/vcr_cassettes/isobib_get_124.yml +13 -13
- data/spec/vcr_cassettes/rfcbib_get_rfc8341.yml +94 -30
- data/spec/vcr_cassettes/separates_iev_citations_by_top_level_clause.yml +45 -45
- metadata +49 -46
- data/lib/asciidoctor/standoc/log.rb +0 -59
@@ -35,10 +35,25 @@ module Asciidoctor
|
|
35
35
|
|
36
36
|
def content_validate(doc)
|
37
37
|
section_validate(doc)
|
38
|
+
norm_ref_validate(doc)
|
38
39
|
repeat_id_validate(doc.root)
|
39
40
|
iev_validate(doc.root)
|
40
41
|
end
|
41
42
|
|
43
|
+
def norm_ref_validate(doc)
|
44
|
+
found = false
|
45
|
+
doc.xpath("//references[@normative = 'true']/bibitem").each do |b|
|
46
|
+
next unless docid = b.at("./docidentifier[@type = 'metanorma']")
|
47
|
+
next unless /^\[\d+\]$/.match(docid.text)
|
48
|
+
@log.add("Bibliography", b, "Numeric reference in normative references")
|
49
|
+
found = true
|
50
|
+
end
|
51
|
+
if found
|
52
|
+
clean_exit
|
53
|
+
abort("Numeric reference in normative references")
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
def repeat_id_validate1(ids, x)
|
43
58
|
if ids[x["id"]]
|
44
59
|
@log.add("Anchors", x, "Anchor #{x['id']} has already been used "\
|
@@ -89,7 +104,7 @@ module Asciidoctor
|
|
89
104
|
def formattedstr_strip(doc)
|
90
105
|
doc.xpath("//*[@format] | //stem | //bibdata//description | "\
|
91
106
|
"//formattedref | //bibdata//note | //bibdata/abstract | "\
|
92
|
-
"//bibitem/abstract | //bibitem/note").each do |n|
|
107
|
+
"//bibitem/abstract | //bibitem/note | //misc-container").each do |n|
|
93
108
|
n.elements.each do |e|
|
94
109
|
e.traverse do |e1|
|
95
110
|
e1.element? and e1.each { |k, _v| e1.delete(k) }
|
data/metanorma-standoc.gemspec
CHANGED
@@ -28,26 +28,26 @@ Gem::Specification.new do |spec|
|
|
28
28
|
|
29
29
|
spec.add_dependency "asciidoctor", "~> 2.0.0"
|
30
30
|
spec.add_dependency "ruby-jing"
|
31
|
-
spec.add_dependency "isodoc", "~> 1.
|
31
|
+
spec.add_dependency "isodoc", "~> 1.5.0"
|
32
32
|
spec.add_dependency "iev", "~> 0.2.1"
|
33
33
|
spec.add_dependency "metanorma-plugin-datastruct"
|
34
34
|
spec.add_dependency "metanorma-plugin-lutaml", "~> 0.2.1"
|
35
35
|
# relaton-cli not just relaton, to avoid circular reference in metanorma
|
36
36
|
spec.add_dependency "relaton-cli", "~> 1.7.0"
|
37
37
|
spec.add_dependency "relaton-iev", "~> 1.1.0"
|
38
|
-
spec.add_dependency "sterile", "~> 1.0.14"
|
39
38
|
spec.add_dependency "concurrent-ruby"
|
40
39
|
spec.add_dependency "unicode2latex", "~> 0.0.1"
|
41
|
-
spec.add_dependency "
|
40
|
+
spec.add_dependency "metanorma-utils", "~> 1.0.2"
|
42
41
|
spec.add_dependency "mathml2asciimath"
|
43
42
|
spec.add_dependency "latexmath"
|
43
|
+
spec.add_dependency "asciimath2unitsml", "~> 0.2.0"
|
44
44
|
|
45
45
|
spec.add_development_dependency "byebug"
|
46
46
|
spec.add_development_dependency "sassc", "2.4.0"
|
47
47
|
spec.add_development_dependency "equivalent-xml", "~> 0.6"
|
48
48
|
spec.add_development_dependency "guard", "~> 2.14"
|
49
49
|
spec.add_development_dependency "guard-rspec", "~> 4.7"
|
50
|
-
spec.add_development_dependency "rake", "~>
|
50
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
51
51
|
spec.add_development_dependency "rspec", "~> 3.6"
|
52
52
|
spec.add_development_dependency "rubocop", "= 0.54.0"
|
53
53
|
spec.add_development_dependency "simplecov", "~> 0.15"
|
@@ -32,7 +32,36 @@ RSpec.describe Asciidoctor::Standoc do
|
|
32
32
|
expect(File.exist?("htmlstyle.css")).to be false
|
33
33
|
end
|
34
34
|
|
35
|
-
it "
|
35
|
+
it "assigns default scripts to major languages" do
|
36
|
+
FileUtils.rm_f "test.doc"
|
37
|
+
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
38
|
+
= Document title
|
39
|
+
Author
|
40
|
+
:docfile: test.adoc
|
41
|
+
:novalid:
|
42
|
+
:language: ar
|
43
|
+
INPUT
|
44
|
+
<standard-document xmlns='https://www.metanorma.org/ns/standoc' type='semantic' version='#{Metanorma::Standoc::VERSION}'>
|
45
|
+
<bibdata type='standard'>
|
46
|
+
<title language='en' format='text/plain'>Document title</title>
|
47
|
+
<language>ar</language>
|
48
|
+
<script>Arab</script>
|
49
|
+
<status>
|
50
|
+
<stage>published</stage>
|
51
|
+
</status>
|
52
|
+
<copyright>
|
53
|
+
<from>2021</from>
|
54
|
+
</copyright>
|
55
|
+
<ext>
|
56
|
+
<doctype>article</doctype>
|
57
|
+
</ext>
|
58
|
+
</bibdata>
|
59
|
+
<sections> </sections>
|
60
|
+
</standard-document>
|
61
|
+
OUTPUT
|
62
|
+
end
|
63
|
+
|
64
|
+
it "processes publisher abbreviations" do
|
36
65
|
mock_org_abbrevs
|
37
66
|
expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
38
67
|
= Document title
|
File without changes
|
File without changes
|
@@ -3,6 +3,170 @@ require "relaton_iec"
|
|
3
3
|
require "fileutils"
|
4
4
|
|
5
5
|
RSpec.describe Asciidoctor::Standoc do
|
6
|
+
it "processes svgmap" do
|
7
|
+
FileUtils.cp "spec/fixtures/action_schemaexpg1.svg", "action_schemaexpg1.svg"
|
8
|
+
FileUtils.cp "spec/fixtures/action_schemaexpg1.svg", "action_schemaexpg2.svg"
|
9
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
10
|
+
#{ASCIIDOC_BLANK_HDR}
|
11
|
+
|
12
|
+
[svgmap]
|
13
|
+
====
|
14
|
+
* <<ref1,Computer>>; http://www.example.com
|
15
|
+
====
|
16
|
+
|
17
|
+
[[ref1]]
|
18
|
+
[.svgmap]
|
19
|
+
====
|
20
|
+
image::action_schemaexpg1.svg[]
|
21
|
+
|
22
|
+
* <<ref1,Computer>>; mn://action_schema
|
23
|
+
* http://www.example.com[Phone]; http://www.example.com
|
24
|
+
====
|
25
|
+
|
26
|
+
[svgmap]
|
27
|
+
====
|
28
|
+
[alt=Workmap]
|
29
|
+
image::action_schemaexpg2.svg[]
|
30
|
+
|
31
|
+
* <<ref1,Computer>>; href1.htm
|
32
|
+
* http://www.example.com[Phone]; mn://basic_attribute_schema
|
33
|
+
* <<express:action_schema:action_schema.basic,Coffee>>; mn://support_resource_schema
|
34
|
+
====
|
35
|
+
INPUT
|
36
|
+
#{BLANK_HDR}
|
37
|
+
<sections>
|
38
|
+
<svgmap id='_'>
|
39
|
+
<target href='http://www.example.com'>
|
40
|
+
<xref target='ref1'>Computer</xref>
|
41
|
+
</target>
|
42
|
+
</svgmap>
|
43
|
+
<figure id='_'>
|
44
|
+
<image src='action_schemaexpg1.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto'/>
|
45
|
+
</figure>
|
46
|
+
<svgmap id='_'>
|
47
|
+
<figure id='_'>
|
48
|
+
<image src='action_schemaexpg2.svg' id='_' mimetype='image/svg+xml' height='auto' width='auto' alt='Workmap'/>
|
49
|
+
</figure>
|
50
|
+
<target href='mn://support_resource_schema'>
|
51
|
+
<eref bibitemid='express_action_schema' citeas=''>
|
52
|
+
<localityStack>
|
53
|
+
<locality type='anchor'>
|
54
|
+
<referenceFrom>action_schema.basic</referenceFrom>
|
55
|
+
</locality>
|
56
|
+
</localityStack>
|
57
|
+
Coffee
|
58
|
+
</eref>
|
59
|
+
</target>
|
60
|
+
</svgmap>
|
61
|
+
</sections>
|
62
|
+
<bibliography>
|
63
|
+
<references hidden='true' normative='false'>
|
64
|
+
<bibitem id='express_action_schema' type='internal'>
|
65
|
+
<docidentifier type='repository'>express/action_schema</docidentifier>
|
66
|
+
</bibitem>
|
67
|
+
</references>
|
68
|
+
</bibliography>
|
69
|
+
</standard-document>
|
70
|
+
OUTPUT
|
71
|
+
expect(xmlpp(File.read("action_schemaexpg1.svg", encoding: "utf-8").sub(%r{<image .*</image>}m, ""))).to be_equivalent_to <<~OUTPUT
|
72
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
73
|
+
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
74
|
+
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
|
75
|
+
<style type='text/css'> .st0{fill:none;stroke:#000000;stroke-miterlimit:10;} </style>
|
76
|
+
<a xlink:href='#ref1'>
|
77
|
+
<rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
|
78
|
+
</a>
|
79
|
+
<a xlink:href='mn://basic_attribute_schema'>
|
80
|
+
<rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
|
81
|
+
</a>
|
82
|
+
<a xlink:href='mn://support_resource_schema'>
|
83
|
+
<rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
|
84
|
+
</a>
|
85
|
+
</svg>
|
86
|
+
OUTPUT
|
87
|
+
expect(xmlpp(File.read("action_schemaexpg2.svg", encoding: "utf-8").sub(%r{<image .*</image>}m, ""))).to be_equivalent_to <<~OUTPUT
|
88
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
89
|
+
<!-- Generator: Adobe Illustrator 25.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
90
|
+
<svg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' id='Layer_1' x='0px' y='0px' viewBox='0 0 595.28 841.89' style='enable-background:new 0 0 595.28 841.89;' xml:space='preserve'>
|
91
|
+
<style type='text/css'> .st0{fill:none;stroke:#000000;stroke-miterlimit:10;} </style>
|
92
|
+
<a xlink:href='mn://action_schema'>
|
93
|
+
<rect x='123.28' y='273.93' class='st0' width='88.05' height='41.84'/>
|
94
|
+
</a>
|
95
|
+
<a xlink:href='http://www.example.com'>
|
96
|
+
<rect x='324.69' y='450.52' class='st0' width='132.62' height='40.75'/>
|
97
|
+
</a>
|
98
|
+
<a xlink:href='mn://support_resource_schema'>
|
99
|
+
<rect x='324.69' y='528.36' class='st0' width='148.16' height='40.75'/>
|
100
|
+
</a>
|
101
|
+
</svg>
|
102
|
+
OUTPUT
|
103
|
+
end
|
104
|
+
|
105
|
+
it "processes markup in sourcecode" do
|
106
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
107
|
+
#{ASCIIDOC_BLANK_HDR}
|
108
|
+
|
109
|
+
[source]
|
110
|
+
----
|
111
|
+
<tag/>
|
112
|
+
----
|
113
|
+
|
114
|
+
[[A]]
|
115
|
+
[source]
|
116
|
+
----
|
117
|
+
var {{{*x*}}} : {{{<<A,recursive>>}}} <tag/>
|
118
|
+
----
|
119
|
+
|
120
|
+
|
121
|
+
INPUT
|
122
|
+
#{BLANK_HDR}
|
123
|
+
<sections>
|
124
|
+
<sourcecode id='_'><tag/></sourcecode>
|
125
|
+
<sourcecode id='A'>
|
126
|
+
var
|
127
|
+
<strong>x</strong>
|
128
|
+
:
|
129
|
+
<xref target='A'>recursive</xref>
|
130
|
+
<tag/>
|
131
|
+
</sourcecode>
|
132
|
+
</sections>
|
133
|
+
</standard-document>
|
134
|
+
OUTPUT
|
135
|
+
end
|
136
|
+
|
137
|
+
it "processes markup in sourcecode with custom delimiters" do
|
138
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
139
|
+
= Document title
|
140
|
+
Author
|
141
|
+
:docfile: test.adoc
|
142
|
+
:nodoc:
|
143
|
+
:novalid:
|
144
|
+
:no-isobib:
|
145
|
+
:sourcecode-markup-start: [[[
|
146
|
+
:sourcecode-markup-end: ]]]
|
147
|
+
|
148
|
+
[[A]]
|
149
|
+
[source]
|
150
|
+
----
|
151
|
+
var [[[*x*]]] : [[[<<A,recursive>>]]]
|
152
|
+
----
|
153
|
+
|
154
|
+
|
155
|
+
INPUT
|
156
|
+
#{BLANK_HDR}
|
157
|
+
<sections>
|
158
|
+
<sourcecode id='A'>
|
159
|
+
var
|
160
|
+
<strong>x</strong>
|
161
|
+
:
|
162
|
+
<xref target='A'>recursive</xref>
|
163
|
+
</sourcecode>
|
164
|
+
</sections>
|
165
|
+
</standard-document>
|
166
|
+
OUTPUT
|
167
|
+
end
|
168
|
+
|
169
|
+
|
6
170
|
it "applies smartquotes by default" do
|
7
171
|
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
8
172
|
#{ASCIIDOC_BLANK_HDR}
|
@@ -1597,7 +1761,7 @@ it "sorts symbols lists" do
|
|
1597
1761
|
== Symbols and abbreviated terms
|
1598
1762
|
|
1599
1763
|
α:: Definition 1
|
1600
|
-
|
1764
|
+
Xa:: Definition 2
|
1601
1765
|
x_1_:: Definition 3
|
1602
1766
|
x_m_:: Definition 4
|
1603
1767
|
x:: Definition 5
|
@@ -1635,7 +1799,7 @@ it "sorts symbols lists" do
|
|
1635
1799
|
<dd>
|
1636
1800
|
<p id='_'>Definition 3</p>
|
1637
1801
|
</dd>
|
1638
|
-
<dt>
|
1802
|
+
<dt>Xa</dt>
|
1639
1803
|
<dd>
|
1640
1804
|
<p id='_'>Definition 2</p>
|
1641
1805
|
</dd>
|
@@ -1867,6 +2031,8 @@ input = <<~INPUT
|
|
1867
2031
|
<<1:>>
|
1868
2032
|
<<1#b>>
|
1869
2033
|
<<:a#b:>>
|
2034
|
+
<</%ab>>
|
2035
|
+
<<1!>>
|
1870
2036
|
|
1871
2037
|
INPUT
|
1872
2038
|
expect(xmlpp(Asciidoctor.convert(input, backend: :standoc, header_footer: true).gsub(/<p id="_[^"]+">/, "").gsub('</p>', ""))).to be_equivalent_to (<<~"OUTPUT")
|
@@ -1888,18 +2054,27 @@ expect(xmlpp(Asciidoctor.convert(input, backend: :standoc, header_footer: true).
|
|
1888
2054
|
<sections>
|
1889
2055
|
<clause id='a_b' inline-header='false' obligation='normative'>
|
1890
2056
|
<title>A</title>
|
1891
|
-
<
|
2057
|
+
<eref bibitemid='__ab' citeas=''/>
|
1892
2058
|
<xref target='_'/>
|
1893
2059
|
<xref target='_1'/>
|
1894
2060
|
<xref target='_1_'/>
|
1895
2061
|
<xref target='1#b'/>
|
1896
2062
|
<xref target='_a#b_'/>
|
2063
|
+
<xref target='_%ab'/>
|
2064
|
+
<xref target='_1_'/>
|
1897
2065
|
</clause>
|
1898
2066
|
</sections>
|
2067
|
+
<bibliography>
|
2068
|
+
<references hidden='true' normative='false'>
|
2069
|
+
<bibitem id='__ab' type='internal'>
|
2070
|
+
<docidentifier type='repository'>//ab</docidentifier>
|
2071
|
+
</bibitem>
|
2072
|
+
</references>
|
2073
|
+
</bibliography>
|
1899
2074
|
</standard-document>
|
1900
2075
|
OUTPUT
|
1901
2076
|
expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <clause id="a_b" inline-header="false" obligation="normative"/> from a:b}).to_stderr
|
1902
|
-
expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <
|
2077
|
+
expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <eref bibitemid="__ab" citeas=""/> from /_ab}).to_stderr
|
1903
2078
|
expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="_"/> from :}).to_stderr
|
1904
2079
|
expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="_1"/> from 1}).to_stderr
|
1905
2080
|
expect{Asciidoctor.convert(input, backend: :standoc, header_footer: true)}.to output(%r{normalised identifier in <xref target="_1_"/> from 1:}).to_stderr
|
@@ -1943,6 +2118,123 @@ expect(xmlpp(Asciidoctor.convert(input, backend: :standoc, header_footer: true))
|
|
1943
2118
|
OUTPUT
|
1944
2119
|
|
1945
2120
|
end
|
2121
|
+
|
2122
|
+
it "converts UnitsML to MathML" do
|
2123
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~INPUT, backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
2124
|
+
= Document title
|
2125
|
+
Author
|
2126
|
+
:stem:
|
2127
|
+
|
2128
|
+
[stem]
|
2129
|
+
++++
|
2130
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
2131
|
+
<mrow>
|
2132
|
+
<mn>7</mn>
|
2133
|
+
<mtext>unitsml(m*kg^-2)</mtext>
|
2134
|
+
<mo>+</mo>
|
2135
|
+
<mn>8</mn>
|
2136
|
+
<mtext>unitsml(m*kg^-2)</mtext>
|
2137
|
+
</mrow>
|
2138
|
+
</math>
|
2139
|
+
++++
|
2140
|
+
INPUT
|
2141
|
+
#{BLANK_HDR}
|
2142
|
+
<misc-container>
|
2143
|
+
<UnitsML xmlns='http://unitsml.nist.gov/2005'>
|
2144
|
+
<UnitSet>
|
2145
|
+
<Unit xml:id='U_m.kg-2' dimensionURL='#D_LM-2'>
|
2146
|
+
<UnitSystem name='SI' type='SI_derived' xml:lang='en-US'/>
|
2147
|
+
<UnitName xml:lang='en'>m*kg^-2</UnitName>
|
2148
|
+
<UnitSymbol type='HTML'>
|
2149
|
+
m kg
|
2150
|
+
<sup>−2</sup>
|
2151
|
+
</UnitSymbol>
|
2152
|
+
<UnitSymbol type='MathML'>
|
2153
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
2154
|
+
<mrow>
|
2155
|
+
<mi mathvariant='normal'>m</mi>
|
2156
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
2157
|
+
<msup>
|
2158
|
+
<mrow>
|
2159
|
+
<mi mathvariant='normal'>kg</mi>
|
2160
|
+
</mrow>
|
2161
|
+
<mrow>
|
2162
|
+
<mo>−</mo>
|
2163
|
+
<mn>2</mn>
|
2164
|
+
</mrow>
|
2165
|
+
</msup>
|
2166
|
+
</mrow>
|
2167
|
+
</math>
|
2168
|
+
</UnitSymbol>
|
2169
|
+
<RootUnits>
|
2170
|
+
<EnumeratedRootUnit unit='meter'/>
|
2171
|
+
<EnumeratedRootUnit unit='gram' prefix='k' powerNumerator='-2'/>
|
2172
|
+
</RootUnits>
|
2173
|
+
</Unit>
|
2174
|
+
</UnitSet>
|
2175
|
+
<DimensionSet>
|
2176
|
+
<Dimension xml:id='D_LM-2'>
|
2177
|
+
<Length symbol='L' powerNumerator='1'/>
|
2178
|
+
<Mass symbol='M' powerNumerator='-2'/>
|
2179
|
+
</Dimension>
|
2180
|
+
</DimensionSet>
|
2181
|
+
<PrefixSet>
|
2182
|
+
<Prefix prefixBase='10' prefixPower='3' xml:id='NISTp10_3'>
|
2183
|
+
<PrefixName xml:lang='en'>kilo</PrefixName>
|
2184
|
+
<PrefixSymbol type='ASCII'>k</PrefixSymbol>
|
2185
|
+
<PrefixSymbol type='unicode'>k</PrefixSymbol>
|
2186
|
+
<PrefixSymbol type='LaTeX'>k</PrefixSymbol>
|
2187
|
+
<PrefixSymbol type='HTML'>k</PrefixSymbol>
|
2188
|
+
</Prefix>
|
2189
|
+
</PrefixSet>
|
2190
|
+
</UnitsML>
|
2191
|
+
</misc-container>
|
2192
|
+
<sections>
|
2193
|
+
<formula id='_'>
|
2194
|
+
<stem type='MathML'>
|
2195
|
+
<math xmlns='http://www.w3.org/1998/Math/MathML'>
|
2196
|
+
<mrow>
|
2197
|
+
<mn>7</mn>
|
2198
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
2199
|
+
<mrow xref='U_m.kg-2'>
|
2200
|
+
<mi mathvariant='normal'>m</mi>
|
2201
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
2202
|
+
<msup>
|
2203
|
+
<mrow>
|
2204
|
+
<mi mathvariant='normal'>kg</mi>
|
2205
|
+
</mrow>
|
2206
|
+
<mrow>
|
2207
|
+
<mo>−</mo>
|
2208
|
+
<mn>2</mn>
|
2209
|
+
</mrow>
|
2210
|
+
</msup>
|
2211
|
+
</mrow>
|
2212
|
+
<mo>+</mo>
|
2213
|
+
<mn>8</mn>
|
2214
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
2215
|
+
<mrow xref='U_m.kg-2'>
|
2216
|
+
<mi mathvariant='normal'>m</mi>
|
2217
|
+
<mo rspace='thickmathspace'>⁢</mo>
|
2218
|
+
<msup>
|
2219
|
+
<mrow>
|
2220
|
+
<mi mathvariant='normal'>kg</mi>
|
2221
|
+
</mrow>
|
2222
|
+
<mrow>
|
2223
|
+
<mo>−</mo>
|
2224
|
+
<mn>2</mn>
|
2225
|
+
</mrow>
|
2226
|
+
</msup>
|
2227
|
+
</mrow>
|
2228
|
+
</mrow>
|
2229
|
+
</math>
|
2230
|
+
</stem>
|
2231
|
+
</formula>
|
2232
|
+
</sections>
|
2233
|
+
</standard-document>
|
2234
|
+
OUTPUT
|
2235
|
+
|
2236
|
+
end
|
2237
|
+
|
1946
2238
|
it "customises italicisation of MathML" do
|
1947
2239
|
input = <<~INPUT
|
1948
2240
|
= Document title
|
@@ -2109,6 +2401,118 @@ mock_mathml_italicise({ uppergreek: true, upperroman: true, lowergreek: true, lo
|
|
2109
2401
|
|
2110
2402
|
end
|
2111
2403
|
|
2404
|
+
it "process express_ref macro with existing bibliography" do
|
2405
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
2406
|
+
#{ASCIIDOC_BLANK_HDR}
|
2407
|
+
== Clause
|
2408
|
+
|
2409
|
+
<<uml:A:A.B.C,C>>
|
2410
|
+
<<uml:A>>
|
2411
|
+
<<express-schema:action:action.AA,AA>>
|
2412
|
+
<<express-schema:action:action.AB>>
|
2413
|
+
|
2414
|
+
[[action]]
|
2415
|
+
[type="express-schema"]
|
2416
|
+
== Action
|
2417
|
+
|
2418
|
+
[[action.AA]]
|
2419
|
+
=== AA
|
2420
|
+
|
2421
|
+
[bibliography]
|
2422
|
+
== Bibliography
|
2423
|
+
* [[[D,E]]] F
|
2424
|
+
INPUT
|
2425
|
+
#{BLANK_HDR}
|
2426
|
+
<sections>
|
2427
|
+
<clause id='_' inline-header='false' obligation='normative'>
|
2428
|
+
<title>Clause</title>
|
2429
|
+
<p id='_'>
|
2430
|
+
<eref bibitemid='uml_A' citeas="">
|
2431
|
+
<localityStack>
|
2432
|
+
<locality type='anchor'><referenceFrom>A.B.C</referenceFrom></locality>
|
2433
|
+
</localityStack>
|
2434
|
+
C
|
2435
|
+
</eref>
|
2436
|
+
<eref bibitemid='uml_A' citeas=""/>
|
2437
|
+
<xref target='action.AA'>AA</xref>
|
2438
|
+
<xref target='action'>** Missing target action.AB</xref>
|
2439
|
+
</p>
|
2440
|
+
</clause>
|
2441
|
+
<clause id='action' type='express-schema' inline-header='false' obligation='normative'>
|
2442
|
+
<title>Action</title>
|
2443
|
+
<clause id='action.AA' inline-header='false' obligation='normative'>
|
2444
|
+
<title>AA</title>
|
2445
|
+
</clause>
|
2446
|
+
</clause>
|
2447
|
+
</sections>
|
2448
|
+
<bibliography>
|
2449
|
+
<references id='_' normative='false' obligation='informative'>
|
2450
|
+
<title>Bibliography</title>
|
2451
|
+
<bibitem id='D'>
|
2452
|
+
<formattedref format='application/x-isodoc+xml'>F</formattedref>
|
2453
|
+
<docidentifier>E</docidentifier>
|
2454
|
+
</bibitem>
|
2455
|
+
</references>
|
2456
|
+
<references hidden='true' normative='false'>
|
2457
|
+
<bibitem id='uml_A' type='internal'>
|
2458
|
+
<docidentifier type='repository'>uml/A</docidentifier>
|
2459
|
+
</bibitem>
|
2460
|
+
</references>
|
2461
|
+
</bibliography>
|
2462
|
+
</standard-document>
|
2463
|
+
OUTPUT
|
2464
|
+
end
|
2465
|
+
|
2466
|
+
|
2467
|
+
it "process express_ref macro with no existing bibliography" do
|
2468
|
+
expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true, agree_to_terms: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
|
2469
|
+
#{ASCIIDOC_BLANK_HDR}
|
2470
|
+
[[B]]
|
2471
|
+
[type="express-schema"]
|
2472
|
+
== Clause
|
2473
|
+
|
2474
|
+
[[B1]]
|
2475
|
+
NOTE: X
|
2476
|
+
|
2477
|
+
<<express-schema:A:A.B.C,C>>
|
2478
|
+
<<express-schema:A>>
|
2479
|
+
<<express-schema:B>>
|
2480
|
+
<<express-schema:B1>>
|
2481
|
+
INPUT
|
2482
|
+
#{BLANK_HDR}
|
2483
|
+
<sections>
|
2484
|
+
<clause id='B' type='express-schema' inline-header='false' obligation='normative'>
|
2485
|
+
<title>Clause</title>
|
2486
|
+
<note id='B1'>
|
2487
|
+
<p id='_'>X</p>
|
2488
|
+
</note>
|
2489
|
+
<p id='_'>
|
2490
|
+
<eref bibitemid='express-schema_A' citeas=''>
|
2491
|
+
<localityStack>
|
2492
|
+
<locality type='anchor'>
|
2493
|
+
<referenceFrom>A.B.C</referenceFrom>
|
2494
|
+
</locality>
|
2495
|
+
</localityStack>
|
2496
|
+
C
|
2497
|
+
</eref>
|
2498
|
+
<eref bibitemid='express-schema_A' citeas=''/>
|
2499
|
+
<xref target='B'/>
|
2500
|
+
<xref target='B1'/>
|
2501
|
+
</p>
|
2502
|
+
</clause>
|
2503
|
+
</sections>
|
2504
|
+
<bibliography>
|
2505
|
+
<references hidden='true' normative='false'>
|
2506
|
+
<bibitem id='express-schema_A' type='internal'>
|
2507
|
+
<docidentifier type='repository'>express-schema/A</docidentifier>
|
2508
|
+
</bibitem>
|
2509
|
+
</references>
|
2510
|
+
</bibliography>
|
2511
|
+
</standard-document>
|
2512
|
+
OUTPUT
|
2513
|
+
end
|
2514
|
+
|
2515
|
+
|
2112
2516
|
private
|
2113
2517
|
|
2114
2518
|
def mock_mathml_italicise(x)
|
@@ -2230,6 +2634,4 @@ OUTPUT
|
|
2230
2634
|
end.at_least :once
|
2231
2635
|
end
|
2232
2636
|
|
2233
|
-
|
2234
|
-
|
2235
2637
|
end
|