asciidoctor-iso 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +9 -3
- data/README.adoc +14 -0
- data/asciidoctor-iso.gemspec +1 -0
- data/lib/asciidoctor/iso/base.rb +26 -4
- data/lib/asciidoctor/iso/biblio.rng +584 -0
- data/lib/asciidoctor/iso/cleanup.rb +23 -0
- data/lib/asciidoctor/iso/cleanup_block.rb +0 -83
- data/lib/asciidoctor/iso/cleanup_footnotes.rb +96 -0
- data/lib/asciidoctor/iso/front.rb +7 -0
- data/lib/asciidoctor/iso/html/header.html +3 -3
- data/lib/asciidoctor/iso/html/{htmlstyle.css → htmlstyle.scss} +2 -2
- data/lib/asciidoctor/iso/html/{isodoc.css → isodoc.scss} +69 -107
- data/lib/asciidoctor/iso/html/{wordstyle.css → wordstyle.scss} +123 -125
- data/lib/asciidoctor/iso/isodoc.rng +10 -562
- data/lib/asciidoctor/iso/isostandard.rng +133 -69
- data/lib/asciidoctor/iso/lists.rb +2 -2
- data/lib/asciidoctor/iso/section.rb +2 -2
- data/lib/asciidoctor/iso/validate_section.rb +10 -5
- data/lib/asciidoctor/iso/version.rb +1 -1
- data/spec/asciidoctor-iso/base_spec.rb +69 -1
- data/spec/asciidoctor-iso/section_spec.rb +23 -17
- data/spec/asciidoctor-iso/validate_spec.rb +1 -0
- data/spec/examples/rice.doc +4971 -4941
- data/spec/examples/rice.html +567 -858
- data/spec/examples/rice.xml +175 -175
- metadata +21 -5
@@ -17,20 +17,6 @@
|
|
17
17
|
<value>Latn</value>
|
18
18
|
</element>
|
19
19
|
</define>
|
20
|
-
<!-- draft into isodoc? To replace version/version? -->
|
21
|
-
<define name="version">
|
22
|
-
<element name="version">
|
23
|
-
<optional>
|
24
|
-
<ref name="edition"/>
|
25
|
-
</optional>
|
26
|
-
<optional>
|
27
|
-
<ref name="revision-date"/>
|
28
|
-
</optional>
|
29
|
-
<optional>
|
30
|
-
<ref name="draft"/>
|
31
|
-
</optional>
|
32
|
-
</element>
|
33
|
-
</define>
|
34
20
|
<!-- add type to docidentifier in isodoc? -->
|
35
21
|
<define name="docidentifier">
|
36
22
|
<element name="docidentifier">
|
@@ -128,9 +114,9 @@
|
|
128
114
|
<optional>
|
129
115
|
<ref name="editorialgroup"/>
|
130
116
|
</optional>
|
131
|
-
<
|
117
|
+
<zeroOrMore>
|
132
118
|
<ref name="ics"/>
|
133
|
-
</
|
119
|
+
</zeroOrMore>
|
134
120
|
</define>
|
135
121
|
<define name="BibData">
|
136
122
|
<optional>
|
@@ -182,9 +168,9 @@
|
|
182
168
|
<ref name="docrelation"/>
|
183
169
|
</zeroOrMore>
|
184
170
|
<ref name="editorialgroup"/>
|
185
|
-
<
|
171
|
+
<zeroOrMore>
|
186
172
|
<ref name="ics"/>
|
187
|
-
</
|
173
|
+
</zeroOrMore>
|
188
174
|
</define>
|
189
175
|
<define name="bfrom">
|
190
176
|
<element name="from">
|
@@ -213,6 +199,9 @@
|
|
213
199
|
<optional>
|
214
200
|
<ref name="substage"/>
|
215
201
|
</optional>
|
202
|
+
<optional>
|
203
|
+
<ref name="iteration"/>
|
204
|
+
</optional>
|
216
205
|
</group>
|
217
206
|
</choice>
|
218
207
|
</element>
|
@@ -236,9 +225,12 @@
|
|
236
225
|
<define name="sections">
|
237
226
|
<element name="sections">
|
238
227
|
<ref name="clause"/>
|
239
|
-
<
|
228
|
+
<choice>
|
229
|
+
<ref name="term-clause"/>
|
230
|
+
<ref name="terms"/>
|
231
|
+
</choice>
|
240
232
|
<optional>
|
241
|
-
<ref name="
|
233
|
+
<ref name="definitions"/>
|
242
234
|
</optional>
|
243
235
|
<oneOrMore>
|
244
236
|
<ref name="clause"/>
|
@@ -276,6 +268,42 @@
|
|
276
268
|
</oneOrMore>
|
277
269
|
</choice>
|
278
270
|
</define>
|
271
|
+
<define name="Clause-Section">
|
272
|
+
<optional>
|
273
|
+
<attribute name="id">
|
274
|
+
<data type="ID"/>
|
275
|
+
</attribute>
|
276
|
+
</optional>
|
277
|
+
<optional>
|
278
|
+
<attribute name="inline-header">
|
279
|
+
<data type="boolean"/>
|
280
|
+
</attribute>
|
281
|
+
</optional>
|
282
|
+
<optional>
|
283
|
+
<attribute name="obligation">
|
284
|
+
<choice>
|
285
|
+
<value>normative</value>
|
286
|
+
<value>informative</value>
|
287
|
+
</choice>
|
288
|
+
</attribute>
|
289
|
+
</optional>
|
290
|
+
<optional>
|
291
|
+
<ref name="section-title"/>
|
292
|
+
</optional>
|
293
|
+
<choice>
|
294
|
+
<group>
|
295
|
+
<oneOrMore>
|
296
|
+
<ref name="BasicBlock"/>
|
297
|
+
</oneOrMore>
|
298
|
+
<zeroOrMore>
|
299
|
+
<ref name="note"/>
|
300
|
+
</zeroOrMore>
|
301
|
+
</group>
|
302
|
+
<oneOrMore>
|
303
|
+
<ref name="clause-subsection"/>
|
304
|
+
</oneOrMore>
|
305
|
+
</choice>
|
306
|
+
</define>
|
279
307
|
<define name="references">
|
280
308
|
<element name="references">
|
281
309
|
<optional>
|
@@ -302,8 +330,8 @@
|
|
302
330
|
</zeroOrMore>
|
303
331
|
</element>
|
304
332
|
</define>
|
305
|
-
<define name="
|
306
|
-
<element name="
|
333
|
+
<define name="definitions">
|
334
|
+
<element name="definitions">
|
307
335
|
<optional>
|
308
336
|
<attribute name="id">
|
309
337
|
<data type="ID"/>
|
@@ -338,9 +366,6 @@
|
|
338
366
|
<optional>
|
339
367
|
<ref name="section-title"/>
|
340
368
|
</optional>
|
341
|
-
<zeroOrMore>
|
342
|
-
<ref name="termdocsource"/>
|
343
|
-
</zeroOrMore>
|
344
369
|
<choice>
|
345
370
|
<oneOrMore>
|
346
371
|
<ref name="term"/>
|
@@ -350,7 +375,7 @@
|
|
350
375
|
<ref name="terms"/>
|
351
376
|
</zeroOrMore>
|
352
377
|
<optional>
|
353
|
-
<ref name="
|
378
|
+
<ref name="definitions"/>
|
354
379
|
</optional>
|
355
380
|
</group>
|
356
381
|
</choice>
|
@@ -594,42 +619,6 @@
|
|
594
619
|
<ref name="paragraph"/>
|
595
620
|
</element>
|
596
621
|
</define>
|
597
|
-
<define name="Clause-Section">
|
598
|
-
<optional>
|
599
|
-
<attribute name="id">
|
600
|
-
<data type="ID"/>
|
601
|
-
</attribute>
|
602
|
-
</optional>
|
603
|
-
<optional>
|
604
|
-
<attribute name="inline-header">
|
605
|
-
<data type="boolean"/>
|
606
|
-
</attribute>
|
607
|
-
</optional>
|
608
|
-
<optional>
|
609
|
-
<attribute name="obligation">
|
610
|
-
<choice>
|
611
|
-
<value>normative</value>
|
612
|
-
<value>informative</value>
|
613
|
-
</choice>
|
614
|
-
</attribute>
|
615
|
-
</optional>
|
616
|
-
<optional>
|
617
|
-
<ref name="section-title"/>
|
618
|
-
</optional>
|
619
|
-
<choice>
|
620
|
-
<group>
|
621
|
-
<oneOrMore>
|
622
|
-
<ref name="BasicBlock"/>
|
623
|
-
</oneOrMore>
|
624
|
-
<zeroOrMore>
|
625
|
-
<ref name="note"/>
|
626
|
-
</zeroOrMore>
|
627
|
-
</group>
|
628
|
-
<oneOrMore>
|
629
|
-
<ref name="clause-subsection"/>
|
630
|
-
</oneOrMore>
|
631
|
-
</choice>
|
632
|
-
</define>
|
633
622
|
</include>
|
634
623
|
<!-- end overrides -->
|
635
624
|
<!--
|
@@ -642,6 +631,9 @@
|
|
642
631
|
<optional>
|
643
632
|
<ref name="version"/>
|
644
633
|
</optional>
|
634
|
+
<zeroOrMore>
|
635
|
+
<ref name="termdocsource"/>
|
636
|
+
</zeroOrMore>
|
645
637
|
<ref name="foreword"/>
|
646
638
|
<optional>
|
647
639
|
<ref name="introduction"/>
|
@@ -653,7 +645,10 @@
|
|
653
645
|
<ref name="annex"/>
|
654
646
|
</zeroOrMore>
|
655
647
|
<oneOrMore>
|
656
|
-
<
|
648
|
+
<choice>
|
649
|
+
<ref name="references"/>
|
650
|
+
<ref name="reference-clause"/>
|
651
|
+
</choice>
|
657
652
|
</oneOrMore>
|
658
653
|
</element>
|
659
654
|
</define>
|
@@ -691,11 +686,6 @@
|
|
691
686
|
<ref name="Content-Section"/>
|
692
687
|
</element>
|
693
688
|
</define>
|
694
|
-
<define name="draft">
|
695
|
-
<element name="draft">
|
696
|
-
<text/>
|
697
|
-
</element>
|
698
|
-
</define>
|
699
689
|
<define name="stage">
|
700
690
|
<element name="stage">
|
701
691
|
<choice>
|
@@ -725,6 +715,11 @@
|
|
725
715
|
</choice>
|
726
716
|
</element>
|
727
717
|
</define>
|
718
|
+
<define name="iteration">
|
719
|
+
<element name="iteration">
|
720
|
+
<data type="int"/>
|
721
|
+
</element>
|
722
|
+
</define>
|
728
723
|
<define name="documentnumber">
|
729
724
|
<element name="project-number">
|
730
725
|
<optional>
|
@@ -838,7 +833,7 @@
|
|
838
833
|
</element>
|
839
834
|
</define>
|
840
835
|
<define name="termdocsource">
|
841
|
-
<element name="
|
836
|
+
<element name="termdocsource">
|
842
837
|
<ref name="erefType"/>
|
843
838
|
</element>
|
844
839
|
</define>
|
@@ -847,4 +842,73 @@
|
|
847
842
|
<text/>
|
848
843
|
</element>
|
849
844
|
</define>
|
845
|
+
<define name="term-clause">
|
846
|
+
<element name="clause">
|
847
|
+
<optional>
|
848
|
+
<attribute name="id">
|
849
|
+
<data type="ID"/>
|
850
|
+
</attribute>
|
851
|
+
</optional>
|
852
|
+
<optional>
|
853
|
+
<attribute name="inline-header">
|
854
|
+
<data type="boolean"/>
|
855
|
+
</attribute>
|
856
|
+
</optional>
|
857
|
+
<optional>
|
858
|
+
<attribute name="obligation">
|
859
|
+
<choice>
|
860
|
+
<value>normative</value>
|
861
|
+
<value>informative</value>
|
862
|
+
</choice>
|
863
|
+
</attribute>
|
864
|
+
</optional>
|
865
|
+
<optional>
|
866
|
+
<ref name="section-title"/>
|
867
|
+
</optional>
|
868
|
+
<choice>
|
869
|
+
<oneOrMore>
|
870
|
+
<ref name="term-clause"/>
|
871
|
+
</oneOrMore>
|
872
|
+
<zeroOrMore>
|
873
|
+
<choice>
|
874
|
+
<ref name="terms"/>
|
875
|
+
<ref name="definitions"/>
|
876
|
+
</choice>
|
877
|
+
</zeroOrMore>
|
878
|
+
</choice>
|
879
|
+
</element>
|
880
|
+
</define>
|
881
|
+
<define name="reference-clause">
|
882
|
+
<element name="clause">
|
883
|
+
<optional>
|
884
|
+
<attribute name="id">
|
885
|
+
<data type="ID"/>
|
886
|
+
</attribute>
|
887
|
+
</optional>
|
888
|
+
<optional>
|
889
|
+
<attribute name="inline-header">
|
890
|
+
<data type="boolean"/>
|
891
|
+
</attribute>
|
892
|
+
</optional>
|
893
|
+
<optional>
|
894
|
+
<attribute name="obligation">
|
895
|
+
<choice>
|
896
|
+
<value>normative</value>
|
897
|
+
<value>informative</value>
|
898
|
+
</choice>
|
899
|
+
</attribute>
|
900
|
+
</optional>
|
901
|
+
<optional>
|
902
|
+
<ref name="section-title"/>
|
903
|
+
</optional>
|
904
|
+
<choice>
|
905
|
+
<oneOrMore>
|
906
|
+
<ref name="reference-clause"/>
|
907
|
+
</oneOrMore>
|
908
|
+
<zeroOrMore>
|
909
|
+
<ref name="references"/>
|
910
|
+
</zeroOrMore>
|
911
|
+
</choice>
|
912
|
+
</element>
|
913
|
+
</define>
|
850
914
|
</grammar>
|
@@ -77,8 +77,8 @@ module Asciidoctor
|
|
77
77
|
xml.bibitem **attr_code(ref_attributes(m)) do |t|
|
78
78
|
t.title(**plaintxt) { |i| i << ref_normalise(m[:text]) }
|
79
79
|
t.docidentifier "#{m[:code]}:All Parts"
|
80
|
-
m
|
81
|
-
set_date_range(d, m[:year])
|
80
|
+
if m.named_captures.has_key?("year")
|
81
|
+
t.date **{ type: "published" } { |d| set_date_range(d, m[:year]) }
|
82
82
|
end
|
83
83
|
iso_publisher(t, m[:code])
|
84
84
|
end
|
@@ -98,7 +98,7 @@ module Asciidoctor
|
|
98
98
|
end
|
99
99
|
|
100
100
|
def symbols_parse(attrs, xml, node)
|
101
|
-
xml.
|
101
|
+
xml.definitions **attr_code(attrs) do |xml_section|
|
102
102
|
xml_section << node.content
|
103
103
|
end
|
104
104
|
end
|
@@ -128,7 +128,7 @@ module Asciidoctor
|
|
128
128
|
xml.terms **attr_code(attrs) do |section|
|
129
129
|
section.title { |t| t << term_def_title(toplevel, node) }
|
130
130
|
(s = node.attr("source")) && s.split(/,/).each do |s1|
|
131
|
-
section.
|
131
|
+
section.termdocsource(nil, **attr_code(target: s1, type: "inline"))
|
132
132
|
end
|
133
133
|
section << node.content
|
134
134
|
end
|
@@ -32,7 +32,7 @@ module Asciidoctor
|
|
32
32
|
"only contain a definition list".freeze
|
33
33
|
|
34
34
|
def symbols_validate(root)
|
35
|
-
f = root.xpath("//
|
35
|
+
f = root.xpath("//definitions")
|
36
36
|
f.empty? && return
|
37
37
|
(f.size == 1) || warn(ONE_SYMBOLS_WARNING)
|
38
38
|
f.first.elements.each do |e|
|
@@ -74,18 +74,23 @@ module Asciidoctor
|
|
74
74
|
"Terms and Definitions",
|
75
75
|
val: [
|
76
76
|
{ tag: "terms", title: "Terms and Definitions" },
|
77
|
+
{ tag: "clause", title: "Terms and Definitions" },
|
77
78
|
{
|
78
79
|
tag: "terms",
|
79
80
|
title: "Terms, Definitions, Symbols and Abbreviated Terms",
|
80
81
|
},
|
82
|
+
{
|
83
|
+
tag: "clause",
|
84
|
+
title: "Terms, Definitions, Symbols and Abbreviated Terms",
|
85
|
+
},
|
81
86
|
],
|
82
87
|
},
|
83
88
|
].freeze
|
84
89
|
|
85
90
|
SECTIONS_XPATH =
|
86
|
-
"
|
87
|
-
"//
|
88
|
-
"//
|
91
|
+
"//foreword | //introduction | //sections/terms | .//annex | "\
|
92
|
+
"//definitions | //sections/clause | //references[not(parent::clause)] | "\
|
93
|
+
"//clause[descendant::references][not(parent::clause)]".freeze
|
89
94
|
|
90
95
|
def sections_sequence_validate(root)
|
91
96
|
f = root.xpath(SECTIONS_XPATH)
|
@@ -98,7 +103,7 @@ module Asciidoctor
|
|
98
103
|
end
|
99
104
|
names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val]) || return
|
100
105
|
n = names.shift
|
101
|
-
if n == { tag: "
|
106
|
+
if n == { tag: "definitions", title: nil }
|
102
107
|
n = names.shift || return
|
103
108
|
end
|
104
109
|
unless n
|
@@ -36,7 +36,6 @@ RSpec.describe Asciidoctor::ISO do
|
|
36
36
|
expect(File.exist?("test.doc")).to be true
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
39
|
it "processes default metadata" do
|
41
40
|
expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
|
42
41
|
= Document title
|
@@ -62,6 +61,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
62
61
|
:copyright-year: 2001
|
63
62
|
:docstage: 10
|
64
63
|
:docsubstage: 20
|
64
|
+
:iteration: 3
|
65
65
|
:language: en
|
66
66
|
:title-intro-en: Introduction
|
67
67
|
:title-main-en: Main Title
|
@@ -69,6 +69,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
69
69
|
:title-intro-fr: Introduction Française
|
70
70
|
:title-main-fr: Titre Principal
|
71
71
|
:title-part-fr: Part du Titre
|
72
|
+
:library-ics: 1,2,3
|
72
73
|
INPUT
|
73
74
|
<?xml version="1.0" encoding="UTF-8"?>
|
74
75
|
<iso-standard xmlns="http://riboseinc.com/isoxml">
|
@@ -105,6 +106,7 @@ RSpec.describe Asciidoctor::ISO do
|
|
105
106
|
<status>
|
106
107
|
<stage>10</stage>
|
107
108
|
<substage>20</substage>
|
109
|
+
<iteration>3</iteration>
|
108
110
|
</status>
|
109
111
|
<copyright>
|
110
112
|
<from>2001</from>
|
@@ -121,6 +123,9 @@ RSpec.describe Asciidoctor::ISO do
|
|
121
123
|
<workgroup number="3" type="C">WG</workgroup>
|
122
124
|
<secretariat>SECRETARIAT</secretariat>
|
123
125
|
</editorialgroup>
|
126
|
+
<ics>1</ics>
|
127
|
+
<ics>2</ics>
|
128
|
+
<ics>3</ics>
|
124
129
|
</bibdata><version>
|
125
130
|
<edition>2</edition>
|
126
131
|
<revision-date>2000-01-01</revision-date>
|
@@ -219,4 +224,67 @@ RSpec.describe Asciidoctor::ISO do
|
|
219
224
|
OUTPUT
|
220
225
|
end
|
221
226
|
|
227
|
+
it "uses default fonts" do
|
228
|
+
system "rm -f test.html"
|
229
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
|
230
|
+
= Document title
|
231
|
+
Author
|
232
|
+
:docfile: test.adoc
|
233
|
+
:novalid:
|
234
|
+
INPUT
|
235
|
+
html = File.read("test.html")
|
236
|
+
expect(html).to match(%r[p\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
237
|
+
expect(html).to match(%r[p\.Biblio[^{]+\{[^{]+font-family: "Cambria", serif;]m)
|
238
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "Cambria", serif;]m)
|
239
|
+
end
|
240
|
+
|
241
|
+
it "uses Chinese fonts" do
|
242
|
+
system "rm -f test.html"
|
243
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
|
244
|
+
= Document title
|
245
|
+
Author
|
246
|
+
:docfile: test.adoc
|
247
|
+
:novalid:
|
248
|
+
:script: Hans
|
249
|
+
INPUT
|
250
|
+
html = File.read("test.html")
|
251
|
+
expect(html).to match(%r[p\.Sourcecode[^{]+\{[^{]+font-family: "Courier New", monospace;]m)
|
252
|
+
expect(html).to match(%r[p\.Biblio[^{]+\{[^{]+font-family: "SimSun", serif;]m)
|
253
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: "SimHei", sans-serif;]m)
|
254
|
+
end
|
255
|
+
|
256
|
+
it "uses specified fonts" do
|
257
|
+
system "rm -f test.html"
|
258
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
|
259
|
+
= Document title
|
260
|
+
Author
|
261
|
+
:docfile: test.adoc
|
262
|
+
:novalid:
|
263
|
+
:script: Hans
|
264
|
+
:body-font: Zapf Chancery
|
265
|
+
:header-font: Comic Sans
|
266
|
+
:monospace-font: Andale Mono
|
267
|
+
INPUT
|
268
|
+
html = File.read("test.html")
|
269
|
+
expect(html).to match(%r[p\.Sourcecode[^{]+\{[^{]+font-family: Andale Mono;]m)
|
270
|
+
expect(html).to match(%r[p\.Biblio[^{]+\{[^{]+font-family: Zapf Chancery;]m)
|
271
|
+
expect(html).to match(%r[\.h2Annex[^{]+\{[^{]+font-family: Comic Sans;]m)
|
272
|
+
end
|
273
|
+
|
274
|
+
it "strips MS-specific CSS" do
|
275
|
+
system "rm -f test.html"
|
276
|
+
system "rm -f test.doc"
|
277
|
+
Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
|
278
|
+
= Document title
|
279
|
+
Author
|
280
|
+
:docfile: test.adoc
|
281
|
+
:novalid:
|
282
|
+
INPUT
|
283
|
+
word = File.read("test.doc", encoding: "utf-8")
|
284
|
+
html = File.read("test.html", encoding: "utf-8")
|
285
|
+
expect(word).to match(%r[mso-style-name: "Intro Title";]m)
|
286
|
+
expect(html).not_to match(%r[mso-style-name: "Intro Title";]m)
|
287
|
+
end
|
288
|
+
|
289
|
+
|
222
290
|
end
|