asciidoctor-iso 0.6.1 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.gitattributes +2 -0
  3. data/.travis.yml +5 -0
  4. data/Gemfile.lock +12 -10
  5. data/README.adoc +113 -16
  6. data/bin/rspec +18 -0
  7. data/lib/asciidoctor/iso/base.rb +30 -28
  8. data/lib/asciidoctor/iso/blocks.rb +33 -33
  9. data/lib/asciidoctor/iso/cleanup.rb +79 -33
  10. data/lib/asciidoctor/iso/cleanup_block.rb +71 -18
  11. data/lib/asciidoctor/iso/cleanup_ref.rb +35 -30
  12. data/lib/asciidoctor/iso/converter.rb +0 -3
  13. data/lib/asciidoctor/iso/front.rb +29 -16
  14. data/lib/asciidoctor/iso/html/isodoc.css +34 -0
  15. data/lib/asciidoctor/iso/html/wordstyle.css +138 -6
  16. data/lib/asciidoctor/iso/inline.rb +10 -22
  17. data/lib/asciidoctor/iso/isodoc.rng +66 -16
  18. data/lib/asciidoctor/iso/isostandard.rng +129 -15
  19. data/lib/asciidoctor/iso/lists.rb +49 -42
  20. data/lib/asciidoctor/iso/macros.rb +12 -8
  21. data/lib/asciidoctor/iso/section.rb +53 -37
  22. data/lib/asciidoctor/iso/table.rb +9 -1
  23. data/lib/asciidoctor/iso/utils.rb +18 -13
  24. data/lib/asciidoctor/iso/validate.rb +100 -24
  25. data/lib/asciidoctor/iso/validate_requirements.rb +106 -0
  26. data/lib/asciidoctor/iso/validate_section.rb +85 -65
  27. data/lib/asciidoctor/iso/validate_style.rb +68 -115
  28. data/lib/asciidoctor/iso/version.rb +1 -1
  29. data/spec/asciidoctor-iso/base_spec.rb +193 -0
  30. data/spec/asciidoctor-iso/blocks_spec.rb +426 -0
  31. data/spec/asciidoctor-iso/cleanup_spec.rb +687 -0
  32. data/spec/asciidoctor-iso/inline_spec.rb +159 -0
  33. data/spec/asciidoctor-iso/lists_spec.rb +189 -0
  34. data/spec/asciidoctor-iso/macros_spec.rb +20 -0
  35. data/spec/asciidoctor-iso/refs_spec.rb +194 -0
  36. data/spec/asciidoctor-iso/section_spec.rb +301 -0
  37. data/spec/asciidoctor-iso/table_spec.rb +307 -0
  38. data/spec/asciidoctor-iso/validate_spec.rb +749 -0
  39. data/spec/examples/english.yaml +69 -0
  40. data/spec/examples/rice.adoc +30 -28
  41. data/spec/examples/rice.doc +3035 -2865
  42. data/spec/examples/rice.html +281 -234
  43. data/spec/examples/rice.preview.html +30 -20
  44. data/spec/examples/rice.xml +250 -282
  45. data/spec/spec_helper.rb +87 -0
  46. metadata +17 -2
