asciidoctor-rfc 0.2.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.adoc +116 -6
  3. data/asciidoctor-rfc.gemspec +15 -1
  4. data/lib/asciidoctor/rfc/common/base.rb +74 -7
  5. data/lib/asciidoctor/rfc/common/front.rb +1 -1
  6. data/lib/asciidoctor/rfc/v2/base.rb +87 -38
  7. data/lib/asciidoctor/rfc/v2/blocks.rb +29 -2
  8. data/lib/asciidoctor/rfc/v2/converter.rb +0 -1
  9. data/lib/asciidoctor/rfc/v2/inline_anchor.rb +2 -8
  10. data/lib/asciidoctor/rfc/v2/lists.rb +7 -4
  11. data/lib/asciidoctor/rfc/v2/table.rb +1 -1
  12. data/lib/asciidoctor/rfc/v3/base.rb +41 -43
  13. data/lib/asciidoctor/rfc/v3/blocks.rb +29 -2
  14. data/lib/asciidoctor/rfc/v3/converter.rb +0 -2
  15. data/lib/asciidoctor/rfc/v3/inline_anchor.rb +2 -6
  16. data/lib/asciidoctor/rfc/version.rb +1 -1
  17. data/spec/asciidoctor/rfc/v2/comments_spec.rb +7 -3
  18. data/spec/asciidoctor/rfc/v2/date_spec.rb +23 -0
  19. data/spec/asciidoctor/rfc/v2/dlist_spec.rb +107 -9
  20. data/spec/asciidoctor/rfc/v2/image_spec.rb +17 -0
  21. data/spec/asciidoctor/rfc/v2/inline_formatting_spec.rb +12 -0
  22. data/spec/asciidoctor/rfc/v2/listing_spec.rb +22 -0
  23. data/spec/asciidoctor/rfc/v2/literal_spec.rb +22 -2
  24. data/spec/asciidoctor/rfc/v2/preamble_spec.rb +72 -0
  25. data/spec/asciidoctor/rfc/v2/references_spec.rb +3 -1
  26. data/spec/asciidoctor/rfc/v2/table_spec.rb +104 -4
  27. data/spec/asciidoctor/rfc/v2/text_spec.rb +89 -0
  28. data/spec/asciidoctor/rfc/v2/ulist_spec.rb +40 -0
  29. data/spec/asciidoctor/rfc/v3/dlist_spec.rb +103 -1
  30. data/spec/asciidoctor/rfc/v3/image_spec.rb +18 -0
  31. data/spec/asciidoctor/rfc/v3/listing_spec.rb +26 -0
  32. data/spec/asciidoctor/rfc/v3/literal_spec.rb +20 -1
  33. data/spec/asciidoctor/rfc/v3/preamble_spec.rb +150 -0
  34. data/spec/asciidoctor/rfc/v3/references_spec.rb +35 -34
  35. data/spec/asciidoctor/rfc/v3/series_info_spec.rb +39 -0
  36. data/spec/examples/README.adoc +162 -0
  37. data/spec/examples/davies-template-bare-06.adoc +3 -0
  38. data/spec/examples/draft-ietf-core-block-xx.mkd +935 -0
  39. data/spec/examples/draft-ietf-core-block-xx.mkd.adoc +1013 -0
  40. data/spec/examples/draft-ietf-core-block-xx.xml.orig +1251 -0
  41. data/spec/examples/example-v2.adoc +6 -2
  42. data/spec/examples/example-v3.adoc +5 -1
  43. data/spec/examples/hoffmanv2.xml.adoc +247 -0
  44. data/spec/examples/hoffmanv2.xml.orig +339 -0
  45. data/spec/examples/hoffmanv3.xml.orig +346 -0
  46. data/spec/examples/mib-doc-template-xml-06.adoc +5 -1
  47. data/spec/examples/rfc2100.md.adoc +2 -3
  48. data/spec/examples/rfc3514.md.adoc +3 -2
  49. data/spec/examples/rfc5841.md.adoc +1 -1
  50. data/spec/examples/rfc748.md.adoc +7 -6
  51. data/spec/examples/rfc7511.md.adoc +15 -15
  52. data/spec/examples/skel.mkd +32 -0
  53. data/spec/examples/skel.mkd.adoc +50 -0
  54. data/spec/examples/skel.xml.orig +105 -0
  55. data/spec/examples/stupid-s.mkd +569 -0
  56. data/spec/examples/stupid-s.mkd.adoc +771 -0
  57. data/spec/examples/stupid-s.xml.orig +880 -0
  58. data/spec/spec_helper.rb +1 -1
  59. metadata +32 -4
