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.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +3 -0
  3. data/.rubocop.ribose.yml +65 -0
  4. data/.rubocop.tb.yml +640 -0
  5. data/.rubocop.yml +13 -30
  6. data/.travis.yml +8 -3
  7. data/CODE_OF_CONDUCT.md +46 -0
  8. data/Gemfile +8 -1
  9. data/LICENSE +21 -17
  10. data/README.adoc +471 -52
  11. data/asciidoctor-rfc.gemspec +14 -13
  12. data/lib/asciidoctor-rfc.rb +4 -4
  13. data/lib/asciidoctor/rfc/common/base.rb +304 -58
  14. data/lib/asciidoctor/rfc/common/front.rb +3 -3
  15. data/lib/asciidoctor/rfc/v2/base.rb +71 -82
  16. data/lib/asciidoctor/rfc/v2/blocks.rb +33 -10
  17. data/lib/asciidoctor/rfc/v2/converter.rb +0 -3
  18. data/lib/asciidoctor/rfc/v2/inline_anchor.rb +35 -20
  19. data/lib/asciidoctor/rfc/v2/lists.rb +11 -13
  20. data/lib/asciidoctor/rfc/v2/table.rb +11 -9
  21. data/lib/asciidoctor/rfc/v2/validate.rb +18 -724
  22. data/lib/asciidoctor/rfc/v3/base.rb +75 -102
  23. data/lib/asciidoctor/rfc/v3/blocks.rb +7 -9
  24. data/lib/asciidoctor/rfc/v3/converter.rb +0 -1
  25. data/lib/asciidoctor/rfc/v3/front.rb +14 -7
  26. data/lib/asciidoctor/rfc/v3/inline_anchor.rb +12 -9
  27. data/lib/asciidoctor/rfc/v3/lists.rb +31 -45
  28. data/lib/asciidoctor/rfc/v3/table.rb +2 -2
  29. data/lib/asciidoctor/rfc/v3/validate.rb +19 -2153
  30. data/lib/asciidoctor/rfc/v3/validate.rng +1 -1
  31. data/lib/asciidoctor/rfc/version.rb +1 -1
  32. data/rfc2629-other.ent +61 -0
  33. data/rfc2629-xhtml.ent +165 -0
  34. data/rfc2629.dtd +312 -0
  35. data/spec/asciidoctor/rfc/v2/biblio_spec.rb +9 -0
  36. data/spec/asciidoctor/rfc/v2/comments_spec.rb +67 -1
  37. data/spec/asciidoctor/rfc/v2/crossref_spec.rb +127 -5
  38. data/spec/asciidoctor/rfc/v2/date_spec.rb +24 -28
  39. data/spec/asciidoctor/rfc/v2/dlist_spec.rb +5 -5
  40. data/spec/asciidoctor/rfc/v2/image_spec.rb +2 -2
  41. data/spec/asciidoctor/rfc/v2/inline_formatting_spec.rb +28 -0
  42. data/spec/asciidoctor/rfc/v2/listing_spec.rb +2 -2
  43. data/spec/asciidoctor/rfc/v2/literal_spec.rb +4 -4
  44. data/spec/asciidoctor/rfc/v2/preamble_spec.rb +1 -1
  45. data/spec/asciidoctor/rfc/v2/quote_spec.rb +1 -1
  46. data/spec/asciidoctor/rfc/v2/references_spec.rb +210 -3
  47. data/spec/asciidoctor/rfc/v2/section_spec.rb +33 -0
  48. data/spec/asciidoctor/rfc/v2/table_spec.rb +40 -1
  49. data/spec/asciidoctor/rfc/v2/text_spec.rb +71 -14
  50. data/spec/asciidoctor/rfc/v2/ulist_spec.rb +1 -1
  51. data/spec/asciidoctor/rfc/v3/biblio_spec.rb +13 -0
  52. data/spec/asciidoctor/rfc/v3/comments_spec.rb +71 -0
  53. data/spec/asciidoctor/rfc/v3/crossref_spec.rb +7 -0
  54. data/spec/asciidoctor/rfc/v3/dlist_spec.rb +4 -4
  55. data/spec/asciidoctor/rfc/v3/literal_spec.rb +1 -1
  56. data/spec/asciidoctor/rfc/v3/preamble_spec.rb +1 -1
  57. data/spec/asciidoctor/rfc/v3/references_spec.rb +208 -3
  58. data/spec/asciidoctor/rfc/v3/series_info_spec.rb +1 -1
  59. data/spec/asciidoctor/rfc/v3/table_spec.rb +70 -1
  60. data/spec/examples/README.adoc +42 -6
  61. data/spec/examples/biblio-insert-v2.adoc +29 -0
  62. data/spec/examples/biblio-insert-v3.adoc +30 -0
  63. data/spec/examples/davies-template-bare-06.adoc +1 -0
  64. data/spec/examples/draft-iab-html-rfc-bis.xml.adoc +2300 -0
  65. data/spec/examples/draft-iab-html-rfc-bis.xml.orig +1999 -0
  66. data/spec/examples/draft-iab-html-rfc-bis.xml.txt +2298 -0
  67. data/spec/examples/draft-iab-rfc-framework-bis.xml.adoc +662 -0
  68. data/spec/examples/draft-iab-rfc-framework-bis.xml.orig +476 -0
  69. data/spec/examples/draft-ietf-core-block-xx.mkd.adoc +8 -33
  70. data/spec/examples/hoffmanv2.xml.adoc +4 -0
  71. data/spec/examples/mib-doc-template-xml-06.adoc +6 -8
  72. data/spec/examples/refs-v2-database.xml +86 -0
  73. data/spec/examples/refs-v2.adoc +49 -0
  74. data/spec/examples/refs-v2.xml +50 -0
  75. data/spec/examples/refs-v2/AsciiDoc.xml +8 -0
  76. data/spec/examples/refs-v2/AsciiMathML.xml +8 -0
  77. data/spec/examples/refs-v2/IETF-BibXML.xml +9 -0
  78. data/spec/examples/refs-v2/MathJax.xml +8 -0
  79. data/spec/examples/refs-v2/NroffEdit.xml +8 -0
  80. data/spec/examples/refs-v2/TeX-LaTeX.xml +8 -0
  81. data/spec/examples/refs-v2/abarth +17 -0
  82. data/spec/examples/refs-v2/asciidoctor-bibliography.xml +19 -0
  83. data/spec/examples/refs-v2/asciidoctor-manual.xml +11 -0
  84. data/spec/examples/refs-v2/asciidoctor-rfc.xml +18 -0
  85. data/spec/examples/refs-v2/asciidoctor.xml +10 -0
  86. data/spec/examples/refs-v2/draftr.xml +8 -0
  87. data/spec/examples/refs-v2/kramdown-rfc2629.xml +8 -0
  88. data/spec/examples/refs-v2/lyx2rfc.xml +8 -0
  89. data/spec/examples/refs-v2/mmark.xml +9 -0
  90. data/spec/examples/refs-v2/pandoc2rfc.xml +8 -0
  91. data/spec/examples/refs-v2/reference.RFC.2119.xml +7 -0
  92. data/spec/examples/refs-v2/reference.RFC.5385.xml +7 -0
  93. data/spec/examples/refs-v2/reference.RFC.7328.xml +7 -0
  94. data/spec/examples/refs-v2/reference.RFC.7749.xml +7 -0
  95. data/spec/examples/refs-v2/reference.RFC.7763.xml +7 -0
  96. data/spec/examples/refs-v2/reference.RFC.7764.xml +7 -0
  97. data/spec/examples/refs-v2/reference.RFC.7990.xml +7 -0
  98. data/spec/examples/refs-v2/reference.RFC.7991.xml +7 -0
  99. data/spec/examples/refs-v3-database.xml +137 -0
  100. data/spec/examples/refs-v3.adoc +57 -0
  101. data/spec/examples/refs-v3.xml +90 -0
  102. data/spec/examples/refs-v3/AsciiDoc.xml +8 -0
  103. data/spec/examples/refs-v3/AsciiMathML.xml +8 -0
  104. data/spec/examples/refs-v3/IETF-BibXML.xml +9 -0
  105. data/spec/examples/refs-v3/MathJax.xml +8 -0
  106. data/spec/examples/refs-v3/NroffEdit.xml +8 -0
  107. data/spec/examples/refs-v3/TeX-LaTeX.xml +8 -0
  108. data/spec/examples/refs-v3/abarth +17 -0
  109. data/spec/examples/refs-v3/asciidoctor-bibliography.xml +19 -0
  110. data/spec/examples/refs-v3/asciidoctor-manual.xml +11 -0
  111. data/spec/examples/refs-v3/asciidoctor-rfc.xml +18 -0
  112. data/spec/examples/refs-v3/asciidoctor.xml +10 -0
  113. data/spec/examples/refs-v3/draftr.xml +8 -0
  114. data/spec/examples/refs-v3/kramdown-rfc2629.xml +8 -0
  115. data/spec/examples/refs-v3/lyx2rfc.xml +8 -0
  116. data/spec/examples/refs-v3/mathrefs.xml +19 -0
  117. data/spec/examples/refs-v3/mmark.xml +9 -0
  118. data/spec/examples/refs-v3/pandoc2rfc.xml +8 -0
  119. data/spec/examples/refs-v3/reference.RFC.2119.xml +7 -0
  120. data/spec/examples/refs-v3/reference.RFC.5385.xml +7 -0
  121. data/spec/examples/refs-v3/reference.RFC.7328.xml +7 -0
  122. data/spec/examples/refs-v3/reference.RFC.7749.xml +7 -0
  123. data/spec/examples/refs-v3/reference.RFC.7763.xml +7 -0
  124. data/spec/examples/refs-v3/reference.RFC.7764.xml +7 -0
  125. data/spec/examples/refs-v3/reference.RFC.7990.xml +7 -0
  126. data/spec/examples/refs-v3/reference.RFC.7991.xml +7 -0
  127. data/spec/examples/rfc2100.md.adoc +57 -44
  128. data/spec/examples/rfc3514.md.adoc +1 -1
  129. data/spec/examples/rfc6350.adoc +701 -695
  130. data/spec/examples/rfc6350.txt.orig +3372 -0
  131. data/spec/examples/rfc6350_refs.xml +774 -0
  132. data/spec/examples/rfc748.md.adoc +1 -1
  133. data/spec/examples/rfc7511.md.adoc +3 -3
  134. data/spec/examples/skel.mkd.adoc +1 -0
  135. data/spec/examples/stupid-s.mkd.adoc +4 -4
  136. metadata +94 -8
  137. data/spec/examples/rfc6350.bib +0 -763
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  module Asciidoctor
2
4
  module RFC::V3
