module Asciidoctor::RFC::V3::Blocks
Public Instance Methods
admonition(node)
click to toggle source
Syntax:
= Title Author :HEADER ABSTRACT NOTE: note [NOTE] .Title (in preamble) ==== Content ==== [NOTE,removeInRFC=true] (in preamble) [NOTE,display=true|false,source=name] (in body) .Title ==== Content ====
@note admonitions within preamble are notes. Elsewhere, they are comments.
# File lib/asciidoctor/rfc/v3/blocks.rb, line 131 def admonition(node) result = [] if node.parent.context == :preamble note_attributes = { removeInRFC: node.attr("remove-in-rfc"), } result << noko do |xml| xml.note **attr_code(note_attributes) do |xml_note| xml_note.name node.title unless node.title.nil? xml_note << HTMLEntities.new.decode([paragraph1(node)].flatten.join("\n")) end end else cref_attributes = { anchor: node.id, display: node.attr("display"), source: node.attr("source"), } cref_contents = node.blocks? ? flatten(node) : node.content cref_contents = [cref_contents].flatten.join("\n") warn <<~WARNING_MESSAGE if node.blocks? asciidoctor: WARNING (#{current_location(node)}): comment can not contain blocks of text in XML RFC:\n #{node.content} WARNING_MESSAGE result << noko do |xml| xml.cref **attr_code(cref_attributes) do |xml_cref| xml_cref << cref_contents end end end result end
example(node)
click to toggle source
Syntax:
.Title ==== Example ====
# File lib/asciidoctor/rfc/v3/blocks.rb, line 187 def example(node) node.blocks.each do |b| unless %i{listing image literal stem}.include? b.context warn "asciidoctor: WARNING (#{current_location(b)}): examples (figures) should only contain listings (sourcecode), images (artwork), or literal (artwork):\n#{b.lines}" end end figure_attributes = { anchor: node.id, } noko do |xml| xml.figure **attr_code(figure_attributes) do |xml_figure| xml_figure.name node.title if node.title? # TODO iref xml_figure << node.content end end end
floating_title(node)
click to toggle source
listing(node)
click to toggle source
Syntax:
.name [source,type,src=uri] (src is mutually exclusive with listing content) (v3) [source,type,src=uri,align,alt] (src is mutually exclusive with listing content) (v2) ---- code ----
# File lib/asciidoctor/rfc/v3/blocks.rb, line 214 def listing(node) sourcecode_attributes = { anchor: node.id, align: nil, alt: nil, name: node.title, type: node.attr("language"), src: node.attr("src"), } # NOTE: html escaping is performed by Nokogiri sourcecode_content = sourcecode_attributes[:src].nil? ? "\n" + node.lines.join("\n") + "\n" : "" noko do |xml| if node.parent.context != :example xml.figure do |xml_figure| # xml_figure.sourcecode sourcecode_content, **attr_code(sourcecode_attributes) xml_figure.sourcecode **attr_code(sourcecode_attributes) do |a| a.cdata sourcecode_content end end else # xml.sourcecode sourcecode_content, **attr_code(sourcecode_attributes) xml.sourcecode **attr_code(sourcecode_attributes) do |a| a.cdata sourcecode_content end end end end
literal(node)
click to toggle source
Syntax:
[[id]] .name [align=left|center|right,alt=alt_text] (optional) .... literal ....
# File lib/asciidoctor/rfc/v3/blocks.rb, line 23 def literal(node) artwork_attributes = { anchor: node.id, align: node.attr("align"), type: "ascii-art", name: node.title, alt: node.attr("alt"), } # NOTE: html escaping is performed by Nokogiri artwork_content = "\n" + node.lines.join("\n") + "\n" noko do |xml| if node.parent.context != :example xml.figure do |xml_figure| # xml_figure.artwork artwork_content, **attr_code(artwork_attributes) xml_figure.artwork **attr_code(artwork_attributes) do |a| a.cdata artwork_content end end else # xml.artwork artwork_content, **attr_code(artwork_attributes) xml.artwork **attr_code(artwork_attributes) do |a| a.cdata artwork_content end end end end
quote(node)
click to toggle source
Syntax:
[[id]] [quote, attribution, citation info] # citation info limited to URL Text
# File lib/asciidoctor/rfc/v3/blocks.rb, line 86 def quote(node) cite_value = node.attr("citetitle") cite_value = nil unless cite_value.to_s =~ URI::DEFAULT_PARSER.make_regexp blockquote_attributes = { anchor: node.id, quotedFrom: node.attr("attribution"), cite: cite_value, } noko do |xml| xml.blockquote **attr_code(blockquote_attributes) do |xml_blockquote| xml_blockquote << node.content end end end
stem(node)
click to toggle source
stem is treated as literal, but with center alignment
# File lib/asciidoctor/rfc/v3/blocks.rb, line 53 def stem(node) artwork_attributes = { anchor: node.id, align: node.attr("align") || "center", type: "ascii-art", name: node.title, alt: node.attr("alt"), } # NOTE: html escaping is performed by Nokogiri artwork_content = "\n" + node.lines.join("\n") + "\n" noko do |xml| if node.parent.context != :example xml.figure do |xml_figure| # xml_figure.artwork artwork_content, **attr_code(artwork_attributes) xml_figure.artwork **attr_code(artwork_attributes) do |a| a.cdata artwork_content end end else # xml.artwork artwork_content, **attr_code(artwork_attributes) xml.artwork **attr_code(artwork_attributes) do |a| a.cdata artwork_content end end end end
verse(node)
click to toggle source
realise as quote() ; <br/> in v3 does not have the applicability of <vspace/>, it is restricted to tables
# File lib/asciidoctor/rfc/v3/blocks.rb, line 105 def verse(node) quote(node) end