asciidoctor-rfc 0.8.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.hound.yml +3 -0
- data/.rubocop.ribose.yml +65 -0
- data/.rubocop.tb.yml +640 -0
- data/.rubocop.yml +13 -30
- data/.travis.yml +8 -3
- data/CODE_OF_CONDUCT.md +46 -0
- data/Gemfile +8 -1
- data/LICENSE +21 -17
- data/README.adoc +471 -52
- data/asciidoctor-rfc.gemspec +14 -13
- data/lib/asciidoctor-rfc.rb +4 -4
- data/lib/asciidoctor/rfc/common/base.rb +304 -58
- data/lib/asciidoctor/rfc/common/front.rb +3 -3
- data/lib/asciidoctor/rfc/v2/base.rb +71 -82
- data/lib/asciidoctor/rfc/v2/blocks.rb +33 -10
- data/lib/asciidoctor/rfc/v2/converter.rb +0 -3
- data/lib/asciidoctor/rfc/v2/inline_anchor.rb +35 -20
- data/lib/asciidoctor/rfc/v2/lists.rb +11 -13
- data/lib/asciidoctor/rfc/v2/table.rb +11 -9
- data/lib/asciidoctor/rfc/v2/validate.rb +18 -724
- data/lib/asciidoctor/rfc/v3/base.rb +75 -102
- data/lib/asciidoctor/rfc/v3/blocks.rb +7 -9
- data/lib/asciidoctor/rfc/v3/converter.rb +0 -1
- data/lib/asciidoctor/rfc/v3/front.rb +14 -7
- data/lib/asciidoctor/rfc/v3/inline_anchor.rb +12 -9
- data/lib/asciidoctor/rfc/v3/lists.rb +31 -45
- data/lib/asciidoctor/rfc/v3/table.rb +2 -2
- data/lib/asciidoctor/rfc/v3/validate.rb +19 -2153
- data/lib/asciidoctor/rfc/v3/validate.rng +1 -1
- data/lib/asciidoctor/rfc/version.rb +1 -1
- data/rfc2629-other.ent +61 -0
- data/rfc2629-xhtml.ent +165 -0
- data/rfc2629.dtd +312 -0
- data/spec/asciidoctor/rfc/v2/biblio_spec.rb +9 -0
- data/spec/asciidoctor/rfc/v2/comments_spec.rb +67 -1
- data/spec/asciidoctor/rfc/v2/crossref_spec.rb +127 -5
- data/spec/asciidoctor/rfc/v2/date_spec.rb +24 -28
- data/spec/asciidoctor/rfc/v2/dlist_spec.rb +5 -5
- data/spec/asciidoctor/rfc/v2/image_spec.rb +2 -2
- data/spec/asciidoctor/rfc/v2/inline_formatting_spec.rb +28 -0
- data/spec/asciidoctor/rfc/v2/listing_spec.rb +2 -2
- data/spec/asciidoctor/rfc/v2/literal_spec.rb +4 -4
- data/spec/asciidoctor/rfc/v2/preamble_spec.rb +1 -1
- data/spec/asciidoctor/rfc/v2/quote_spec.rb +1 -1
- data/spec/asciidoctor/rfc/v2/references_spec.rb +210 -3
- data/spec/asciidoctor/rfc/v2/section_spec.rb +33 -0
- data/spec/asciidoctor/rfc/v2/table_spec.rb +40 -1
- data/spec/asciidoctor/rfc/v2/text_spec.rb +71 -14
- data/spec/asciidoctor/rfc/v2/ulist_spec.rb +1 -1
- data/spec/asciidoctor/rfc/v3/biblio_spec.rb +13 -0
- data/spec/asciidoctor/rfc/v3/comments_spec.rb +71 -0
- data/spec/asciidoctor/rfc/v3/crossref_spec.rb +7 -0
- data/spec/asciidoctor/rfc/v3/dlist_spec.rb +4 -4
- data/spec/asciidoctor/rfc/v3/literal_spec.rb +1 -1
- data/spec/asciidoctor/rfc/v3/preamble_spec.rb +1 -1
- data/spec/asciidoctor/rfc/v3/references_spec.rb +208 -3
- data/spec/asciidoctor/rfc/v3/series_info_spec.rb +1 -1
- data/spec/asciidoctor/rfc/v3/table_spec.rb +70 -1
- data/spec/examples/README.adoc +42 -6
- data/spec/examples/biblio-insert-v2.adoc +29 -0
- data/spec/examples/biblio-insert-v3.adoc +30 -0
- data/spec/examples/davies-template-bare-06.adoc +1 -0
- data/spec/examples/draft-iab-html-rfc-bis.xml.adoc +2300 -0
- data/spec/examples/draft-iab-html-rfc-bis.xml.orig +1999 -0
- data/spec/examples/draft-iab-html-rfc-bis.xml.txt +2298 -0
- data/spec/examples/draft-iab-rfc-framework-bis.xml.adoc +662 -0
- data/spec/examples/draft-iab-rfc-framework-bis.xml.orig +476 -0
- data/spec/examples/draft-ietf-core-block-xx.mkd.adoc +8 -33
- data/spec/examples/hoffmanv2.xml.adoc +4 -0
- data/spec/examples/mib-doc-template-xml-06.adoc +6 -8
- data/spec/examples/refs-v2-database.xml +86 -0
- data/spec/examples/refs-v2.adoc +49 -0
- data/spec/examples/refs-v2.xml +50 -0
- data/spec/examples/refs-v2/AsciiDoc.xml +8 -0
- data/spec/examples/refs-v2/AsciiMathML.xml +8 -0
- data/spec/examples/refs-v2/IETF-BibXML.xml +9 -0
- data/spec/examples/refs-v2/MathJax.xml +8 -0
- data/spec/examples/refs-v2/NroffEdit.xml +8 -0
- data/spec/examples/refs-v2/TeX-LaTeX.xml +8 -0
- data/spec/examples/refs-v2/abarth +17 -0
- data/spec/examples/refs-v2/asciidoctor-bibliography.xml +19 -0
- data/spec/examples/refs-v2/asciidoctor-manual.xml +11 -0
- data/spec/examples/refs-v2/asciidoctor-rfc.xml +18 -0
- data/spec/examples/refs-v2/asciidoctor.xml +10 -0
- data/spec/examples/refs-v2/draftr.xml +8 -0
- data/spec/examples/refs-v2/kramdown-rfc2629.xml +8 -0
- data/spec/examples/refs-v2/lyx2rfc.xml +8 -0
- data/spec/examples/refs-v2/mmark.xml +9 -0
- data/spec/examples/refs-v2/pandoc2rfc.xml +8 -0
- data/spec/examples/refs-v2/reference.RFC.2119.xml +7 -0
- data/spec/examples/refs-v2/reference.RFC.5385.xml +7 -0
- data/spec/examples/refs-v2/reference.RFC.7328.xml +7 -0
- data/spec/examples/refs-v2/reference.RFC.7749.xml +7 -0
- data/spec/examples/refs-v2/reference.RFC.7763.xml +7 -0
- data/spec/examples/refs-v2/reference.RFC.7764.xml +7 -0
- data/spec/examples/refs-v2/reference.RFC.7990.xml +7 -0
- data/spec/examples/refs-v2/reference.RFC.7991.xml +7 -0
- data/spec/examples/refs-v3-database.xml +137 -0
- data/spec/examples/refs-v3.adoc +57 -0
- data/spec/examples/refs-v3.xml +90 -0
- data/spec/examples/refs-v3/AsciiDoc.xml +8 -0
- data/spec/examples/refs-v3/AsciiMathML.xml +8 -0
- data/spec/examples/refs-v3/IETF-BibXML.xml +9 -0
- data/spec/examples/refs-v3/MathJax.xml +8 -0
- data/spec/examples/refs-v3/NroffEdit.xml +8 -0
- data/spec/examples/refs-v3/TeX-LaTeX.xml +8 -0
- data/spec/examples/refs-v3/abarth +17 -0
- data/spec/examples/refs-v3/asciidoctor-bibliography.xml +19 -0
- data/spec/examples/refs-v3/asciidoctor-manual.xml +11 -0
- data/spec/examples/refs-v3/asciidoctor-rfc.xml +18 -0
- data/spec/examples/refs-v3/asciidoctor.xml +10 -0
- data/spec/examples/refs-v3/draftr.xml +8 -0
- data/spec/examples/refs-v3/kramdown-rfc2629.xml +8 -0
- data/spec/examples/refs-v3/lyx2rfc.xml +8 -0
- data/spec/examples/refs-v3/mathrefs.xml +19 -0
- data/spec/examples/refs-v3/mmark.xml +9 -0
- data/spec/examples/refs-v3/pandoc2rfc.xml +8 -0
- data/spec/examples/refs-v3/reference.RFC.2119.xml +7 -0
- data/spec/examples/refs-v3/reference.RFC.5385.xml +7 -0
- data/spec/examples/refs-v3/reference.RFC.7328.xml +7 -0
- data/spec/examples/refs-v3/reference.RFC.7749.xml +7 -0
- data/spec/examples/refs-v3/reference.RFC.7763.xml +7 -0
- data/spec/examples/refs-v3/reference.RFC.7764.xml +7 -0
- data/spec/examples/refs-v3/reference.RFC.7990.xml +7 -0
- data/spec/examples/refs-v3/reference.RFC.7991.xml +7 -0
- data/spec/examples/rfc2100.md.adoc +57 -44
- data/spec/examples/rfc3514.md.adoc +1 -1
- data/spec/examples/rfc6350.adoc +701 -695
- data/spec/examples/rfc6350.txt.orig +3372 -0
- data/spec/examples/rfc6350_refs.xml +774 -0
- data/spec/examples/rfc748.md.adoc +1 -1
- data/spec/examples/rfc7511.md.adoc +3 -3
- data/spec/examples/skel.mkd.adoc +1 -0
- data/spec/examples/stupid-s.mkd.adoc +4 -4
- metadata +94 -8
- data/spec/examples/rfc6350.bib +0 -763
@@ -88,7 +88,7 @@ module Asciidoctor
|
|
88
88
|
else
|
89
89
|
d = Date.iso8601 revdate
|
90
90
|
date_attributes = {
|
91
|
-
day: d.day,
|
91
|
+
day: d.day.to_s.gsub(/^0/, ""),
|
92
92
|
month: Date::MONTHNAMES[d.month],
|
93
93
|
year: d.year,
|
94
94
|
}
|
@@ -104,13 +104,13 @@ module Asciidoctor
|
|
104
104
|
revdate = node.attr("revdate") || node.attr("date")
|
105
105
|
if revdate.nil?
|
106
106
|
revdate = DateTime.now.iso8601
|
107
|
-
warn %(asciidoctor: WARNING: revdate attribute missing from header, provided current date)
|
107
|
+
warn %(asciidoctor: WARNING (#{current_location(node)}): revdate attribute missing from header, provided current date)
|
108
108
|
end
|
109
109
|
unless revdate.nil?
|
110
110
|
begin
|
111
111
|
date1(revdate, xml)
|
112
112
|
rescue ArgumentError # invalid date
|
113
|
-
warn %(asciidoctor: WARNING: invalid date in header, provided current date)
|
113
|
+
warn %(asciidoctor: WARNING (#{current_location(node)}): invalid date in header, provided current date)
|
114
114
|
date1(DateTime.now.iso8601, xml)
|
115
115
|
end
|
116
116
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require "pp"
|
2
|
+
# coding: utf-8
|
1
3
|
module Asciidoctor
|
2
4
|
module RFC::V2
|
3
5
|
module Base
|
@@ -33,7 +35,6 @@ module Asciidoctor
|
|
33
35
|
# == Appendix
|
34
36
|
def document(node)
|
35
37
|
$seen_back_matter = false
|
36
|
-
$seen_abstract = false
|
37
38
|
$smart_quotes = (node.attr("smart-quotes") != "false")
|
38
39
|
$inline_definition_lists = (node.attr("inline-definition-lists") == "true")
|
39
40
|
|
@@ -86,10 +87,25 @@ module Asciidoctor
|
|
86
87
|
end
|
87
88
|
|
88
89
|
ret = result * "\n"
|
89
|
-
ret = set_pis(node, Nokogiri::XML(ret)).to_xml
|
90
90
|
ret = cleanup(ret)
|
91
|
-
|
92
|
-
|
91
|
+
ret1 = Nokogiri::XML(ret)
|
92
|
+
# Validate::validate(ret1)
|
93
|
+
ret1 = set_pis(node, ret1)
|
94
|
+
ret1 = insert_biblio(node, ret1) unless node.attr("biblio-dir").nil? || node.attr("biblio-dir").empty?
|
95
|
+
Validate::validate(ret1)
|
96
|
+
ret1 = resolve_references(node, ret1)
|
97
|
+
# Validate::validate(ret1)
|
98
|
+
ret1.to_xml
|
99
|
+
end
|
100
|
+
|
101
|
+
def resolve_references(node, doc)
|
102
|
+
extract_entities(node, doc).each do |entity|
|
103
|
+
Nokogiri::XML::EntityDecl::new(entity[:entity], doc,
|
104
|
+
Nokogiri::XML::EntityDecl::EXTERNAL_GENERAL_PARSED,
|
105
|
+
nil, entity[:url], nil)
|
106
|
+
entity[:node].replace(Nokogiri::XML::EntityReference.new(doc, entity[:entity]))
|
107
|
+
end
|
108
|
+
doc
|
93
109
|
end
|
94
110
|
|
95
111
|
def inline_break(node)
|
@@ -120,6 +136,8 @@ module Asciidoctor
|
|
120
136
|
# [bcp14]#MUST NOT#
|
121
137
|
if node.role == "bcp14"
|
122
138
|
xml.spanx node.text.upcase, style: "strong"
|
139
|
+
elsif node.role == "comment"
|
140
|
+
xml.comment " " + node.text + " "
|
123
141
|
else
|
124
142
|
xml << node.text
|
125
143
|
end
|
@@ -131,33 +149,26 @@ module Asciidoctor
|
|
131
149
|
# [[id]]
|
132
150
|
# Text
|
133
151
|
def paragraph(node)
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
result << "<abstract>"
|
152
|
+
if node.role == "comment"
|
153
|
+
return noko do |xml|
|
154
|
+
xml.comment " " + [flatten_rawtext(node)].flatten.join("\n") + " "
|
155
|
+
end.join("\n")
|
139
156
|
end
|
140
157
|
|
141
158
|
t_attributes = {
|
142
159
|
anchor: node.id,
|
143
160
|
}
|
144
161
|
|
145
|
-
|
162
|
+
noko do |xml|
|
146
163
|
xml.t **attr_code(t_attributes) do |xml_t|
|
147
164
|
xml_t << node.content
|
148
165
|
end
|
149
|
-
end
|
150
|
-
result
|
166
|
+
end.join("\n")
|
151
167
|
end
|
152
168
|
|
153
169
|
def verse(node)
|
154
170
|
result = []
|
155
171
|
|
156
|
-
if (node.parent.context == :preamble) && !$seen_abstract
|
157
|
-
$seen_abstract = true
|
158
|
-
result << "<abstract>"
|
159
|
-
end
|
160
|
-
|
161
172
|
t_attributes = {
|
162
173
|
anchor: node.id,
|
163
174
|
}
|
@@ -194,26 +205,28 @@ module Asciidoctor
|
|
194
205
|
references_attributes = {
|
195
206
|
title: node.title,
|
196
207
|
}
|
197
|
-
|
208
|
+
if node.blocks.empty?
|
209
|
+
result << noko { |xml| xml.references **references_attributes }
|
210
|
+
end
|
198
211
|
node.blocks.each do |block|
|
199
212
|
if block.context == :section
|
200
213
|
result << node.content
|
201
214
|
elsif block.context == :pass
|
202
|
-
#
|
215
|
+
# NOTE: references are assumed to be found in a single passthrough
|
216
|
+
# block containing <reference> tags.
|
217
|
+
|
203
218
|
result << noko do |xml|
|
204
|
-
xml.references **
|
205
|
-
|
219
|
+
xml.references **references_attributes do |xml_references|
|
220
|
+
# NOTE: we're allowing the user to do more or less whathever
|
221
|
+
# in the passthrough since the xpath below just fishes out ALL
|
222
|
+
# <reference>s in an unrooted fragment, regardless of structure.
|
223
|
+
Nokogiri::XML::DocumentFragment.
|
224
|
+
parse(block.content).xpath(".//reference").
|
225
|
+
each { |reference| xml_references << reference.to_xml }
|
206
226
|
end
|
207
227
|
end
|
208
228
|
end
|
209
229
|
end
|
210
|
-
=begin
|
211
|
-
result << noko do |xml|
|
212
|
-
xml.references **attr_code(references_attributes) do |xml_references|
|
213
|
-
node.blocks.each { |b| xml_references << reflist(b).join }
|
214
|
-
end
|
215
|
-
end
|
216
|
-
=end
|
217
230
|
|
218
231
|
result = result.unshift("</middle><back>") unless $seen_back_matter
|
219
232
|
$processing_reflist = false
|
@@ -226,7 +239,7 @@ module Asciidoctor
|
|
226
239
|
|
227
240
|
section_attributes = {
|
228
241
|
anchor: node.id,
|
229
|
-
title: node.title,
|
242
|
+
title: node.title.gsub(/<[^>]+>/, ""),
|
230
243
|
}
|
231
244
|
|
232
245
|
result << noko do |xml|
|
@@ -259,7 +272,10 @@ module Asciidoctor
|
|
259
272
|
|
260
273
|
noko do |xml|
|
261
274
|
if node.parent.context != :example
|
262
|
-
|
275
|
+
figure_attributes = {
|
276
|
+
anchor: node.id,
|
277
|
+
}
|
278
|
+
xml.figure **attr_code(figure_attributes) do |xml_figure|
|
263
279
|
xml_figure.artwork **attr_code(artwork_attributes)
|
264
280
|
end
|
265
281
|
else
|
@@ -289,25 +305,20 @@ module Asciidoctor
|
|
289
305
|
end
|
290
306
|
end
|
291
307
|
end
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
if node.text?
|
299
|
-
node.content = node.content.tr("\u2019", "'")
|
300
|
-
node.content = node.content.gsub(/\’/, "'")
|
301
|
-
node.content = node.content.gsub(/\’/, "'")
|
302
|
-
elsif node.element?
|
303
|
-
node.attributes.each do |k, v|
|
304
|
-
node.set_attribute(k, v.content.tr("\u2019", "'"))
|
305
|
-
node.set_attribute(k, v.content.gsub(/\’/, "'"))
|
306
|
-
node.set_attribute(k, v.content.gsub(/\’/, "'"))
|
307
|
-
end
|
308
|
-
end
|
308
|
+
# any instances of spanx must be stripped of any internal tags
|
309
|
+
spanxs = xmldoc.xpath("//spanx[descendant::*]")
|
310
|
+
while !spanxs.empty?
|
311
|
+
spanx = spanxs[0]
|
312
|
+
spanx_text = ""
|
313
|
+
spanx.traverse do |node|
|
314
|
+
spanx_text = spanx_text + node.text.gsub(/<[^>]+>/, "") if node.text?
|
309
315
|
end
|
316
|
+
spanx.children = spanx_text
|
317
|
+
spanxs = xmldoc.xpath("//spanx[descendant::*]")
|
310
318
|
end
|
319
|
+
|
320
|
+
xmldoc.root = merge_vspace(xmldoc.root)
|
321
|
+
xmldoc = smart_quote_cleanup(xmldoc) unless $smart_quotes
|
311
322
|
xmldoc.to_xml(encoding: "US-ASCII")
|
312
323
|
end
|
313
324
|
|
@@ -319,21 +330,18 @@ module Asciidoctor
|
|
319
330
|
end
|
320
331
|
|
321
332
|
counter = 0
|
322
|
-
while counter < nodes.size
|
333
|
+
while counter < nodes.size
|
323
334
|
if nodes[counter].name == "vspace"
|
324
335
|
blankLines = 0
|
325
|
-
while counter < nodes.size && nodes[counter].name == "vspace"
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
if counter+1 < nodes.size && nodes[counter+1].text?
|
332
|
-
if nodes[counter+1].text =~ /\A[\n ]+\Z/m
|
333
|
-
counter += 1
|
334
|
-
end
|
335
|
-
end
|
336
|
+
while counter < nodes.size && nodes[counter].name == "vspace"
|
337
|
+
blankLines += 1
|
338
|
+
if nodes[counter][:blankLines].nil?
|
339
|
+
blankLines += nodes[counter][:blankLines].to_i
|
340
|
+
end
|
341
|
+
if counter + 1 < nodes.size && nodes[counter + 1].text? && nodes[counter + 1].text =~ /\A[\n ]+\Z/m
|
336
342
|
counter += 1
|
343
|
+
end
|
344
|
+
counter += 1
|
337
345
|
end
|
338
346
|
counter -= 1 if counter == nodes.size
|
339
347
|
newnodes << noko do |xml|
|
@@ -341,33 +349,14 @@ module Asciidoctor
|
|
341
349
|
end.join
|
342
350
|
else
|
343
351
|
newnodes << merge_vspace(nodes[counter])
|
344
|
-
nodes[counter].remove
|
345
352
|
counter += 1
|
346
353
|
end
|
347
|
-
|
348
|
-
node.children.remove
|
349
|
-
newnodes.each do |item|
|
350
|
-
node.add_child(item)
|
351
|
-
end
|
352
354
|
end
|
353
|
-
node
|
354
|
-
|
355
|
-
|
356
|
-
def set_pis(node, doc)
|
357
|
-
# Below are generally applicable Processing Instructions (PIs)
|
358
|
-
# that most I-Ds might want to use. (Here they are set differently than
|
359
|
-
# their defaults in xml2rfc v1.32)
|
360
|
-
rfc_pis = common_rfc_pis(node)
|
361
|
-
|
362
|
-
doc.create_internal_subset("rfc", nil, "rfc2629.dtd")
|
363
|
-
rfc_pis.each_pair do |k, v|
|
364
|
-
pi = Nokogiri::XML::ProcessingInstruction.new(doc,
|
365
|
-
"rfc",
|
366
|
-
"#{k}=\"#{v}\"")
|
367
|
-
doc.root.add_previous_sibling(pi)
|
355
|
+
node.children.remove
|
356
|
+
newnodes.each do |item|
|
357
|
+
node.add_child(item)
|
368
358
|
end
|
369
|
-
|
370
|
-
doc
|
359
|
+
node
|
371
360
|
end
|
372
361
|
|
373
362
|
# replace any <t>text</t> instances with <vspace blankLines="1"/>text
|
@@ -34,7 +34,10 @@ module Asciidoctor
|
|
34
34
|
|
35
35
|
ret = noko do |xml|
|
36
36
|
if node.parent.context != :example
|
37
|
-
|
37
|
+
figure_attributes = {
|
38
|
+
anchor: node.id,
|
39
|
+
}
|
40
|
+
xml.figure **attr_code(figure_attributes) do |xml_figure|
|
38
41
|
xml_figure.artwork artwork_content, **attr_code(artwork_attributes)
|
39
42
|
end
|
40
43
|
else
|
@@ -58,7 +61,10 @@ module Asciidoctor
|
|
58
61
|
|
59
62
|
ret = noko do |xml|
|
60
63
|
if node.parent.context != :example
|
61
|
-
|
64
|
+
figure_attributes = {
|
65
|
+
anchor: node.id,
|
66
|
+
}
|
67
|
+
xml.figure **attr_code(figure_attributes) do |xml_figure|
|
62
68
|
xml_figure.artwork artwork_content, **attr_code(artwork_attributes)
|
63
69
|
end
|
64
70
|
else
|
@@ -68,7 +74,6 @@ module Asciidoctor
|
|
68
74
|
ret
|
69
75
|
end
|
70
76
|
|
71
|
-
|
72
77
|
# Syntax:
|
73
78
|
# = Title
|
74
79
|
# Author
|
@@ -95,11 +100,6 @@ module Asciidoctor
|
|
95
100
|
def admonition(node)
|
96
101
|
result = []
|
97
102
|
if node.parent.context == :preamble
|
98
|
-
if $seen_abstract
|
99
|
-
result << "</abstract>"
|
100
|
-
$seen_abstract = false
|
101
|
-
end
|
102
|
-
|
103
103
|
note_attributes = {
|
104
104
|
# default title provided: title is mandatory
|
105
105
|
title: (node.title.nil? ? "NOTE" : node.title),
|
@@ -122,7 +122,7 @@ module Asciidoctor
|
|
122
122
|
cref_contents = flatten_rawtext(node)
|
123
123
|
cref_contents = [cref_contents].flatten.join("\n")
|
124
124
|
warn <<~WARNING_MESSAGE if node.blocks?
|
125
|
-
asciidoctor: WARNING: comment can not contain blocks of text in XML RFC:\n #{node.content}
|
125
|
+
asciidoctor: WARNING (#{node.lineno}): comment can not contain blocks of text in XML RFC:\n #{node.content}
|
126
126
|
WARNING_MESSAGE
|
127
127
|
|
128
128
|
result << noko do |xml|
|
@@ -206,7 +206,10 @@ module Asciidoctor
|
|
206
206
|
|
207
207
|
noko do |xml|
|
208
208
|
if node.parent.context != :example
|
209
|
-
|
209
|
+
figure_attributes = {
|
210
|
+
anchor: node.id,
|
211
|
+
}
|
212
|
+
xml.figure **attr_code(figure_attributes) do |xml_figure|
|
210
213
|
xml_figure.artwork sourcecode_content, **attr_code(sourcecode_attributes)
|
211
214
|
end
|
212
215
|
else
|
@@ -214,6 +217,26 @@ module Asciidoctor
|
|
214
217
|
end
|
215
218
|
end
|
216
219
|
end
|
220
|
+
|
221
|
+
def quote(node)
|
222
|
+
result = []
|
223
|
+
if node.blocks?
|
224
|
+
node.blocks.each do |b|
|
225
|
+
result << send(b.context, b)
|
226
|
+
end
|
227
|
+
else
|
228
|
+
result = paragraph(node)
|
229
|
+
end
|
230
|
+
if node.attr("citetitle") || node.attr("attribution")
|
231
|
+
cite = node.attr("attribution") || ""
|
232
|
+
cite += ", " if node.attr("citetitle") && node.attr("attribution")
|
233
|
+
cite += (node.attr("citetitle") || "")
|
234
|
+
cite = "-- " + cite
|
235
|
+
result << "<t>#{cite}</t>"
|
236
|
+
end
|
237
|
+
result
|
238
|
+
end
|
239
|
+
|
217
240
|
end
|
218
241
|
end
|
219
242
|
end
|
@@ -35,7 +35,6 @@ module Asciidoctor
|
|
35
35
|
register_for "rfc2"
|
36
36
|
|
37
37
|
$seen_back_matter = false
|
38
|
-
$seen_abstract = false
|
39
38
|
$xreftext = {}
|
40
39
|
|
41
40
|
def initialize(backend, opts)
|
@@ -56,8 +55,6 @@ module Asciidoctor
|
|
56
55
|
alias_method :inline_kbd, :skip
|
57
56
|
alias_method :inline_menu, :skip
|
58
57
|
alias_method :inline_image, :skip
|
59
|
-
|
60
|
-
alias_method :quote, :paragraph
|
61
58
|
end
|
62
59
|
end
|
63
60
|
end
|
@@ -12,7 +12,7 @@ module Asciidoctor
|
|
12
12
|
when :ref
|
13
13
|
inline_anchor_ref node
|
14
14
|
else
|
15
|
-
warn %(asciidoctor: WARNING: unknown anchor type: #{node.type.inspect})
|
15
|
+
warn %(asciidoctor: WARNING (#{current_location(node)}): unknown anchor type: #{node.type.inspect})
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -24,43 +24,58 @@ module Asciidoctor
|
|
24
24
|
# render equivalent in v2
|
25
25
|
matched = /(?<section>\S+)\s+(?<format>[a-z]+)(: )?(?<text>.*)$/.match node.text
|
26
26
|
|
27
|
-
|
28
|
-
|
29
|
-
reftarget =
|
27
|
+
# fragment inserts file suffix, e.g. rfc2911#fragment becomes rfc2911.xml#fragment
|
28
|
+
target = node.target.gsub(/^#/, "").gsub(/(.)(\.xml)?#.*$/, "\\1")
|
29
|
+
# reftarget = target
|
30
|
+
warn %(asciidoctor: WARNING (#{current_location(node)}): fragments not supported on crossreferences in v2: #{node.target} #{node.text}) if node.target =~ /.#/
|
31
|
+
# reftarget = "#{target}##{node.attributes['fragment']}" unless node.attributes["path"].nil?
|
30
32
|
|
31
|
-
xref_contents =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
33
|
+
xref_contents = ""
|
34
|
+
case matched[:format]
|
35
|
+
when "of"
|
36
|
+
prefix = "Section #{matched[:section]} of "
|
37
|
+
when "comma"
|
38
|
+
suffix = ", Section #{matched[:section]}"
|
39
|
+
when "parens"
|
40
|
+
suffix = " (Section #{matched[:section]})"
|
41
|
+
when "bare"
|
42
|
+
xref_contents = matched[:section]
|
43
|
+
end
|
41
44
|
unless matched[:text].empty?
|
42
|
-
xref_contents =
|
45
|
+
xref_contents = if xref_contents.empty?
|
46
|
+
matched[:text].to_s
|
47
|
+
else
|
48
|
+
"#{xref_contents}: #{matched[:text]}"
|
49
|
+
end
|
43
50
|
end
|
44
51
|
|
45
52
|
xref_attributes = {
|
46
|
-
target:
|
53
|
+
target: target,
|
47
54
|
}.reject { |_, value| value.nil? }
|
48
55
|
|
49
56
|
else
|
50
57
|
|
51
|
-
matched = /^format=(?<format>counter|title|none|default)
|
52
|
-
xref_contents = matched.nil?
|
58
|
+
matched = /^format=(?<format>counter|title|none|default)(?<text>:\s*.*)?$/.match node.text
|
59
|
+
xref_contents = if matched.nil?
|
60
|
+
node.text
|
61
|
+
else
|
62
|
+
matched[:text].nil? ? "" : matched[:text].gsub(/^:\s*/, "")
|
63
|
+
end
|
53
64
|
matched ||= {}
|
54
65
|
|
66
|
+
warn %(asciidoctor: WARNING (#{current_location(node)}): fragments not supported on crossreferences in v2: #{node.target} #{node.text}) if node.target =~ /.#/
|
55
67
|
xref_attributes = {
|
56
|
-
|
68
|
+
# fragment inserts file suffix, e.g. rfc2911#fragment becomes rfc2911.xml#fragment
|
69
|
+
target: node.target.gsub(/^#/, "").gsub(/(.)(\.xml)?#.*$/, "\\1"),
|
57
70
|
format: matched[:format],
|
58
71
|
align: node.attr("align"),
|
59
72
|
}
|
60
73
|
end
|
61
74
|
|
62
75
|
noko do |xml|
|
76
|
+
xml << prefix unless prefix.nil? || prefix.empty?
|
63
77
|
xml.xref xref_contents, **attr_code(xref_attributes)
|
78
|
+
xml << suffix unless suffix.nil? || suffix.empty?
|
64
79
|
end.join
|
65
80
|
end
|
66
81
|
|
@@ -89,7 +104,7 @@ module Asciidoctor
|
|
89
104
|
end
|
90
105
|
|
91
106
|
def inline_anchor_ref(node)
|
92
|
-
|
107
|
+
warn %(asciidoctor: WARNING (#{current_location(node)}): anchor "#{node.id}" is not in a place where XML RFC will recognise it as an anchor attribute)
|
93
108
|
end
|
94
109
|
end
|
95
110
|
end
|