asciidoctor-iso 0.0.1
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 +7 -0
- data/.oss-guides.rubocop.yml +1077 -0
- data/.rubocop.yml +15 -0
- data/Gemfile +4 -0
- data/README.adoc +96 -0
- data/asciidoctor-iso.gemspec +44 -0
- data/grammar1.gif +0 -0
- data/grammar2.gif +0 -0
- data/grammar3.gif +0 -0
- data/grammar4.gif +0 -0
- data/lib/asciidoctor-iso.rb +3 -0
- data/lib/asciidoctor/iso/base.rb +145 -0
- data/lib/asciidoctor/iso/blocks.rb +185 -0
- data/lib/asciidoctor/iso/converter.rb +53 -0
- data/lib/asciidoctor/iso/front.rb +80 -0
- data/lib/asciidoctor/iso/inline_anchor.rb +65 -0
- data/lib/asciidoctor/iso/lists.rb +158 -0
- data/lib/asciidoctor/iso/table.rb +53 -0
- data/lib/asciidoctor/iso/utils.rb +224 -0
- data/lib/asciidoctor/iso/validate.rb +37 -0
- data/lib/asciidoctor/iso/validate.rnc +444 -0
- data/lib/asciidoctor/iso/validate.rng +1001 -0
- data/lib/asciidoctor/iso/version.rb +5 -0
- data/spec/examples/rice.adoc +654 -0
- data/spec/examples/rice.html +1805 -0
- data/spec/examples/rice.xml +63 -0
- metadata +268 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require "nokogiri"
|
2
|
+
|
3
|
+
module Asciidoctor
|
4
|
+
module ISO
|
5
|
+
module Validate
|
6
|
+
class << self
|
7
|
+
def title_validate(root)
|
8
|
+
if root.at("//title_en/title_intro").nil? &&
|
9
|
+
!root.at("//title_fr/title_intro").nil?
|
10
|
+
warn "No English Title Intro!"
|
11
|
+
end
|
12
|
+
if !root.at("//title_en/title_intro").nil? &&
|
13
|
+
root.at("//title_fr/title_intro").nil?
|
14
|
+
warn "No French Title Intro!"
|
15
|
+
end
|
16
|
+
if root.at("//title_en/title_part").nil? &&
|
17
|
+
!root.at("//title_fr/title_part").nil?
|
18
|
+
warn "No English Title Part!"
|
19
|
+
end
|
20
|
+
if !root.at("//title_en/title_part").nil? &&
|
21
|
+
root.at("//title_fr/title_part").nil?
|
22
|
+
warn "No French Title Part!"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def validate(doc)
|
27
|
+
filename = File.join(File.dirname(__FILE__), "validate.rng")
|
28
|
+
schema = Nokogiri::XML::RelaxNG(File.read(filename))
|
29
|
+
title_validate(doc.root)
|
30
|
+
schema.validate(doc).each do |error|
|
31
|
+
warn "RELAXNG Validation: #{error.message}"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,444 @@
|
|
1
|
+
start = iso_standard
|
2
|
+
|
3
|
+
iso_standard =
|
4
|
+
element iso-standard {
|
5
|
+
front,
|
6
|
+
middle,
|
7
|
+
back?
|
8
|
+
}
|
9
|
+
|
10
|
+
front =
|
11
|
+
element front {
|
12
|
+
title,
|
13
|
+
documenttype,
|
14
|
+
documentstatus?,
|
15
|
+
id,
|
16
|
+
language,
|
17
|
+
version?,
|
18
|
+
author,
|
19
|
+
foreword,
|
20
|
+
introduction?
|
21
|
+
}
|
22
|
+
|
23
|
+
language =
|
24
|
+
element language {
|
25
|
+
( "en" | "fr" )
|
26
|
+
}
|
27
|
+
|
28
|
+
version =
|
29
|
+
element version {
|
30
|
+
edition?,
|
31
|
+
revdate?,
|
32
|
+
copyright_year?
|
33
|
+
}
|
34
|
+
|
35
|
+
id =
|
36
|
+
element id {
|
37
|
+
documentnumber,
|
38
|
+
tc_documentnumber?,
|
39
|
+
ref_documentnumber?
|
40
|
+
}
|
41
|
+
|
42
|
+
author =
|
43
|
+
element author {
|
44
|
+
technical_committee,
|
45
|
+
subcommittee?,
|
46
|
+
workgroup?,
|
47
|
+
secretariat?
|
48
|
+
}
|
49
|
+
|
50
|
+
documenttype =
|
51
|
+
element documenttype {
|
52
|
+
("international-standard" | "technical-specification" | "technical-report" | "publicly-available-specification" | "international-workshop-agreement" | "guide" )
|
53
|
+
}
|
54
|
+
|
55
|
+
documentstatus =
|
56
|
+
element documentstatus {
|
57
|
+
stage,
|
58
|
+
substage?
|
59
|
+
}
|
60
|
+
|
61
|
+
stage =
|
62
|
+
element stage {
|
63
|
+
("00" | "10" | "20" | "30" | "40" | "50" | "60" | "90" | "95" )
|
64
|
+
}
|
65
|
+
|
66
|
+
substage =
|
67
|
+
element substage {
|
68
|
+
("00" | "20" | "60" | "90" | "92" | "93" | "98" | "99" )
|
69
|
+
}
|
70
|
+
|
71
|
+
documentnumber =
|
72
|
+
element documentnumber {
|
73
|
+
attribute partnumber { text }?,
|
74
|
+
text
|
75
|
+
}
|
76
|
+
|
77
|
+
tc_documentnumber =
|
78
|
+
element tc_documentnumber {
|
79
|
+
text
|
80
|
+
}
|
81
|
+
|
82
|
+
ref_documentnumber =
|
83
|
+
element ref_documentnumber {
|
84
|
+
text
|
85
|
+
}
|
86
|
+
|
87
|
+
technical_committee =
|
88
|
+
element technical_committee {
|
89
|
+
attribute number { text }?,
|
90
|
+
text
|
91
|
+
}
|
92
|
+
|
93
|
+
subcommittee =
|
94
|
+
element subcommittee {
|
95
|
+
attribute number { text }?,
|
96
|
+
text
|
97
|
+
}
|
98
|
+
|
99
|
+
workgroup =
|
100
|
+
element workgroup {
|
101
|
+
attribute number { text }?,
|
102
|
+
text
|
103
|
+
}
|
104
|
+
|
105
|
+
secretariat =
|
106
|
+
element secretariat { text }
|
107
|
+
|
108
|
+
revdate =
|
109
|
+
element revdate { text }
|
110
|
+
|
111
|
+
copyright_year =
|
112
|
+
element copyright_year { text }
|
113
|
+
|
114
|
+
edition =
|
115
|
+
element edition { text }
|
116
|
+
|
117
|
+
title =
|
118
|
+
element title {title_en, title_fr}
|
119
|
+
|
120
|
+
title_en =
|
121
|
+
element en { title_intro?, title_main, title_part? }
|
122
|
+
|
123
|
+
title_fr =
|
124
|
+
element fr { title_intro?, title_main, title_part? }
|
125
|
+
|
126
|
+
title_intro =
|
127
|
+
element title_intro { text }
|
128
|
+
|
129
|
+
title_main =
|
130
|
+
element title_main { text }
|
131
|
+
|
132
|
+
title_part =
|
133
|
+
element title_part {
|
134
|
+
text
|
135
|
+
}
|
136
|
+
|
137
|
+
foreword =
|
138
|
+
element foreword {
|
139
|
+
( para | table | note | formula | warning | ol | ul | dl | figure | quote | sourcecode | review_note )*
|
140
|
+
}
|
141
|
+
|
142
|
+
introduction =
|
143
|
+
element introduction {
|
144
|
+
attribute anchor { xsd:ID }?,
|
145
|
+
( para | table | note | formula | warning | ol | ul | dl | figure | quote | sourcecode | review_note )*,
|
146
|
+
patent_notice?
|
147
|
+
}
|
148
|
+
|
149
|
+
patent_notice =
|
150
|
+
element patent_notice {
|
151
|
+
attribute anchor { xsd:ID }?,
|
152
|
+
para+
|
153
|
+
}
|
154
|
+
|
155
|
+
middle =
|
156
|
+
element middle {
|
157
|
+
scope, norm_ref, terms_defs, clause+
|
158
|
+
}
|
159
|
+
|
160
|
+
scope =
|
161
|
+
element scope {
|
162
|
+
attribute anchor { xsd:ID }?,
|
163
|
+
para+
|
164
|
+
}
|
165
|
+
|
166
|
+
norm_ref =
|
167
|
+
element norm_ref {
|
168
|
+
attribute anchor { xsd:ID }?,
|
169
|
+
# boilerplate
|
170
|
+
para,
|
171
|
+
iso_ref_title*
|
172
|
+
}
|
173
|
+
|
174
|
+
iso_ref_title =
|
175
|
+
element iso_ref_title {
|
176
|
+
attribute anchor { xsd:ID },
|
177
|
+
isocode, (isodate, date_footnote?)?, isotitle
|
178
|
+
}
|
179
|
+
|
180
|
+
isocode =
|
181
|
+
element isocode { text }
|
182
|
+
|
183
|
+
isodate =
|
184
|
+
element isodate { text }
|
185
|
+
|
186
|
+
date_footnote =
|
187
|
+
element date_footnote { text }
|
188
|
+
|
189
|
+
isotitle =
|
190
|
+
element isotitle { text }
|
191
|
+
|
192
|
+
terms_defs =
|
193
|
+
element terms_defs {
|
194
|
+
attribute anchor { xsd:ID }?,
|
195
|
+
# boilerplate
|
196
|
+
para, para, ul,
|
197
|
+
termdef+
|
198
|
+
}
|
199
|
+
|
200
|
+
termdef =
|
201
|
+
element termdef {
|
202
|
+
attribute anchor { xsd:ID }?,
|
203
|
+
term, admitted_term*, termsymbol?, deprecated_term*,
|
204
|
+
termdomain?, para, termnote*, termexample*, termref*
|
205
|
+
}
|
206
|
+
|
207
|
+
term =
|
208
|
+
element term { text }
|
209
|
+
|
210
|
+
admitted_term =
|
211
|
+
element admitted_term { text }
|
212
|
+
|
213
|
+
termsymbol =
|
214
|
+
element termsymbol { stem }
|
215
|
+
|
216
|
+
deprecated_term =
|
217
|
+
element deprecated_term { text }
|
218
|
+
|
219
|
+
termdomain =
|
220
|
+
element termdomain { text }
|
221
|
+
|
222
|
+
termnote =
|
223
|
+
element termnote { (text | xref | eref)* }
|
224
|
+
|
225
|
+
termexample =
|
226
|
+
element termexample { text }
|
227
|
+
|
228
|
+
termref =
|
229
|
+
element termref { xref, (isosection, modification?)? }
|
230
|
+
|
231
|
+
isosection =
|
232
|
+
element isosection { text }
|
233
|
+
|
234
|
+
modification =
|
235
|
+
element modification { text }
|
236
|
+
|
237
|
+
clause =
|
238
|
+
element clause {
|
239
|
+
attribute anchor { xsd:ID }?,
|
240
|
+
tname?,
|
241
|
+
( para | table | note | formula | warning | ol | ul | dl | figure | quote | sourcecode | review_note )*,
|
242
|
+
clause*
|
243
|
+
}
|
244
|
+
|
245
|
+
quote =
|
246
|
+
element quote {
|
247
|
+
attribute anchor { xsd:ID }?,
|
248
|
+
( para | table | note | formula | warning | ol | ul | dl | figure | quote | sourcecode | review_note )*
|
249
|
+
}
|
250
|
+
|
251
|
+
|
252
|
+
back =
|
253
|
+
element back {
|
254
|
+
annex*,
|
255
|
+
bibliography
|
256
|
+
}
|
257
|
+
|
258
|
+
annex =
|
259
|
+
element annex {
|
260
|
+
attribute anchor { xsd:ID }?,
|
261
|
+
tname?,
|
262
|
+
( para | table | note | formula | warning | ol | ul | dl | figure | quote | sourcecode | review_note )*,
|
263
|
+
clause*
|
264
|
+
}
|
265
|
+
|
266
|
+
bibliography =
|
267
|
+
element bibliography {
|
268
|
+
attribute anchor { xsd:ID }?,
|
269
|
+
(iso_ref_title | reference)+
|
270
|
+
}
|
271
|
+
|
272
|
+
reference =
|
273
|
+
element reference { ref, para }
|
274
|
+
|
275
|
+
ref =
|
276
|
+
element ref {
|
277
|
+
attribute anchor { xsd:ID }?,
|
278
|
+
text
|
279
|
+
}
|
280
|
+
|
281
|
+
para =
|
282
|
+
element p {
|
283
|
+
(text | em | eref | strong | stem | sub | sup | tt | xref | fn | br)*
|
284
|
+
}
|
285
|
+
|
286
|
+
figure =
|
287
|
+
element figure {
|
288
|
+
attribute src { text }?,
|
289
|
+
attribute anchor { xsd:ID }?,
|
290
|
+
tname?,
|
291
|
+
dl?,
|
292
|
+
figure*
|
293
|
+
}
|
294
|
+
|
295
|
+
sourcecode =
|
296
|
+
element sourcecode {
|
297
|
+
attribute anchor { xsd:ID }?,
|
298
|
+
tname?,
|
299
|
+
( text | callout )*,
|
300
|
+
colist?
|
301
|
+
}
|
302
|
+
|
303
|
+
review_note =
|
304
|
+
element review_note {
|
305
|
+
attribute color { text }?,
|
306
|
+
text
|
307
|
+
}
|
308
|
+
|
309
|
+
callout =
|
310
|
+
element callout {
|
311
|
+
xsd:ID
|
312
|
+
}
|
313
|
+
|
314
|
+
colist =
|
315
|
+
element colist {
|
316
|
+
annotation+
|
317
|
+
}
|
318
|
+
|
319
|
+
annotation =
|
320
|
+
element annotation {
|
321
|
+
attribute anchor { xsd:ID }?,
|
322
|
+
text
|
323
|
+
}
|
324
|
+
|
325
|
+
fn =
|
326
|
+
element fn {
|
327
|
+
(text | em | eref | stem | strong | sub | sup | tt | xref | br)*
|
328
|
+
}
|
329
|
+
|
330
|
+
ol =
|
331
|
+
element ol {
|
332
|
+
attribute type { text },
|
333
|
+
li+
|
334
|
+
}
|
335
|
+
|
336
|
+
ul =
|
337
|
+
element ul { li+ }
|
338
|
+
|
339
|
+
li =
|
340
|
+
element li {
|
341
|
+
( para | table | note | formula | warning | ol | ul | dl | quote | sourcecode | review_note )+
|
342
|
+
}
|
343
|
+
|
344
|
+
dl =
|
345
|
+
element dl {
|
346
|
+
(dt, dd)+
|
347
|
+
}
|
348
|
+
|
349
|
+
dt =
|
350
|
+
element dt {
|
351
|
+
(text | em | eref | stem | strong | sub | sup | tt | xref | br)
|
352
|
+
}
|
353
|
+
|
354
|
+
dd =
|
355
|
+
element dd {
|
356
|
+
( para | table | note | formula | warning | ol | ul | dl | quote | sourcecode | review_note )*
|
357
|
+
}
|
358
|
+
|
359
|
+
note =
|
360
|
+
element note { para+ }
|
361
|
+
|
362
|
+
warning =
|
363
|
+
element warning { para+ }
|
364
|
+
|
365
|
+
formula =
|
366
|
+
element formula {
|
367
|
+
attribute anchor { xsd:ID }?,
|
368
|
+
stem,
|
369
|
+
dl?
|
370
|
+
}
|
371
|
+
|
372
|
+
xref =
|
373
|
+
element xref {
|
374
|
+
attribute format { "footnote" | "inline" }?,
|
375
|
+
attribute target { text },
|
376
|
+
( text | iso_ref )
|
377
|
+
}
|
378
|
+
|
379
|
+
iso_ref =
|
380
|
+
element iso_ref { isocode, (isodate, (isosection?)?)? }
|
381
|
+
|
382
|
+
eref =
|
383
|
+
element eref {
|
384
|
+
attribute target { text },
|
385
|
+
text
|
386
|
+
}
|
387
|
+
|
388
|
+
br =
|
389
|
+
element br { empty }
|
390
|
+
|
391
|
+
em =
|
392
|
+
element em { text }
|
393
|
+
|
394
|
+
strong =
|
395
|
+
element strong { text }
|
396
|
+
|
397
|
+
stem =
|
398
|
+
element stem { text }
|
399
|
+
|
400
|
+
sub =
|
401
|
+
element sub { text }
|
402
|
+
|
403
|
+
sup =
|
404
|
+
element sup { text }
|
405
|
+
|
406
|
+
tt =
|
407
|
+
element tt { text }
|
408
|
+
|
409
|
+
table =
|
410
|
+
element table {
|
411
|
+
attribute anchor { xsd:ID }?,
|
412
|
+
tname?, thead?, tbody, tfoot?, note*
|
413
|
+
}
|
414
|
+
|
415
|
+
tname =
|
416
|
+
element name { text }
|
417
|
+
|
418
|
+
thead =
|
419
|
+
element thead { tr+ }
|
420
|
+
|
421
|
+
tbody =
|
422
|
+
element tbody { tr+ }
|
423
|
+
|
424
|
+
tfoot =
|
425
|
+
element tfoot { tr+ }
|
426
|
+
|
427
|
+
tr =
|
428
|
+
element tr { (td | th)+ }
|
429
|
+
|
430
|
+
th =
|
431
|
+
element th {
|
432
|
+
attribute colspan { text }?,
|
433
|
+
attribute rowspan { text }?,
|
434
|
+
attribute align { text }?,
|
435
|
+
(text | em | eref | stem | strong | sub | sup | tt | xref | fn | br | para)*
|
436
|
+
}
|
437
|
+
|
438
|
+
td =
|
439
|
+
element td {
|
440
|
+
attribute colspan { text }?,
|
441
|
+
attribute rowspan { text }?,
|
442
|
+
attribute align { text }?,
|
443
|
+
(text | em | eref | stem | strong | sub | sup | tt | xref | fn | br | para)*
|
444
|
+
}
|