3
5
  module Base
@@ -29,7 +31,6 @@ module Asciidoctor
29
31
  # == Appendix
30
32
  def document(node)
31
33
  $seen_back_matter = false
32
- $seen_abstract = false
33
34
  # If this is present, then BCP14 keywords in boldface are not assumed to be <bcp14> tags. By default they are.
34
35
  $bcp_bold = !(node.attr? "no-rfc-bold-bcp14")
35
36
  $smart_quotes = (node.attr("smart-quotes") != "false")
@@ -57,6 +58,7 @@ module Asciidoctor
57
58
  'xml:lang': node.attr("xml-lang"),
58
59
  prepTime: preptime,
59
60
  version: "3",
61
+ 'xmlns:xi': "http://www.w3.org/2001/XInclude",
60
62
  }
61
63
 
62
64
  rfc_open = noko { |xml| xml.rfc **attr_code(rfc_attributes) }.join.gsub(/\/>$/, ">")
@@ -80,26 +82,21 @@ module Asciidoctor
80
82
  result.map { |e| e =~ /<\/front><middle1>/ ? "</front><middle>" : e }
81
83
  end
82
84
  ret = result * "\n"
83
- ret = set_pis(node, Nokogiri::XML(ret)).to_xml
84
- ret = cleanup ret
85
- Validate::validate(ret)
86
- ret
85
+ ret = cleanup(ret)
86
+ ret1 = Nokogiri::XML(ret)
87
+ ret1 = set_pis(node, ret1)
88
+ ret1 = insert_biblio(node, ret1) unless node.attr("biblio-dir").nil? || node.attr("biblio-dir").empty?
89
+ Validate::validate(ret1)
90
+ ret1 = resolve_references(node, ret1)
91
+ # Validate::validate(ret1)
92
+ ret1.to_xml
87
93
  end