@@ -93,4 +93,44 @@ describe Asciidoctor::RFC::V2::Converter do
93
93
  </t>
94
94
  OUTPUT
95
95
  end
96
+
97
+ it "renders a nested list containing a literal" do
98
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
99
+ [[id]]
100
+ * First
101
+ * Second
102
+ +
103
+ ....
104
+ <entry>
105
+ ....
106
+ INPUT
107
+ <t>
108
+ <list style="symbols">
109
+ <t>First</t>
110
+ <t>Second<figure>
111
+ <artwork>&lt;entry&gt;</artwork>
112
+ </figure></t>
113
+ </list>
114
+ </t>
115
+ OUTPUT
116
+ end
117
+
118
+ it "renders a nested list containing a comment" do
119
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc2)).to be_equivalent_to <<~'OUTPUT'
120
+ [[id]]
121
+ * First
122
+ * Second
123
+ +
124
+ NOTE: Note
125
+ INPUT
126
+ <t>
127
+ <list style="symbols">
128
+ <t>First</t>
129
+ <t>Second<vspace blankLines="1"/>
130
+ <cref>Note</cref>
131
+ </t>
132
+ </list>
133
+ </t>
134
+ OUTPUT
135
+ end
96
136
  end
@@ -96,7 +96,26 @@ describe Asciidoctor::RFC::V3::Converter do
96
96
  </dl>
97
97
  OUTPUT
98
98
  end
99
- it "permits multi paragraph list items" do
99
+ it "renders a description list with definitions on the next line" do
100
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
101
+ = Document title
102
+ Author
103
+
104
+ == Section 1
105
+ A::
106
+ +
107
+ B
108
+ INPUT
109
+ <section anchor="_section_1" numbered="false">
110
+ <name>Section 1</name>
111
+ <dl>
112
+ <dt>A</dt>
113
+ <dd><t>B</t></dd>
114
+ </dl>
115
+ </section>
116
+ OUTPUT
117
+ end
118
+ it "permits multi paragraph definition list items through list continuation" do
100
119
  expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
101
120
  = Document title
102
121
  Author
@@ -118,4 +137,87 @@ describe Asciidoctor::RFC::V3::Converter do
118
137
  </section>
119
138
  OUTPUT
120
139
  end
140
+ it "permits multi paragraph definition list items through open blocks" do
141
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
142
+ = Document title
143
+ Author
144
+
145
+ == Section 1
146
+ Notes:: Note 1.
147
+ +
148
+ --
149
+ Note 2.
150
+
151
+ Note 3.
152
+ --
153
+ INPUT
154
+ <section anchor="_section_1" numbered="false">
155
+ <name>Section 1</name>
156
+ <dl>
157
+ <dt>Notes</dt>
158
+ <dd><t>Note 1.</t><t>Note 2.</t>
159
+ <t>Note 3.</t></dd>
160
+ </dl>
161
+ </section>
162
+ OUTPUT
163
+ end
164
+ it "permits definition list items with a single open block" do
165
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
166
+ = Document title
167
+ Author
168
+
169
+ == Section 1
170
+ Notes:: Note 1.
171
+ +
172
+ --
173
+ Note 2.
174
+ --
175
+ INPUT
176
+ <section anchor="_section_1" numbered="false">
177
+ <name>Section 1</name>
178
+ <dl>
179
+ <dt>Notes</dt>
180
+ <dd><t>Note 1.</t><t>Note 2.</t>
181
+ </dd>
182
+ </dl>
183
+ </section>
184
+ OUTPUT
185
+ end
186
+ it "renders definition lists without definitions" do
187
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
188
+ = Document title
189
+ Author
190
+
191
+ == Section 1
192
+ Notes::
193
+ INPUT
194
+ <section anchor="_section_1" numbered="false">
195
+ <name>Section 1</name>
196
+ <dl>
197
+ <dt>Notes</dt>
198
+ <dd/>
199
+ </dl>
200
+ </section>
201
+ OUTPUT
202
+ end
203
+ it "renders definition lists with more definition terms than definitions" do
204
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
205
+ = Document title
206
+ Author
207
+
208
+ == Section 1
209
+ Notes1::
210
+ Notes2:: Definition
211
+ INPUT
212
+ <section anchor="_section_1" numbered="false">
213
+ <name>Section 1</name>
214
+ <dl>
215
+ <dt>Notes1</dt>
216
+ <dd/>
217
+ <dt>Notes2</dt>
218
+ <dd>Definition</dd>
219
+ </dl>
220
+ </section>
221
+ OUTPUT
222
+ end
121
223
  end
