class Asciidoctor::DocBook45::DocumentTemplate

Public Instance Methods

author(indexed = false) click to toggle source
# File lib/asciidoctor/backends/docbook45.rb, line 90
  def author indexed = false
    <<-EOF
<author>
#{tag 'firstname', indexed ? :"firstname_\#{idx}" : :firstname, indexed}
#{tag 'othername', indexed ? :"middlename_\#{idx}" : :middlename, indexed}
#{tag 'surname', indexed ? :"lastname_\#{idx}" : :lastname, indexed}
#{tag 'email', indexed ? :"email_\#{idx}" : :email, indexed}
</author>
    EOF
  end
docinfo() click to toggle source
# File lib/asciidoctor/backends/docbook45.rb, line 53
  def docinfo
    <<-EOF
<% unless notitle %><%= has_header? ? template.title_tags(@header.title) : %(<title>\#{attr 'untitled-label'}</title>) %><% end
if attr? :revdate %>
<date><%= attr :revdate %></date><%
else %>
<date><%= attr :docdate %></date><%
end
if has_header?
  if attr? :author
    if (attr :authorcount).to_i < 2 %>
#{author}
#{tag 'authorinitials', :authorinitials}<%
    else %>
<authorgroup><%
      (1..((attr :authorcount).to_i)).each do |idx| %>
#{author true}<%
      end %>
</authorgroup><%
    end
  end
  if (attr? :revnumber) || (attr? :revremark) %>
<revhistory>
<revision>
#{tag 'revnumber', :revnumber}
#{tag 'date', :revdate}
#{tag 'authorinitials', :authorinitials}
#{tag 'revremark', :revremark}
</revision>
</revhistory><%
  end %>
<%= docinfo %>
#{tag 'orgname', :orgname}<%
end %>
    EOF
  end
template() click to toggle source
# File lib/asciidoctor/backends/docbook45.rb, line 101
  def template
    @template ||= @eruby.new <<-EOF
<%#encoding:UTF-8%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE <%= doctype %> PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"><%
if attr? :toc %>
<?asciidoc-toc?><%
end
if attr? :numbered %>
<?asciidoc-numbered?><%
end
if doctype == 'book' %>
<book<% unless attr? :noxmlns %> xmlns="http://docbook.org/ns/docbook"<% end %><% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
<bookinfo>
#{docinfo}
</bookinfo>
<%= content %><%= (docinfo_content = docinfo :footer).empty? ? nil : %(
\#{docinfo_content}) %>
</book><%
else %>
<article<% unless attr? :noxmlns %> xmlns="http://docbook.org/ns/docbook"<% end %><% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
<articleinfo>
#{docinfo}
</articleinfo>
<%= content %><%= (docinfo_content = docinfo :footer).empty? ? nil : %(
\#{docinfo_content}) %>
</article><%
end %>
    EOF
  end
title_tags(str) click to toggle source
# File lib/asciidoctor/backends/docbook45.rb, line 43
  def title_tags(str)
    if str.include?(': ')
      title, _, subtitle = str.rpartition(': ')
      %Q(<title>#{title}</title>
<subtitle>#{subtitle}</subtitle>)
    else
      %Q(<title>#{str}</title>)
    end
  end