88
94
 
89
- def set_pis(node, doc)
90
- # Below are generally applicable Processing Instructions (PIs)
91
- # that most I-Ds might want to use. (Here they are set differently than
92
- # their defaults in xml2rfc v1.32)
93
- rfc_pis = common_rfc_pis(node)
94
-
95
- doc.create_internal_subset("rfc", nil, "rfc2629.dtd")
96
- rfc_pis.each_pair do |k, v|
97
- pi = Nokogiri::XML::ProcessingInstruction.new(doc,
98
- "rfc",
99
- "#{k}=\"#{v}\"")
100
- doc.root.add_previous_sibling(pi)
95
+ def resolve_references(node, doc)
96
+ extract_entities(node, doc).each do |entity|
97
+ # TODO actual XML
98
+ entity[:node].replace("<xi:include href='#{entity[:url]}' parse='text'/>")
101
99
  end
102
-
103
100
  doc
104
101
  end
105
102
 
@@ -110,7 +107,7 @@ module Asciidoctor
110
107
  def link(node)
111
108
  result = []
112
109
  result << noko do |xml|
113
- links = (node.attr("link") || "").split(/,/)
110
+ links = (node.attr("link") || "").split(/,\s*/)
114
111
  links.each do |link|
115
112
  matched = /^(?<href>\S+)\s+(?<rel>\S+)$/.match link
