class Asciidoctor::Converter::DocBook45Converter

A built-in {Converter} implementation that generates DocBook 4.5 output consistent with the docbook45 backend from AsciiDoc Python.

Public Instance Methods

admonition(node) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 8
    def admonition node
      # address a bug in the DocBook 4.5 DTD
      if node.parent.context == :example
        %(<para>
#{super}
</para>)
      else
        super
      end
    end
author_tag(author) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 55
def author_tag author
  result = []
  result << '<author>'
  result << %(<firstname>#{author.firstname}</firstname>) if author.firstname
  result << %(<othername>#{author.middlename}</othername>) if author.middlename
  result << %(<surname>#{author.lastname}</surname>) if author.lastname
  result << %(<email>#{author.email}</email>) if author.email
  result << '</author>'
  result.join LF
end
common_attributes(id, role = nil, reftext = nil) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 66
def common_attributes id, role = nil, reftext = nil
  res = id ? %( id="#{id}") : ''
  res = %(#{res} role="#{role}") if role
  res = %(#{res} xreflabel="#{reftext}") if reftext
  res
end
doctype_declaration(root_tag_name) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 73
def doctype_declaration root_tag_name
  %(<!DOCTYPE #{root_tag_name} PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">)
end
document_info_tag(doc, info_tag_prefix) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 77
def document_info_tag doc, info_tag_prefix
  super doc, info_tag_prefix, true
end
document_ns_attributes(doc) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 85
def document_ns_attributes doc
  if (ns = doc.attr 'xmlns')
    ns.empty? ? ' xmlns="http://docbook.org/ns/docbook"' : %( xmlns="#{ns}")
  else
    ''
  end
end
inline_anchor(node) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 35
def inline_anchor node
  case node.type
  when :ref
    %(<anchor#{common_attributes node.target, nil, node.text}/>)
  when :xref
    if (path = node.attributes['path'])
      # QUESTION should we use refid as fallback text instead? (like the html5 backend?)
      %(<ulink url="#{node.target}">#{node.text || path}</ulink>)
    else
      linkend = node.attributes['fragment'] || node.target
      (text = node.text) ? %(<link linkend="#{linkend}">#{text}</link>) : %(<xref linkend="#{linkend}"/>)
    end
  when :link
    %(<ulink url="#{node.target}">#{node.text}</ulink>)
  when :bibref
    target = node.target
    %(<anchor#{common_attributes target, nil, "[#{target}]"}/>[#{target}])
  end
end
lang_attribute_name() click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 81
def lang_attribute_name
  'lang'
end
olist(node) click to toggle source
# File lib/asciidoctor/converter/docbook45.rb, line 19
def olist node
  result = []
  num_attribute = node.style ? %( numeration="#{node.style}") : ''
  start_attribute = (node.attr? 'start') ? %( override="#{node.attr 'start'}") : ''
  result << %(<orderedlist#{common_attributes node.id, node.role, node.reftext}#{num_attribute}>)
  result << %(<title>#{node.title}</title>) if node.title?
  node.items.each_with_index do |item, idx|
    result << (idx == 0 ? %(<listitem#{start_attribute}>) : '<listitem>')
    result << %(<simpara>#{item.text}</simpara>)
    result << item.content if item.blocks?
    result << '</listitem>'
  end
  result << %(</orderedlist>)
  result.join LF
end