class Asciidoctor::Converter::DocBook45Converter - asciidoctor-1.5.6.2 Documentation

# 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
Calls superclass method Asciidoctor::Converter::DocBook5Converter#admonition

    # File lib/asciidoctor/converter/docbook45.rb, line 7
        def admonition node
          # address a bug in the DocBook 4.5 DTD
          if node.parent.context == :example
            %Q(<para>
    #{super}
    </para>)
          else
            super
          end
        end

author_element(doc, index = nil) click to toggle source

    # File lib/asciidoctor/converter/docbook45.rb, line 54
    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 << %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 << %Q(<email>#{doc.attr email_key}</email>) if doc.attr? email_key
      result << '</author>'

      result * LF
    end

common_attributes(id, role = nil, reftext = nil) click to toggle source

    # File lib/asciidoctor/converter/docbook45.rb, line 71
    def common_attributes id, role = nil, reftext = nil
      res = id ? %Q( id="#{id}") : ''
      res = %Q(#{res} role="#{role}") if role
      res = %Q(#{res} xreflabel="#{reftext}") if reftext
      res
    end

doctype_declaration(root_tag_name) click to toggle source

    # File lib/asciidoctor/converter/docbook45.rb, line 78
    def doctype_declaration root_tag_name
      %Q(<!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_element(doc, info_tag_prefix) click to toggle source
Calls superclass method Asciidoctor::Converter::DocBook5Converter#document_info_element

    # File lib/asciidoctor/converter/docbook45.rb, line 82
    def document_info_element 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 90
    def document_ns_attributes doc
      if (ns = doc.attr 'xmlns')
        ns.empty? ? ' xmlns="http://docbook.org/ns/docbook"' : %Q( xmlns="#{ns}")
      else
        nil
      end
    end

inline_anchor(node) click to toggle source

    # File lib/asciidoctor/converter/docbook45.rb, line 34
    def inline_anchor node
      case node.type
      when :ref
        %Q(<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?)
          %Q(<ulink url="#{node.target}">#{node.text || path}</ulink>)
        else
          linkend = node.attributes['fragment'] || node.target
          (text = node.text) ? %Q(<link linkend="#{linkend}">#{text}</link>) : %Q(<xref linkend="#{linkend}"/>)
        end
      when :link
        %Q(<ulink url="#{node.target}">#{node.text}</ulink>)
      when :bibref
        target = node.target
        %Q(<anchor#{common_attributes target, nil, "[#{target}]"}/>[#{target}])
      end
    end

lang_attribute_name() click to toggle source

    # File lib/asciidoctor/converter/docbook45.rb, line 86
    def lang_attribute_name
      'lang'
    end

olist(node) click to toggle source

    # File lib/asciidoctor/converter/docbook45.rb, line 18
    def olist node
      result = []
      num_attribute = node.style ? %Q( numeration="#{node.style}") : nil
      start_attribute = (node.attr? 'start') ? %Q( override="#{node.attr 'start'}") : nil
      result << %Q(<orderedlist#{common_attributes node.id, node.role, node.reftext}#{num_attribute}>)
      result << %Q(<title>#{node.title}</title>) if node.title?
      node.items.each_with_index do |item, idx|
        result << (idx == 0 ? %Q(<listitem#{start_attribute}>) : '<listitem>')
        result << %Q(<simpara>#{item.text}</simpara>)
        result << item.content if item.blocks?
        result << '</listitem>'
      end
      result << %Q(</orderedlist>)
      result * LF
    end