116
113
  link_attributes = {
@@ -132,15 +129,16 @@ module Asciidoctor
132
129
  end
133
130
 
134
131
  BCP_KEYWORDS = [
135
- 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL', 'SHALL NOT',
136
- 'SHOULD', 'SHOULD NOT', 'RECOMMENDED', 'MAY', 'OPTIONAL'
137
- ]
132
+ "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
133
+ "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", "OPTIONAL"
134
+ ].freeze
135
+
138
136
  def inline_quoted(node)
139
137
  noko do |xml|
140
138
  case node.type
141
139
  when :emphasis then xml.em node.text
142
140
  when :strong
143
- if $bcp_bold && BCP_KEYWORDS.exist?(node.text)
141
+ if $bcp_bold && BCP_KEYWORDS.include?(node.text)
144
142
  xml.bcp14 node.text
145
143
  else
146
144
  xml.strong node.text
@@ -156,6 +154,8 @@ module Asciidoctor
156
154
  # [bcp14]#MUST NOT#
157
155
  if node.role == "bcp14"
158
156
  xml.bcp14 node.text.upcase
157
+ elsif node.role == "comment"
158
+ xml.comment " " + node.text + " "
159
159
  else
160
160
  xml << node.text
161
161
  end
@@ -168,11 +168,10 @@ module Asciidoctor
168
168
  # [keepWithNext=true,keepWithPrevious=true] (optional)
169
169
  # Text
170
170
  def paragraph(node)
171
- result = []
172
-
173
- if (node.parent.context == :preamble) && !$seen_abstract
174
- $seen_abstract = true
175
- result << "<abstract>"
171
+ if node.role == "comment"
172
+ return noko do |xml|
173
+ xml.comment " " + [flatten_rawtext(node)].flatten.join("\n") + " "
174
+ end.join("\n")
176
175
  end
177
176
 
178
177
  t_attributes = {
@@ -180,13 +179,56 @@ module Asciidoctor
180
179
  keepWithNext: node.attr("keep-with-next"),
181
180
  keepWithPrevious: node.attr("keep-with-previous"),
182
181
  }
183
-
184
- result << noko do |xml|
182
+ return noko do |xml|
185
183
  xml.t **attr_code(t_attributes) do |xml_t|
186
184
  xml_t << node.content
187
185
  end
186
+ end.join("\n")
187
+ end
188
+
189
+ def ref_section(node)
190
+ result = []
191
+ $processing_reflist = true
192
+ references_attributes = {
193
+ anchor: node.id,
194
+ }
195
+
196
+ if node.blocks.empty?
197
+ result << noko do |xml|
198
+ xml.references **references_attributes do |xml_references|
199
+ xml_references.name node.title unless node.title.nil?
200
+ end
201
+ end
202
+ end
203
+ node.blocks.each do |block|
204
+ if block.context == :section
205
+ result << section(block)
206
+ elsif block.context == :pass
207
+ # we are assuming a single contiguous :pass block of XML
208
+ result << noko do |xml|
209
+ xml.references **references_attributes do |xml_references|
210
+ xml_references.name node.title unless node.title.nil?
211
+ # xml_references << reflist(block).join("\n")
212
+ # NOTE: we're allowing the user to do more or less whathever
213
+ # in the passthrough since the xpath below just fishes out ALL
214
+ # <reference>s in an unrooted fragment, regardless of structure.
215
+ Nokogiri::XML::DocumentFragment.
216
+ parse(block.content).xpath(".//reference").
217
+ each { |reference| xml_references << reference.to_xml }
218
+ end
219
+ end
220
+ elsif block.context == :ulist
221
+ block.items.each(&:text)
222
+ # we only process the item for its displayreferences
223
+ end
188
224
  end
