metanorma-standoc 1.3.20 → 1.3.21

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,18 +2,41 @@ require "spec_helper"
2
2
 
3
3
  RSpec.describe Asciidoctor::Standoc do
4
4
  it "processes the Asciidoctor::Standoc inline macros" do
5
- expect(xmlpp(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true))).to be_equivalent_to xmlpp(<<~"OUTPUT")
5
+ expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
6
6
  #{ASCIIDOC_BLANK_HDR}
7
7
  alt:[term1]
8
8
  deprecated:[term1]
9
9
  domain:[term1]
10
+ inherit:[<<ref1>>]
11
+
12
+ [bibliography]
13
+ == Bibliography
14
+ * [[[ref1,XYZ 123]]] _Title_
10
15
  INPUT
11
16
  #{BLANK_HDR}
12
- <sections>
13
- <admitted>term1</admitted>
14
- <deprecates>term1</deprecates>
15
- <domain>term1</domain>
16
- </sections>
17
+ <preface>
18
+ <foreword id='_' obligation='informative'>
19
+ <title>Foreword</title>
20
+ <admitted>term1</admitted>
21
+ <deprecates>term1</deprecates>
22
+ <domain>term1</domain>
23
+ <inherit>
24
+ <eref type='inline' bibitemid='ref1' citeas='XYZ 123'/>
25
+ </inherit>
26
+ </foreword>
27
+ </preface>
28
+ <sections> </sections>
29
+ <bibliography>
30
+ <references id='_' obligation='informative'>
31
+ <title>Bibliography</title>
32
+ <bibitem id='ref1'>
33
+ <formattedref format='application/x-isodoc+xml'>
34
+ <em>Title</em>
35
+ </formattedref>
36
+ <docidentifier>XYZ 123</docidentifier>
37
+ </bibitem>
38
+ </references>
39
+ </bibliography>
17
40
  </standard-document>
18
41
  OUTPUT
19
42
  end
@@ -114,7 +114,7 @@ RSpec.describe Asciidoctor::Standoc do
114
114
  it "processes complex tables" do
115
115
  expect(xmlpp(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)))).to be_equivalent_to xmlpp(<<~"OUTPUT")
116
116
  #{ASCIIDOC_BLANK_HDR}
117
- [cols="<,^,^,^,^",options="header,footer",headerrows=2,alt="An extensive summary, and illustration, of tables",subsequence="A",options="unnumbered",summary="This is an extremely long, convoluted summary"]
117
+ [cols="<,^,^,^,^",options="header,footer",headerrows=2,alt="An extensive summary, and illustration, of tables",subsequence="A",options="unnumbered",summary="This is an extremely long, convoluted summary",width=70%]
118
118
  .Maximum _permissible_ mass fraction of defects
119
119
  |===
120
120
  .2+|Defect 4+^| Maximum permissible mass fraction of defects in husked rice +
@@ -144,7 +144,7 @@ RSpec.describe Asciidoctor::Standoc do
144
144
  INPUT
145
145
  #{BLANK_HDR}
146
146
  <sections>
147
- <table id="_" alt="An extensive summary, and illustration, of tables" unnumbered="true" subsequence="A" summary="This is an extremely long, convoluted summary">
147
+ <table id="_" alt="An extensive summary, and illustration, of tables" unnumbered="true" subsequence="A" summary="This is an extremely long, convoluted summary" width="70%">
148
148
  <name>Maximum <em>permissible</em> mass fraction of defects</name>
149
149
  <thead>
150
150
  <tr>
@@ -5,7 +5,8 @@ require "fileutils"
5
5
  RSpec.describe Asciidoctor::Standoc do
6
6
 
7
7
  it "warns about hanging paragraphs" do
8
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(/Hanging paragraph in clause/).to_stderr
8
+ FileUtils.rm_f "test.err"
9
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
9
10
  #{VALIDATING_BLANK_HDR}
10
11
 
11
12
  == Clause 1
@@ -16,26 +17,32 @@ RSpec.describe Asciidoctor::Standoc do
16
17
 
17
18
  Subclause
18
19
  INPUT
20
+ expect(File.read("test.err")).to include "Hanging paragraph in clause"
19
21
  end
20
22
 
21
23
  it "warns that video is a skipped node" do
