asciidoctor-iso 0.7.3 → 0.7.4
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/.travis.yml +3 -1
- data/Gemfile.lock +11 -11
- data/README.adoc +13 -8
- data/lib/asciidoctor/iso/base.rb +3 -0
- data/lib/asciidoctor/iso/biblio.rng +43 -25
- data/lib/asciidoctor/iso/blocks.rb +2 -2
- data/lib/asciidoctor/iso/cleanup.rb +4 -4
- data/lib/asciidoctor/iso/cleanup_block.rb +20 -6
- data/lib/asciidoctor/iso/cleanup_ref.rb +5 -4
- data/lib/asciidoctor/iso/front.rb +10 -3
- data/lib/asciidoctor/iso/html/isodoc.scss +15 -1
- data/lib/asciidoctor/iso/html/word_iso_titlepage.html +1 -1
- data/lib/asciidoctor/iso/html/wordstyle.scss +7 -0
- data/lib/asciidoctor/iso/isodoc.rng +19 -30
- data/lib/asciidoctor/iso/isostandard.rng +52 -14
- data/lib/asciidoctor/iso/section.rb +12 -1
- data/lib/asciidoctor/iso/utils.rb +3 -0
- data/lib/asciidoctor/iso/validate.rb +6 -6
- data/lib/asciidoctor/iso/validate_section.rb +6 -6
- data/lib/asciidoctor/iso/validate_style.rb +1 -1
- data/lib/asciidoctor/iso/version.rb +1 -1
- data/spec/asciidoctor-iso/base_spec.rb +3 -2
- data/spec/asciidoctor-iso/blocks_spec.rb +3 -3
- data/spec/asciidoctor-iso/cleanup_spec.rb +18 -12
- data/spec/asciidoctor-iso/inline_spec.rb +2 -1
- data/spec/asciidoctor-iso/refs_spec.rb +14 -7
- data/spec/asciidoctor-iso/section_spec.rb +57 -30
- data/spec/asciidoctor-iso/validate_spec.rb +8 -8
- data/spec/examples/rice.adoc +4 -1
- data/spec/examples/rice.preview.html +10 -3
- metadata +2 -5
- data/spec/examples/rice.doc +0 -18053
- data/spec/examples/rice.html +0 -1112
- data/spec/examples/rice.xml +0 -965
@@ -115,23 +115,30 @@ module Asciidoctor
|
|
115
115
|
metadata_ics(node, xml)
|
116
116
|
end
|
117
117
|
|
118
|
+
def asciidoc_sub(x)
|
119
|
+
return nil if x.nil?
|
120
|
+
d = Asciidoctor::Document.new(x.lines.entries, {header_footer: false})
|
121
|
+
b = d.parse.blocks.first
|
122
|
+
b.apply_subs(b.source)
|
123
|
+
end
|
124
|
+
|
118
125
|
def title_intro(node, t, lang, at)
|
119
126
|
return unless node.attr("title-intro-#{lang}")
|
120
127
|
t.title_intro(**attr_code(at)) do |t1|
|
121
|
-
t1 << node.attr("title-intro-#{lang}")
|
128
|
+
t1 << asciidoc_sub(node.attr("title-intro-#{lang}"))
|
122
129
|
end
|
123
130
|
end
|
124
131
|
|
125
132
|
def title_main(node, t, lang, at)
|
126
133
|
t.title_main **attr_code(at) do |t1|
|
127
|
-
t1 << node.attr("title-main-#{lang}")
|
134
|
+
t1 << asciidoc_sub(node.attr("title-main-#{lang}"))
|
128
135
|
end
|
129
136
|
end
|
130
137
|
|
131
138
|
def title_part(node, t, lang, at)
|
132
139
|
return unless node.attr("title-part-#{lang}")
|
133
140
|
t.title_part(**attr_code(at)) do |t1|
|
134
|
-
t1 << node.attr("title-part-#{lang}")
|
141
|
+
t1 << asciidoc_sub(node.attr("title-part-#{lang}"))
|
135
142
|
end
|
136
143
|
end
|
137
144
|
|
@@ -47,6 +47,7 @@ p.FigureTitle
|
|
47
47
|
tab-stops:20.15pt;
|
48
48
|
font-size:11.0pt;
|
49
49
|
font-family:$bodyfont;
|
50
|
+
font-weight:bold;
|
50
51
|
mso-fareast-font-family:$bodyfont;
|
51
52
|
mso-bidi-font-family:$bodyfont;
|
52
53
|
mso-ansi-language:EN-GB;}
|
@@ -64,11 +65,12 @@ p.TableTitle
|
|
64
65
|
mso-pagination:widow-orphan;
|
65
66
|
tab-stops:20.15pt;
|
66
67
|
font-size:11.0pt;
|
68
|
+
font-weight:bold;
|
67
69
|
font-family:$bodyfont;
|
68
70
|
mso-fareast-font-family:$bodyfont;
|
69
71
|
mso-bidi-font-family:$bodyfont;
|
70
72
|
mso-ansi-language:EN-GB;}
|
71
|
-
p.Note, div.Note, li.Note
|
73
|
+
p.Note, div.Note, li.Note, p.TableFootnote, div.TableFootnote, li.TableFootnote
|
72
74
|
{mso-style-unhide:no;
|
73
75
|
mso-style-qformat:yes;
|
74
76
|
mso-style-parent:"";
|
@@ -663,3 +665,15 @@ div.example {
|
|
663
665
|
margin-left:70.9pt;
|
664
666
|
text-indent:-70.9pt;
|
665
667
|
}
|
668
|
+
p.example, li.example, div.example, td.example, td.example p
|
669
|
+
{ margin:0in;
|
670
|
+
margin-bottom:.0001pt;
|
671
|
+
mso-pagination:none;
|
672
|
+
font-size:10.0pt;
|
673
|
+
font-family:$bodyfont;}
|
674
|
+
span.note_label, span.example_label, td.example_label, td.note_label
|
675
|
+
{
|
676
|
+
font-size: 10.0pt;
|
677
|
+
font-family:$bodyfont;
|
678
|
+
}
|
679
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<p class="MsoNormal" align="right" style='text-align:right'><b style='mso-bidi-font-weight:
|
2
|
-
normal'><span lang="EN-GB" style='font-size:14.0pt;mso-no-proof:yes'>{{ agency }} {{ docnumber }}:{{
|
2
|
+
normal'><span lang="EN-GB" style='font-size:14.0pt;mso-no-proof:yes'>{{ agency }} {{ docnumber }}:{{ docyear }}(E) {{ draftinfo }}</span></b><b
|
3
3
|
style='mso-bidi-font-weight:normal'><span lang="EN-GB" style='font-size:14.0pt'><o:p></o:p></span></b></p>
|
4
4
|
|
5
5
|
<p class="MsoNormal" align="right" style='text-align:right'><span lang="EN-GB"
|
@@ -44,30 +44,6 @@
|
|
44
44
|
<ref name="BibData"/>
|
45
45
|
</element>
|
46
46
|
</define>
|
47
|
-
<define name="docrelation">
|
48
|
-
<element name="relation">
|
49
|
-
<attribute name="type">
|
50
|
-
<choice>
|
51
|
-
<value>parent</value>
|
52
|
-
<value>child</value>
|
53
|
-
<value>obsoletes</value>
|
54
|
-
<value>updates</value>
|
55
|
-
<value>complements</value>
|
56
|
-
<value>derivedFrom</value>
|
57
|
-
<value>adoptedFrom</value>
|
58
|
-
<value>equivalent</value>
|
59
|
-
<value>identical</value>
|
60
|
-
<value>nonequivalent</value>
|
61
|
-
</choice>
|
62
|
-
</attribute>
|
63
|
-
<element name="bibitem">
|
64
|
-
<ref name="BibliographicItem"/>
|
65
|
-
</element>
|
66
|
-
<zeroOrMore>
|
67
|
-
<ref name="locality"/>
|
68
|
-
</zeroOrMore>
|
69
|
-
</element>
|
70
|
-
</define>
|
71
47
|
<define name="status">
|
72
48
|
<element name="status">
|
73
49
|
<ref name="FormattedString"/>
|
@@ -137,10 +113,26 @@
|
|
137
113
|
</element>
|
138
114
|
</define>
|
139
115
|
<define name="content-subsection">
|
140
|
-
<element name="
|
116
|
+
<element name="clause">
|
141
117
|
<ref name="Content-Section"/>
|
142
118
|
</element>
|
143
119
|
</define>
|
120
|
+
<define name="Basic-Section">
|
121
|
+
<optional>
|
122
|
+
<attribute name="id">
|
123
|
+
<data type="ID"/>
|
124
|
+
</attribute>
|
125
|
+
</optional>
|
126
|
+
<optional>
|
127
|
+
<ref name="section-title"/>
|
128
|
+
</optional>
|
129
|
+
<oneOrMore>
|
130
|
+
<ref name="BasicBlock"/>
|
131
|
+
</oneOrMore>
|
132
|
+
<zeroOrMore>
|
133
|
+
<ref name="note"/>
|
134
|
+
</zeroOrMore>
|
135
|
+
</define>
|
144
136
|
<define name="Content-Section">
|
145
137
|
<optional>
|
146
138
|
<attribute name="id">
|
@@ -193,7 +185,7 @@
|
|
193
185
|
</choice>
|
194
186
|
</define>
|
195
187
|
<define name="clause-subsection">
|
196
|
-
<element name="
|
188
|
+
<element name="clause">
|
197
189
|
<ref name="Clause-Section"/>
|
198
190
|
</element>
|
199
191
|
</define>
|
@@ -443,7 +435,7 @@
|
|
443
435
|
<attribute name="reviewer"/>
|
444
436
|
<optional>
|
445
437
|
<attribute name="date">
|
446
|
-
<data type="
|
438
|
+
<data type="dateTime"/>
|
447
439
|
</attribute>
|
448
440
|
</optional>
|
449
441
|
<attribute name="from">
|
@@ -1023,9 +1015,6 @@
|
|
1023
1015
|
<zeroOrMore>
|
1024
1016
|
<ref name="biblionote"/>
|
1025
1017
|
</zeroOrMore>
|
1026
|
-
<zeroOrMore>
|
1027
|
-
<ref name="partof"/>
|
1028
|
-
</zeroOrMore>
|
1029
1018
|
<zeroOrMore>
|
1030
1019
|
<ref name="language"/>
|
1031
1020
|
</zeroOrMore>
|
@@ -73,7 +73,7 @@
|
|
73
73
|
<ref name="formattedref"/>
|
74
74
|
</choice>
|
75
75
|
<optional>
|
76
|
-
<ref name="
|
76
|
+
<ref name="bsource"/>
|
77
77
|
</optional>
|
78
78
|
<zeroOrMore>
|
79
79
|
<ref name="docidentifier"/>
|
@@ -90,9 +90,6 @@
|
|
90
90
|
<zeroOrMore>
|
91
91
|
<ref name="biblionote"/>
|
92
92
|
</zeroOrMore>
|
93
|
-
<zeroOrMore>
|
94
|
-
<ref name="partof"/>
|
95
|
-
</zeroOrMore>
|
96
93
|
<zeroOrMore>
|
97
94
|
<ref name="language"/>
|
98
95
|
</zeroOrMore>
|
@@ -131,7 +128,7 @@
|
|
131
128
|
<ref name="formattedref"/>
|
132
129
|
</optional>
|
133
130
|
<optional>
|
134
|
-
<ref name="
|
131
|
+
<ref name="bsource"/>
|
135
132
|
</optional>
|
136
133
|
<zeroOrMore>
|
137
134
|
<ref name="docidentifier"/>
|
@@ -148,9 +145,6 @@
|
|
148
145
|
<zeroOrMore>
|
149
146
|
<ref name="biblionote"/>
|
150
147
|
</zeroOrMore>
|
151
|
-
<zeroOrMore>
|
152
|
-
<ref name="partof"/>
|
153
|
-
</zeroOrMore>
|
154
148
|
<zeroOrMore>
|
155
149
|
<ref name="language"/>
|
156
150
|
</zeroOrMore>
|
@@ -237,6 +231,32 @@
|
|
237
231
|
</oneOrMore>
|
238
232
|
</element>
|
239
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>
|
240
260
|
<define name="Content-Section">
|
241
261
|
<optional>
|
242
262
|
<attribute name="id">
|
@@ -457,6 +477,9 @@
|
|
457
477
|
<zeroOrMore>
|
458
478
|
<ref name="clause-hanging-paragraph-with-footnote"/>
|
459
479
|
</zeroOrMore>
|
480
|
+
<zeroOrMore>
|
481
|
+
<ref name="annex-appendix"/>
|
482
|
+
</zeroOrMore>
|
460
483
|
</element>
|
461
484
|
</define>
|
462
485
|
<define name="figure">
|
@@ -634,16 +657,26 @@
|
|
634
657
|
<zeroOrMore>
|
635
658
|
<ref name="termdocsource"/>
|
636
659
|
</zeroOrMore>
|
637
|
-
<ref name="
|
638
|
-
<optional>
|
639
|
-
<ref name="introduction"/>
|
640
|
-
</optional>
|
660
|
+
<ref name="preface"/>
|
641
661
|
<oneOrMore>
|
642
662
|
<ref name="sections"/>
|
643
663
|
</oneOrMore>
|
644
664
|
<zeroOrMore>
|
645
665
|
<ref name="annex"/>
|
646
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">
|
647
680
|
<oneOrMore>
|
648
681
|
<choice>
|
649
682
|
<ref name="references"/>
|
@@ -678,7 +711,7 @@
|
|
678
711
|
</define>
|
679
712
|
<define name="foreword">
|
680
713
|
<element name="foreword">
|
681
|
-
<ref name="
|
714
|
+
<ref name="Basic-Section"/>
|
682
715
|
</element>
|
683
716
|
</define>
|
684
717
|
<define name="introduction">
|
@@ -787,7 +820,7 @@
|
|
787
820
|
</element>
|
788
821
|
</define>
|
789
822
|
<define name="clause-hanging-paragraph-with-footnote">
|
790
|
-
<element name="
|
823
|
+
<element name="clause">
|
791
824
|
<optional>
|
792
825
|
<attribute name="id">
|
793
826
|
<data type="ID"/>
|
@@ -911,4 +944,9 @@
|
|
911
944
|
</choice>
|
912
945
|
</element>
|
913
946
|
</define>
|
947
|
+
<define name="annex-appendix">
|
948
|
+
<element name="appendix">
|
949
|
+
<ref name="Clause-Section"/>
|
950
|
+
</element>
|
951
|
+
</define>
|
914
952
|
</grammar>
|
@@ -49,6 +49,8 @@ module Asciidoctor
|
|
49
49
|
elsif @biblio then bibliography_parse(a, xml, node)
|
50
50
|
elsif node.attr("style") == "appendix" && node.level == 1
|
51
51
|
annex_parse(a, xml, node)
|
52
|
+
elsif node.option? "appendix"
|
53
|
+
appendix_parse(a, xml, node)
|
52
54
|
else
|
53
55
|
clause_parse(a, xml, node)
|
54
56
|
end
|
@@ -71,7 +73,7 @@ module Asciidoctor
|
|
71
73
|
def clause_parse(attrs, xml, node)
|
72
74
|
attrs["inline-header".to_sym] = node.option? "inline-header"
|
73
75
|
set_obligation(attrs, node)
|
74
|
-
sect = node.level == 1 ? "clause" : "
|
76
|
+
sect = node.level == 1 ? "clause" : "clause"
|
75
77
|
xml.send sect, **attr_code(attrs) do |xml_section|
|
76
78
|
xml_section.title { |n| n << node.title } unless node.title.nil?
|
77
79
|
xml_section << node.content
|
@@ -87,6 +89,15 @@ module Asciidoctor
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
92
|
+
def appendix_parse(attrs, xml, node)
|
93
|
+
attrs["inline-header".to_sym] = node.option? "inline-header"
|
94
|
+
set_obligation(attrs, node)
|
95
|
+
xml.appendix **attr_code(attrs) do |xml_section|
|
96
|
+
xml_section.title { |name| name << node.title }
|
97
|
+
xml_section << node.content
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
90
101
|
def bibliography_parse(attrs, xml, node)
|
91
102
|
@biblio = true
|
92
103
|
xml.references **attr_code(attrs) do |xml_section|
|
@@ -64,7 +64,7 @@ module Asciidoctor
|
|
64
64
|
def title_first_level_validate(root)
|
65
65
|
root.xpath(SECTIONS_XPATH).each do |s|
|
66
66
|
title = s&.at("./title")&.text || s.name
|
67
|
-
s.xpath("./
|
67
|
+
s.xpath("./clause | ./terms | ./references").each do |ss|
|
68
68
|
subtitle = ss.at("./title")
|
69
69
|
!subtitle.nil? && !subtitle&.text&.empty? ||
|
70
70
|
warn("#{title}: each first-level subclause must have a title")
|
@@ -76,11 +76,11 @@ module Asciidoctor
|
|
76
76
|
notitle = false
|
77
77
|
withtitle = false
|
78
78
|
xpath.each do |s|
|
79
|
-
title_all_siblings(s.xpath("./
|
79
|
+
title_all_siblings(s.xpath("./clause | ./terms | ./references"),
|
80
80
|
s&.at("./title")&.text || s["id"])
|
81
81
|
subtitle = s.at("./title")
|
82
82
|
notitle = notitle || (!subtitle || subtitle.text.empty?)
|
83
|
-
withtitle = withtitle || !subtitle
|
83
|
+
withtitle = withtitle || (subtitle && !subtitle.text.empty?)
|
84
84
|
end
|
85
85
|
notitle && withtitle &&
|
86
86
|
warn("#{label}: all subclauses must have a title, or none")
|
@@ -97,12 +97,12 @@ module Asciidoctor
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def onlychild_clause_validate(root)
|
100
|
-
root.xpath(
|
101
|
-
next unless c.xpath("../
|
100
|
+
root.xpath(Utils::SUBCLAUSE_XPATH).each do |c|
|
101
|
+
next unless c.xpath("../clause").size == 1
|
102
102
|
title = c.at("./title")
|
103
103
|
location = c["id"] || c.text[0..60] + "..."
|
104
104
|
location += ":#{title.text}" if c["id"] && !title.nil?
|
105
|
-
warn "ISO style: #{location}:
|
105
|
+
warn "ISO style: #{location}: subclause is only child"
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
@@ -15,14 +15,14 @@ module Asciidoctor
|
|
15
15
|
|
16
16
|
def foreword_validate(root)
|
17
17
|
f = root.at("//foreword") || return
|
18
|
-
s = f.at("./
|
19
|
-
warn "ISO style: foreword contains
|
18
|
+
s = f.at("./clause")
|
19
|
+
warn "ISO style: foreword contains subclauses" unless s.nil?
|
20
20
|
end
|
21
21
|
|
22
22
|
def normref_validate(root)
|
23
23
|
f = root.at("//references[title = 'Normative References']") || return
|
24
|
-
f.at("./references") &&
|
25
|
-
warn("ISO style: normative references contains
|
24
|
+
f.at("./references | ./clause") &&
|
25
|
+
warn("ISO style: normative references contains subclauses")
|
26
26
|
end
|
27
27
|
|
28
28
|
ONE_SYMBOLS_WARNING = "ISO style: only one Symbols and Abbreviated "\
|
@@ -143,13 +143,13 @@ module Asciidoctor
|
|
143
143
|
end
|
144
144
|
|
145
145
|
NORM_ISO_WARN = "non-ISO/IEC reference not expected as normative".freeze
|
146
|
-
SCOPE_WARN = "Scope contains
|
146
|
+
SCOPE_WARN = "Scope contains subclauses: should be succint".freeze
|
147
147
|
|
148
148
|
def section_style(root)
|
149
149
|
foreword_style(root.at("//foreword"))
|
150
150
|
introduction_style(root.at("//introduction"))
|
151
151
|
scope_style(root.at("//clause[title = 'Scope']"))
|
152
|
-
scope = root.at("//clause[title = 'Scope']/
|
152
|
+
scope = root.at("//clause[title = 'Scope']/clause")
|
153
153
|
scope.nil? || style_warning(scope, SCOPE_WARN, nil)
|
154
154
|
end
|
155
155
|
|
@@ -7,7 +7,7 @@ module Asciidoctor
|
|
7
7
|
module Validate
|
8
8
|
def extract_text(node)
|
9
9
|
return "" if node.nil?
|
10
|
-
node1 = node.
|
10
|
+
node1 = Nokogiri::XML.fragment(node.to_s)
|
11
11
|
node1.xpath("//link | //locality").each(&:remove)
|
12
12
|
ret = ""
|
13
13
|
node1.traverse { |x| ret += x.text if x.text? }
|