@@ -12,6 +12,24 @@ describe Asciidoctor::RFC::V3::Converter do
12
12
  </figure>
13
13
  OUTPUT
14
14
  end
15
+ it "renders an image within an example" do
16
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
17
+ [[id1]]
18
+ .Example Title
19
+ [align=right,alt=Example]
20
+ ====
21
+ [[id]]
22
+ .Image Title
23
+ [align=center,alt=alt_text]
24
+ image::http:://www.example/org/filename.jpg[]
25
+ ====
26
+ INPUT
27
+ <figure anchor="id1">
28
+ <name>Example Title</name>
29
+ <artwork align="center" alt="alt_text" anchor="id" name="Image Title" src="http:://www.example/org/filename.jpg" type="binary-art"/>
30
+ </figure>
31
+ OUTPUT
32
+ end
15
33
  it "renders an image with macro attributes" do
16
34
  expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
17
35
  [[id]]
@@ -19,6 +19,32 @@ describe Asciidoctor::RFC::V3::Converter do
19
19
  OUTPUT
20
20
  end
21
21
 
22
+ it "renders a listing block within an example" do
23
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
24
+ [#id]
25
+ ====
26
+ [[literal-id]]
27
+ .filename.rb
28
+ [source,ruby]
29
+ ----
30
+ def listing(node)
31
+ result = []
32
+ result << "<figure>" if node.parent.context != :example
33
+ end
34
+ ----
35
+ ====
36
+ INPUT
37
+ <figure anchor="id">
38
+ <sourcecode anchor="literal-id" name="filename.rb" type="ruby">
39
+ def listing(node)
40
+ result = []
41
+ result &lt;&lt; "&lt;figure&gt;" if node.parent.context != :example
42
+ end
43
+ </sourcecode>
44
+ </figure>
45
+ OUTPUT
46
+ end
47
+
22
48
  it "renders a listing block without source attribute" do
23
49
  expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
24
50
  [[literal-id]]
@@ -42,7 +42,26 @@ describe Asciidoctor::RFC::V3::Converter do
42
42
  ++++
43
43
  INPUT
44
44
  <figure>
45
- <artwork type="ascii-art">
45
+ <artwork type="ascii-art" align="center">
46
+ sqrt(4) = 2
47
+ </artwork>
48
+ </figure>
49
+ OUTPUT
50
+ end
51
+ it "renders stem as a literal within an example" do
52
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
53
+ :stem:
54
+
55
+ [#id]
56
+ ====
57
+ [stem]
58
+ ++++
59
+ sqrt(4) = 2
60
+ ++++
61
+ ====
62
+ INPUT
63
+ <figure anchor="id">
64
+ <artwork type="ascii-art" align="center">
46
65
  sqrt(4) = 2
47
66
  </artwork>
48
67
  </figure>
@@ -64,6 +64,156 @@ describe Asciidoctor::RFC::V3::Converter do
64
64
  </rfc>
65
65
  OUTPUT
66
66
  end
67
+ it "renders admonitions in preamble as notes, following an abstract" do
68
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
69
+ = Document title
70
+ Author
71
+ :docName:
72
+
73
+ Abstract
74
+
75
+ [NOTE]
76
+ .Title of Note
77
+ ====
78
+ This is another note.
79
+ ====
80
+
81
+ == Lorem
82
+ Ipsum.
83
+ INPUT
84
+ <?xml version="1.0" encoding="US-ASCII"?>
85
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
86
+
87
+ <rfc submissionType="IETF" prepTime="2000-01-01T05:00:00Z" version="3">
88
+ <front>
89
+ <title>Document title</title>
90
+ <author fullname="Author"/>
91
+ <date day="1" month="January" year="2000"/>
92
+ <abstract><t>Abstract</t></abstract>
93
+ <note>
94
+ <name>Title of Note</name>
95
+ <t>This is another note.</t>
96
+ </note>
97
+ </front><middle>
98
+ <section anchor="_lorem" numbered="false">
99
+ <name>Lorem</name>
100
+ <t>Ipsum.</t>
101
+ </section>
102
+ </middle>
103
+ </rfc>
104
+ OUTPUT
105
+ end
106
+
107
+ it "renders unordered lists in preamble as abstract" do
108
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
109
+ = Document title
110
+ Author
111
+ :docName:
112
+
113
+ * Preamble 1
114
+ * Preamble 2
115
+
116
+ == Lorem
117
+ Ipsum.
118
+ INPUT
119
+ <?xml version="1.0" encoding="US-ASCII"?>
120
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
121
+
122
+ <rfc prepTime="2000-01-01T05:00:00Z"
123
+ version="3" submissionType="IETF">
124
+ <front>
125
+ <title>Document title</title>
126
+ <author fullname="Author">
127
+ </author>
128
+ <date day="1" month="January" year="2000"/>
129
+ <abstract>
130
+ <ul>
131
+ <li>Preamble 1</li>
132
+ <li>Preamble 2</li>
133
+ </ul>
134
+ </abstract>
135
+ </front><middle>
136
+ <section anchor="_lorem" numbered="false">
137
+ <name>Lorem</name>
138
+ <t>Ipsum.</t>
139
+ </section>
140
+ </middle>
141
+ </rfc>
142
+ OUTPUT
143
+ end
144
+ it "renders ordered lists in preamble as abstract" do
145
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
146
+ = Document title
147
+ Author
148
+ :docName:
149
+
150
+ . Preamble 1
151
+ . Preamble 2
152
+
153
+ == Lorem
154
+ Ipsum.
155
+ INPUT
156
+ <?xml version="1.0" encoding="US-ASCII"?>
157
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
158
+
159
+ <rfc prepTime="2000-01-01T05:00:00Z"
160
+ version="3" submissionType="IETF">
161
+ <front>
162
+ <title>Document title</title>
163
+ <author fullname="Author">
164
+ </author>
165
+ <date day="1" month="January" year="2000"/>
166
+ <abstract>
167
+ <ol type="1">
168
+ <li>Preamble 1</li>
169
+ <li>Preamble 2</li>
170
+ </ol>
171
+ </abstract>
172
+ </front><middle>
173
+ <section anchor="_lorem" numbered="false">
174
+ <name>Lorem</name>
175
+ <t>Ipsum.</t>
176
+ </section>
177
+ </middle>
178
+ </rfc>
179
+ OUTPUT
180
+ end
181
+ it "renders definition lists in preamble as abstract" do
182
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
183
+ = Document title
184
+ Author
185
+ :docName:
186
+
187
+ Preamble 1:: Preamble 2
188
+
189
+ == Lorem
190
+ Ipsum.
191
+ INPUT
192
+ <?xml version="1.0" encoding="US-ASCII"?>
193
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
194
+
195
+ <rfc prepTime="2000-01-01T05:00:00Z"
196
+ version="3" submissionType="IETF">
197
+ <front>
198
+ <title>Document title</title>
199
+ <author fullname="Author">
200
+ </author>
201
+ <date day="1" month="January" year="2000"/>
202
+ <abstract>
203
+ <dl>
204
+ <dt>Preamble 1</dt>
205
+ <dd>Preamble 2</dd>
206
+ </dl>
207
+ </abstract>
208
+ </front><middle>
209
+ <section anchor="_lorem" numbered="false">
210
+ <name>Lorem</name>
211
+ <t>Ipsum.</t>
212
+ </section>
213
+ </middle>
214
+ </rfc>
215
+ OUTPUT
216
+ end
67
217
  it "renders admonitions in preamble as notes" do
68
218
  expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
69
219
  = Document title
@@ -11,6 +11,8 @@ describe Asciidoctor::RFC::V3::Converter do
11
11
 
12
12
  [bibliography]
13
13
  == References
14
+
15
+ === Normative References
14
16
  ++++
15
17
  <reference anchor='ISO.IEC.10118-3' target='https://www.iso.org/standard/67116.html'>
16
18
  <front>
@@ -43,7 +45,7 @@ describe Asciidoctor::RFC::V3::Converter do
43
45
  </section>
44
46
  </middle><back>
45
47
  <references anchor="_references">
46
- <name>References</name>
48
+ <name>Normative References</name>
47
49
  <reference anchor='ISO.IEC.10118-3' target='https://www.iso.org/standard/67116.html'>
48
50
  <front>
49
51
  <title>ISO/IEC FDIS 10118-3 -- Information technology -- Security techniques -- Hash-functions -- Part 3: Dedicated hash-functions</title>
@@ -72,7 +74,7 @@ describe Asciidoctor::RFC::V3::Converter do
72
74
  end
73
75
 
74
76
  it "renders raw RFC XML as references, with displayreferences" do
75
- expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3)).to be_equivalent_to <<~'OUTPUT'
77
+ expect(Asciidoctor.convert(<<~'INPUT', backend: :rfc3, header_footer: true)).to be_equivalent_to <<~'OUTPUT'
76
78
  = Document title