22
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(/converter missing for video node/).to_stderr
24
+ FileUtils.rm_f "test.err"
25
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
23
26
  #{VALIDATING_BLANK_HDR}
24
27
 
25
28
  video::video_file.mp4[]
26
29
  INPUT
30
+ expect(File.read("test.err")).to include "converter missing for video node"
27
31
  end
28
32
 
29
33
  it "warns that figure does not have title" do
30
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(/Figure should have title/).to_stderr
34
+ FileUtils.rm_f "test.err"
35
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
31
36
  #{VALIDATING_BLANK_HDR}
32
37
 
33
38
  image::spec/examples/rice_images/rice_image1.png[]
34
39
  INPUT
40
+ expect(File.read("test.err")).to include "Figure should have title"
35
41
  end
36
42
 
37
43
  it "warns that callouts do not match annotations" do
38
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(/mismatch of callouts and annotations/).to_stderr
44
+ FileUtils.rm_f "test.err"
45
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
39
46
  #{VALIDATING_BLANK_HDR}
40
47
  [source,ruby]
41
48
  --
@@ -47,50 +54,60 @@ it "warns that callouts do not match annotations" do
47
54
  <1> This is one callout
48
55
  <2> This is another callout
49
56
  INPUT
57
+ expect(File.read("test.err")).to include "mismatch of callouts and annotations"
50
58
  end
51
59
 
52
60
  it "warns that term source is not a real reference" do
53
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(/iso123 is not a real reference/).to_stderr
61
+ FileUtils.rm_f "test.err"
62
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
54
63
  #{VALIDATING_BLANK_HDR}
55
64
 
56
65
  [.source]
57
66
  <<iso123>>
58
67
  INPUT
68
+ expect(File.read("test.err")).to include "iso123 is not a real reference"
59
69
  end
60
70
 
61
71
  it "warns of Non-reference in bibliography" do
62
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(/no anchor on reference/).to_stderr
72
+ FileUtils.rm_f "test.err"
73
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
63
74
  #{VALIDATING_BLANK_HDR}
64
75
 
65
76
  == Normative References
66
77
  * I am not a reference
67
78
  INPUT
79
+ expect(File.read("test.err")).to include "no anchor on reference"
68
80
  end
69
81
 
70
82
  it "warns that Table should have title" do
71
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(%r{Table should have title}).to_stderr
83
+ FileUtils.rm_f "test.err"
84
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
72
85
  #{VALIDATING_BLANK_HDR}
73
86
 
74
87
  |===
75
88
  |a |b |c
76
89
  |===
77
90
  INPUT
91
+ expect(File.read("test.err")).to include "Table should have title"
78
92
  end
79
93
 
80
94
  it "validates document against ISO XML schema" do
81
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(%r{value of attribute "align" is invalid; must be equal to}).to_stderr
95
+ FileUtils.rm_f "test.err"
96
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
82
97
  #{VALIDATING_BLANK_HDR}
83
98
 
84
99
  [align=mid-air]
85
100
  Para
86
101
  INPUT
102
+ expect(File.read("test.err")).to include 'value of attribute "align" is invalid; must be equal to'
87
103
  end
88
104
 
89
105
  it "Warning if terms mismatches IEV" do
106
+ FileUtils.rm_f "test.err"
90
107
  FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
91
108
  FileUtils.rm_f "test_iev/pstore"
92
109
  mock_open_uri('103-01-02')
93
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.to output(%r{Term "automation" does not match IEV 103-01-02 "functional"}).to_stderr
110
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
94
111
  = Document title
95
112
  Author
96
113
  :docfile: test.adoc
@@ -105,14 +122,16 @@ it "Warning if terms mismatches IEV" do
105
122
  [.source]
106
123
  <<iev,clause="103-01-02">>
107
124
  INPUT
125
+ expect(File.read("test.err")).to include 'Term "automation" does not match IEV 103-01-02 "functional"'
108
126
  FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
109
127
  end
110
128
 
111
129
  it "No warning if English term matches IEV" do
130
+ FileUtils.rm_f "test.err"
112
131
  FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
113
132
  FileUtils.rm_f "test_iev/cache"
114
133
  mock_open_uri('103-01-02')
