asciidoctor-gb 0.1.5 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.tb.yml +20 -10
- data/LICENSE +25 -0
- data/README.adoc +262 -34
- data/asciidoctor-gb.gemspec +2 -1
- data/bin/rspec +18 -0
- data/lib/asciidoctor/gb/biblio.rng +602 -0
- data/lib/asciidoctor/gb/converter.rb +104 -70
- data/lib/asciidoctor/gb/front.rb +109 -61
- data/lib/asciidoctor/gb/gbstandard.rng +135 -31
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.gif +0 -0
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.png +0 -0
- data/lib/asciidoctor/gb/html/gb-logos/gb-issuer-default.svg +980 -0
- data/lib/asciidoctor/gb/html/{gb.css → gb.scss} +133 -219
- data/lib/asciidoctor/gb/html/html_gb_intro.html +1 -37
- data/lib/asciidoctor/gb/html/html_gb_titlepage.html +6 -5
- data/lib/asciidoctor/gb/html/{htmlstyle.css → htmlstyle.scss} +85 -3
- data/lib/asciidoctor/gb/html/word_gb_intro.html +1 -1
- data/lib/asciidoctor/gb/html/word_gb_titlepage.html +320 -166
- data/lib/asciidoctor/gb/html/{wordstyle.css → wordstyle.scss} +605 -429
- data/lib/asciidoctor/gb/isodoc.rng +36 -564
- data/lib/asciidoctor/gb/isostandard.rng +198 -91
- data/lib/asciidoctor/gb/section_input.rb +21 -56
- data/lib/asciidoctor/gb/validate.rb +115 -0
- data/lib/asciidoctor/gb/version.rb +1 -1
- data/lib/asciidoctor-gb.rb +2 -1
- data/lib/isodoc/gb/agencies.rb +327 -0
- data/lib/isodoc/gb/block_output.rb +86 -0
- data/lib/isodoc/gb/gbcleanup.rb +87 -0
- data/lib/isodoc/gb/gbconvert.rb +153 -0
- data/lib/isodoc/gb/gbwordconvert.rb +89 -0
- data/lib/isodoc/gb/html/blank.png +0 -0
- data/lib/isodoc/gb/html/footer.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-issuer-default.svg +980 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-db.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gb.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gjb.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-gm.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-jjf.svg +1 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.gif +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.png +0 -0
- data/lib/isodoc/gb/html/gb-logos/gb-standard-zb.svg +13 -0
- data/lib/isodoc/gb/html/gb.scss +556 -0
- data/lib/isodoc/gb/html/header.html +216 -0
- data/lib/isodoc/gb/html/html_gb_intro.html +9 -0
- data/lib/isodoc/gb/html/html_gb_titlepage.html +99 -0
- data/lib/isodoc/gb/html/htmlstyle.scss +269 -0
- data/lib/isodoc/gb/html/logo.png +0 -0
- data/lib/isodoc/gb/html/scripts.html +71 -0
- data/lib/isodoc/gb/html/word_gb_intro.html +3 -0
- data/lib/isodoc/gb/html/word_gb_titlepage.html +388 -0
- data/lib/isodoc/gb/html/wordstyle.scss +2543 -0
- data/lib/isodoc/gb/i18n-en.yaml +12 -0
- data/lib/isodoc/gb/i18n-zh-Hans.yaml +12 -0
- data/lib/isodoc/gb/i18n.rb +20 -0
- data/lib/isodoc/gb/metadata.rb +216 -0
- data/lib/{asciidoctor → isodoc}/gb/section_output.rb +22 -4
- data/lib/isodoc/gb/xref_gen.rb +17 -0
- metadata +75 -15
- data/lib/asciidoctor/gb/agencies.rb +0 -186
- data/lib/asciidoctor/gb/gbconvert.rb +0 -86
- data/lib/asciidoctor/gb/metadata.rb +0 -186
- data/lib/asciidoctor/gb/xref_gen.rb +0 -25
@@ -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">
|
@@ -48,6 +34,9 @@
|
|
48
34
|
<define name="organization">
|
49
35
|
<element name="organization">
|
50
36
|
<ref name="orgname"/>
|
37
|
+
<optional>
|
38
|
+
<ref name="abbreviation"/>
|
39
|
+
</optional>
|
51
40
|
<optional>
|
52
41
|
<ref name="uri"/>
|
53
42
|
</optional>
|
@@ -84,7 +73,7 @@
|
|
84
73
|
<ref name="formattedref"/>
|
85
74
|
</choice>
|
86
75
|
<optional>
|
87
|
-
<ref name="
|
76
|
+
<ref name="bsource"/>
|
88
77
|
</optional>
|
89
78
|
<zeroOrMore>
|
90
79
|
<ref name="docidentifier"/>
|
@@ -101,9 +90,6 @@
|
|
101
90
|
<zeroOrMore>
|
102
91
|
<ref name="biblionote"/>
|
103
92
|
</zeroOrMore>
|
104
|
-
<zeroOrMore>
|
105
|
-
<ref name="partof"/>
|
106
|
-
</zeroOrMore>
|
107
93
|
<zeroOrMore>
|
108
94
|
<ref name="language"/>
|
109
95
|
</zeroOrMore>
|
@@ -125,6 +111,9 @@
|
|
125
111
|
<optional>
|
126
112
|
<ref name="editorialgroup"/>
|
127
113
|
</optional>
|
114
|
+
<zeroOrMore>
|
115
|
+
<ref name="ics"/>
|
116
|
+
</zeroOrMore>
|
128
117
|
</define>
|
129
118
|
<define name="BibData">
|
130
119
|
<optional>
|
@@ -139,7 +128,7 @@
|
|
139
128
|
<ref name="formattedref"/>
|
140
129
|
</optional>
|
141
130
|
<optional>
|
142
|
-
<ref name="
|
131
|
+
<ref name="bsource"/>
|
143
132
|
</optional>
|
144
133
|
<zeroOrMore>
|
145
134
|
<ref name="docidentifier"/>
|
@@ -156,9 +145,6 @@
|
|
156
145
|
<zeroOrMore>
|
157
146
|
<ref name="biblionote"/>
|
158
147
|
</zeroOrMore>
|
159
|
-
<zeroOrMore>
|
160
|
-
<ref name="partof"/>
|
161
|
-
</zeroOrMore>
|
162
148
|
<zeroOrMore>
|
163
149
|
<ref name="language"/>
|
164
150
|
</zeroOrMore>
|
@@ -176,18 +162,12 @@
|
|
176
162
|
<ref name="docrelation"/>
|
177
163
|
</zeroOrMore>
|
178
164
|
<ref name="editorialgroup"/>
|
165
|
+
<zeroOrMore>
|
166
|
+
<ref name="ics"/>
|
167
|
+
</zeroOrMore>
|
179
168
|
</define>
|
180
|
-
<define name="
|
181
|
-
<element name="
|
182
|
-
<attribute name="type">
|
183
|
-
<choice>
|
184
|
-
<value>published</value>
|
185
|
-
<value>accessed</value>
|
186
|
-
<value>created</value>
|
187
|
-
<value>activated</value>
|
188
|
-
<value>obsoleted</value>
|
189
|
-
</choice>
|
190
|
-
</attribute>
|
169
|
+
<define name="bfrom">
|
170
|
+
<element name="from">
|
191
171
|
<choice>
|
192
172
|
<data type="gYear"/>
|
193
173
|
<data type="date"/>
|
@@ -213,6 +193,9 @@
|
|
213
193
|
<optional>
|
214
194
|
<ref name="substage"/>
|
215
195
|
</optional>
|
196
|
+
<optional>
|
197
|
+
<ref name="iteration"/>
|
198
|
+
</optional>
|
216
199
|
</group>
|
217
200
|
</choice>
|
218
201
|
</element>
|
@@ -236,15 +219,44 @@
|
|
236
219
|
<define name="sections">
|
237
220
|
<element name="sections">
|
238
221
|
<ref name="clause"/>
|
239
|
-
<
|
222
|
+
<choice>
|
223
|
+
<ref name="term-clause"/>
|
224
|
+
<ref name="terms"/>
|
225
|
+
</choice>
|
240
226
|
<optional>
|
241
|
-
<ref name="
|
227
|
+
<ref name="definitions"/>
|
242
228
|
</optional>
|
243
229
|
<oneOrMore>
|
244
230
|
<ref name="clause"/>
|
245
231
|
</oneOrMore>
|
246
232
|
</element>
|
247
233
|
</define>
|
234
|
+
<define name="Basic-Section">
|
235
|
+
<optional>
|
236
|
+
<attribute name="id">
|
237
|
+
<data type="ID"/>
|
238
|
+
</attribute>
|
239
|
+
</optional>
|
240
|
+
<optional>
|
241
|
+
<attribute name="obligation">
|
242
|
+
<choice>
|
243
|
+
<value>normative</value>
|
244
|
+
<value>informative</value>
|
245
|
+
</choice>
|
246
|
+
</attribute>
|
247
|
+
</optional>
|
248
|
+
<optional>
|
249
|
+
<ref name="section-title"/>
|
250
|
+
</optional>
|
251
|
+
<group>
|
252
|
+
<oneOrMore>
|
253
|
+
<ref name="BasicBlock"/>
|
254
|
+
</oneOrMore>
|
255
|
+
<zeroOrMore>
|
256
|
+
<ref name="note"/>
|
257
|
+
</zeroOrMore>
|
258
|
+
</group>
|
259
|
+
</define>
|
248
260
|
<define name="Content-Section">
|
249
261
|
<optional>
|
250
262
|
<attribute name="id">
|
@@ -276,6 +288,42 @@
|
|
276
288
|
</oneOrMore>
|
277
289
|
</choice>
|
278
290
|
</define>
|
291
|
+
<define name="Clause-Section">
|
292
|
+
<optional>
|
293
|
+
<attribute name="id">
|
294
|
+
<data type="ID"/>
|
295
|
+
</attribute>
|
296
|
+
</optional>
|
297
|
+
<optional>
|
298
|
+
<attribute name="inline-header">
|
299
|
+
<data type="boolean"/>
|
300
|
+
</attribute>
|
301
|
+
</optional>
|
302
|
+
<optional>
|
303
|
+
<attribute name="obligation">
|
304
|
+
<choice>
|
305
|
+
<value>normative</value>
|
306
|
+
<value>informative</value>
|
307
|
+
</choice>
|
308
|
+
</attribute>
|
309
|
+
</optional>
|
310
|
+
<optional>
|
311
|
+
<ref name="section-title"/>
|
312
|
+
</optional>
|
313
|
+
<choice>
|
314
|
+
<group>
|
315
|
+
<oneOrMore>
|
316
|
+
<ref name="BasicBlock"/>
|
317
|
+
</oneOrMore>
|
318
|
+
<zeroOrMore>
|
319
|
+
<ref name="note"/>
|
320
|
+
</zeroOrMore>
|
321
|
+
</group>
|
322
|
+
<oneOrMore>
|
323
|
+
<ref name="clause-subsection"/>
|
324
|
+
</oneOrMore>
|
325
|
+
</choice>
|
326
|
+
</define>
|
279
327
|
<define name="references">
|
280
328
|
<element name="references">
|
281
329
|
<optional>
|
@@ -302,8 +350,8 @@
|
|
302
350
|
</zeroOrMore>
|
303
351
|
</element>
|
304
352
|
</define>
|
305
|
-
<define name="
|
306
|
-
<element name="
|
353
|
+
<define name="definitions">
|
354
|
+
<element name="definitions">
|
307
355
|
<optional>
|
308
356
|
<attribute name="id">
|
309
357
|
<data type="ID"/>
|
@@ -338,9 +386,6 @@
|
|
338
386
|
<optional>
|
339
387
|
<ref name="section-title"/>
|
340
388
|
</optional>
|
341
|
-
<zeroOrMore>
|
342
|
-
<ref name="termdocsource"/>
|
343
|
-
</zeroOrMore>
|
344
389
|
<choice>
|
345
390
|
<oneOrMore>
|
346
391
|
<ref name="term"/>
|
@@ -350,7 +395,7 @@
|
|
350
395
|
<ref name="terms"/>
|
351
396
|
</zeroOrMore>
|
352
397
|
<optional>
|
353
|
-
<ref name="
|
398
|
+
<ref name="definitions"/>
|
354
399
|
</optional>
|
355
400
|
</group>
|
356
401
|
</choice>
|
@@ -432,6 +477,9 @@
|
|
432
477
|
<zeroOrMore>
|
433
478
|
<ref name="clause-hanging-paragraph-with-footnote"/>
|
434
479
|
</zeroOrMore>
|
480
|
+
<zeroOrMore>
|
481
|
+
<ref name="annex-appendix"/>
|
482
|
+
</zeroOrMore>
|
435
483
|
</element>
|
436
484
|
</define>
|
437
485
|
<define name="figure">
|
@@ -594,42 +642,6 @@
|
|
594
642
|
<ref name="paragraph"/>
|
595
643
|
</element>
|
596
644
|
</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
645
|
</include>
|
634
646
|
<!-- end overrides -->
|
635
647
|
<!--
|
@@ -642,18 +654,34 @@
|
|
642
654
|
<optional>
|
643
655
|
<ref name="version"/>
|
644
656
|
</optional>
|
645
|
-
<
|
646
|
-
|
647
|
-
|
648
|
-
|
657
|
+
<zeroOrMore>
|
658
|
+
<ref name="termdocsource"/>
|
659
|
+
</zeroOrMore>
|
660
|
+
<ref name="preface"/>
|
649
661
|
<oneOrMore>
|
650
662
|
<ref name="sections"/>
|
651
663
|
</oneOrMore>
|
652
664
|
<zeroOrMore>
|
653
665
|
<ref name="annex"/>
|
654
666
|
</zeroOrMore>
|
667
|
+
<ref name="bibliography"/>
|
668
|
+
</element>
|
669
|
+
</define>
|
670
|
+
<define name="preface">
|
671
|
+
<element name="preface">
|
672
|
+
<ref name="foreword"/>
|
673
|
+
<optional>
|
674
|
+
<ref name="introduction"/>
|
675
|
+
</optional>
|
676
|
+
</element>
|
677
|
+
</define>
|
678
|
+
<define name="bibliography">
|
679
|
+
<element name="bibliography">
|
655
680
|
<oneOrMore>
|
656
|
-
<
|
681
|
+
<choice>
|
682
|
+
<ref name="references"/>
|
683
|
+
<ref name="reference-clause"/>
|
684
|
+
</choice>
|
657
685
|
</oneOrMore>
|
658
686
|
</element>
|
659
687
|
</define>
|
@@ -683,7 +711,7 @@
|
|
683
711
|
</define>
|
684
712
|
<define name="foreword">
|
685
713
|
<element name="foreword">
|
686
|
-
<ref name="
|
714
|
+
<ref name="Basic-Section"/>
|
687
715
|
</element>
|
688
716
|
</define>
|
689
717
|
<define name="introduction">
|
@@ -691,11 +719,6 @@
|
|
691
719
|
<ref name="Content-Section"/>
|
692
720
|
</element>
|
693
721
|
</define>
|
694
|
-
<define name="draft">
|
695
|
-
<element name="draft">
|
696
|
-
<text/>
|
697
|
-
</element>
|
698
|
-
</define>
|
699
722
|
<define name="stage">
|
700
723
|
<element name="stage">
|
701
724
|
<choice>
|
@@ -725,6 +748,11 @@
|
|
725
748
|
</choice>
|
726
749
|
</element>
|
727
750
|
</define>
|
751
|
+
<define name="iteration">
|
752
|
+
<element name="iteration">
|
753
|
+
<data type="int"/>
|
754
|
+
</element>
|
755
|
+
</define>
|
728
756
|
<define name="documentnumber">
|
729
757
|
<element name="project-number">
|
730
758
|
<optional>
|
@@ -792,7 +820,7 @@
|
|
792
820
|
</element>
|
793
821
|
</define>
|
794
822
|
<define name="clause-hanging-paragraph-with-footnote">
|
795
|
-
<element name="
|
823
|
+
<element name="clause">
|
796
824
|
<optional>
|
797
825
|
<attribute name="id">
|
798
826
|
<data type="ID"/>
|
@@ -838,8 +866,87 @@
|
|
838
866
|
</element>
|
839
867
|
</define>
|
840
868
|
<define name="termdocsource">
|
841
|
-
<element name="
|
842
|
-
<ref name="
|
869
|
+
<element name="termdocsource">
|
870
|
+
<ref name="CitationType"/>
|
871
|
+
</element>
|
872
|
+
</define>
|
873
|
+
<define name="ics">
|
874
|
+
<element name="ics">
|
875
|
+
<text/>
|
876
|
+
</element>
|
877
|
+
</define>
|
878
|
+
<define name="term-clause">
|
879
|
+
<element name="clause">
|
880
|
+
<optional>
|
881
|
+
<attribute name="id">
|
882
|
+
<data type="ID"/>
|
883
|
+
</attribute>
|
884
|
+
</optional>
|
885
|
+
<optional>
|
886
|
+
<attribute name="inline-header">
|
887
|
+
<data type="boolean"/>
|
888
|
+
</attribute>
|
889
|
+
</optional>
|
890
|
+
<optional>
|
891
|
+
<attribute name="obligation">
|
892
|
+
<choice>
|
893
|
+
<value>normative</value>
|
894
|
+
<value>informative</value>
|
895
|
+
</choice>
|
896
|
+
</attribute>
|
897
|
+
</optional>
|
898
|
+
<optional>
|
899
|
+
<ref name="section-title"/>
|
900
|
+
</optional>
|
901
|
+
<choice>
|
902
|
+
<oneOrMore>
|
903
|
+
<ref name="term-clause"/>
|
904
|
+
</oneOrMore>
|
905
|
+
<zeroOrMore>
|
906
|
+
<choice>
|
907
|
+
<ref name="terms"/>
|
908
|
+
<ref name="definitions"/>
|
909
|
+
</choice>
|
910
|
+
</zeroOrMore>
|
911
|
+
</choice>
|
912
|
+
</element>
|
913
|
+
</define>
|
914
|
+
<define name="reference-clause">
|
915
|
+
<element name="clause">
|
916
|
+
<optional>
|
917
|
+
<attribute name="id">
|
918
|
+
<data type="ID"/>
|
919
|
+
</attribute>
|
920
|
+
</optional>
|
921
|
+
<optional>
|
922
|
+
<attribute name="inline-header">
|
923
|
+
<data type="boolean"/>
|
924
|
+
</attribute>
|
925
|
+
</optional>
|
926
|
+
<optional>
|
927
|
+
<attribute name="obligation">
|
928
|
+
<choice>
|
929
|
+
<value>normative</value>
|
930
|
+
<value>informative</value>
|
931
|
+
</choice>
|
932
|
+
</attribute>
|
933
|
+
</optional>
|
934
|
+
<optional>
|
935
|
+
<ref name="section-title"/>
|
936
|
+
</optional>
|
937
|
+
<choice>
|
938
|
+
<oneOrMore>
|
939
|
+
<ref name="reference-clause"/>
|
940
|
+
</oneOrMore>
|
941
|
+
<zeroOrMore>
|
942
|
+
<ref name="references"/>
|
943
|
+
</zeroOrMore>
|
944
|
+
</choice>
|
945
|
+
</element>
|
946
|
+
</define>
|
947
|
+
<define name="annex-appendix">
|
948
|
+
<element name="appendix">
|
949
|
+
<ref name="Clause-Section"/>
|
843
950
|
</element>
|
844
951
|
</define>
|
845
952
|
</grammar>
|
@@ -22,7 +22,7 @@ module Asciidoctor
|
|
22
22
|
a = { id: Asciidoctor::ISO::Utils::anchor_or_uuid(node) }
|
23
23
|
noko do |xml|
|
24
24
|
case sectiontype(node)
|
25
|
-
when "引言" then
|
25
|
+
when "引言", "introduction" then
|
26
26
|
if node.level == 1 then introduction_parse(a, xml, node)
|
27
27
|
else
|
28
28
|
clause_parse(a, xml, node)
|
@@ -54,50 +54,6 @@ module Asciidoctor
|
|
54
54
|
end
|
55
55
|
|
56
56
|
=begin
|
57
|
-
def preamble(node)
|
58
|
-
noko do |xml|
|
59
|
-
xml.foreword do |xml_abstract|
|
60
|
-
xml_abstract.title { |t| t << "前言" }
|
61
|
-
content = node.content
|
62
|
-
xml_abstract << content
|
63
|
-
text = Asciidoctor::ISO::Utils::flatten_rawtext(content).join("\n")
|
64
|
-
foreword_style(node, text)
|
65
|
-
end
|
66
|
-
end.join("\n")
|
67
|
-
end
|
68
|
-
=end
|
69
|
-
|
70
|
-
def normref_cleanup(xmldoc)
|
71
|
-
q = "//references[title = '规范性引用文件']"
|
72
|
-
r = xmldoc.at(q)
|
73
|
-
if r.nil?
|
74
|
-
warn "You have no normative references!"
|
75
|
-
return
|
76
|
-
end
|
77
|
-
r.elements.each do |n|
|
78
|
-
n.remove unless ["title", "bibitem"].include? n.name
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def normref_validate(root)
|
83
|
-
f = root.at("//references[title = '规范性引用文件']") ||
|
84
|
-
return
|
85
|
-
f.at("./references") &&
|
86
|
-
warn("ISO style: normative references contains subsections")
|
87
|
-
end
|
88
|
-
|
89
|
-
def symbols_validate(root)
|
90
|
-
f = root.at("//clause[title = '符号、代号和缩略语']")
|
91
|
-
return if f.nil?
|
92
|
-
f.elements do |e|
|
93
|
-
unless e.name == "dl"
|
94
|
-
warn "ISO style: Symbols and Abbreviations can only contain "\
|
95
|
-
"a definition list"
|
96
|
-
return
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
57
|
# spec of permissible section sequence
|
102
58
|
SEQ = [
|
103
59
|
{ msg: "Initial section must be (content) 前言",
|
@@ -111,16 +67,22 @@ module Asciidoctor
|
|
111
67
|
"术语和定义",
|
112
68
|
val: [
|
113
69
|
{ tag: "terms", title: "术语和定义" },
|
70
|
+
{ tag: "clause", title: "术语和定义" },
|
71
|
+
{ tag: "clause",
|
72
|
+
title: "术语、定义、符号、代号和缩略语" },
|
114
73
|
{ tag: "terms",
|
115
74
|
title: "术语、定义、符号、代号和缩略语" }
|
116
75
|
] },
|
117
76
|
]
|
118
77
|
|
78
|
+
SECTIONS_XPATH =
|
79
|
+
"//foreword | //introduction | //sections/terms | .//annex | "\
|
80
|
+
"//definitions | //sections/clause | //references[not(parent::clause)] | "\
|
81
|
+
"//clause[descendant::references][not(parent::clause)]".freeze
|
82
|
+
|
119
83
|
def sections_sequence_validate(root)
|
120
|
-
f = root.xpath(
|
121
|
-
|
122
|
-
"./annex")
|
123
|
-
names = f.map { |s| { tag: s.name, title: s.at("./title").text } }
|
84
|
+
f = root.xpath(SECTIONS_XPATH)
|
85
|
+
names = f.map { |s| { tag: s.name, title: s&.at("./title")&.text } }
|
124
86
|
names = seqcheck(names, SEQ[0][:msg], SEQ[0][:val]) || return
|
125
87
|
n = names[0]
|
126
88
|
names = seqcheck(names, SEQ[1][:msg], SEQ[1][:val]) || return
|
@@ -129,31 +91,33 @@ module Asciidoctor
|
|
129
91
|
end
|
130
92
|
names = seqcheck(names, SEQ[3][:msg], SEQ[3][:val]) || return
|
131
93
|
n = names.shift
|
132
|
-
if n == { tag: "
|
133
|
-
n = names.shift
|
94
|
+
if n == { tag: "definitions", title: nil }
|
95
|
+
n = names.shift || return
|
134
96
|
end
|
135
97
|
unless n
|
136
98
|
warn "ISO style: Document must contain at least one clause"
|
137
99
|
return
|
138
100
|
end
|
139
101
|
n[:tag] == "clause" or
|
140
|
-
warn "ISO style: Document must contain
|
102
|
+
warn "ISO style: Document must contain clause after Terms and Definitions"
|
141
103
|
(n == { tag: "clause", title: "范围" }) &&
|
142
104
|
warn("ISO style: 范围 must occur before 术语和定义")
|
143
105
|
n = names.shift or return
|
144
106
|
while n[:tag] == "clause"
|
145
107
|
(n[:title] == "范围") &&
|
146
108
|
warn("ISO style: 范围 must occur before 术语和定义")
|
147
|
-
n[:title] == "符号、代号和缩略语" and
|
148
|
-
warn "ISO style: 符号、代号和缩略语 must occur "\
|
149
|
-
"right after Terms and Definitions"
|
150
109
|
n = names.shift or return
|
151
110
|
end
|
152
111
|
unless n[:tag] == "annex" or n[:tag] == "references"
|
153
112
|
warn "ISO style: Only annexes and references can follow clauses"
|
154
113
|
end
|
155
114
|
while n[:tag] == "annex"
|
156
|
-
n = names.shift
|
115
|
+
n = names.shift
|
116
|
+
if n.nil?
|
117
|
+
warn("ISO style: Document must include (references) "\
|
118
|
+
"Normative References")
|
119
|
+
return
|
120
|
+
end
|
157
121
|
end
|
158
122
|
n == { tag: "references", title: "规范性引用文件" } or
|
159
123
|
warn "ISO style: Document must include (references) 规范性引用文件"
|
@@ -163,6 +127,7 @@ module Asciidoctor
|
|
163
127
|
names.empty? or
|
164
128
|
warn "ISO style: There are sections after the final Bibliography"
|
165
129
|
end
|
130
|
+
=end
|
166
131
|
end
|
167
132
|
end
|
168
133
|
end
|