module Asciidoctor::RFC::V3::Lists

Constants

OLIST_TYPES

Public Instance Methods

dlist(node) click to toggle source

Syntax:

[[id]]
[horizontal,compact] (optional)
A:: B
C:: D
# File lib/asciidoctor/rfc/v3/lists.rb, line 136
def dlist(node)
  result = []

  result << noko do |xml|
    dl_attributes = {
      anchor: node.id,
      hanging: ("true" if node.style == "horizontal"),
      spacing: ("compact" if node.style == "compact"),
    }

    xml.dl **attr_code(dl_attributes) do |xml_dl|
      node.items.each do |terms, dd|
        terms.each_with_index do |dt, idx|
          xml_dl.dt { |xml_dt| xml_dt << dt.text }
          if idx < terms.size - 1
            xml_dl.dd
          end
        end

        if dd.nil?
          xml_dl.dd
        else
          xml_dl.dd do |xml_dd|
            if dd.blocks?
              if dd.text?
                xml_dd.t { |t| t << dd.text }
              end
              xml_dd << dd.content
            else
              xml_dd << dd.text
            end
          end
        end
      end
    end
  end
  result
end
olist(node) click to toggle source

Syntax:

[[id]]
[start=n,group=n,spacing=normal|compact] (optional)
. A
. B
# File lib/asciidoctor/rfc/v3/lists.rb, line 96
def olist(node)
  result = []

  result << noko do |xml|
    type = OLIST_TYPES[node.style.to_sym]
    type = node.attr("format") unless node.attr("format").nil?
    ol_attributes = {
      anchor: node.id,
      start: node.attr("start"),
      group: node.attr("group"),
      type: type,
      spacing: ("compact" if node.style == "compact") || node.attr("spacing"),
    }

    xml.ol **attr_code(ol_attributes) do |xml_ol|
      node.items.each do |item|
        li_attributes = {
          anchor: item.id,
        }
        xml_ol.li **attr_code(li_attributes) do |xml_li|
          if item.blocks?
            xml_li.t do |t|
              t << item.text
            end
            xml_li << item.content
          else
            xml_li << item.text
          end
        end
      end
    end
  end
  result
end
ulist(node) click to toggle source

Syntax:

[[id]]
[empty=true,spacing=compact|normal] (optional)
* A
* B
# File lib/asciidoctor/rfc/v3/lists.rb, line 48
def ulist(node)
  result = []

  result << noko do |xml|
    ul_attributes = {
      anchor: node.id,
      empty: node.attr("empty"),
      spacing: node.attr("spacing"),
    }

    xml.ul **attr_code(ul_attributes) do |xml_ul|
      node.items.each do |item|
        li_attributes = {
          anchor: item.id,
        }

        xml_ul.li **attr_code(li_attributes) do |xml_li|
          if item.blocks?
            xml_li.t do |t|
              t << item.text
            end
            xml_li << item.content
          else
            xml_li << item.text
          end
        end
      end
    end
  end

  result
end