class Asciidoctor::Converter::DocBook5Converter

A built-in {Converter} implementation that generates DocBook 5 output similar to the docbook45 backend from AsciiDoc Python, but migrated to the DocBook 5 specification.

Constants

DLIST_TAGS
QUOTE_TAGS
TABLE_PI_NAMES
TABLE_SECTIONS

Public Instance Methods

admonition(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 63
    def admonition node
      %Q(<#{tag_name = node.attr 'name'}#{common_attributes node.id, node.role, node.reftext}>
#{title_tag node}#{resolve_content node}
</#{tag_name}>)
    end
author_element(doc, index = nil) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 615
def author_element doc, index = nil
  firstname_key = index ? %Q(firstname_#{index}) : 'firstname'
  middlename_key = index ? %Q(middlename_#{index}) : 'middlename'
  lastname_key = index ? %Q(lastname_#{index}) : 'lastname'
  email_key = index ? %Q(email_#{index}) : 'email'

  result = []
  result << '<author>'
  result << '<personname>'
  result << %Q(<firstname>#{doc.attr firstname_key}</firstname>) if doc.attr? firstname_key
  result << %Q(<othername>#{doc.attr middlename_key}</othername>) if doc.attr? middlename_key
  result << %Q(<surname>#{doc.attr lastname_key}</surname>) if doc.attr? lastname_key
  result << '</personname>'
  result << %Q(<email>#{doc.attr email_key}</email>) if doc.attr? email_key
  result << '</author>'

  result * EOL
end
colist(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 71
def colist node
  result = []
  result << %Q(<calloutlist#{common_attributes node.id, node.role, node.reftext}>)
  result << %Q(<title>#{node.title}</title>) if node.title?
  node.items.each do |item|
    result << %Q(<callout arearefs="#{item.attr 'coids'}">)
    result << %Q(<para>#{item.text}</para>)
    result << item.content if item.blocks?
    result << '</callout>'
  end
  result << %Q(</calloutlist>)
  result * EOL
end
common_attributes(id, role = nil, reftext = nil) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 634
def common_attributes id, role = nil, reftext = nil
  res = id ? %Q( xml:id="#{id}") : ''
  res = %Q(#{res} role="#{role}") if role
  res = %Q(#{res} xreflabel="#{reftext}") if reftext
  res
end
dlist(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 108
    def dlist node
      result = []
      if node.style == 'horizontal'
        result << %Q(<#{tag_name = node.title? ? 'table' : 'informaltable'}#{common_attributes node.id, node.role, node.reftext} tabstyle="horizontal" frame="none" colsep="0" rowsep="0">
#{title_tag node}<tgroup cols="2">
<colspec colwidth="#{node.attr 'labelwidth', 15}*"/>
<colspec colwidth="#{node.attr 'itemwidth', 85}*"/>
<tbody valign="top">)
        node.items.each do |terms, dd|
          result << %Q(<row>
<entry>)
          [*terms].each do |dt|
            result << %Q(<simpara>#{dt.text}</simpara>)
          end
          result << %Q(</entry>
<entry>)
          unless dd.nil?
            result << %Q(<simpara>#{dd.text}</simpara>) if dd.text?
            result << dd.content if dd.blocks?
          end
          result << %Q(</entry>
</row>)
        end
        result << %Q(</tbody>
</tgroup>
</#{tag_name}>)
      else
        tags = DLIST_TAGS[node.style]
        list_tag = tags[:list]
        entry_tag = tags[:entry]
        label_tag = tags[:label]
        term_tag = tags[:term]
        item_tag = tags[:item]
        if list_tag
          result << %Q(<#{list_tag}#{common_attributes node.id, node.role, node.reftext}>)
          result << %Q(<title>#{node.title}</title>) if node.title?
        end

        node.items.each do |terms, dd|
          result << %Q(<#{entry_tag}>)
          result << %Q(<#{label_tag}>) if label_tag

          [*terms].each do |dt|
            result << %Q(<#{term_tag}>#{dt.text}</#{term_tag}>)
          end

          result << %Q(</#{label_tag}>) if label_tag
          result << %Q(<#{item_tag}>)
          unless dd.nil?
            result << %Q(<simpara>#{dd.text}</simpara>) if dd.text?
            result << dd.content if dd.blocks?
          end
          result << %Q(</#{item_tag}>)
          result << %Q(</#{entry_tag}>)
        end

        result << %Q(</#{list_tag}>) if list_tag
      end

      result * EOL
    end
doctype_declaration(root_tag_name) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 641
def doctype_declaration root_tag_name
  nil
end
document(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 6
def document node
  result = []
  if (root_tag_name = node.doctype) == 'manpage'
    root_tag_name = 'refentry'
  end
  result << '<?xml version="1.0" encoding="UTF-8"?>'
  if (doctype_line = doctype_declaration root_tag_name)
    result << doctype_line
  end
  if node.attr? 'toc'
    if node.attr? 'toclevels'
      result << %Q(<?asciidoc-toc maxdepth="#{node.attr 'toclevels'}"?>)
    else
      result << '<?asciidoc-toc?>'
    end
  end
  if node.attr? 'sectnums'
    if node.attr? 'sectnumlevels'
      result << %Q(<?asciidoc-numbered maxdepth="#{node.attr 'sectnumlevels'}"?>)
    else
      result << '<?asciidoc-numbered?>'
    end
  end
  lang_attribute = (node.attr? 'nolang') ? nil : %Q( #{lang_attribute_name}="#{node.attr 'lang', 'en'}")
  result << %Q(<#{root_tag_name}#{document_ns_attributes node}#{lang_attribute}>)
  result << (document_info_element node, root_tag_name)
  result << node.content if node.blocks?
  unless (footer_docinfo = node.docinfo :footer).empty?
    result << footer_docinfo
  end
  result << %Q(</#{root_tag_name}>)

  result * EOL
end
document_info_element(doc, info_tag_prefix, use_info_tag_prefix = false) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 645
    def document_info_element doc, info_tag_prefix, use_info_tag_prefix = false
      info_tag_prefix = '' unless use_info_tag_prefix
      result = []
      result << %Q(<#{info_tag_prefix}info>)
      result << document_title_tags(doc.doctitle :partition => true, :use_fallback => true) unless doc.notitle
      result << %Q(<date>#{(doc.attr? 'revdate') ? (doc.attr 'revdate') : (doc.attr 'docdate')}</date>)
      if doc.has_header?
        if doc.attr? 'author'
          if (authorcount = (doc.attr 'authorcount').to_i) < 2
            result << (author_element doc)
            result << %Q(<authorinitials>#{doc.attr 'authorinitials'}</authorinitials>) if doc.attr? 'authorinitials'
          else
            result << '<authorgroup>'
            authorcount.times do |index|
              result << (author_element doc, index + 1)
            end
            result << '</authorgroup>'
          end
        end
        if (doc.attr? 'revdate') && ((doc.attr? 'revnumber') || (doc.attr? 'revremark'))
          result << %Q(<revhistory>
<revision>)
          result << %Q(<revnumber>#{doc.attr 'revnumber'}</revnumber>) if doc.attr? 'revnumber'
          result << %Q(<date>#{doc.attr 'revdate'}</date>) if doc.attr? 'revdate'
          result << %Q(<authorinitials>#{doc.attr 'authorinitials'}</authorinitials>) if doc.attr? 'authorinitials'
          result << %Q(<revremark>#{doc.attr 'revremark'}</revremark>) if doc.attr? 'revremark'
          result << %Q(</revision>
</revhistory>)
        end
        unless (header_docinfo = doc.docinfo :header).empty?
          result << header_docinfo
        end
        result << %Q(<orgname>#{doc.attr 'orgname'}</orgname>) if doc.attr? 'orgname'
      end
      result << %Q(</#{info_tag_prefix}info>)

      if doc.doctype == 'manpage'
        result << '<refmeta>'
        result << %Q(<refentrytitle>#{doc.attr 'mantitle'}</refentrytitle>) if doc.attr? 'mantitle'
        result << %Q(<manvolnum>#{doc.attr 'manvolnum'}</manvolnum>) if doc.attr? 'manvolnum'
        result << '</refmeta>'
        result << '<refnamediv>'
        result << %Q(<refname>#{doc.attr 'manname'}</refname>) if doc.attr? 'manname'
        result << %Q(<refpurpose>#{doc.attr 'manpurpose'}</refpurpose>) if doc.attr? 'manpurpose'
        result << '</refnamediv>'
      end

      result * EOL
    end
document_ns_attributes(doc) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 695
def document_ns_attributes doc
  ' xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0"'
end
document_title_tags(title) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 703
    def document_title_tags title
      if title.subtitle?
        %Q(<title>#{title.main}</title>
<subtitle>#{title.subtitle}</subtitle>)
      else
        %Q(<title>#{title}</title>)
      end
    end
example(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 170
    def example node
      if node.title?
        %Q(<example#{common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
#{resolve_content node}
</example>)
      else
        %Q(<informalexample#{common_attributes node.id, node.role, node.reftext}>
#{resolve_content node}
</informalexample>)
      end
    end
floating_title(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 183
def floating_title node
  %Q(<bridgehead#{common_attributes node.id, node.role, node.reftext} renderas="sect#{node.level}">#{node.title}</bridgehead>)
end
image(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 187
    def image node
      width_attribute = (node.attr? 'width') ? %Q( contentwidth="#{node.attr 'width'}") : nil
      depth_attribute = (node.attr? 'height') ? %Q( contentdepth="#{node.attr 'height'}") : nil
      swidth_attribute = (node.attr? 'scaledwidth') ? %Q( width="#{node.attr 'scaledwidth'}" scalefit="1") : nil
      scale_attribute = (node.attr? 'scale') ? %Q( scale="#{node.attr 'scale'}") : nil
      align_attribute = (node.attr? 'align') ? %Q( align="#{node.attr 'align'}") : nil

      mediaobject = %Q(<mediaobject>
<imageobject>
<imagedata fileref="#{node.image_uri(node.attr 'target')}"#{width_attribute}#{depth_attribute}#{swidth_attribute}#{scale_attribute}#{align_attribute}/>
</imageobject>
<textobject><phrase>#{node.attr 'alt'}</phrase></textobject>
</mediaobject>)

      if node.title?
        %Q(<figure#{common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
#{mediaobject}
</figure>)
      else
        %Q(<informalfigure#{common_attributes node.id, node.role, node.reftext}>
#{mediaobject}
</informalfigure>)
      end
    end
inline_anchor(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 485
def inline_anchor node
  case node.type
  when :ref
    %Q(<anchor#{common_attributes node.target, nil, node.text}/>)
  when :xref
    if node.attr? 'path', nil
      linkend = (node.attr 'fragment') || node.target
      (text = node.text) ? %Q(<link linkend="#{linkend}">#{text}</link>) : %Q(<xref linkend="#{linkend}"/>)
    else
      %Q(<link xlink:href="#{target}">#{node.text || (node.attr 'path')}</link>)
    end
  when :link
    %Q(<link xlink:href="#{node.target}">#{node.text}</link>)
  when :bibref
    %Q(<anchor#{common_attributes node.target, nil, "[#{node.target}]"}/>[#{node.target}])
  else
    warn %Q(asciidoctor: WARNING: unknown anchor type: #{node.type.inspect})
  end
end
inline_break(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 505
def inline_break node
  %Q(#{node.text}<?asciidoc-br?>)
end
inline_button(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 509
def inline_button node
  %Q(<guibutton>#{node.text}</guibutton>)
end
inline_callout(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 513
def inline_callout node
  %Q(<co#{common_attributes node.id}/>)
end
inline_footnote(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 517
def inline_footnote node
  if node.type == :xref
    %Q(<footnoteref linkend="#{node.target}"/>)
  else
    %Q(<footnote#{common_attributes node.id}><simpara>#{node.text}</simpara></footnote>)
  end
end
inline_image(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 525
    def inline_image node
      width_attribute = (node.attr? 'width') ? %Q( contentwidth="#{node.attr 'width'}") : nil
      depth_attribute = (node.attr? 'height') ? %Q( contentdepth="#{node.attr 'height'}") : nil
      %Q(<inlinemediaobject>
<imageobject>
<imagedata fileref="#{node.type == 'icon' ? (node.icon_uri node.target) : (node.image_uri node.target)}"#{width_attribute}#{depth_attribute}/>
</imageobject>
<textobject><phrase>#{node.attr 'alt'}</phrase></textobject>
</inlinemediaobject>)
    end
inline_indexterm(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 536
    def inline_indexterm node
      if node.type == :visible
        %Q(<indexterm><primary>#{node.text}</primary></indexterm>#{node.text})
      else
        terms = node.attr 'terms'
        result = []
        if (numterms = terms.size) > 2
          result << %Q(<indexterm>
<primary>#{terms[0]}</primary><secondary>#{terms[1]}</secondary><tertiary>#{terms[2]}</tertiary>
</indexterm>)
        end
        if numterms > 1
          result << %Q(<indexterm>
<primary>#{terms[-2]}</primary><secondary>#{terms[-1]}</secondary>
</indexterm>)
        end
        result << %Q(<indexterm>
<primary>#{terms[-1]}</primary>
</indexterm>)
        result * EOL
      end
    end
inline_kbd(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 559
def inline_kbd node
  if (keys = node.attr 'keys').size == 1
    %Q(<keycap>#{keys[0]}</keycap>)
  else
    key_combo = keys.map {|key| %Q(<keycap>#{key}</keycap>) }.join
    %Q(<keycombo>#{key_combo}</keycombo>)
  end
end
inline_menu(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 568
def inline_menu node
  menu = node.attr 'menu'
  if !(submenus = node.attr 'submenus').empty?
    submenu_path = submenus.map {|submenu| %Q(<guisubmenu>#{submenu}</guisubmenu> ) }.join.chop
    %Q(<menuchoice><guimenu>#{menu}</guimenu> #{submenu_path} <guimenuitem>#{node.attr 'menuitem'}</guimenuitem></menuchoice>)
  elsif (menuitem = node.attr 'menuitem')
    %Q(<menuchoice><guimenu>#{menu}</guimenu> <guimenuitem>#{menuitem}</guimenuitem></menuchoice>)
  else
    %Q(<guimenu>#{menu}</guimenu>)
  end
end
inline_quoted(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 592
    def inline_quoted node
      if (type = node.type) == :latexmath
        %Q(<inlineequation>
<alt><![CDATA[#{node.text}]]></alt>
<inlinemediaobject><textobject><phrase><![CDATA[#{node.text}]]></phrase></textobject></inlinemediaobject>
</inlineequation>)
      else
        open, close, supports_phrase = QUOTE_TAGS[type]
        text = node.text
        if (role = node.role)
          if supports_phrase
            quoted_text = %Q(#{open}<phrase role="#{role}">#{text}</phrase>#{close})
          else
            quoted_text = %Q(#{open.chop} role="#{role}">#{text}#{close})
          end
        else
          quoted_text = %Q(#{open}#{text}#{close})
        end

        node.id ? %Q(<anchor#{common_attributes node.id, nil, text}/>#{quoted_text}) : quoted_text
      end
    end
lang_attribute_name() click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 699
def lang_attribute_name
  'xml:lang'
end
listing(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 213
    def listing node
      informal = !node.title?
      listing_attributes = (common_attributes node.id, node.role, node.reftext)
      if node.style == 'source' && (node.attr? 'language')
        numbering = (node.attr? 'linenums') ? 'numbered' : 'unnumbered'
        listing_content = %Q(<programlisting#{informal ? listing_attributes : nil} language="#{node.attr 'language', nil, false}" linenumbering="#{numbering}">#{node.content}</programlisting>)
      else
        listing_content = %Q(<screen#{informal ? listing_attributes : nil}>#{node.content}</screen>)
      end
      if informal
        listing_content
      else
        %Q(<formalpara#{listing_attributes}>
<title>#{node.title}</title>
<para>
#{listing_content}
</para>
</formalpara>)
      end
    end
literal(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 234
    def literal node
      if node.title?
        %Q(<formalpara#{common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
<para>
<literallayout class="monospaced">#{node.content}</literallayout>
</para>
</formalpara>)
      else
        %Q(<literallayout#{common_attributes node.id, node.role, node.reftext} class="monospaced">#{node.content}</literallayout>)
      end
    end
olist(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 273
def olist node
  result = []
  num_attribute = node.style ? %Q( numeration="#{node.style}") : nil
  start_attribute = (node.attr? 'start') ? %Q( startingnumber="#{node.attr 'start'}") : nil
  result << %Q(<orderedlist#{common_attributes node.id, node.role, node.reftext}#{num_attribute}#{start_attribute}>)
  result << %Q(<title>#{node.title}</title>) if node.title?
  node.items.each do |item|
    result << '<listitem>'
    result << %Q(<simpara>#{item.text}</simpara>)
    result << item.content if item.blocks?
    result << '</listitem>'
  end
  result << %Q(</orderedlist>)
  result * EOL
end
open(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 289
    def open node
      case node.style
      when 'abstract'
        if node.parent == node.document && node.document.attr?('doctype', 'book')
          warn 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
          ''
        else
          %Q(<abstract>
#{title_tag node}#{resolve_content node}
</abstract>)
        end
      when 'partintro'
        unless node.level == 0 && node.parent.context == :section && node.document.doctype == 'book'
          warn 'asciidoctor: ERROR: partintro block can only be used when doctype is book and it\s a child of a part section. Excluding block content.'
          ''
        else
          %Q(<partintro#{common_attributes node.id, node.role, node.reftext}>
#{title_tag node}#{resolve_content node}
</partintro>)
        end
      else
        node.content
      end
    end
page_break(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 314
def page_break node
  '<simpara><?asciidoc-pagebreak?></simpara>'
end
paragraph(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 318
    def paragraph node
      if node.title?
        %Q(<formalpara#{common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
<para>#{node.content}</para>
</formalpara>)
      else
        %Q(<simpara#{common_attributes node.id, node.role, node.reftext}>#{node.content}</simpara>)
      end
    end
preamble(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 329
    def preamble node
      if node.document.doctype == 'book'
        %Q(<preface#{common_attributes node.id, node.role, node.reftext}>
#{title_tag node, false}#{node.content}
</preface>)
      else
        node.content
      end
    end
quote(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 339
def quote node
  result = []
  result << %Q(<blockquote#{common_attributes node.id, node.role, node.reftext}>)
  result << %Q(<title>#{node.title}</title>) if node.title?
  if (node.attr? 'attribution') || (node.attr? 'citetitle')
    result << '<attribution>'
    if node.attr? 'attribution'
      result << (node.attr 'attribution')
    end
    if node.attr? 'citetitle'
      result << %Q(<citetitle>#{node.attr 'citetitle'}</citetitle>)
    end
    result << '</attribution>'
  end
  result << (resolve_content node)
  result << '</blockquote>'
  result * EOL
end
resolve_content(node) click to toggle source

FIXME this should be handled through a template mechanism

# File lib/asciidoctor/converter/docbook5.rb, line 713
def resolve_content node
  node.content_model == :compound ? node.content : %Q(<simpara>#{node.content}</simpara>)
end
section(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 43
    def section node
      doctype = node.document.doctype
      tag_name = if node.special
        node.level <= 1 ? node.sectname : 'section'
      else
        doctype == 'book' && node.level <= 1 ? (node.level == 0 ? 'part' : 'chapter') : 'section'
      end
      if doctype == 'manpage'
        if tag_name == 'section'
          tag_name = 'refsection'
        elsif tag_name == 'synopsis'
          tag_name = 'refsynopsisdiv'
        end
      end
      %Q(<#{tag_name}#{common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
#{node.content}
</#{tag_name}>)
    end
sidebar(node) click to toggle source
stem(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 247
    def stem node
      if (idx = node.subs.index :specialcharacters)
        node.subs.delete :specialcharacters
      end
      equation = node.content
      node.subs.insert idx, :specialcharacters if idx
      if node.style == 'latexmath'
        equation_data = %Q(<alt><![CDATA[#{equation}]]></alt>
<mediaobject><textobject><phrase></phrase></textobject></mediaobject>)
      # asciimath
      else
        # DocBook backends can't handle AsciiMath, so output raw expression in text object
        equation_data = %Q(<mediaobject><textobject><phrase><![CDATA[#{equation}]]></phrase></textobject></mediaobject>)
      end
      if node.title?
        %Q(<equation#{common_attributes node.id, node.role, node.reftext}>
<title>#{node.title}</title>
#{equation_data}
</equation>)
      else
        %Q(<informalequation#{common_attributes node.id, node.role, node.reftext}>
#{equation_data}
</informalequation>)
      end
    end
table(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 371
def table node
  has_body = false
  result = []
  pgwide_attribute = (node.option? 'pgwide') ? ' pgwide="1"' : nil
  result << %Q(<#{tag_name = node.title? ? 'table' : 'informaltable'}#{common_attributes node.id, node.role, node.reftext}#{pgwide_attribute} frame="#{node.attr 'frame', 'all'}" rowsep="#{['none', 'cols'].include?(node.attr 'grid') ? 0 : 1}" colsep="#{['none', 'rows'].include?(node.attr 'grid') ? 0 : 1}">)
  result << %Q(<title>#{node.title}</title>) if tag_name == 'table'
  if (width = (node.attr? 'width') ? (node.attr 'width') : nil)
    TABLE_PI_NAMES.each do |pi_name|
      result << %Q(<?#{pi_name} table-width="#{width}"?>)
    end
  end
  result << %Q(<tgroup cols="#{node.attr 'colcount'}">)
  node.columns.each do |col|
    result << %Q(<colspec colname="col_#{col.attr 'colnumber'}" colwidth="#{col.attr(width ? 'colabswidth' : 'colpcwidth')}*"/>)
  end
  TABLE_SECTIONS.select {|tblsec| !node.rows[tblsec].empty? }.each do |tblsec|
    has_body = true if tblsec == :body
    result << %Q(<t#{tblsec}>)
    node.rows[tblsec].each do |row|
      result << '<row>'
      row.each do |cell|
        halign_attribute = (cell.attr? 'halign') ? %Q( align="#{cell.attr 'halign'}") : nil
        valign_attribute = (cell.attr? 'valign') ? %Q( valign="#{cell.attr 'valign'}") : nil
        colspan_attribute = cell.colspan ? %Q( namest="col_#{colnum = cell.column.attr 'colnumber'}" nameend="col_#{colnum + cell.colspan - 1}") : nil
        rowspan_attribute = cell.rowspan ? %Q( morerows="#{cell.rowspan - 1}") : nil
        # NOTE <entry> may not have whitespace (e.g., line breaks) as a direct descendant according to DocBook rules
        entry_start = %Q(<entry#{halign_attribute}#{valign_attribute}#{colspan_attribute}#{rowspan_attribute}>)
        cell_content = if tblsec == :head
          cell.text
        else
          case cell.style
          when :asciidoc
            cell.content
          when :verse
            %Q(<literallayout>#{cell.text}</literallayout>)
          when :literal
            %Q(<literallayout class="monospaced">#{cell.text}</literallayout>)
          when :header
            cell.content.map {|text| %Q(<simpara><emphasis role="strong">#{text}</emphasis></simpara>) }.join
          else
            cell.content.map {|text| %Q(<simpara>#{text}</simpara>) }.join
          end
        end
        entry_end = (node.document.attr? 'cellbgcolor') ? %Q(<?dbfo bgcolor="#{node.document.attr 'cellbgcolor'}"?></entry>) : '</entry>'
        result << %Q(#{entry_start}#{cell_content}#{entry_end})
      end
      result << '</row>'
    end
    result << %Q(</t#{tblsec}>)
  end
  result << '</tgroup>'
  result << %Q(</#{tag_name}>)

  warn 'asciidoctor: WARNING: tables must have at least one body row' unless has_body
  result * EOL
end
thematic_break(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 358
def thematic_break node
  '<simpara><?asciidoc-hr?></simpara>'
end
title_tag(node, optional = true) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 717
def title_tag node, optional = true
  !optional || node.title? ? %Q(<title>#{node.title}</title>\n) : nil
end
ulist(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 430
def ulist node
  result = []
  if node.style == 'bibliography'
    result << %Q(<bibliodiv#{common_attributes node.id, node.role, node.reftext}>)
    result << %Q(<title>#{node.title}</title>) if node.title?
    node.items.each do |item|
      result << '<bibliomixed>'
      result << %Q(<bibliomisc>#{item.text}</bibliomisc>)
      result << item.content if item.blocks?
      result << '</bibliomixed>'
    end
    result << '</bibliodiv>'
  else
    mark_type = (checklist = node.option? 'checklist') ? 'none' : node.style
    mark_attribute = mark_type ? %Q( mark="#{mark_type}") : nil
    result << %Q(<itemizedlist#{common_attributes node.id, node.role, node.reftext}#{mark_attribute}>)
    result << %Q(<title>#{node.title}</title>) if node.title?
    node.items.each do |item|
      text_marker = if checklist && (item.attr? 'checkbox')
        (item.attr? 'checked') ? '&#10003; ' : '&#10063; '
      else
        nil
      end
      result << '<listitem>'
      result << %Q(<simpara>#{text_marker}#{item.text}</simpara>)
      result << item.content if item.blocks?
      result << '</listitem>'
    end
    result << '</itemizedlist>'
  end

  result * EOL
end
verse(node) click to toggle source
# File lib/asciidoctor/converter/docbook5.rb, line 464
def verse node
  result = []
  result << %Q(<blockquote#{common_attributes node.id, node.role, node.reftext}>)
  result << %Q(<title>#{node.title}</title>) if node.title?
  if (node.attr? 'attribution') || (node.attr? 'citetitle')
    result << '<attribution>'
    if node.attr? 'attribution'
      result << (node.attr 'attribution')
    end
    if node.attr? 'citetitle'
      result << %Q(<citetitle>#{node.attr 'citetitle'}</citetitle>)
    end
    result << '</attribution>'
  end
  result << %Q(<literallayout>#{node.content}</literallayout>)
  result << '</blockquote>'
  result * EOL
end