isodoc 1.7.7 → 1.8.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/isodoc.gemspec +2 -2
- data/lib/isodoc/class_utils.rb +1 -1
- data/lib/isodoc/convert.rb +8 -0
- data/lib/isodoc/function/cleanup.rb +4 -0
- data/lib/isodoc/function/inline.rb +3 -5
- data/lib/isodoc/html_function/html.rb +1 -0
- data/lib/isodoc/html_function/postprocess.rb +4 -6
- data/lib/isodoc/metadata_date.rb +13 -11
- data/lib/isodoc/presentation_function/bibdata.rb +2 -2
- data/lib/isodoc/presentation_function/block.rb +0 -36
- data/lib/isodoc/presentation_function/inline.rb +2 -3
- data/lib/isodoc/presentation_function/terms.rb +223 -0
- data/lib/isodoc/presentation_xml_convert.rb +11 -4
- data/lib/isodoc/version.rb +1 -1
- data/lib/isodoc/word_function/body.rb +24 -14
- data/lib/isodoc/word_function/comments.rb +0 -4
- data/lib/isodoc/word_function/postprocess.rb +184 -176
- data/lib/isodoc/xref/xref_gen.rb +18 -22
- data/lib/isodoc/xref/xref_gen_seq.rb +10 -16
- data/lib/isodoc/xslfo_convert.rb +9 -6
- data/lib/isodoc-yaml/i18n-ar.yaml +25 -0
- data/lib/isodoc-yaml/i18n-de.yaml +23 -0
- data/lib/isodoc-yaml/i18n-en.yaml +23 -0
- data/lib/isodoc-yaml/i18n-es.yaml +23 -0
- data/lib/isodoc-yaml/i18n-fr.yaml +23 -0
- data/lib/isodoc-yaml/i18n-ru.yaml +24 -1
- data/lib/isodoc-yaml/i18n-zh-Hans.yaml +24 -0
- data/lib/metanorma/output/xslfo.rb +4 -11
- data/spec/isodoc/blocks_spec.rb +14 -8
- data/spec/isodoc/i18n_spec.rb +20 -15
- data/spec/isodoc/inline_spec.rb +71 -3
- data/spec/isodoc/lists_spec.rb +344 -222
- data/spec/isodoc/section_spec.rb +23 -22
- data/spec/isodoc/table_spec.rb +71 -73
- data/spec/isodoc/terms_spec.rb +498 -124
- data/spec/isodoc/xref_numbering_spec.rb +347 -0
- data/spec/isodoc/xref_spec.rb +274 -353
- data/spec/isodoc/xslfo_convert_spec.rb +20 -7
- metadata +12 -11
- data/lib/isodoc/presentation_function/concept.rb +0 -68
@@ -0,0 +1,347 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
RSpec.describe IsoDoc do
|
4
|
+
it "realises subsequences" do
|
5
|
+
input = <<~INPUT
|
6
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
7
|
+
<preface>
|
8
|
+
<foreword id="fwd">
|
9
|
+
<p>
|
10
|
+
<xref target="N1"/>
|
11
|
+
<xref target="N2"/>
|
12
|
+
<xref target="N3"/>
|
13
|
+
<xref target="N4"/>
|
14
|
+
<xref target="N5"/>
|
15
|
+
<xref target="N6"/>
|
16
|
+
<xref target="N7"/>
|
17
|
+
<xref target="N8"/>
|
18
|
+
</p>
|
19
|
+
</foreword>
|
20
|
+
<introduction id="intro">
|
21
|
+
<figure id="N1"> <name>Split-it-right sample divider</name>
|
22
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
23
|
+
</figure>
|
24
|
+
<figure id="N2" subsequence="A"> <name>Split-it-right sample divider</name>
|
25
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
26
|
+
</figure>
|
27
|
+
<figure id="N3" subsequence="A"> <name>Split-it-right sample divider</name>
|
28
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
29
|
+
</figure>
|
30
|
+
<figure id="N4" subsequence="B"> <name>Split-it-right sample divider</name>
|
31
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
32
|
+
</figure>
|
33
|
+
<figure id="N5" subsequence="B"> <name>Split-it-right sample divider</name>
|
34
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
35
|
+
</figure>
|
36
|
+
<figure id="N6" subsequence="B"> <name>Split-it-right sample divider</name>
|
37
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
38
|
+
</figure>
|
39
|
+
<figure id="N7"> <name>Split-it-right sample divider</name>
|
40
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
41
|
+
</figure>
|
42
|
+
<figure id="N8"> <name>Split-it-right sample divider</name>
|
43
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
44
|
+
</figure>
|
45
|
+
</introduction>
|
46
|
+
</iso-standard>
|
47
|
+
INPUT
|
48
|
+
output = <<~OUTPUT
|
49
|
+
<foreword id='fwd' displayorder="1">
|
50
|
+
<p>
|
51
|
+
<xref target='N1'>Figure 1</xref>
|
52
|
+
<xref target='N2'>Figure 2a</xref>
|
53
|
+
<xref target='N3'>Figure 2b</xref>
|
54
|
+
<xref target='N4'>Figure 3a</xref>
|
55
|
+
<xref target='N5'>Figure 3b</xref>
|
56
|
+
<xref target='N6'>Figure 3c</xref>
|
57
|
+
<xref target='N7'>Figure 4</xref>
|
58
|
+
<xref target='N8'>Figure 5</xref>
|
59
|
+
</p>
|
60
|
+
</foreword>
|
61
|
+
OUTPUT
|
62
|
+
expect(xmlpp(Nokogiri::XML(IsoDoc::PresentationXMLConvert.new({})
|
63
|
+
.convert("test", input, true))
|
64
|
+
.at("//xmlns:foreword").to_xml))
|
65
|
+
.to be_equivalent_to xmlpp(output)
|
66
|
+
end
|
67
|
+
|
68
|
+
it "realises numbering overrides" do
|
69
|
+
input = <<~INPUT
|
70
|
+
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
71
|
+
<preface>
|
72
|
+
<foreword id="fwd">
|
73
|
+
<p>
|
74
|
+
<xref target="N1"/>
|
75
|
+
<xref target="N2"/>
|
76
|
+
<xref target="N3"/>
|
77
|
+
<xref target="N4"/>
|
78
|
+
<xref target="N5"/>
|
79
|
+
<xref target="N6"/>
|
80
|
+
<xref target="N7"/>
|
81
|
+
<xref target="N8"/>
|
82
|
+
<xref target="N9"/>
|
83
|
+
<xref target="N10"/>
|
84
|
+
<xref target="N11"/>
|
85
|
+
<xref target="N12"/>
|
86
|
+
<xref target="N13"/>
|
87
|
+
</p>
|
88
|
+
<p>
|
89
|
+
<xref target="S1"/>
|
90
|
+
<xref target="S2"/>
|
91
|
+
<xref target="S3"/>
|
92
|
+
<xref target="S4"/>
|
93
|
+
<xref target="S12"/>
|
94
|
+
<xref target="S13"/>
|
95
|
+
<xref target="S14"/>
|
96
|
+
<xref target="S15"/>
|
97
|
+
<xref target="S16"/>
|
98
|
+
<xref target="S17"/>
|
99
|
+
<xref target="S18"/>
|
100
|
+
<xref target="S19"/>
|
101
|
+
<xref target="S20"/>
|
102
|
+
<xref target="S21"/>
|
103
|
+
<xref target="S22"/>
|
104
|
+
<xref target="S23"/>
|
105
|
+
<xref target="S24"/>
|
106
|
+
<xref target="S25"/>
|
107
|
+
<xref target="S26"/>
|
108
|
+
<xref target="S27"/>
|
109
|
+
<xref target="S28"/>
|
110
|
+
<xref target="S29"/>
|
111
|
+
<xref target="S30"/>
|
112
|
+
</p>
|
113
|
+
</foreword>
|
114
|
+
<introduction id="intro">
|
115
|
+
<figure id="N1"> <name>Split-it-right sample divider</name>
|
116
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
117
|
+
</figure>
|
118
|
+
<figure id="N2" number="A"> <name>Split-it-right sample divider</name>
|
119
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
120
|
+
</figure>
|
121
|
+
<figure id="N3"> <name>Split-it-right sample divider</name>
|
122
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
123
|
+
</figure>
|
124
|
+
<figure id="N4" number="7"> <name>Split-it-right sample divider</name>
|
125
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
126
|
+
</figure>
|
127
|
+
<figure id="N5"> <name>Split-it-right sample divider</name>
|
128
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
129
|
+
</figure>
|
130
|
+
<figure id="N6" subsequence="B"> <name>Split-it-right sample divider</name>
|
131
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
132
|
+
</figure>
|
133
|
+
<figure id="N7" subsequence="B" number="c"> <name>Split-it-right sample divider</name>
|
134
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
135
|
+
</figure>
|
136
|
+
<figure id="N8" subsequence="B"> <name>Split-it-right sample divider</name>
|
137
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
138
|
+
</figure>
|
139
|
+
<figure id="N9" subsequence="C" number="20f"> <name>Split-it-right sample divider</name>
|
140
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
141
|
+
</figure>
|
142
|
+
<figure id="N10" subsequence="C"> <name>Split-it-right sample divider</name>
|
143
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
144
|
+
</figure>
|
145
|
+
<figure id="N11" number="A.1"> <name>Split-it-right sample divider</name>
|
146
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
147
|
+
</figure>
|
148
|
+
<figure id="N12"> <name>Split-it-right sample divider</name>
|
149
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
150
|
+
</figure>
|
151
|
+
<figure id="N13" number="100"> <name>Split-it-right sample divider</name>
|
152
|
+
<image src="rice_images/rice_image1.png" id="_8357ede4-6d44-4672-bac4-9a85e82ab7f0" mimetype="image/png"/>
|
153
|
+
</figure>
|
154
|
+
</introduction>
|
155
|
+
</preface>
|
156
|
+
<sections>
|
157
|
+
<clause id='S1' number='1bis' type='scope' inline-header='false' obligation='normative'>
|
158
|
+
<title>Scope</title>
|
159
|
+
<p id='_'>Text</p>
|
160
|
+
</clause>
|
161
|
+
<terms id='S3' number='3bis' obligation='normative'>
|
162
|
+
<title>Terms and definitions</title>
|
163
|
+
<p id='_'>For the purposes of this document, the following terms and definitions apply.</p>
|
164
|
+
<term id='S4' number='4bis'>
|
165
|
+
<preferred><expression><name>Term1</name></expression></preferred>
|
166
|
+
</term>
|
167
|
+
</terms>
|
168
|
+
<definitions id='S12' number='12bis' type='abbreviated_terms' obligation='normative'>
|
169
|
+
<title>Abbreviated terms</title>
|
170
|
+
</definitions>
|
171
|
+
<clause id='S13' number='13bis' inline-header='false' obligation='normative'>
|
172
|
+
<title>Clause 4</title>
|
173
|
+
<clause id='S14' number='14bis' inline-header='false' obligation='normative'>
|
174
|
+
<title>Introduction</title>
|
175
|
+
</clause>
|
176
|
+
<clause id='S15' inline-header='false' obligation='normative'>
|
177
|
+
<title>Clause A</title>
|
178
|
+
</clause>
|
179
|
+
<clause id='S16' inline-header='false' obligation='normative'>
|
180
|
+
<title>Clause B</title>
|
181
|
+
</clause>
|
182
|
+
<clause id='S17' number='0' inline-header='false' obligation='normative'>
|
183
|
+
<title>Clause C</title>
|
184
|
+
</clause>
|
185
|
+
<clause id='S18' inline-header='false' obligation='normative'>
|
186
|
+
<title>Clause D</title>
|
187
|
+
</clause>
|
188
|
+
<clause id='S19' inline-header='false' obligation='normative'>
|
189
|
+
<title>Clause E</title>
|
190
|
+
</clause>
|
191
|
+
<clause id='S20' number='a' inline-header='false' obligation='normative'>
|
192
|
+
<title>Clause F</title>
|
193
|
+
</clause>
|
194
|
+
<clause id='S21' inline-header='false' obligation='normative'>
|
195
|
+
<title>Clause G</title>
|
196
|
+
</clause>
|
197
|
+
<clause id='S22' number='B' inline-header='false' obligation='normative'>
|
198
|
+
<title>Clause H</title>
|
199
|
+
</clause>
|
200
|
+
<clause id='S23' inline-header='false' obligation='normative'>
|
201
|
+
<title>Clause I</title>
|
202
|
+
</clause>
|
203
|
+
</clause>
|
204
|
+
<clause id='S24' number='16bis' inline-header='false' obligation='normative'>
|
205
|
+
<title>Terms and Definitions</title>
|
206
|
+
</clause>
|
207
|
+
</sections>
|
208
|
+
<annex id='S25' obligation='normative'>
|
209
|
+
<title>First Annex</title>
|
210
|
+
</annex>
|
211
|
+
<annex id='S26' number='17bis' inline-header='false' obligation='normative'>
|
212
|
+
<title>Annex</title>
|
213
|
+
<clause id='S27' number='18bis' inline-header='false' obligation='normative'>
|
214
|
+
<title>Annex A.1</title>
|
215
|
+
</clause>
|
216
|
+
</annex>
|
217
|
+
<annex id='S28' inline-header='false' obligation='normative'>
|
218
|
+
<title>Another Annex</title>
|
219
|
+
</annex>
|
220
|
+
<bibliography>
|
221
|
+
<references id='S2' number='2bis' normative='true' obligation='informative'>
|
222
|
+
<title>Normative references</title>
|
223
|
+
<p id='_'>There are no normative references in this document.</p>
|
224
|
+
</references>
|
225
|
+
<clause id='S29' number='19bis' obligation='informative'>
|
226
|
+
<title>Bibliography</title>
|
227
|
+
<references id='S30' number='20bis' normative='false' obligation='informative'>
|
228
|
+
<title>Bibliography Subsection</title>
|
229
|
+
</references>
|
230
|
+
</clause>
|
231
|
+
</bibliography>
|
232
|
+
</iso-standard>
|
233
|
+
INPUT
|
234
|
+
output = <<~OUTPUT
|
235
|
+
<foreword id='fwd' displayorder='1'>
|
236
|
+
<p>
|
237
|
+
<xref target='N1'>Figure 1</xref>
|
238
|
+
<xref target='N2'>Figure A</xref>
|
239
|
+
<xref target='N3'>Figure B</xref>
|
240
|
+
<xref target='N4'>Figure 7</xref>
|
241
|
+
<xref target='N5'>Figure 8</xref>
|
242
|
+
<xref target='N6'>Figure 9a</xref>
|
243
|
+
<xref target='N7'>Figure 9c</xref>
|
244
|
+
<xref target='N8'>Figure 9d</xref>
|
245
|
+
<xref target='N9'>Figure 20f</xref>
|
246
|
+
<xref target='N10'>Figure 20g</xref>
|
247
|
+
<xref target='N11'>Figure A.1</xref>
|
248
|
+
<xref target='N12'>Figure A.2</xref>
|
249
|
+
<xref target='N13'>Figure 100</xref>
|
250
|
+
</p>
|
251
|
+
<p>
|
252
|
+
<xref target='S1'>Clause 1bis</xref>
|
253
|
+
<xref target='S2'>Clause 2bis</xref>
|
254
|
+
<xref target='S3'>Clause 3bis</xref>
|
255
|
+
<xref target='S4'>Clause 3bis.4bis</xref>
|
256
|
+
<xref target='S12'>Clause 12bis</xref>
|
257
|
+
<xref target='S13'>Clause 13bis</xref>
|
258
|
+
<xref target='S14'>Clause 13bis.14bis</xref>
|
259
|
+
<xref target='S15'>Clause 13bis.14bit</xref>
|
260
|
+
<xref target='S16'>Clause 13bis.14biu</xref>
|
261
|
+
<xref target='S17'>Clause 13bis.0</xref>
|
262
|
+
<xref target='S18'>Clause 13bis.1</xref>
|
263
|
+
<xref target='S19'>Clause 13bis.2</xref>
|
264
|
+
<xref target='S20'>Clause 13bis.a</xref>
|
265
|
+
<xref target='S21'>Clause 13bis.b</xref>
|
266
|
+
<xref target='S22'>Clause 13bis.B</xref>
|
267
|
+
<xref target='S23'>Clause 13bis.C</xref>
|
268
|
+
<xref target='S24'>Clause 16bis</xref>
|
269
|
+
<xref target='S25'>Annex A</xref>
|
270
|
+
<xref target='S26'>Annex 17bis</xref>
|
271
|
+
<xref target='S27'>Annex 17bis.18bis</xref>
|
272
|
+
<xref target='S28'>Annex 17bit</xref>
|
273
|
+
<xref target='S29'>Bibliography</xref>
|
274
|
+
<xref target='S30'>Bibliography Subsection</xref>
|
275
|
+
</p>
|
276
|
+
</foreword>
|
277
|
+
OUTPUT
|
278
|
+
expect(xmlpp(Nokogiri::XML(IsoDoc::PresentationXMLConvert.new({})
|
279
|
+
.convert("test", input, true))
|
280
|
+
.at("//xmlns:foreword").to_xml))
|
281
|
+
.to be_equivalent_to xmlpp(output)
|
282
|
+
end
|
283
|
+
|
284
|
+
it "realises roman counter for xrefs" do
|
285
|
+
a = IsoDoc::XrefGen::Counter.new(0, numerals: :roman)
|
286
|
+
a.increment({})
|
287
|
+
expect(a.print).to eq "I"
|
288
|
+
a.increment({})
|
289
|
+
expect(a.print).to eq "II"
|
290
|
+
a.increment({})
|
291
|
+
expect(a.print).to eq "III"
|
292
|
+
a.increment({})
|
293
|
+
expect(a.print).to eq "IV"
|
294
|
+
a.increment({})
|
295
|
+
expect(a.print).to eq "V"
|
296
|
+
end
|
297
|
+
|
298
|
+
it "skips I in counter for xrefs" do
|
299
|
+
a = IsoDoc::XrefGen::Counter.new("@", skip_i: true)
|
300
|
+
a.increment({})
|
301
|
+
a.increment({})
|
302
|
+
a.increment({})
|
303
|
+
a.increment({})
|
304
|
+
a.increment({})
|
305
|
+
a.increment({})
|
306
|
+
a.increment({})
|
307
|
+
a.increment({})
|
308
|
+
expect(a.print).to eq "H"
|
309
|
+
a.increment({})
|
310
|
+
expect(a.print).to eq "J"
|
311
|
+
a = IsoDoc::XrefGen::Counter.new("@")
|
312
|
+
a.increment({})
|
313
|
+
a.increment({})
|
314
|
+
a.increment({})
|
315
|
+
a.increment({})
|
316
|
+
a.increment({})
|
317
|
+
a.increment({})
|
318
|
+
a.increment({})
|
319
|
+
a.increment({})
|
320
|
+
expect(a.print).to eq "H"
|
321
|
+
a.increment({})
|
322
|
+
expect(a.print).to eq "I"
|
323
|
+
end
|
324
|
+
|
325
|
+
it "increments counter past Z for xrefs" do
|
326
|
+
a = IsoDoc::XrefGen::Counter.new("Z")
|
327
|
+
a.increment({})
|
328
|
+
expect(a.print).to eq "AA"
|
329
|
+
a.increment({})
|
330
|
+
expect(a.print).to eq "AB"
|
331
|
+
a = IsoDoc::XrefGen::Counter.new("BZ")
|
332
|
+
a.increment({})
|
333
|
+
expect(a.print).to eq "CA"
|
334
|
+
a.increment({})
|
335
|
+
expect(a.print).to eq "CB"
|
336
|
+
a = IsoDoc::XrefGen::Counter.new("z")
|
337
|
+
a.increment({})
|
338
|
+
expect(a.print).to eq "aa"
|
339
|
+
a.increment({})
|
340
|
+
expect(a.print).to eq "ab"
|
341
|
+
a = IsoDoc::XrefGen::Counter.new("Az")
|
342
|
+
a.increment({})
|
343
|
+
expect(a.print).to eq "Ba"
|
344
|
+
a.increment({})
|
345
|
+
expect(a.print).to eq "Bb"
|
346
|
+
end
|
347
|
+
end
|