189
225
 
226
+ unless $xreftext.empty? || $seen_back_matter
227
+ result = result.unshift($xreftext.keys.map { |k| %(<displayreference target="#{k}" to="#{$xreftext[k]}"/>) })
228
+ end
229
+ result = result.unshift("</middle><back>") unless $seen_back_matter
230
+ $processing_reflist = false
231
+ $seen_back_matter = true
190
232
  result
191
233
  end
192
234
 
@@ -204,65 +246,11 @@ module Asciidoctor
204
246
  # * [[[ref1]]] Ref [must provide references as list]
205
247
  # * [[[ref2]]] Ref
206
248
  def section(node)
207
- result = []
208
249
  if node.attr("style") == "bibliography" ||
209
250
  node.parent.context == :section && node.parent.attr("style") == "bibliography"
210
- $processing_reflist = true
211
-
212
- references_attributes = {
213
- anchor: node.id,
214
- }
215
- =begin
216
- result << noko do |xml|
217
- xml.references **attr_code(references_attributes) do |references_xml|
218
- references_xml.name node.title unless node.title.nil?
219
- node.blocks.each { |b| references_xml << reflist(b).join }
220
- end
221
- end
222
-
223
- anchor_attribute = node.id.nil? ? nil : " anchor=\"#{node.id}\""
224
- result << "<references#{anchor_attribute}>"
225
- result << "<name>#{node.title}</name>" unless node.title.nil?
226
- # require that references be a :pass xml block
227
- # potentially with an initial block of display reference equivalences
228
- node.blocks.each do |b|
229
- if b.context == :pass
230
- result << reflist(b)
231
- elsif b.context == :section
232
- result << node.content
233
- elsif b.context == :ulist
234
- b.items.each do |i|
235
- i.text # we only process the item for its displayreferences
236
- end
237
- end
238
- end
239
- result << "</references>"
240
- =end
241
- node.blocks.each do |block|
242
- if block.context == :section
243
- result << section(block)
244
- elsif block.context == :pass
245
- # we are assuming a single contiguous :pass block of XML
246
- result << noko do |xml|
247
- xml.references **attr_code(references_attributes) do |xml_references|
248
- xml_references.name node.title unless node.title.nil?
249
- xml_references << reflist(block).join
250
- end
251
- end
252
- elsif block.context == :ulist
253
- block.items.each do |i|
254
- i.text # we only process the item for its displayreferences
255
- end
256
- end
257
- end
258
-
259
- unless $xreftext.empty? || $seen_back_matter
260
- result = result.unshift($xreftext.keys.map { |k| %(<displayreference target="#{k}" to="#{$xreftext[k]}"/>) })
261
- end
262
- result = result.unshift("</middle><back>") unless $seen_back_matter
263
- $processing_reflist = false
264
- $seen_back_matter = true
251
+ result = ref_section(node)
265
252
  else
253
+ result = []
266
254
  if node.attr("style") == "appendix"
267
255
  result << "</middle><back>" unless $seen_back_matter
268
256
  $seen_back_matter = true
@@ -333,22 +321,7 @@ module Asciidoctor
333
321
  end
334
322
  end
335
323
  end