77
79
  Author
78
80
  :doctype: internet-draft
@@ -84,6 +86,8 @@ describe Asciidoctor::RFC::V3::Converter do
84
86
  == References
85
87
  * [[[xxx,1]]]
86
88
  * [[[gof,2]]]
89
+
90
+ === Normative References
87
91
  ++++
88
92
  <reference anchor='ISO.IEC.10118-3' target='https://www.iso.org/standard/67116.html'>
89
93
  <front>
@@ -110,38 +114,35 @@ describe Asciidoctor::RFC::V3::Converter do
110
114
  </reference>
111
115
  ++++
112
116
  INPUT
113
- <section anchor="_text" numbered="false">
114
- <name>Text</name>
115
- <t>Text</t>
116
- </section>
117
- <displayreference target="xxx" to="1"/>
118
- <displayreference target="gof" to="2"/>
119
- <references anchor="_references">
120
- <name>References</name>
121
- <reference anchor='ISO.IEC.10118-3' target='https://www.iso.org/standard/67116.html'>
122
- <front>
123
- <title>ISO/IEC FDIS 10118-3 -- Information technology -- Security techniques -- Hash-functions -- Part 3: Dedicated hash-functions</title>
124
- <author>
125
- <organization>International Organization for Standardization</organization>
126
- <address>
127
- <postal>
128
- <street>BIBC II</street>
129
- <street>Chemin de Blandonnet 8</street>
130
- <street>CP 401</street>
131
- <city>Vernier</city>
132
- <region>Geneva</region>
133
- <code>1214</code>
134
- <country>Switzerland</country>
135
- </postal>
136
- <phone>+41 22 749 01 11</phone>
137
- <email>central@iso.org</email>
138
- <uri>https://www.iso.org/</uri>
139
- </address>
140
- </author>
141
- <date day='15' month='September' year='2017'/>
142
- </front>
143
- </reference>
144
- </references>
117
+ <?xml version="1.0" encoding="US-ASCII"?>
118
+ <!DOCTYPE rfc SYSTEM "rfc2629.dtd">
119
+ <?rfc strict="yes"?>
120
+ <?rfc toc="yes"?>
121
+ <?rfc tocdepth="4"?>
122
+ <?rfc symrefs=""?>
123
+ <?rfc sortrefs=""?>
124
+ <?rfc compact="yes"?>
125
+ <?rfc subcompact="no"?>
126
+ <rfc submissionType="IETF" prepTime="2000-01-01T05:00:00Z" version="3">
127
+ <front>
128
+ <title>Document title</title>
129
+ <author fullname="Author"/>
130
+ <date day="1" month="January" year="2000"/>
131
+
132
+ </front><middle>
133
+ <section anchor="_text" numbered="false">
134
+ <name>Text</name>
135
+ <t>Text</t>
136
+ </section>
137
+ </middle><back>
138
+ <displayreference target="xxx" to="1"/>
139
+ <displayreference target="gof" to="2"/>
140
+ <references anchor="_normative_references">
141
+ <name>Normative References</name>
142
+ <reference anchor="ISO.IEC.10118-3" target="https://www.iso.org/standard/67116.html"> <front> <title>ISO/IEC FDIS 10118-3 -- Information technology -- Security techniques -- Hash-functions -- Part 3: Dedicated hash-functions</title> <author> <organization>International Organization for Standardization</organization> <address> <postal> <street>BIBC II</street> <street>Chemin de Blandonnet 8</street> <street>CP 401</street> <city>Vernier</city> <region>Geneva</region> <code>1214</code> <country>Switzerland</country> </postal> <phone>+41 22 749 01 11</phone> <email>central@iso.org</email> <uri>https://www.iso.org/</uri> </address> </author> <date day="15" month="September" year="2017"/> </front></reference>
143
+ </references>
144
+ </back>
145
+ </rfc>
145
146
  OUTPUT
146
147
  end
147
148
  end