asciidoctor-m3d 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,51 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "asciidoctor/m3d/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "asciidoctor-m3d"
7
+ spec.version = Asciidoctor::M3d::VERSION
8
+ spec.authors = ["Ribose Inc."]
9
+ spec.email = ["open.source@ribose.com"]
10
+
11
+ spec.summary = "asciidoctor-m3d lets you write M3AAWG Documents (M3D) in AsciiDoc."
12
+ spec.description = <<~DESCRIPTION
13
+ asciidoctor-m3d lets you write M3AAWG Documents (M3D) in AsciiDoc syntax.
14
+
15
+ This gem is in active development.
16
+ DESCRIPTION
17
+
18
+ spec.homepage = "https://github.com/riboseinc/asciidoctor-m3d"
19
+ spec.license = "MIT"
20
+
21
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
22
+ f.match(%r{^(test|spec|features)/})
23
+ end
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "asciidoctor", "~> 1.5.7"
29
+ spec.add_dependency "asciimath"
30
+ spec.add_dependency "htmlentities", "~> 4.3.4"
31
+ spec.add_dependency "image_size"
32
+ spec.add_dependency "mime-types"
33
+ spec.add_dependency "nokogiri"
34
+ spec.add_dependency "ruby-jing"
35
+ spec.add_dependency "ruby-xslt"
36
+ spec.add_dependency "thread_safe"
37
+ spec.add_dependency "uuidtools"
38
+ spec.add_dependency "asciidoctor-iso", ">= 0.7.5"
39
+ spec.add_dependency "isodoc"
40
+
41
+ spec.add_development_dependency "bundler", "~> 1.15"
42
+ spec.add_development_dependency "byebug", "~> 9.1"
43
+ spec.add_development_dependency "equivalent-xml", "~> 0.6"
44
+ spec.add_development_dependency "guard", "~> 2.14"
45
+ spec.add_development_dependency "guard-rspec", "~> 4.7"
46
+ spec.add_development_dependency "rake", "~> 12.0"
47
+ spec.add_development_dependency "rspec", "~> 3.6"
48
+ spec.add_development_dependency "rubocop", "~> 0.50"
49
+ spec.add_development_dependency "simplecov", "~> 0.15"
50
+ spec.add_development_dependency "timecop", "~> 0.9"
51
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "asciidoctor/m3d"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/rspec ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file was generated by Bundler.
4
+ #
5
+ # The application 'rspec' is installed as part of a gem, and
6
+ # this file is here to facilitate running it.
7
+ #
8
+
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path(
11
+ "../../Gemfile", Pathname.new(__FILE__).realpath
12
+ )
13
+
14
+ require "rubygems"
15
+ require "bundler/setup"
16
+
17
+ load Gem.bin_path("rspec-core", "rspec")
18
+
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ require "asciidoctor" unless defined? Asciidoctor::Converter
2
+ require_relative "asciidoctor/m3d/converter"
3
+ require_relative "asciidoctor/m3d/m3dconvert"
4
+ require_relative "asciidoctor/m3d/version"
@@ -0,0 +1,7 @@
1
+ require "asciidoctor/m3d/version"
2
+
3
+ module Asciidoctor
4
+ module M3d
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,602 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ instantiations of this grammar may replace leaf strings
4
+ with more elaborated types; e.g. title (text) replaced with
5
+ title-main, title-intro, title-part; type replaced with
6
+ enum.
7
+
8
+ some renaming at leaf nodes is permissible
9
+
10
+ obligations can change both from optional to mandatory,
11
+ and from mandatory to optional; optional elements may
12
+ be omitted; freely positioned alternatives may be replaced
13
+ with strict ordering
14
+
15
+ DO NOT introduce a namespace here. We do not want a distinct namespace
16
+ for these elements, and a distinct namespace for any grammar inheriting
17
+ these elements; we just want one namespace for any child grammars
18
+ of this.
19
+ -->
20
+ <grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
21
+ <define name="status">
22
+ <element name="status">
23
+ <ref name="LocalizedString"/>
24
+ </element>
25
+ </define>
26
+ <define name="language">
27
+ <element name="language">
28
+ <text/>
29
+ </element>
30
+ </define>
31
+ <define name="script">
32
+ <a:documentation>ISO-639</a:documentation>
33
+ <element name="script">
34
+ <text/>
35
+ </element>
36
+ </define>
37
+ <define name="edition">
38
+ <a:documentation>ISO-15924: Latn</a:documentation>
39
+ <element name="edition">
40
+ <data type="int"/>
41
+ </element>
42
+ </define>
43
+ <define name="LocalizedString">
44
+ <optional>
45
+ <!-- multiple languages and scripts possible: comma delimit them if so -->
46
+ <attribute name="language"/>
47
+ </optional>
48
+ <optional>
49
+ <attribute name="script"/>
50
+ </optional>
51
+ <text/>
52
+ </define>
53
+ <!--
54
+ Unlike UML, change type to format: type is overloaded
55
+ Would be need if plain were default value and could omit the attribute
56
+ Added LocalizedStringOrXsAny
57
+ -->
58
+ <define name="FormattedString">
59
+ <optional>
60
+ <!-- attribute format { ( "plain" | "html" | "docbook" | "tei" | "asciidoc" | "markdown" ) }?, -->
61
+ <attribute name="format">
62
+ <choice>
63
+ <value>text/plain</value>
64
+ <value>text/html</value>
65
+ <value>application/docbook+xml</value>
66
+ <value>application/tei+xml</value>
67
+ <value>text/x-asciidoc</value>
68
+ <value>text/markdown</value>
69
+ <value>application/x-isodoc+xml</value>
70
+ <text/>
71
+ </choice>
72
+ </attribute>
73
+ </optional>
74
+ <ref name="LocalizedStringOrXsAny"/>
75
+ </define>
76
+ <define name="LocalizedStringOrXsAny">
77
+ <optional>
78
+ <!-- multiple languages and scripts possible: comma delimit them if so -->
79
+ <attribute name="language"/>
80
+ </optional>
81
+ <optional>
82
+ <attribute name="script"/>
83
+ </optional>
84
+ <oneOrMore>
85
+ <choice>
86
+ <text/>
87
+ <ref name="AnyElement"/>
88
+ </choice>
89
+ </oneOrMore>
90
+ </define>
91
+ <define name="contributor">
92
+ <element name="contributor">
93
+ <zeroOrMore>
94
+ <ref name="role"/>
95
+ </zeroOrMore>
96
+ <ref name="ContributorInfo"/>
97
+ </element>
98
+ </define>
99
+ <define name="role">
100
+ <element name="role">
101
+ <optional>
102
+ <attribute name="type">
103
+ <choice>
104
+ <value>author</value>
105
+ <value>edition</value>
106
+ <value>publisher</value>
107
+ <text/>
108
+ </choice>
109
+ </attribute>
110
+ </optional>
111
+ <zeroOrMore>
112
+ <ref name="roledescription"/>
113
+ </zeroOrMore>
114
+ </element>
115
+ </define>
116
+ <define name="ContributorInfo">
117
+ <choice>
118
+ <ref name="person"/>
119
+ <ref name="organization"/>
120
+ </choice>
121
+ </define>
122
+ <define name="roledescription">
123
+ <element name="description">
124
+ <ref name="FormattedString"/>
125
+ </element>
126
+ </define>
127
+ <define name="person">
128
+ <element name="person">
129
+ <optional>
130
+ <ref name="fullname"/>
131
+ </optional>
132
+ <zeroOrMore>
133
+ <ref name="affiliation"/>
134
+ </zeroOrMore>
135
+ <zeroOrMore>
136
+ <ref name="person-identifier"/>
137
+ </zeroOrMore>
138
+ <zeroOrMore>
139
+ <ref name="contact"/>
140
+ </zeroOrMore>
141
+ <optional>
142
+ <ref name="uri"/>
143
+ </optional>
144
+ </element>
145
+ </define>
146
+ <define name="fullname">
147
+ <element name="name">
148
+ <zeroOrMore>
149
+ <ref name="prefix"/>
150
+ </zeroOrMore>
151
+ <zeroOrMore>
152
+ <ref name="forename"/>
153
+ </zeroOrMore>
154
+ <zeroOrMore>
155
+ <ref name="initial"/>
156
+ </zeroOrMore>
157
+ <ref name="surname"/>
158
+ <zeroOrMore>
159
+ <ref name="addition"/>
160
+ </zeroOrMore>
161
+ </element>
162
+ </define>
163
+ <define name="prefix">
164
+ <element name="prefix">
165
+ <ref name="LocalizedString"/>
166
+ </element>
167
+ </define>
168
+ <define name="initial">
169
+ <element name="initial">
170
+ <ref name="LocalizedString"/>
171
+ </element>
172
+ </define>
173
+ <define name="addition">
174
+ <element name="addition">
175
+ <ref name="LocalizedString"/>
176
+ </element>
177
+ </define>
178
+ <define name="surname">
179
+ <element name="surname">
180
+ <ref name="LocalizedString"/>
181
+ </element>
182
+ </define>
183
+ <define name="forename">
184
+ <element name="forename">
185
+ <ref name="LocalizedString"/>
186
+ </element>
187
+ </define>
188
+ <define name="affiliation">
189
+ <element name="affiliation">
190
+ <optional>
191
+ <ref name="affiliationname"/>
192
+ </optional>
193
+ <zeroOrMore>
194
+ <ref name="affiliationdescription"/>
195
+ </zeroOrMore>
196
+ <ref name="organization"/>
197
+ </element>
198
+ </define>
199
+ <define name="affiliationname">
200
+ <element name="name">
201
+ <ref name="LocalizedString"/>
202
+ </element>
203
+ </define>
204
+ <define name="affiliationdescription">
205
+ <element name="description">
206
+ <ref name="FormattedString"/>
207
+ </element>
208
+ </define>
209
+ <define name="organization">
210
+ <element name="organization">
211
+ <ref name="orgname"/>
212
+ <optional>
213
+ <ref name="abbreviation"/>
214
+ </optional>
215
+ <optional>
216
+ <ref name="uri"/>
217
+ </optional>
218
+ <zeroOrMore>
219
+ <ref name="org-identifier"/>
220
+ </zeroOrMore>
221
+ <zeroOrMore>
222
+ <ref name="contact"/>
223
+ </zeroOrMore>
224
+ </element>
225
+ </define>
226
+ <define name="orgname">
227
+ <element name="name">
228
+ <ref name="LocalizedString"/>
229
+ </element>
230
+ </define>
231
+ <define name="abbreviation">
232
+ <element name="abbreviation">
233
+ <ref name="LocalizedString"/>
234
+ </element>
235
+ </define>
236
+ <define name="uri">
237
+ <element name="uri">
238
+ <data type="anyURI"/>
239
+ </element>
240
+ </define>
241
+ <!-- TODO may change -->
242
+ <define name="contact">
243
+ <choice>
244
+ <ref name="address"/>
245
+ <ref name="phone"/>
246
+ <ref name="email"/>
247
+ <ref name="uri"/>
248
+ </choice>
249
+ </define>
250
+ <define name="phone">
251
+ <element name="phone">
252
+ <text/>
253
+ </element>
254
+ </define>
255
+ <define name="email">
256
+ <element name="email">
257
+ <text/>
258
+ </element>
259
+ </define>
260
+ <define name="address">
261
+ <element name="address">
262
+ <oneOrMore>
263
+ <!-- iso191606 TODO -->
264
+ <ref name="street"/>
265
+ </oneOrMore>
266
+ <ref name="city"/>
267
+ <optional>
268
+ <ref name="state"/>
269
+ </optional>
270
+ <ref name="country"/>
271
+ <optional>
272
+ <ref name="postcode"/>
273
+ </optional>
274
+ </element>
275
+ </define>
276
+ <define name="street">
277
+ <element name="street">
278
+ <text/>
279
+ </element>
280
+ </define>
281
+ <define name="city">
282
+ <element name="city">
283
+ <text/>
284
+ </element>
285
+ </define>
286
+ <define name="state">
287
+ <element name="state">
288
+ <text/>
289
+ </element>
290
+ </define>
291
+ <define name="country">
292
+ <element name="country">
293
+ <text/>
294
+ </element>
295
+ </define>
296
+ <define name="postcode">
297
+ <element name="postcode">
298
+ <text/>
299
+ </element>
300
+ </define>
301
+ <define name="person-identifier">
302
+ <element name="identifier">
303
+ <attribute name="type">
304
+ <choice>
305
+ <value>isni</value>
306
+ <value>uri</value>
307
+ </choice>
308
+ </attribute>
309
+ <text/>
310
+ </element>
311
+ </define>
312
+ <define name="org-identifier">
313
+ <element name="identifier">
314
+ <attribute name="type">
315
+ <choice>
316
+ <value>orcid</value>
317
+ <value>uri</value>
318
+ </choice>
319
+ </attribute>
320
+ <text/>
321
+ </element>
322
+ </define>
323
+ <define name="citation">
324
+ <element name="citation">
325
+ <ref name="CitationType"/>
326
+ </element>
327
+ </define>
328
+ <define name="CitationType">
329
+ <attribute name="bibitemid">
330
+ <data type="IDREF"/>
331
+ </attribute>
332
+ <zeroOrMore>
333
+ <ref name="locality"/>
334
+ </zeroOrMore>
335
+ <optional>
336
+ <ref name="date"/>
337
+ </optional>
338
+ </define>
339
+ <define name="date">
340
+ <element name="date">
341
+ <choice>
342
+ <data type="gYear"/>
343
+ <data type="date"/>
344
+ </choice>
345
+ </element>
346
+ </define>
347
+ <define name="locality">
348
+ <element name="locality">
349
+ <!-- attribute type { ( "section" | "clause" | "part" | "paragraph" | "chapter" | "page" | "whole" | "table" | "annex" | "figure" | "note" | "example" | ("locality:", text) ) }, -->
350
+ <attribute name="type">
351
+ <ref name="LocalityType"/>
352
+ </attribute>
353
+ <ref name="referenceFrom"/>
354
+ <optional>
355
+ <ref name="referenceTo"/>
356
+ </optional>
357
+ </element>
358
+ </define>
359
+ <define name="LocalityType">
360
+ <data type="string">
361
+ <param name="pattern">section|clause|part|paragraph|chapter|page|whole|table|annex|figure|note|example|locality:[a-zA-Z0-9_]+</param>
362
+ </data>
363
+ </define>
364
+ <define name="referenceFrom">
365
+ <element name="referenceFrom">
366
+ <text/>
367
+ </element>
368
+ </define>
369
+ <define name="referenceTo">
370
+ <element name="referenceTo">
371
+ <text/>
372
+ </element>
373
+ </define>
374
+ <!-- unlike UML, has id attribute; that results from including bibitem in a docmodel -->
375
+ <define name="bibitem">
376
+ <element name="bibitem">
377
+ <attribute name="id">
378
+ <data type="ID"/>
379
+ </attribute>
380
+ <ref name="BibliographicItem"/>
381
+ </element>
382
+ </define>
383
+ <define name="bibitem_no_id">
384
+ <element name="bibitem">
385
+ <ref name="BibliographicItem"/>
386
+ </element>
387
+ </define>
388
+ <define name="BibItemType" combine="choice">
389
+ <choice>
390
+ <value>article</value>
391
+ <value>book</value>
392
+ <value>booklet</value>
393
+ <value>conference</value>
394
+ <value>manual</value>
395
+ <value>proceedings</value>
396
+ <value>presentation</value>
397
+ <value>thesis</value>
398
+ <value>techreport</value>
399
+ <value>standard</value>
400
+ <value>unpublished</value>
401
+ </choice>
402
+ </define>
403
+ <define name="BibliographicItem">
404
+ <optional>
405
+ <attribute name="type">
406
+ <ref name="BibItemType"/>
407
+ </attribute>
408
+ </optional>
409
+ <choice>
410
+ <oneOrMore>
411
+ <ref name="btitle"/>
412
+ </oneOrMore>
413
+ <ref name="formattedref"/>
414
+ </choice>
415
+ <zeroOrMore>
416
+ <ref name="bsource"/>
417
+ </zeroOrMore>
418
+ <zeroOrMore>
419
+ <ref name="docidentifier"/>
420
+ </zeroOrMore>
421
+ <zeroOrMore>
422
+ <ref name="bdate"/>
423
+ </zeroOrMore>
424
+ <zeroOrMore>
425
+ <ref name="contributor"/>
426
+ </zeroOrMore>
427
+ <optional>
428
+ <ref name="edition"/>
429
+ </optional>
430
+ <zeroOrMore>
431
+ <ref name="biblionote"/>
432
+ </zeroOrMore>
433
+ <zeroOrMore>
434
+ <ref name="language"/>
435
+ </zeroOrMore>
436
+ <zeroOrMore>
437
+ <ref name="script"/>
438
+ </zeroOrMore>
439
+ <optional>
440
+ <ref name="abstract"/>
441
+ </optional>
442
+ <optional>
443
+ <ref name="status"/>
444
+ </optional>
445
+ <optional>
446
+ <ref name="copyright"/>
447
+ </optional>
448
+ <zeroOrMore>
449
+ <ref name="docrelation"/>
450
+ </zeroOrMore>
451
+ </define>
452
+ <define name="btitle">
453
+ <element name="title">
454
+ <ref name="FormattedString"/>
455
+ </element>
456
+ </define>
457
+ <define name="bsource">
458
+ <element name="source">
459
+ <ref name="TypedUri"/>
460
+ </element>
461
+ </define>
462
+ <define name="formattedref">
463
+ <element name="formattedref">
464
+ <ref name="FormattedString"/>
465
+ </element>
466
+ </define>
467
+ <define name="link">
468
+ <element name="link">
469
+ <ref name="TypedUri"/>
470
+ </element>
471
+ </define>
472
+ <define name="TypedUri">
473
+ <optional>
474
+ <attribute name="type"/>
475
+ </optional>
476
+ <data type="anyURI"/>
477
+ </define>
478
+ <define name="bdate">
479
+ <element name="date">
480
+ <attribute name="type">
481
+ <choice>
482
+ <value>published</value>
483
+ <value>accessed</value>
484
+ <value>created</value>
485
+ <value>implemented</value>
486
+ <value>obsoleted</value>
487
+ <value>confirmed</value>
488
+ <value>updated</value>
489
+ <value>issued</value>
490
+ </choice>
491
+ </attribute>
492
+ <ref name="bfrom"/>
493
+ <optional>
494
+ <ref name="bto"/>
495
+ </optional>
496
+ </element>
497
+ </define>
498
+ <define name="bfrom">
499
+ <element name="from">
500
+ <choice>
501
+ <data type="gYear"/>
502
+ <data type="date"/>
503
+ </choice>
504
+ </element>
505
+ </define>
506
+ <define name="bto">
507
+ <element name="to">
508
+ <choice>
509
+ <data type="gYear"/>
510
+ <data type="date"/>
511
+ </choice>
512
+ </element>
513
+ </define>
514
+ <define name="docidentifier">
515
+ <element name="docidentifier">
516
+ <optional>
517
+ <attribute name="type"/>
518
+ </optional>
519
+ <text/>
520
+ </element>
521
+ </define>
522
+ <define name="biblionote">
523
+ <element name="note">
524
+ <ref name="FormattedString"/>
525
+ </element>
526
+ </define>
527
+ <define name="abstract">
528
+ <element name="abstract">
529
+ <ref name="FormattedString"/>
530
+ </element>
531
+ </define>
532
+ <define name="copyright">
533
+ <element name="copyright">
534
+ <ref name="from"/>
535
+ <optional>
536
+ <ref name="to"/>
537
+ </optional>
538
+ <ref name="owner"/>
539
+ </element>
540
+ </define>
541
+ <define name="from">
542
+ <element name="from">
543
+ <data type="gYear"/>
544
+ </element>
545
+ </define>
546
+ <define name="to">
547
+ <element name="to">
548
+ <data type="gYear"/>
549
+ </element>
550
+ </define>
551
+ <define name="owner">
552
+ <element name="owner">
553
+ <ref name="ContributorInfo"/>
554
+ </element>
555
+ </define>
556
+ <define name="docrelation">
557
+ <element name="relation">
558
+ <attribute name="type">
559
+ <choice>
560
+ <value>parent</value>
561
+ <value>child</value>
562
+ <value>obsoletes</value>
563
+ <value>updates</value>
564
+ <value>updatedBy</value>
565
+ <value>complements</value>
566
+ <value>derivedFrom</value>
567
+ <value>adoptedFrom</value>
568
+ <value>equivalent</value>
569
+ <value>identical</value>
570
+ <value>nonequivalent</value>
571
+ </choice>
572
+ </attribute>
573
+ <element name="bibitem">
574
+ <ref name="BibliographicItem"/>
575
+ </element>
576
+ <zeroOrMore>
577
+ <ref name="locality"/>
578
+ </zeroOrMore>
579
+ </element>
580
+ </define>
581
+ <!--
582
+ Anycontents = mixed {
583
+ https://github.com/relaxng/jing-trang/issues/211
584
+ https://lists.oasis-open.org/archives/office/200808/msg00024.html
585
+ https://lists.oasis-open.org/archives/office/200808/msg00099.html
586
+ For this to work, we will actually strip any attributes in the Anycontents before
587
+ passing it for validation. Horrible I know, but there are no good alternatives
588
+ that also allow us to do grammar inheritance
589
+ (attribute * { text } | Any)*
590
+ Any*
591
+ }
592
+ -->
593
+ <define name="AnyElement">
594
+ <element>
595
+ <anyName/>
596
+ <choice>
597
+ <text/>
598
+ <ref name="AnyElement"/>
599
+ </choice>
600
+ </element>
601
+ </define>
602
+ </grammar>