336
- unless $smart_quotes
337
- xmldoc.traverse do |node|
338
- if node.text?
339
- node.content = node.content.tr("\u2019", "'")
340
- node.content = node.content.gsub(/\&#8217;/, "'")
341
- node.content = node.content.gsub(/\&#x2019;/, "'")
342
- elsif node.element?
343
- node.attributes.each do |k, v|
344
- node.set_attribute(k, v.content.tr("\u2019", "'"))
345
- node.set_attribute(k, v.content.gsub(/\&#8217;/, "'"))
346
- node.set_attribute(k, v.content.gsub(/\&#x2019;/, "'"))
347
- end
348
- end
349
- end
350
- end
351
-
324
+ xmldoc = smart_quote_cleanup(xmldoc) unless $smart_quotes
352
325
  xmldoc.to_xml(encoding: "US-ASCII")
353
326
  end
354
327
  end
@@ -1,4 +1,5 @@
1
1
  require "htmlentities"
2
+ require "uri"
2
3
 
3
4
  module Asciidoctor
4
5
  module RFC::V3
@@ -66,7 +67,6 @@ module Asciidoctor
66
67
  end
67
68
  end
68
69
 
69
-
70
70
  # Syntax:
71
71
  # [[id]]
72
72
  # [quote, attribution, citation info] # citation info limited to URL
@@ -119,11 +119,6 @@ module Asciidoctor
119
119
  def admonition(node)
120
120
  result = []
121
121
  if node.parent.context == :preamble
122
- if $seen_abstract
123
- result << "</abstract>"
124
- $seen_abstract = false
125
- end
126
-
127
122
  note_attributes = {
128
123
  removeInRFC: node.attr("remove-in-rfc"),
129
124
  }
@@ -144,7 +139,7 @@ module Asciidoctor
144
139
  cref_contents = node.blocks? ? flatten(node) : node.content
145
140
  cref_contents = [cref_contents].flatten.join("\n")
146
141
  warn <<~WARNING_MESSAGE if node.blocks?
147
- asciidoctor: WARNING: comment can not contain blocks of text in XML RFC:\n #{node.content}
142
+ asciidoctor: WARNING (#{current_location(node)}): comment can not contain blocks of text in XML RFC:\n #{node.content}
148
143
  WARNING_MESSAGE
149
144
 
150
145
  result << noko do |xml|
@@ -162,8 +157,11 @@ module Asciidoctor
162
157
  # Sidebar
163
158
  # ****
164
159
  def sidebar(node)
160
+ aside_attributes = {
161
+ anchor: node.id,
162
+ }
165
163
  noko do |xml|
166
- xml.aside anchor: node.id do |xml_aside|
164
+ xml.aside **attr_code(aside_attributes) do |xml_aside|
167
165
  xml_aside << node.content
168
166
  end
169
167
  end
@@ -177,7 +175,7 @@ module Asciidoctor
177
175
  def example(node)
178
176
  node.blocks.each do |b|
179
177
  unless %i{listing image literal stem}.include? b.context
180
- warn "asciidoctor: WARNING: examples (figures) should only contain listings (sourcecode), images (artwork), or literal (artwork):\n#{b.lines}"
178
+ warn "asciidoctor: WARNING (#{current_location(b)}): examples (figures) should only contain listings (sourcecode), images (artwork), or literal (artwork):\n#{b.lines}"
181
179
  end
182
180
  end
183
181
 
@@ -35,7 +35,6 @@ module Asciidoctor
35
35
  register_for "rfc3"
36
36
 
37
37
  $seen_back_matter = false
38
- $seen_abstract = false
39
38
  $xreftext = {}
40
39
 
41
40
  def initialize(backend, opts)
@@ -22,8 +22,13 @@ module Asciidoctor
22
22
  return if docname.nil? || docname&.empty?
23
23
  is_rfc = docname =~ /^rfc-?/i || node.attr("doctype") == "rfc"
24
24
 
25
- name = is_rfc ? docname.gsub(/^rfc-?/i, "") : docname
26
- nameattr = is_rfc ? "RFC" : "Internet-Draft"
25
+ if is_rfc
26
+ name = docname.gsub(/^rfc-?/i, "")
27
+ nameattr = "RFC"
28
+ else
29
+ name = docname
30
+ nameattr = "Internet-Draft"
31
+ end
27
32
  value = name.gsub(/\.[^\/]+$/, "")
28
33
 
29
34
  seriesInfo_attributes = {
@@ -37,7 +42,7 @@ module Asciidoctor
37
42
  intendedstatus = node.attr("intended-series")
38
43
  if !is_rfc && !intendedstatus.nil?
39
44
  unless intendedstatus =~ /^(standard|full-standard|bcp|fyi|informational|experimental|historic)$/
40
- warn %(asciidoctor: WARNING: disallowed value for intended-series: #{intendedstatus})
45
+ warn %(asciidoctor: WARNING (#{current_location(node)}): disallowed value for intended-series in document header: #{intendedstatus})
41
46
  end
42
47
  seriesInfo_attributes = {
43
48
  name: "",
@@ -53,14 +58,16 @@ module Asciidoctor
53
58
  if m.nil?
54
59
  rfcstatus = "exp" if rfcstatus == "experimental"
55
60
  rfcstatus = "info" if rfcstatus == "informational"
56
- warn %(asciidoctor: WARNING: disallowed value for intended-series with no series number: #{rfcstatus}) unless rfcstatus =~ /^(info|exp|historic)$/
61
+ warn %(asciidoctor: WARNING (#{current_location(node)}): disallowed value for intended-series in document header with no series number: #{rfcstatus}) unless rfcstatus =~ /^(info|exp|historic)$/
57
62
  else
58
- warn %(asciidoctor: WARNING: disallowed value for intended-series with series number: #{m[1]}) unless m[1] =~ /^(standard|full-standard|bcp)$/
63
+ rfcstatus = m[1]
64
+ value = m[2]
65
+ warn %(asciidoctor: WARNING (#{current_location(node)}): disallowed value for intended-series in document header with series number: #{rfcstatus}) unless rfcstatus =~ /^(standard|full-standard|bcp)$/
59
66
  end
60
67
  seriesInfo_attributes = {
61
68
  name: "",
62
- status: m.nil? ? rfcstatus : m[1],
63
- value: m.nil? ? value : m[2],
69
+ status: rfcstatus,
70
+ value: value,
64
71
  }
65
72
  xml.seriesInfo **attr_code(seriesInfo_attributes)
66
73
  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
 
@@ -30,7 +30,8 @@ module Asciidoctor
30
30
  relative: node.attributes["path"].nil? ? nil : node.attributes["fragment"],
31
31
  section: matched[:section],
32
32
  displayFormat: matched[:format],
33
- target: node.target.gsub(/\..*$/, "").gsub(/^#/, ""),
33
+ # fragment inserts file suffix, e.g. rfc2911#fragment becomes rfc2911.xml#fragment
34
+ target: node.target.gsub(/^#/, "").gsub(/(.)(\.xml)?#.*$/, "\\1"),
34
35
  }
35
36
 
36
37
  noko do |xml|
@@ -38,14 +39,17 @@ module Asciidoctor
38
39
  end.join
39
40
  else
40
41
  xref_contents = node.text
42
+ matched = /^format=(?<format>counter|title|none|default)(?<text>:\s*.*)?$/.match xref_contents
43
+ xref_contents = if matched.nil?
44
+ xref_contents
45
+ else
46
+ matched[:text].nil? ? "" : matched[:text].gsub(/^:\s*/, "")
47
+ end
41
48
 
42
- matched = /^format=(?<format>counter|title|none|default):\s*(?<text>.*)$/.match xref_contents
43
-
44
- xref_contents = matched[:text] if matched
45
-
49
+ warn %(asciidoctor: WARNING (#{current_location(node)}): fragments not supported on crossreferences in v3 without relref: #{node.target} #{node.text}) if node.target =~ /.#/
46
50
  xref_attributes = {
47
51
  format: matched&.[](:format),
48
- target: node.target.gsub(/^#/, ""),
52
+ target: node.target.gsub(/^#/, "").gsub(/(.)(\.xml)?#.*$/, "\\1"),
49
53
  }
50
54
 
51
55
  noko do |xml|
@@ -56,7 +60,6 @@ module Asciidoctor
56
60
 
57
61
  def inline_anchor_link(node)
58
62
  eref_contents = node.target == node.text ? nil : node.text
59
-
60
63
  eref_attributes = {
61
64
  target: node.target,
62
65
  }
@@ -79,7 +82,7 @@ module Asciidoctor
79
82
  end
80
83
 
81
84
  def inline_anchor_ref(node)
82
- warn %(asciidoctor: WARNING: anchor "#{node.id}" is not in a place where XML RFC will recognise it as an anchor attribute)
85
+ warn %(asciidoctor: WARNING (#{current_location(node)}): anchor "#{node.id}" is not in a place where XML RFC will recognise it as an anchor attribute)
83
86
  end
84
87
  end
85
88
  end
@@ -8,37 +8,37 @@ module Asciidoctor
8
8
  # * [[[ref4]]] C
9
9
  # * [[[ref4]]] D
10
10
  # @note ulist repurposed as reference list
11
- # def reflist(node)
12
- # result = []
13
- # if node.context == :ulist
14
- # node.items.each do |item|
15
- # # we expect the biblio anchor to be right at the start of the reference
16
- # if item.blocks?
17
- # # we expect any list to be embedded, and only one level of embedding
18
- # # we expect no content in the referencegroup line other than the bibliographic anchor
19
- # result << "<referencegroup>#{item.text}".gsub(/<referencegroup>\s*\[?<bibanchor="([^"]+)">\]?.*$/, "<referencegroup anchor=\"\\1\">")
20
- # item.blocks.each { |b| result << reflist(b) }
21
- # result << "</referencegroup>"
22
- # else
23
- # # quoteTitle = get_header_attribute item, "quoteTitle"
24
- # # target = get_header_attribute item, "target"
25
- # # annotation = get_header_attribute item, "annotation"
26
- # # FIXME: [[[x]]] within embedded list is processed as [<bibref>]
27
- # result << "<reference>#{item.text}</refcontent></reference>".gsub(/<reference>\s*\[?<bibanchor="([^"]+)">\]?\s*/, "<reference anchor=\"\\1\"><refcontent>")
28
- # end
29
- # end
30
- # elsif node.context == :pass
31
- # # we expect raw xml
32
- # node.lines.each do |item|
33
- # # undo XML substitution
34
- # ref = item.gsub(/\&lt;/, "<").gsub(/\&gt;/, ">")
35
- # result << ref
36
- # end
37
- # else
38
- # warn %(asciidoctor: WARNING: references are not a ulist or raw XML: #{node.context})
39
- # end
40
- # result
41
- # end
11
+ # def reflist(node)
12
+ # result = []
13
+ # if node.context == :ulist
14
+ # node.items.each do |item|
15
+ # # we expect the biblio anchor to be right at the start of the reference
16
+ # if item.blocks?
17
+ # # we expect any list to be embedded, and only one level of embedding
18
+ # # we expect no content in the referencegroup line other than the bibliographic anchor
19
+ # result << "<referencegroup>#{item.text}".gsub(/<referencegroup>\s*\[?<bibanchor="([^"]+)">\]?.*$/, "<referencegroup anchor=\"\\1\">")
20
+ # item.blocks.each { |b| result << reflist(b) }
21
+ # result << "</referencegroup>"
22
+ # else
23
+ # # quoteTitle = get_header_attribute item, "quoteTitle"
24
+ # # target = get_header_attribute item, "target"
25
+ # # annotation = get_header_attribute item, "annotation"
26
+ # # FIXME: [[[x]]] within embedded list is processed as [<bibref>]
27
+ # result << "<reference>#{item.text}</refcontent></reference>".gsub(/<reference>\s*\[?<bibanchor="([^"]+)">\]?\s*/, "<reference anchor=\"\\1\"><refcontent>")
28
+ # end
29
+ # end
30
+ # elsif node.context == :pass
31
+ # # we expect raw xml
32
+ # node.lines.each do |item|
33
+ # # undo XML substitution
34
+ # ref = item.gsub(/\&lt;/, "<").gsub(/\&gt;/, ">")
35
+ # result << ref
36
+ # end
37
+ # else
38
+ # warn %(asciidoctor: WARNING: references are not a ulist or raw XML: #{node.context})
39
+ # end
40
+ # result
41
+ # end
42
42
 
43
43
  # Syntax:
44
44
  # [[id]]
@@ -48,11 +48,6 @@ module Asciidoctor
48
48
  def ulist(node)
49
49
  result = []
50
50
 
51
- if node.parent.context == :preamble && !$seen_abstract
52
- $seen_abstract = true
53
- result << "<abstract>"
54
- end
55
-
56
51
  result << noko do |xml|
57
52
  ul_attributes = {
58
53
  anchor: node.id,
@@ -100,10 +95,6 @@ module Asciidoctor
100
95
  # . B
101
96
  def olist(node)
102
97
  result = []
103
- if node.parent.context == :preamble && !$seen_abstract
104
- $seen_abstract = true
105
- result << "<abstract>"
106
- end
107
98
 
108
99
  result << noko do |xml|
109
100
  type = OLIST_TYPES[node.style.to_sym]
@@ -145,11 +136,6 @@ module Asciidoctor
145
136
  def dlist(node)
146
137
  result = []
147
138
 
148
- if node.parent.context == :preamble && !$seen_abstract
149
- $seen_abstract = true
150
- result << "<abstract>"
151
- end
152
-
153
139
  result << noko do |xml|
154
140
  dl_attributes = {
155
141
  anchor: node.id,