115
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.not_to output(%r{does not match IEV 103-01-02}).to_stderr
134
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
116
135
  = Document title
117
136
  Author
118
137
  :docfile: test.adoc
@@ -127,14 +146,16 @@ it "No warning if English term matches IEV" do
127
146
  [.source]
128
147
  <<iev,clause="103-01-02">>
129
148
  INPUT
149
+ expect(File.read("test.err")).not_to include "does not match IEV 103-01-02"
130
150
  FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
131
151
  end
132
152
 
133
153
  it "No warning if French term matches IEV" do
154
+ FileUtils.rm_f "test.err"
134
155
  FileUtils.mv File.expand_path("~/.iev/cache"), File.expand_path("~/.iev.pstore1"), force: true
135
156
  FileUtils.rm_f "test_iev/cache"
136
157
  mock_open_uri('103-01-02')
137
- expect { Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true) }.not_to output(%r{does not match IEV 103-01-02}).to_stderr
158
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
138
159
  = Document title
139
160
  Author
140
161
  :docfile: test.adoc
@@ -151,16 +172,36 @@ it "No warning if French term matches IEV" do
151
172
  [.source]
152
173
  <<iev,clause="103-01-02">>
153
174
  INPUT
175
+ expect(File.read("test.err")).not_to include "does not match IEV 103-01-02"
154
176
  FileUtils.mv File.expand_path("~/.iev.pstore1"), File.expand_path("~/.iev/cache"), force: true
155
177
  end
156
178
 
179
+ =begin
157
180
  it "No warning if attributes on formatted strong or stem extraneous to Metanomra XML" do
158
181
  expect { Asciidoctor::Standoc::Converter.new(nil,nil).validate(Nokogiri::XML(<<~INPUT)) }.not_to output('found attribute "close", but no attributes allowed here').to_stderr
159
182
  <standard-document>
160
183
  <stem type="MathML"><math xmlns="http://www.w3.org/1998/Math/MathML"><mfenced open="(" close=")"><mi>r</mi></mfenced></stem>
161
184
  </standard-document>
162
185
  INPUT
186
+ end
187
+ =end
188
+
189
+ it "warns if id used twice" do
190
+ FileUtils.rm_f "test.err"
191
+ Asciidoctor.convert(<<~"INPUT", backend: :standoc, header_footer: true)
192
+ = Document title
193
+ Author
194
+ :docfile: test.adoc
195
+ :nodoc:
196
+
197
+ [[abc]]
198
+ == Clause 1
163
199
 
200
+ [[abc]]
201
+ == Clause 2
202
+ INPUT
203
+ expect(File.read("test.err")).to include "Anchor abc has already been used at line"
164
204
  end
165
205
 
206
+
166
207
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: metanorma-standoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.20
4
+ version: 1.3.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-05 00:00:00.000000000 Z
11
+ date: 2020-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: asciidoctor
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0
47
+ version: 1.0.20
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0
54
+ version: 1.0.20
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: iev
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -290,20 +290,6 @@ dependencies:
290
290
  - - "~>"
291
291
  - !ruby/object:Gem::Version
292
292
  version: '0.9'
293
- - !ruby/object:Gem::Dependency
294
- name: metanorma
295
- requirement: !ruby/object:Gem::Requirement
296
- requirements:
297
- - - "~>"
298
- - !ruby/object:Gem::Version
299
- version: 0.3.0
300
- type: :development
301
- prerelease: false
302
- version_requirements: !ruby/object:Gem::Requirement
303
- requirements:
304
- - - "~>"
305
- - !ruby/object:Gem::Version
306
- version: 0.3.0
307
293
  - !ruby/object:Gem::Dependency
308
294
  name: vcr
309
295
  requirement: !ruby/object:Gem::Requirement
@@ -382,6 +368,7 @@ files:
382
368
  - lib/asciidoctor/standoc/inline.rb
383
369
  - lib/asciidoctor/standoc/isodoc.rng
384
370
  - lib/asciidoctor/standoc/lists.rb
371
+ - lib/asciidoctor/standoc/log.rb
385
372
  - lib/asciidoctor/standoc/macros.rb
386
373
  - lib/asciidoctor/standoc/macros_plantuml.rb
387
374
  - lib/asciidoctor/standoc/ref.rb