@@ -0,0 +1,159 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::ISO do
4
+ it "processes inline_quoted formatting" do
5
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ _emphasis_
8
+ *strong*
9
+ `monospace`
10
+ "double quote"
11
+ 'single quote'
12
+ super^script^
13
+ sub~script~
14
+ stem:[a_90]
15
+ [alt]#alt#
16
+ [deprecated]#deprecated#
17
+ [domain]#domain#
18
+ [strike]#strike#
19
+ [smallcap]#smallcap#
20
+ INPUT
21
+ #{BLANK_HDR}
22
+ <sections>
23
+ <em>emphasis</em>
24
+ <strong>strong</strong>
25
+ <tt>monospace</tt>
26
+ "double quote"
27
+ 'single quote'
28
+ super<sup>script</sup>
29
+ sub<sub>script</sub>
30
+ <stem type="AsciiMath">a_90</stem>
31
+ <admitted>alt</admitted>
32
+ <deprecates>deprecated</deprecates>
33
+ <domain>domain</domain>
34
+ <strike>strike</strike>
35
+ <smallcap>smallcap</smallcap>
36
+ </sections>
37
+ </iso-standard>
38
+ OUTPUT
39
+ end
40
+
41
+ it "processes breaks" do
42
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
43
+ #{ASCIIDOC_BLANK_HDR}
44
+ Line break +
45
+ line break
46
+
47
+ '''
48
+
49
+ <<<
50
+ INPUT
51
+ #{BLANK_HDR}
52
+ <sections><p id="_">Line break<br/>
53
+ line break</p>
54
+ <hr/>
55
+ <pagebreak/></sections>
56
+ </iso-standard>
57
+ OUTPUT
58
+ end
59
+
60
+ it "processes links" do
61
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
62
+ #{ASCIIDOC_BLANK_HDR}
63
+ mailto:fred@example.com
64
+ http://example.com[]
65
+ http://example.com[Link]
66
+ INPUT
67
+ #{BLANK_HDR}
68
+ <sections>
69
+ <p id="_">mailto:fred@example.com
70
+ <link target="http://example.com"/>
71
+ <link target="http://example.com">Link</link></p>
72
+ </sections>
73
+ </iso-standard>
74
+ OUTPUT
75
+ end
76
+
77
+ it "processes bookmarks" do
78
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
79
+ #{ASCIIDOC_BLANK_HDR}
80
+ Text [[bookmark]] Text
81
+ INPUT
82
+ #{BLANK_HDR}
83
+ <sections>
84
+ <p id="_">Text <bookmark id="bookmark"/> Text</p>
85
+ </sections>
86
+ </iso-standard>
87
+ OUTPUT
88
+ end
89
+
90
+ it "processes crossreferences" do
91
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
92
+ #{ASCIIDOC_BLANK_HDR}
93
+ [[reference]]
94
+ == Section
95
+
96
+ Inline Reference to <<reference>>
97
+ Footnoted Reference to <<reference,fn>>
98
+ Inline Reference with Text to <<reference,text>>
99
+ Footnoted Reference with Text to <<reference,fn: text>>
100
+ INPUT
101
+ #{BLANK_HDR}
102
+ <sections>
103
+ <clause id="reference" inline-header="false" obligation="normative">
104
+ <title>Section</title>
105
+ <p id="_">Inline Reference to <xref target="reference"/>
106
+ Footnoted Reference to <xref target="reference"/>
107
+ Inline Reference with Text to <xref target="reference">text</xref>
108
+ Footnoted Reference with Text to <xref target="reference">text</xref></p>
109
+ </clause>
110
+ </sections>
111
+ </iso-standard>
112
+ OUTPUT
113
+ end
114
+
115
+ it "processes bibliographic anchors" do
116
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
117
+ #{ASCIIDOC_BLANK_HDR}
118
+ [bibliography]
119
+ == Normative References
120
+
121
+ * [[[ISO712,x]]] Reference
122
+ * [[[ISO713]]] Reference
123
+
124
+ INPUT
125
+ #{BLANK_HDR}
126
+ <sections>
127
+
128
+ </sections><references id="_" obligation="informative">
129
+ <title>Normative References</title>
130
+ <bibitem id="ISO712">
131
+ <formattedref format="application/x-isodoc+xml">Reference</formattedref>
132
+ <docidentifier>x</docidentifier>
133
+ </bibitem>
134
+ <bibitem id="ISO713">
135
+ <formattedref format="application/x-isodoc+xml">Reference</formattedref>
136
+ <docidentifier>ISO713</docidentifier>
137
+ </bibitem>
138
+ </references>
139
+ </iso-standard>
140
+ OUTPUT
141
+ end
142
+
143
+ it "processes footnotes" do
144
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
145
+ #{ASCIIDOC_BLANK_HDR}
146
+ Hello!footnote:[Footnote text]
147
+ INPUT
148
+ #{BLANK_HDR}
149
+ <sections>
150
+ <p id="_">Hello!<fn reference="1">
151
+ <p id="_">Footnote text</p>
152
+ </fn></p>
153
+ </sections>
154
+ </iso-standard>
155
+ OUTPUT
156
+ end
157
+
158
+
159
+ end
@@ -0,0 +1,189 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::ISO do
4
+ it "processes simple lists" do
5
+ output = Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ * List 1
8
+ * List 2
9
+ * List 3
10
+
11
+ . List A
12
+ . List B
13
+ . List C
14
+
15
+ List D:: List E
16
+ List F:: List G
17
+
18
+ INPUT
19
+ expect(strip_guid(output)).to be_equivalent_to <<~"OUTPUT"
20
+ #{BLANK_HDR}
21
+ <sections>
22
+ <ul id="_">
23
+ <li>
24
+ <p id="_">List 1</p>
25
+ </li>
26
+ <li>
27
+ <p id="_">List 2</p>
28
+ </li>
29
+ <li>
30
+ <p id="_">List 3</p>
31
+ <ol id="_" type="arabic">
32
+ <li>
33
+ <p id="_">List A</p>
34
+ </li>
35
+ <li>
36
+ <p id="_">List B</p>
37
+ </li>
38
+ <li>
39
+ <p id="_">List C</p>
40
+ <dl id="_">
41
+ <dt>List D</dt>
42
+ <dd>
43
+ <p id="_">List E</p>
44
+ </dd>
45
+ <dt>List F</dt>
46
+ <dd>
47
+ <p id="_">List G</p>
48
+ </dd>
49
+ </dl>
50
+ </li>
51
+ </ol>
52
+ </li>
53
+ </ul>
54
+ </sections>
55
+ </iso-standard>
56
+ OUTPUT
57
+ end
58
+
59
+ it "processes complex lists" do
60
+ output = Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)
61
+ #{ASCIIDOC_BLANK_HDR}
62
+ [[id]]
63
+ * First
64
+ * Second
65
+ +
66
+ --
67
+ entry1
68
+
69
+ entry2
70
+ --
71
+
72
+ [[id1]]
73
+ [loweralpha]
74
+ . First
75
+ . Second
76
+ [upperalpha]
77
+ .. Third
78
+ .. Fourth
79
+ . Fifth
80
+ . Sixth
81
+
82
+ [lowerroman]
83
+ . A
84
+ . B
85
+ [upperroman]
86
+ .. C
87
+ .. D
88
+ [arabic]
89
+ ... E
90
+ ... F
91
+
92
+
93
+ Notes1::
94
+ Notes:: Note 1.
95
+ +
96
+ Note 2.
97
+ +
98
+ Note 3.
99
+
100
+ INPUT
101
+ expect(strip_guid(output)).to be_equivalent_to <<~"OUTPUT"
102
+ #{BLANK_HDR}
103
+ <sections><ul id="id">
104
+ <li>
105
+ <p id="_">First</p>
106
+ </li>
107
+ <li><p id="_">Second</p><p id="_">entry1</p>
108
+ <p id="_">entry2</p></li>
109
+ </ul>
110
+ <ol id="id1" type="alphabet">
111
+ <li>
112
+ <p id="_">First</p>
113
+ </li>
114
+ <li>
115
+ <p id="_">Second</p>
116
+ <ol id="_" type="alphabet_upper">
117
+ <li>
118
+ <p id="_">Third</p>
119
+ </li>
120
+ <li>
121
+ <p id="_">Fourth</p>
122
+ </li>
123
+ </ol>
124
+ </li>
125
+ <li>
126
+ <p id="_">Fifth</p>
127
+ </li>
128
+ <li>
129
+ <p id="_">Sixth</p>
130
+ </li>
131
+ </ol>
132
+ <ol id="_" type="roman">
133
+ <li>
134
+ <p id="_">A</p>
135
+ </li>
136
+ <li>
137
+ <p id="_">B</p>
138
+ <ol id="_" type="roman_upper">
139
+ <li>
140
+ <p id="_">C</p>
141
+ </li>
142
+ <li>
143
+ <p id="_">D</p>
144
+ <ol id="_" type="arabic">
145
+ <li>
146
+ <p id="_">E</p>
147
+ </li>
148
+ <li>
149
+ <p id="_">F</p>
150
+ <dl id="_">
151
+ <dt>Notes1</dt>
152
+ <dd/>
153
+ <dt>Notes</dt>
154
+ <dd><p id="_">Note 1.</p><p id="_">Note 2.</p>
155
+ <p id="_">Note 3.</p></dd>
156
+ </dl>
157
+ </li>
158
+ </ol>
159
+ </li>
160
+ </ol>
161
+ </li>
162
+ </ol></sections>
163
+ </iso-standard>
164
+ OUTPUT
165
+ end
166
+
167
+ it "anchors lists and list items" do
168
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
169
+ #{ASCIIDOC_BLANK_HDR}
170
+ [[id1]]
171
+ * [[id2]] List item
172
+ * Hello [[id3]] List item
173
+
174
+ INPUT
175
+ #{BLANK_HDR}
176
+ <ul id="id1">
177
+ <li id="id2">
178
+ <p id="_">List item</p>
179
+ </li>
180
+ <li>
181
+ <p id="_">Hello <bookmark id="id3"/> List item</p>
182
+ </li>
183
+ </ul>
184
+ </sections>
185
+ </iso-standard>
186
+ OUTPUT
187
+ end
188
+
189
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::ISO do
4
+ it "processes the Asciidoctor::ISO macros" do
5
+ expect(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true)).to be_equivalent_to <<~"OUTPUT"
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ alt:[term1]
8
+ deprecated:[term1]
9
+ domain:[term1]
10
+ INPUT
11
+ #{BLANK_HDR}
12
+ <sections>
13
+ <admitted>term1</admitted>
14
+ <deprecates>term1</deprecates>
15
+ <domain>term1</domain>
16
+ </sections>
17
+ </iso-standard>
18
+ OUTPUT
19
+ end
20
+ end
@@ -0,0 +1,194 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe Asciidoctor::ISO do
4
+ it "processes simple ISO reference" do
5
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
6
+ #{ASCIIDOC_BLANK_HDR}
7
+ [bibliography]
8
+ == Normative References
9
+
10
+ * [[[iso123,ISO 123]]] _Standard_
11
+ INPUT
12
+ #{BLANK_HDR}
13
+ <sections>
14
+ </sections><references id="_" obligation="informative">
15
+ <title>Normative References</title>
16
+ <bibitem id="iso123" type="standard">
17
+ <title format="text/plain">Standard</title>
18
+ <docidentifier>ISO 123</docidentifier>
19
+ <contributor>
20
+ <role type="publisher"/>
21
+ <organization>
22
+ <name>ISO</name>
23
+ </organization>
24
+ </contributor>
25
+ </bibitem>
26
+ </references>
27
+ </iso-standard>
28
+ OUTPUT
29
+ end
30
+
31
+ it "processes simple IEC reference" do
32
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
33
+ #{ASCIIDOC_BLANK_HDR}
34
+ [bibliography]
35
+ == Normative References
36
+
37
+ * [[[iso123,IEC 123]]] _Standard_
38
+ INPUT
39
+ #{BLANK_HDR}
40
+ <sections>
41
+ </sections><references id="_" obligation="informative">
42
+ <title>Normative References</title>
43
+ <bibitem id="iso123" type="standard">
44
+ <title format="text/plain">Standard</title>
45
+ <docidentifier>IEC 123</docidentifier>
46
+ <contributor>
47
+ <role type="publisher"/>
48
+ <organization>
49
+ <name>IEC</name>
50
+ </organization>
51
+ </contributor>
52
+ </bibitem>
53
+ </references>
54
+ </iso-standard>
55
+ OUTPUT
56
+ end
57
+
58
+ it "processes dated ISO reference" do
59
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
60
+ #{ASCIIDOC_BLANK_HDR}
61
+ [bibliography]
62
+ == Normative References
63
+
64
+ * [[[iso123,ISO 123:1066]]] _Standard_
65
+ INPUT
66
+ #{BLANK_HDR}
67
+ <sections>
68
+ </sections><references id="_" obligation="informative">
69
+ <title>Normative References</title>
70
+ <bibitem id="iso123" type="standard">
71
+ <title format="text/plain">Standard</title>
72
+ <docidentifier>ISO 123</docidentifier>
73
+ <date type="published">1066</date>
74
+ <contributor>
75
+ <role type="publisher"/>
76
+ <organization>
77
+ <name>ISO</name>
78
+ </organization>
79
+ </contributor>
80
+ </bibitem>
81
+ </references>
82
+ </iso-standard>
83
+ OUTPUT
84
+ end
85
+
86
+ it "processes draft ISO reference" do
87
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
88
+ #{ASCIIDOC_BLANK_HDR}
89
+ [bibliography]
90
+ == Normative References
91
+
92
+ * [[[iso123,ISO 123:--]]] footnote:[The standard is in press] _Standard_
93
+ INPUT
94
+ #{BLANK_HDR}
95
+ <sections>
96
+ </sections><references id="_" obligation="informative">
97
+ <title>Normative References</title>
98
+ <bibitem id="iso123" type="standard">
99
+ <title format="text/plain">Standard</title>
100
+ <docidentifier>ISO 123</docidentifier>
101
+ <date type="published">--</date>
102
+ <contributor>
103
+ <role type="publisher"/>
104
+ <organization>
105
+ <name>ISO</name>
106
+ </organization>
107
+ </contributor>
108
+ <note format="text/plain" reference="1">ISO DATE: The standard is in press</note>
109
+ </bibitem>
110
+ </references>
111
+ </iso-standard>
112
+ OUTPUT
113
+ end
114
+
115
+ it "processes all-parts ISO reference" do
116
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
117
+ #{ASCIIDOC_BLANK_HDR}
118
+ [bibliography]
119
+ == Normative References
120
+
121
+ * [[[iso123,ISO 123:1066 (all parts)]]] _Standard_
122
+ INPUT
123
+ #{BLANK_HDR}
124
+ <sections>
125
+
126
+ </sections><references id="_" obligation="informative">
127
+ <title>Normative References</title>
128
+ <bibitem id="iso123" type="standard">
129
+ <title format="text/plain">Standard</title>
130
+ <docidentifier>ISO 123:All Parts</docidentifier>
131
+ <date type="published">1066</date>
132
+ <contributor>
133
+ <role type="publisher"/>
134
+ <organization>
135
+ <name>ISO</name>
136
+ </organization>
137
+ </contributor>
138
+ </bibitem>
139
+ </references>
140
+ </iso-standard>
141
+ OUTPUT
142
+ end
143
+
144
+ it "processes non-ISO reference in Normative References" do
145
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
146
+ #{ASCIIDOC_BLANK_HDR}
147
+ [bibliography]
148
+ == Normative References
149
+
150
+ * [[[iso123,XYZ 123:1066 (all parts)]]] _Standard_
151
+ INPUT
152
+ #{BLANK_HDR}
153
+ <sections>
154
+
155
+ </sections><references id="_" obligation="informative">
156
+ <title>Normative References</title>
157
+ <bibitem id="iso123">
158
+ <formattedref format="application/x-isodoc+xml">
159
+ <em>Standard</em>
160
+ </formattedref>
161
+ <docidentifier>XYZ 123:1066 (all parts)</docidentifier>
162
+ </bibitem>
163
+ </references>
164
+ </iso-standard>
165
+ OUTPUT
166
+ end
167
+
168
+ it "processes non-ISO reference in Bibliography" do
169
+ expect(strip_guid(Asciidoctor.convert(<<~"INPUT", backend: :iso, header_footer: true))).to be_equivalent_to <<~"OUTPUT"
170
+ #{ASCIIDOC_BLANK_HDR}
171
+ [bibliography]
172
+ == Bibliography
173
+
174
+ * [[[iso123,1]]] _Standard_
175
+ INPUT
176
+ #{BLANK_HDR}
177
+ <sections>
178
+
179
+ </sections><references id="_" obligation="informative">
180
+ <title>Bibliography</title>
181
+ <bibitem id="iso123">
182
+ <formattedref format="application/x-isodoc+xml">
183
+ <em>Standard</em>
184
+ </formattedref>
185
+ <docidentifier>[1]</docidentifier>
186
+ </bibitem>
187
+ </references>
188
+ </iso-standard>
189
+ OUTPUT
190
+ end
191
+
192
+
193
+
194
+ end