asciidoctor-rfc 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -0
  3. data/.oss-guides.rubocop.yml +1077 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +19 -1063
  6. data/.travis.yml +3 -2
  7. data/Guardfile +22 -0
  8. data/README.adoc +1151 -0
  9. data/Rakefile +1 -1
  10. data/asciidoctor-rfc.gemspec +20 -3
  11. data/bin/asciidoctor-rfc2 +15 -0
  12. data/bin/asciidoctor-rfc3 +15 -0
  13. data/bin/rspec +0 -1
  14. data/lib/asciidoctor-rfc.rb +4 -0
  15. data/lib/asciidoctor/rfc/common/base.rb +218 -0
  16. data/lib/asciidoctor/rfc/common/front.rb +120 -0
  17. data/lib/asciidoctor/rfc/v2/base.rb +341 -0
  18. data/lib/asciidoctor/rfc/v2/blocks.rb +192 -0
  19. data/lib/asciidoctor/rfc/v2/converter.rb +64 -0
  20. data/lib/asciidoctor/rfc/v2/front.rb +69 -0
  21. data/lib/asciidoctor/rfc/v2/inline_anchor.rb +102 -0
  22. data/lib/asciidoctor/rfc/v2/lists.rb +134 -0
  23. data/lib/asciidoctor/rfc/v2/table.rb +112 -0
  24. data/lib/asciidoctor/rfc/v2/validate.rb +738 -0
  25. data/lib/asciidoctor/rfc/v2/validate2.rng +716 -0
  26. data/lib/asciidoctor/rfc/v3/base.rb +358 -0
  27. data/lib/asciidoctor/rfc/v3/blocks.rb +203 -0
  28. data/lib/asciidoctor/rfc/v3/converter.rb +64 -0
  29. data/lib/asciidoctor/rfc/v3/front.rb +115 -0
  30. data/lib/asciidoctor/rfc/v3/inline_anchor.rb +90 -0
  31. data/lib/asciidoctor/rfc/v3/lists.rb +190 -0
  32. data/lib/asciidoctor/rfc/v3/svg.rng +9081 -0
  33. data/lib/asciidoctor/rfc/v3/table.rb +65 -0
  34. data/lib/asciidoctor/rfc/v3/validate.rb +2168 -0
  35. data/lib/asciidoctor/rfc/v3/validate.rng +2143 -0
  36. data/lib/asciidoctor/rfc/version.rb +2 -2
  37. data/spec/asciidoctor/rfc/v2/appendix_spec.rb +124 -0
  38. data/spec/asciidoctor/rfc/v2/area_spec.rb +60 -0
  39. data/spec/asciidoctor/rfc/v2/author_spec.rb +444 -0
  40. data/spec/asciidoctor/rfc/v2/comments_spec.rb +316 -0
  41. data/spec/asciidoctor/rfc/v2/crossref_spec.rb +205 -0
  42. data/spec/asciidoctor/rfc/v2/date_spec.rb +166 -0
  43. data/spec/asciidoctor/rfc/v2/dlist_spec.rb +108 -0
  44. data/spec/asciidoctor/rfc/v2/document_spec.rb +161 -0
  45. data/spec/asciidoctor/rfc/v2/example_spec.rb +50 -0
  46. data/spec/asciidoctor/rfc/v2/front_spec.rb +75 -0
  47. data/spec/asciidoctor/rfc/v2/image_spec.rb +81 -0
  48. data/spec/asciidoctor/rfc/v2/indexterm_spec.rb +66 -0
  49. data/spec/asciidoctor/rfc/v2/inline_formatting_spec.rb +177 -0
  50. data/spec/asciidoctor/rfc/v2/keyword_spec.rb +63 -0
  51. data/spec/asciidoctor/rfc/v2/listing_spec.rb +59 -0
  52. data/spec/asciidoctor/rfc/v2/literal_spec.rb +53 -0
  53. data/spec/asciidoctor/rfc/v2/olist_spec.rb +147 -0
  54. data/spec/asciidoctor/rfc/v2/paragraph_spec.rb +68 -0
  55. data/spec/asciidoctor/rfc/v2/preamble_spec.rb +140 -0
  56. data/spec/asciidoctor/rfc/v2/quote_spec.rb +24 -0
  57. data/spec/asciidoctor/rfc/v2/references_spec.rb +96 -0
  58. data/spec/asciidoctor/rfc/v2/section_spec.rb +260 -0
  59. data/spec/asciidoctor/rfc/v2/sidebar_spec.rb +32 -0
  60. data/spec/asciidoctor/rfc/v2/table_spec.rb +293 -0
  61. data/spec/asciidoctor/rfc/v2/ulist_spec.rb +96 -0
  62. data/spec/asciidoctor/rfc/v2/workgroup_spec.rb +60 -0
  63. data/spec/asciidoctor/rfc/v3/appendix_spec.rb +130 -0
  64. data/spec/asciidoctor/rfc/v3/area_spec.rb +63 -0
  65. data/spec/asciidoctor/rfc/v3/author_spec.rb +540 -0
  66. data/spec/asciidoctor/rfc/v3/comments_spec.rb +308 -0
  67. data/spec/asciidoctor/rfc/v3/crossref_spec.rb +269 -0
  68. data/spec/asciidoctor/rfc/v3/date_spec.rb +149 -0
  69. data/spec/asciidoctor/rfc/v3/dlist_spec.rb +121 -0
  70. data/spec/asciidoctor/rfc/v3/document_spec.rb +109 -0
  71. data/spec/asciidoctor/rfc/v3/example_spec.rb +34 -0
  72. data/spec/asciidoctor/rfc/v3/front_spec.rb +43 -0
  73. data/spec/asciidoctor/rfc/v3/image_spec.rb +81 -0
  74. data/spec/asciidoctor/rfc/v3/indexterm_spec.rb +69 -0
  75. data/spec/asciidoctor/rfc/v3/inline_formatting_spec.rb +319 -0
  76. data/spec/asciidoctor/rfc/v3/keyword_spec.rb +33 -0
  77. data/spec/asciidoctor/rfc/v3/link_spec.rb +34 -0
  78. data/spec/asciidoctor/rfc/v3/listing_spec.rb +59 -0
  79. data/spec/asciidoctor/rfc/v3/literal_spec.rb +51 -0
  80. data/spec/asciidoctor/rfc/v3/olist_spec.rb +168 -0
  81. data/spec/asciidoctor/rfc/v3/paragraph_spec.rb +73 -0
  82. data/spec/asciidoctor/rfc/v3/preamble_spec.rb +112 -0
  83. data/spec/asciidoctor/rfc/v3/quote_spec.rb +91 -0
  84. data/spec/asciidoctor/rfc/v3/references_spec.rb +147 -0
  85. data/spec/asciidoctor/rfc/v3/section_spec.rb +198 -0
  86. data/spec/asciidoctor/rfc/v3/series_info_spec.rb +151 -0
  87. data/spec/asciidoctor/rfc/v3/sidebar_spec.rb +30 -0
  88. data/spec/asciidoctor/rfc/v3/table_spec.rb +275 -0
  89. data/spec/asciidoctor/rfc/v3/ulist_spec.rb +74 -0
  90. data/spec/asciidoctor/rfc/v3/workgroup_spec.rb +33 -0
  91. data/spec/examples/davies-template-bare-06.adoc +361 -0
  92. data/spec/examples/davies-template-bare-06.xml.orig +426 -0
  93. data/spec/examples/example-v2.adoc +181 -0
  94. data/spec/examples/example-v2.xml +675 -0
  95. data/spec/examples/example-v3.adoc +185 -0
  96. data/spec/examples/example-v3.xml +1009 -0
  97. data/spec/examples/mib-doc-template-xml-06.adoc +596 -0
  98. data/spec/examples/mib-doc-template-xml-06.xml.orig +654 -0
  99. data/spec/examples/rfc1149.md +76 -0
  100. data/spec/examples/rfc1149.md.2.xml +94 -0
  101. data/spec/examples/rfc1149.md.3.xml +93 -0
  102. data/spec/examples/rfc1149.md.adoc +65 -0
  103. data/spec/examples/rfc2100.md +149 -0
  104. data/spec/examples/rfc2100.md.2.xml +169 -0
  105. data/spec/examples/rfc2100.md.3.xml +163 -0
  106. data/spec/examples/rfc2100.md.adoc +136 -0
  107. data/spec/examples/rfc3514.md +203 -0
  108. data/spec/examples/rfc3514.md.2.xml +238 -0
  109. data/spec/examples/rfc3514.md.3.xml +258 -0
  110. data/spec/examples/rfc3514.md.adoc +324 -0
  111. data/spec/examples/rfc5841.md +342 -0
  112. data/spec/examples/rfc5841.md.2.xml +393 -0
  113. data/spec/examples/rfc5841.md.3.xml +449 -0
  114. data/spec/examples/rfc5841.md.adoc +414 -0
  115. data/spec/examples/rfc6350.adoc +3499 -0
  116. data/spec/examples/rfc6350.bib +763 -0
  117. data/spec/examples/rfc748.md +79 -0
  118. data/spec/examples/rfc748.md.2.xml +116 -0
  119. data/spec/examples/rfc748.md.3.xml +109 -0
  120. data/spec/examples/rfc748.md.adoc +80 -0
  121. data/spec/examples/rfc7511.md +257 -0
  122. data/spec/examples/rfc7511.md.2.xml +300 -0
  123. data/spec/examples/rfc7511.md.3.xml +347 -0
  124. data/spec/examples/rfc7511.md.adoc +417 -0
  125. data/spec/spec_helper.rb +115 -5
  126. metadata +274 -9
  127. data/.hound.yml +0 -3
  128. data/README.md +0 -84
  129. data/lib/asciidoctor/rfc.rb +0 -7
  130. data/spec/asciidoctor-rfc/.keep +0 -0
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+ describe Asciidoctor::RFC::V2::Converter do
3
+ it "renders a quote as a paragraph" do
4
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
5
+ [[verse-id]]
6
+ [quote, attribution="quote attribution", citetitle="http://www.foo.bar"]
7
+ Text
8
+ INPUT
9
+ <t anchor="verse-id">Text</t>
10
+ OUTPUT
11
+ end
12
+
13
+ it "renders a verse" do
14
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
15
+ [[verse-id]]
16
+ [verse, Carl Sandburg, two lines from the poem Fog]
17
+ The fog comes
18
+ on little cat feet.
19
+ INPUT
20
+ <t anchor="verse-id">The fog comes<vspace/>
21
+ on little cat feet.</t>
22
+ OUTPUT
23
+ end
24
+ end
@@ -0,0 +1,96 @@
1
+ require "spec_helper"
2
+ describe Asciidoctor::RFC::V2::Converter do
3
+ it "rejects an unordered list of references" do
4
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
5
+ = Document title
6
+ Author
7
+ :doctype: internet-draft
8
+
9
+ == Text
10
+ Text
11
+
12
+ [[id]]
13
+ [bibliography]
14
+ == References
15
+ * [[[xxx]]] Andy Hunt & Dave Thomas. The Pragmatic Programmer:
16
+ From Journeyman to Master. Addison-Wesley. 1999.
17
+ * [[[gof]]] Erich Gamma, Richard Helm, Ralph Johnson & John Vlissides. Design Patterns:
18
+ Elements of Reusable Object-Oriented Software. Addison-Wesley. 1994.
19
+ INPUT
20
+ <section anchor="_text" title="Text">
21
+ <t>Text</t>
22
+ </section>
23
+ </middle><back>
24
+ <references title="References">
25
+ </references>
26
+ OUTPUT
27
+ end
28
+
29
+ it "renders raw RFC XML as references" do
30
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
31
+ = Document title
32
+ Author
33
+ :doctype: internet-draft
34
+
35
+ == Text
36
+ Text
37
+
38
+ [bibliography]
39
+ == References
40
+ ++++
41
+ <reference anchor='ISO.IEC.10118-3' target='https://www.iso.org/standard/67116.html'>
42
+ <front>
43
+ <title>ISO/IEC FDIS 10118-3 -- Information technology -- Security techniques -- Hash-functions -- Part 3: Dedicated hash-functions</title>
44
+ <author>
45
+ <organization>International Organization for Standardization</organization>
46
+ <address>
47
+ <postal>
48
+ <street>BIBC II</street>
49
+ <street>Chemin de Blandonnet 8</street>
50
+ <street>CP 401</street>
51
+ <city>Vernier</city>
52
+ <region>Geneva</region>
53
+ <code>1214</code>
54
+ <country>Switzerland</country>
55
+ </postal>
56
+ <phone>+41 22 749 01 11</phone>
57
+ <email>central@iso.org</email>
58
+ <uri>https://www.iso.org/</uri>
59
+ </address>
60
+ </author>
61
+ <date day='15' month='September' year='2017'/>
62
+ </front>
63
+ </reference>
64
+ ++++
65
+ INPUT
66
+ <section anchor="_text" title="Text">
67
+ <t>Text</t>
68
+ </section>
69
+ <references title="References">
70
+ <reference anchor='ISO.IEC.10118-3' target='https://www.iso.org/standard/67116.html'>
71
+ <front>
72
+ <title>ISO/IEC FDIS 10118-3 -- Information technology -- Security techniques -- Hash-functions -- Part 3: Dedicated hash-functions</title>
73
+ <author>
74
+ <organization>International Organization for Standardization</organization>
75
+ <address>
76
+ <postal>
77
+ <street>BIBC II</street>
78
+ <street>Chemin de Blandonnet 8</street>
79
+ <street>CP 401</street>
80
+ <city>Vernier</city>
81
+ <region>Geneva</region>
82
+ <code>1214</code>
83
+ <country>Switzerland</country>
84
+ </postal>
85
+ <phone>+41 22 749 01 11</phone>
86
+ <email>central@iso.org</email>
87
+ <uri>https://www.iso.org/</uri>
88
+ </address>
89
+ </author>
90
+ <date day='15' month='September' year='2017'/>
91
+ </front>
92
+ </reference>
93
+ </references>
94
+ OUTPUT
95
+ end
96
+ end
@@ -0,0 +1,260 @@
1
+ require "spec_helper"
2
+ describe Asciidoctor::RFC::V2::Converter do
3
+ it "renders section with attributes" do
4
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
5
+ = Document title
6
+ :abbrev: abbrev_value
7
+ :docName:
8
+ Author
9
+
10
+ [[id]]
11
+ == Section 1
12
+ Para 1
13
+
14
+ Para 2
15
+ INPUT
16
+ <?xml version="1.0" encoding="US-ASCII"?>
17
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
18
+
19
+ <rfc
20
+ submissionType="IETF">
21
+ <front>
22
+ <title abbrev="abbrev_value">Document title</title>
23
+ <author fullname="Author"/>
24
+ <date day="1" month="January" year="2000"/>
25
+ </front><middle>
26
+ <section anchor="id" title="Section 1">
27
+ <t>Para 1</t>
28
+ <t>Para 2</t>
29
+ </section>
30
+ </middle>
31
+ </rfc>
32
+ OUTPUT
33
+ end
34
+
35
+ it "renders HTML entities and Non-ASCII characters and in section title attributes" do
36
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
37
+ = Document title
38
+ :abbrev: abbrev_value
39
+ :docName:
40
+ Author
41
+
42
+ [[id]]
43
+ == Section&nbsp;(Секция) 1
44
+ Para 1
45
+
46
+ Para 2
47
+ INPUT
48
+ <?xml version="1.0" encoding="US-ASCII"?>
49
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
50
+
51
+ <rfc
52
+ submissionType="IETF">
53
+ <front>
54
+ <title abbrev="abbrev_value">Document title</title>
55
+ <author fullname="Author"/>
56
+ <date day="1" month="January" year="2000"/>
57
+ </front><middle>
58
+ <section anchor="id" title="Section&#160;(&#1057;&#1077;&#1082;&#1094;&#1080;&#1103;) 1">
59
+ <t>Para 1</t>
60
+ <t>Para 2</t>
61
+ </section>
62
+ </middle>
63
+ </rfc>
64
+ OUTPUT
65
+ end
66
+
67
+ it "renders subsections" do
68
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
69
+ = Document title
70
+ :abbrev: abbrev_value
71
+ :docName:
72
+ Author
73
+
74
+ == Section 1
75
+ Para 1
76
+
77
+ === Subsection 1.1
78
+ Para 1a
79
+
80
+ === Subsection 1.2
81
+ Para 2
82
+
83
+ ==== Subsection 1.2.1
84
+ Para 3
85
+ INPUT
86
+ <?xml version="1.0" encoding="US-ASCII"?>
87
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
88
+
89
+ <rfc
90
+ submissionType="IETF">
91
+ <front>
92
+ <title abbrev="abbrev_value">Document title</title>
93
+ <author fullname="Author"/>
94
+ <date day="1" month="January" year="2000"/>
95
+ </front><middle>
96
+ <section anchor="_section_1" title="Section 1">
97
+ <t>Para 1</t>
98
+ <section anchor="_subsection_1_1" title="Subsection 1.1">
99
+ <t>Para 1a</t>
100
+ </section>
101
+ <section anchor="_subsection_1_2" title="Subsection 1.2">
102
+ <t>Para 2</t>
103
+ <section anchor="_subsection_1_2_1" title="Subsection 1.2.1">
104
+ <t>Para 3</t>
105
+ </section>
106
+ </section>
107
+ </section>
108
+ </middle>
109
+ </rfc>
110
+ OUTPUT
111
+ end
112
+
113
+ it "ignores sectnums" do
114
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
115
+ = Document title
116
+ :abbrev: abbrev_value
117
+ :docName:
118
+ Author
119
+
120
+ :sectnums:
121
+ == Section 1
122
+ Para 1
123
+
124
+ === Subsection 1.1
125
+ Para 1a
126
+
127
+ :sectnums!:
128
+ === Subsection 1.2
129
+ Para 2
130
+
131
+ ==== Subsection 1.2.1
132
+ Para 3
133
+ INPUT
134
+ <?xml version="1.0" encoding="US-ASCII"?>
135
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
136
+
137
+ <rfc
138
+ submissionType="IETF">
139
+ <front>
140
+ <title abbrev="abbrev_value">Document title</title>
141
+ <author fullname="Author"/>
142
+ <date day="1" month="January" year="2000"/>
143
+ </front><middle>
144
+ <section anchor="_section_1" title="Section 1">
145
+ <t>Para 1</t>
146
+ <section anchor="_subsection_1_1" title="Subsection 1.1">
147
+ <t>Para 1a</t>
148
+ </section>
149
+ <section anchor="_subsection_1_2" title="Subsection 1.2">
150
+ <t>Para 2</t>
151
+ <section anchor="_subsection_1_2_1" title="Subsection 1.2.1">
152
+ <t>Para 3</t>
153
+ </section>
154
+ </section>
155
+ </section>
156
+ </middle>
157
+ </rfc>
158
+ OUTPUT
159
+ end
160
+
161
+ it "ignores page breaks" do
162
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
163
+ = Document title
164
+ :abbrev: abbrev_value
165
+ :docName:
166
+ Author
167
+
168
+ == Section 1
169
+ Para 1
170
+
171
+ <<<
172
+
173
+ Para 2
174
+ INPUT
175
+ <?xml version="1.0" encoding="US-ASCII"?>
176
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
177
+
178
+ <rfc
179
+ submissionType="IETF">
180
+ <front>
181
+ <title abbrev="abbrev_value">Document title</title>
182
+ <author fullname="Author"/>
183
+ <date day="1" month="January" year="2000"/>
184
+ </front><middle>
185
+ <section anchor="_section_1" title="Section 1">
186
+ <t>Para 1</t>
187
+ <t>Para 2</t>
188
+ </section>
189
+ </middle>
190
+ </rfc>
191
+ OUTPUT
192
+ end
193
+
194
+ it "ignores horizontal rules" do
195
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
196
+ = Document title
197
+ :abbrev: abbrev_value
198
+ :docName:
199
+ Author
200
+
201
+ == Section 1
202
+ Para 1
203
+
204
+ '''
205
+
206
+ Para 2
207
+ INPUT
208
+ <?xml version="1.0" encoding="US-ASCII"?>
209
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
210
+
211
+ <rfc
212
+ submissionType="IETF">
213
+ <front>
214
+ <title abbrev="abbrev_value">Document title</title>
215
+ <author fullname="Author"/>
216
+ <date day="1" month="January" year="2000"/>
217
+ </front><middle>
218
+ <section anchor="_section_1" title="Section 1">
219
+ <t>Para 1</t>
220
+ <t>Para 2</t>
221
+ </section>
222
+ </middle>
223
+ </rfc>
224
+ OUTPUT
225
+ end
226
+
227
+ it "renders floating titles" do
228
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
229
+ = Document title
230
+ :abbrev: abbrev_value
231
+ :docName:
232
+ Author
233
+
234
+ == Section 1
235
+ Para 1
236
+
237
+ [discrete]
238
+ == Section 2
239
+ Para 2
240
+ INPUT
241
+ <?xml version="1.0" encoding="US-ASCII"?>
242
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
243
+
244
+ <rfc
245
+ submissionType="IETF">
246
+ <front>
247
+ <title abbrev="abbrev_value">Document title</title>
248
+ <author fullname="Author"/>
249
+ <date day="1" month="January" year="2000"/>
250
+ </front><middle>
251
+ <section anchor="_section_1" title="Section 1">
252
+ <t>Para 1</t>
253
+ <t><spanx style="strong">Section 2</spanx></t>
254
+ <t>Para 2</t>
255
+ </section>
256
+ </middle>
257
+ </rfc>
258
+ OUTPUT
259
+ end
260
+ end
@@ -0,0 +1,32 @@
1
+ require "spec_helper"
2
+ describe Asciidoctor::RFC::V2::Converter do
3
+ it "renders a sidebar as normal paragraphs" do
4
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
5
+ [[id]]
6
+ ****
7
+ Sidebar
8
+
9
+ Another sidebar
10
+
11
+ * This is a list
12
+
13
+ ....
14
+ And this is ascii-art
15
+ ....
16
+ ****
17
+ INPUT
18
+ <t>Sidebar</t>
19
+ <t>Another sidebar</t>
20
+ <t>
21
+ <list style="symbols">
22
+ <t>This is a list</t>
23
+ </list>
24
+ </t>
25
+ <figure>
26
+ <artwork>
27
+ And this is ascii-art
28
+ </artwork>
29
+ </figure>
30
+ OUTPUT
31
+ end
32
+ end
@@ -0,0 +1,293 @@
1
+ require "spec_helper"
2
+ describe Asciidoctor::RFC::V2::Converter do
3
+ it "renders a table" do
4
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
5
+ = Document title
6
+ Author
7
+
8
+ == Section 1
9
+ [[id]]
10
+ [suppress-title=false,align=left,grid=cols]
11
+ .Table Title
12
+ |===
13
+ |[[id]] head | head
14
+
15
+ h|header cell | body cell
16
+ | | body cell
17
+ ^|centre aligned cell | cell
18
+ <|left aligned cell | cell
19
+ >|right aligned cell | cell
20
+
21
+ |foot | foot
22
+ |===
23
+ INPUT
24
+ <section anchor="_section_1" title="Section 1">
25
+ <texttable anchor="id" title="Table Title" suppress-title="false" align="left" style="full">
26
+ <ttcol align="left"> head</ttcol>
27
+ <ttcol align="left">head</ttcol>
28
+ <c>header cell</c>
29
+ <c>body cell</c>
30
+ <c></c>
31
+ <c>body cell</c>
32
+ <c>centre aligned cell</c>
33
+ <c>cell</c>
34
+ <c>left aligned cell</c>
35
+ <c>cell</c>
36
+ <c>right aligned cell</c>
37
+ <c>cell</c>
38
+ <c>foot</c>
39
+ <c>foot</c>
40
+ </texttable>
41
+ </section>
42
+ OUTPUT
43
+ end
44
+
45
+ it "ignores cell anchors in a table" do
46
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
47
+ = Document title
48
+ Author
49
+
50
+ == Section 1
51
+ [[id]]
52
+ [suppress-title=false,align=left,grid=cols]
53
+ .Table Title
54
+ |===
55
+ |[[id]] head | head
56
+
57
+ h|header cell | body cell
58
+ | | [[id]] body cell
59
+ ^|centre aligned cell | cell
60
+ <|left aligned cell | cell
61
+ >|right aligned cell | cell
62
+
63
+ |foot | foot
64
+ |===
65
+ INPUT
66
+ <section anchor="_section_1" title="Section 1">
67
+ <texttable anchor="id" title="Table Title" suppress-title="false" align="left" style="full">
68
+ <ttcol align="left"> head</ttcol>
69
+ <ttcol align="left">head</ttcol>
70
+ <c>header cell</c>
71
+ <c>body cell</c>
72
+ <c></c>
73
+ <c> body cell</c>
74
+ <c>centre aligned cell</c>
75
+ <c>cell</c>
76
+ <c>left aligned cell</c>
77
+ <c>cell</c>
78
+ <c>right aligned cell</c>
79
+ <c>cell</c>
80
+ <c>foot</c>
81
+ <c>foot</c>
82
+ </texttable>
83
+ </section>
84
+ OUTPUT
85
+ end
86
+
87
+ it "ignores colspan and rowspan in table" do
88
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
89
+ = Document title
90
+ Author
91
+
92
+ == Section 1
93
+ [[id]]
94
+ [suppress-title=false,align=left,grid=cols]
95
+ .Table Title
96
+ |===
97
+ |[[id]] head | head
98
+
99
+ h|header cell | body cell
100
+ | | body cell
101
+ 2+| colspan of 2
102
+ .2+|rowspan of 2 | cell
103
+ |cell
104
+ ^|centre aligned cell | cell
105
+ <|left aligned cell | cell
106
+ >|right aligned cell | cell
107
+
108
+ |foot | foot
109
+ |===
110
+ INPUT
111
+ <section anchor="_section_1" title="Section 1">
112
+ <texttable anchor="id" title="Table Title" suppress-title="false" align="left" style="full">
113
+ <ttcol align="left"> head</ttcol>
114
+ <ttcol align="left">head</ttcol>
115
+ <c>header cell</c>
116
+ <c>body cell</c>
117
+ <c></c>
118
+ <c>body cell</c>
119
+ <c>colspan of 2</c>
120
+ <c>rowspan of 2</c>
121
+ <c>cell</c>
122
+ <c>cell</c>
123
+ <c>centre aligned cell</c>
124
+ <c>cell</c>
125
+ <c>left aligned cell</c>
126
+ <c>cell</c>
127
+ <c>right aligned cell</c>
128
+ <c>cell</c>
129
+ <c>foot</c>
130
+ <c>foot</c>
131
+ </texttable>
132
+ </section>
133
+ OUTPUT
134
+ end
135
+ it "renders inline formatting within a table" do
136
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
137
+ = Document title
138
+ Author
139
+
140
+ == Section 1
141
+ .Table Title
142
+ |===
143
+ |head | head
144
+
145
+ h|header cell | *body* _cell_
146
+ | | body cell<<x>>
147
+ ^|centre aligned cell | cell
148
+ <|left aligned cell | cell
149
+ >|right aligned cell | cell
150
+
151
+ |foot | foot
152
+ |===
153
+ INPUT
154
+ <section anchor="_section_1" title="Section 1">
155
+ <texttable title="Table Title" suppress-title="false" style="all">
156
+ <ttcol align="left">head</ttcol>
157
+ <ttcol align="left">head</ttcol>
158
+ <c>header cell</c>
159
+ <c><spanx style="strong">body</spanx> <spanx style="emph">cell</spanx></c>
160
+ <c/>
161
+ <c>body cell<xref target="x"/></c>
162
+ <c>centre aligned cell</c>
163
+ <c>cell</c>
164
+ <c>left aligned cell</c>
165
+ <c>cell</c>
166
+ <c>right aligned cell</c>
167
+ <c>cell</c>
168
+ <c>foot</c>
169
+ <c>foot</c>
170
+ </texttable>
171
+ </section>
172
+ OUTPUT
173
+ end
174
+ it "ignores block formatting within a table" do
175
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
176
+ = Document title
177
+ Author
178
+
179
+ == Section 1
180
+ [cols="2"]
181
+ .Table Title
182
+ |===
183
+ |head | head
184
+
185
+ h|header cell
186
+ a|
187
+ * List 1
188
+ * List 2
189
+ | | body cell<<x>>
190
+ ^|centre aligned cell | cell
191
+ <|left aligned cell | cell
192
+ >|right aligned cell | cell
193
+
194
+ |foot | foot
195
+ |===
196
+ INPUT
197
+ <section anchor="_section_1" title="Section 1">
198
+ <texttable title="Table Title" suppress-title="false" style="all">
199
+ <ttcol align="left">head</ttcol>
200
+ <ttcol align="left">head</ttcol>
201
+ <c>header cell</c>
202
+ <c>* List 1
203
+ * List 2</c>
204
+ <c/>
205
+ <c>body cell<xref target="x"/></c>
206
+ <c>centre aligned cell</c>
207
+ <c>cell</c>
208
+ <c>left aligned cell</c>
209
+ <c>cell</c>
210
+ <c>right aligned cell</c>
211
+ <c>cell</c>
212
+ <c>foot</c>
213
+ <c>foot</c>
214
+ </texttable>
215
+ </section>
216
+ OUTPUT
217
+ end
218
+ it "renders relative column widths in a table" do
219
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
220
+ = Document title
221
+ Author
222
+
223
+ == Section 1
224
+ [cols="1,2,5"]
225
+ |===
226
+ |a |b |c
227
+
228
+ |a |b |c
229
+ |===
230
+ INPUT
231
+ <section anchor="_section_1" title="Section 1">
232
+ <texttable suppress-title="false" style="all">
233
+ <ttcol align="left" width="12.5%">a</ttcol>
234
+ <ttcol align="left" width="25%">b</ttcol>
235
+ <ttcol align="left" width="62.5%">c</ttcol>
236
+ <c>a</c>
237
+ <c>b</c>
238
+ <c>c</c>
239
+ </texttable>
240
+ </section>
241
+ OUTPUT
242
+ end
243
+ it "renders percentage column widths in a table" do
244
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
245
+ = Document title
246
+ Author
247
+
248
+ == Section 1
249
+ [cols="10%,20%,70%"]
250
+ |===
251
+ |a |b |c
252
+
253
+ |a |b |c
254
+ |===
255
+ INPUT
256
+ <section anchor="_section_1" title="Section 1">
257
+ <texttable suppress-title="false" style="all">
258
+ <ttcol align="left" width="10%">a</ttcol>
259
+ <ttcol align="left" width="20%">b</ttcol>
260
+ <ttcol align="left" width="70%">c</ttcol>
261
+ <c>a</c>
262
+ <c>b</c>
263
+ <c>c</c>
264
+ </texttable>
265
+ </section>
266
+ OUTPUT
267
+ end
268
+ it "ignores '1,1,1,1,...' column widths in a table" do
269
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
270
+ = Document title
271
+ Author
272
+
273
+ == Section 1
274
+ [cols="1,1,1"]
275
+ |===
276
+ |a |b |c
277
+
278
+ |a |b |c
279
+ |===
280
+ INPUT
281
+ <section anchor="_section_1" title="Section 1">
282
+ <texttable suppress-title="false" style="all">
283
+ <ttcol align="left">a</ttcol>
284
+ <ttcol align="left">b</ttcol>
285
+ <ttcol align="left">c</ttcol>
286
+ <c>a</c>
287
+ <c>b</c>
288
+ <c>c</c>
289
+ </texttable>
290
+ </section>
291
+ OUTPUT
292
+ end
293
+ end