A built-in {Converter} implementation that generates DocBook 5 output. The output is inspired by the output produced by the docbook45 backend from AsciiDoc.py, except it has been migrated to the DocBook 5 specification.
# File lib/asciidoctor/converter/docbook5.rb, line 31 def initialize backend, opts = {} @backend = backend init_backend_traits basebackend: 'docbook', filetype: 'xml', outfilesuffix: '.xml', supports_templates: true end
# File lib/asciidoctor/converter/docbook5.rb, line 90 def convert_admonition node %Q(<#{tag_name = node.attr 'name'}#{common_attributes node.id, node.role, node.reftext}> #{title_tag node}#{enclose_content node} </#{tag_name}>) end
# File lib/asciidoctor/converter/docbook5.rb, line 98 def convert_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.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 112 def convert_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 {|dt| result << %Q(<simpara>#{dt.text}</simpara>) } result << %Q(</entry> <entry>) if dd 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 {|dt| result << %Q(<#{term_tag}>#{dt.text}</#{term_tag}>) } result << %Q(</#{label_tag}>) if label_tag result << %Q(<#{item_tag}>) if dd 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.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 36 def convert_document node result = ['<?xml version="1.0" encoding="UTF-8"?>'] result << ((node.attr? 'toclevels') ? %Q(<?asciidoc-toc maxdepth="#{node.attr 'toclevels'}"?>) : '<?asciidoc-toc?>') if node.attr? 'toc' result << ((node.attr? 'sectnumlevels') ? %Q(<?asciidoc-numbered maxdepth="#{node.attr 'sectnumlevels'}"?>) : '<?asciidoc-numbered?>') if node.attr? 'sectnums' lang_attribute = (node.attr? 'nolang') ? '' : %Q( xml:lang="#{node.attr 'lang', 'en'}") if (root_tag_name = node.doctype) == 'manpage' manpage = true root_tag_name = 'article' end root_tag_idx = result.size id = node.id result << (document_info_tag node) unless node.noheader if manpage result << '<refentry>' result << '<refmeta>' result << %Q(<refentrytitle>#{node.apply_reftext_subs node.attr 'mantitle'}</refentrytitle>) if node.attr? 'mantitle' result << %Q(<manvolnum>#{node.attr 'manvolnum'}</manvolnum>) if node.attr? 'manvolnum' result << %Q(<refmiscinfo class="source">#{node.attr 'mansource', ' '}</refmiscinfo>) result << %Q(<refmiscinfo class="manual">#{node.attr 'manmanual', ' '}</refmiscinfo>) result << '</refmeta>' result << '<refnamediv>' result += (node.attr 'mannames').map {|n| %Q(<refname>#{n}</refname>) } if node.attr? 'mannames' result << %Q(<refpurpose>#{node.attr 'manpurpose'}</refpurpose>) if node.attr? 'manpurpose' result << '</refnamediv>' end unless (docinfo_content = node.docinfo :header).empty? result << docinfo_content end result << node.content if node.blocks? unless (docinfo_content = node.docinfo :footer).empty? result << docinfo_content end result << '</refentry>' if manpage id, node.id = node.id, nil unless id # defer adding root tag in case document ID is auto-generated on demand result.insert root_tag_idx, %Q(<#{root_tag_name} xmlns="http://docbook.org/ns/docbook" xmlns:xl="http://www.w3.org/1999/xlink" version="5.0"#{lang_attribute}#{common_attributes id}>) result << %Q(</#{root_tag_name}>) result.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 168 def convert_example node if node.title? %Q(<example#{common_attributes node.id, node.role, node.reftext}> <title>#{node.title}</title> #{enclose_content node} </example>) else %Q(<informalexample#{common_attributes node.id, node.role, node.reftext}> #{enclose_content node} </informalexample>) end end
# File lib/asciidoctor/converter/docbook5.rb, line 181 def convert_floating_title node %Q(<bridgehead#{common_attributes node.id, node.role, node.reftext} renderas="sect#{node.level}">#{node.title}</bridgehead>) end
# File lib/asciidoctor/converter/docbook5.rb, line 185 def convert_image node # NOTE according to the DocBook spec, content area, scaling, and scaling to fit are mutually exclusive # See http://tdg.docbook.org/tdg/4.5/imagedata-x.html#d0e79635 if node.attr? 'scaledwidth' width_attribute = %Q( width="#{node.attr 'scaledwidth'}") depth_attribute = '' scale_attribute = '' elsif node.attr? 'scale' # QUESTION should we set the viewport using width and depth? (the scaled image would be contained within this box) #width_attribute = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : '' #depth_attribute = (node.attr? 'height') ? %( depth="#{node.attr 'height'}") : '' scale_attribute = %Q( scale="#{node.attr 'scale'}") else width_attribute = (node.attr? 'width') ? %Q( contentwidth="#{node.attr 'width'}") : '' depth_attribute = (node.attr? 'height') ? %Q( contentdepth="#{node.attr 'height'}") : '' scale_attribute = '' end align_attribute = (node.attr? 'align') ? %Q( align="#{node.attr 'align'}") : '' mediaobject = %Q(<mediaobject> <imageobject> <imagedata fileref="#{node.image_uri(node.attr 'target')}"#{width_attribute}#{depth_attribute}#{scale_attribute}#{align_attribute}/> </imageobject> <textobject><phrase>#{node.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
# File lib/asciidoctor/converter/docbook5.rb, line 490 def convert_inline_anchor node case node.type when :ref %Q(<anchor#{common_attributes((id = node.id), nil, node.reftext || %([#{id}]))}/>) when :xref if (path = node.attributes['path']) %Q(<link xl:href="#{node.target}">#{node.text || path}</link>) else if (linkend = node.attributes['refid']).nil_or_empty? root_doc = get_root_document node # Q: should we warn instead of generating a document ID on demand? linkend = (root_doc.id ||= generate_document_id root_doc) end # NOTE the xref tag in DocBook does not support explicit link text, so the link tag must be used instead # The section at http://www.sagehill.net/docbookxsl/CrossRefs.html#IdrefLinks gives an explanation for this choice # "link - a cross reference where you supply the text of the reference as the content of the link element." (text = node.text) ? %Q(<link linkend="#{linkend}">#{text}</link>) : %Q(<xref linkend="#{linkend}"/>) end when :link %Q(<link xl:href="#{node.target}">#{node.text}</link>) when :bibref %Q(<anchor#{common_attributes node.id, nil, (text = "[#{node.reftext || node.id}]")}/>#{text}) else logger.warn %Q(unknown anchor type: #{node.type.inspect}) nil end end
# File lib/asciidoctor/converter/docbook5.rb, line 518 def convert_inline_break node %Q(#{node.text}<?asciidoc-br?>) end
# File lib/asciidoctor/converter/docbook5.rb, line 526 def convert_inline_callout node %Q(<co#{common_attributes node.id}/>) end
# File lib/asciidoctor/converter/docbook5.rb, line 530 def convert_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
# File lib/asciidoctor/converter/docbook5.rb, line 538 def convert_inline_image node width_attribute = (node.attr? 'width') ? %Q( contentwidth="#{node.attr 'width'}") : '' depth_attribute = (node.attr? 'height') ? %Q( contentdepth="#{node.attr 'height'}") : '' %Q(<inlinemediaobject#{common_attributes nil, node.role}> <imageobject> <imagedata fileref="#{node.type == 'icon' ? (node.icon_uri node.target) : (node.image_uri node.target)}"#{width_attribute}#{depth_attribute}/> </imageobject> <textobject><phrase>#{node.alt}</phrase></textobject> </inlinemediaobject>) end
# File lib/asciidoctor/converter/docbook5.rb, line 549 def convert_inline_indexterm node if (see = node.attr 'see') rel = %Q(\n<see>#{see}</see>) elsif (see_also_list = node.attr 'see-also') rel = see_also_list.map {|see_also| %Q(\n<seealso>#{see_also}</seealso>) }.join else rel = '' end if node.type == :visible %Q(<indexterm> <primary>#{node.text}</primary>#{rel} </indexterm>#{node.text}) elsif (numterms = (terms = node.attr 'terms').size) > 2 %Q(<indexterm> <primary>#{terms[0]}</primary><secondary>#{terms[1]}</secondary><tertiary>#{terms[2]}</tertiary>#{rel} </indexterm>#{(node.document.option? 'indexterm-promotion') ? %[ <indexterm> <primary>#{terms[1]}</primary><secondary>#{terms[2]}</secondary> </indexterm> <indexterm> <primary>#{terms[2]}</primary> </indexterm>] : ''}) elsif numterms > 1 %Q(<indexterm> <primary>#{terms[0]}</primary><secondary>#{terms[1]}</secondary>#{rel} </indexterm>#{(node.document.option? 'indexterm-promotion') ? %[ <indexterm> <primary>#{terms[1]}</primary> </indexterm>] : ''}) else %Q(<indexterm> <primary>#{terms[0]}</primary>#{rel} </indexterm>) end end
# File lib/asciidoctor/converter/docbook5.rb, line 585 def convert_inline_kbd node if (keys = node.attr 'keys').size == 1 %Q(<keycap>#{keys[0]}</keycap>) else %Q(<keycombo><keycap>#{keys.join '</keycap><keycap>'}</keycap></keycombo>) end end
# File lib/asciidoctor/converter/docbook5.rb, line 606 def convert_inline_quoted node if (type = node.type) == :asciimath # NOTE fop requires jeuclid to process mathml markup asciimath_available? ? %Q(<inlineequation>#{(::AsciiMath.parse node.text).to_mathml 'mml:', 'xmlns:mml' => 'http://www.w3.org/1998/Math/MathML'}</inlineequation>) : %Q(<inlineequation><mathphrase><![CDATA[#{node.text}]]></mathphrase></inlineequation>) elsif type == :latexmath # unhandled math; pass source to alt and required mathphrase element; dblatex will process alt as LaTeX math %Q(<inlineequation><alt><![CDATA[#{equation = node.text}]]></alt><mathphrase><![CDATA[#{equation}]]></mathphrase></inlineequation>) else open, close, supports_phrase = QUOTE_TAGS[type] text = node.text if node.role if supports_phrase quoted_text = %Q(#{open}<phrase role="#{node.role}">#{text}</phrase>#{close}) else quoted_text = %Q(#{open.chop} role="#{node.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
# File lib/asciidoctor/converter/docbook5.rb, line 223 def convert_listing node informal = !node.title? common_attrs = common_attributes node.id, node.role, node.reftext if node.style == 'source' if (attrs = node.attributes).key? 'linenums' numbering_attrs = (attrs.key? 'start') ? %Q( linenumbering="numbered" startinglinenumber="#{attrs['start'].to_i}") : ' linenumbering="numbered"' else numbering_attrs = ' linenumbering="unnumbered"' end if attrs.key? 'language' wrapped_content = %Q(<programlisting#{informal ? common_attrs : ''} language="#{attrs['language']}"#{numbering_attrs}>#{node.content}</programlisting>) else wrapped_content = %Q(<screen#{informal ? common_attrs : ''}#{numbering_attrs}>#{node.content}</screen>) end else wrapped_content = %Q(<screen#{informal ? common_attrs : ''}>#{node.content}</screen>) end informal ? wrapped_content : %Q(<formalpara#{common_attrs}> <title>#{node.title}</title> <para> #{wrapped_content} </para> </formalpara>) end
# File lib/asciidoctor/converter/docbook5.rb, line 248 def convert_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
# File lib/asciidoctor/converter/docbook5.rb, line 292 def convert_olist node result = [] num_attribute = node.style ? %Q( numeration="#{node.style}") : '' start_attribute = (node.attr? 'start') ? %Q( startingnumber="#{node.attr 'start'}") : '' 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 << %Q(<listitem#{common_attributes item.id, item.role}>) result << %Q(<simpara>#{item.text}</simpara>) result << item.content if item.blocks? result << '</listitem>' end result << %Q(</orderedlist>) result.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 308 def convert_open node case node.style when 'abstract' if node.parent == node.document && node.document.doctype == 'book' logger.warn 'abstract block cannot be used in a document without a title when doctype is book. Excluding block content.' '' else %Q(<abstract> #{title_tag node}#{enclose_content node} </abstract>) end when 'partintro' if node.level == 0 && node.parent.context == :section && node.document.doctype == 'book' %Q(<partintro#{common_attributes node.id, node.role, node.reftext}> #{title_tag node}#{enclose_content node} </partintro>) else logger.error 'partintro block can only be used when doctype is book and must be a child of a book part. Excluding block content.' '' end else reftext = node.reftext if (id = node.id) role = node.role if node.title? %Q(<formalpara#{common_attributes id, role, reftext}> <title>#{node.title}</title> <para>#{content_spacer = node.content_model == :compound ? LF : ''}#{node.content}#{content_spacer}</para> </formalpara>) elsif id || role if node.content_model == :compound %Q(<para#{common_attributes id, role, reftext}> #{node.content} </para>) else %Q(<simpara#{common_attributes id, role, reftext}>#{node.content}</simpara>) end else enclose_content node end end end
# File lib/asciidoctor/converter/docbook5.rb, line 350 def convert_page_break node '<simpara><?asciidoc-pagebreak?></simpara>' end
# File lib/asciidoctor/converter/docbook5.rb, line 354 def convert_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
# File lib/asciidoctor/converter/docbook5.rb, line 365 def convert_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
# File lib/asciidoctor/converter/docbook5.rb, line 375 def convert_quote node blockquote_tag(node, (node.has_role? 'epigraph') && 'epigraph') { enclose_content node } end
# File lib/asciidoctor/converter/docbook5.rb, line 78 def convert_section node if node.document.doctype == 'manpage' tag_name = MANPAGE_SECTION_TAGS[tag_name = node.sectname] || tag_name else tag_name = node.sectname end title_el = node.special && ((node.option? 'notitle') || (node.option? 'untitled')) ? '' : %Q(<title>#{node.title}</title>\n) %Q(<#{tag_name}#{common_attributes node.id, node.role, node.reftext}> #{title_el}#{node.content} </#{tag_name}>) end
# File lib/asciidoctor/converter/docbook5.rb, line 263 def convert_stem node if (idx = node.subs.index :specialcharacters) node.subs.delete_at idx equation = node.content idx > 0 ? (node.subs.insert idx, :specialcharacters) : (node.subs.unshift :specialcharacters) else equation = node.content end if node.style == 'asciimath' # NOTE fop requires jeuclid to process mathml markup equation_data = asciimath_available? ? ((::AsciiMath.parse equation).to_mathml 'mml:', 'xmlns:mml' => 'http://www.w3.org/1998/Math/MathML') : %Q(<mathphrase><![CDATA[#{equation}]]></mathphrase>) else # unhandled math; pass source to alt and required mathphrase element; dblatex will process alt as LaTeX math equation_data = %Q(<alt><![CDATA[#{equation}]]></alt> <mathphrase><![CDATA[#{equation}]]></mathphrase>) end if node.title? %Q(<equation#{common_attributes node.id, node.role, node.reftext}> <title>#{node.title}</title> #{equation_data} </equation>) else # WARNING dblatex displays the <informalequation> element inline instead of block as documented (except w/ mathml) %Q(<informalequation#{common_attributes node.id, node.role, node.reftext}> #{equation_data} </informalequation>) end end
# File lib/asciidoctor/converter/docbook5.rb, line 389 def convert_table node has_body = false result = [] pgwide_attribute = (node.option? 'pgwide') ? ' pgwide="1"' : '' frame = 'topbot' if (frame = node.attr 'frame', 'all', 'table-frame') == 'ends' grid = node.attr 'grid', nil, 'table-grid' result << %Q(<#{tag_name = node.title? ? 'table' : 'informaltable'}#{common_attributes node.id, node.role, node.reftext}#{pgwide_attribute} frame="#{frame}" rowsep="#{['none', 'cols'].include?(grid) ? 0 : 1}" colsep="#{['none', 'rows'].include?(grid) ? 0 : 1}"#{(node.attr? 'orientation', 'landscape', 'table-orientation') ? ' orient="land"' : ''}>) if node.option? 'unbreakable' result << '<?dbfo keep-together="always"?>' elsif node.option? 'breakable' result << '<?dbfo keep-together="auto"?>' end 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 col_width_key = 'colabswidth' else col_width_key = 'colpcwidth' end result << %Q(<tgroup cols="#{node.attr 'colcount'}">) node.columns.each do |col| result << %Q(<colspec colname="col_#{col.attr 'colnumber'}" colwidth="#{col.attr col_width_key}*"/>) end node.rows.to_h.each do |tsec, rows| next if rows.empty? has_body = true if tsec == :body result << %Q(<t#{tsec}>) rows.each do |row| result << '<row>' row.each do |cell| colspan_attribute = cell.colspan ? %Q( namest="col_#{colnum = cell.column.attr 'colnumber'}" nameend="col_#{colnum + cell.colspan - 1}") : '' rowspan_attribute = cell.rowspan ? %Q( morerows="#{cell.rowspan - 1}") : '' # NOTE <entry> may not have whitespace (e.g., line breaks) as a direct descendant according to DocBook rules entry_start = %Q(<entry align="#{cell.attr 'halign'}" valign="#{cell.attr 'valign'}"#{colspan_attribute}#{rowspan_attribute}>) if tsec == :head cell_content = cell.text else case cell.style when :asciidoc cell_content = cell.content when :literal cell_content = %Q(<literallayout class="monospaced">#{cell.text}</literallayout>) when :header cell_content = (cell_content = cell.content).empty? ? '' : %Q(<simpara><emphasis role="strong">#{cell_content.join '</emphasis></simpara><simpara><emphasis role="strong">'}</emphasis></simpara>) else cell_content = (cell_content = cell.content).empty? ? '' : %Q(<simpara>#{cell_content.join '</simpara><simpara>'}</simpara>) 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#{tsec}>) end result << '</tgroup>' result << %Q(</#{tag_name}>) logger.warn 'tables must have at least one body row' unless has_body result.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 379 def convert_thematic_break node '<simpara><?asciidoc-hr?></simpara>' end
# File lib/asciidoctor/converter/docbook5.rb, line 455 def convert_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}") : '' 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 = (item.attr? 'checked') ? '✓ ' : '❏ ' if checklist && (item.attr? 'checkbox') result << %Q(<listitem#{common_attributes item.id, item.role}>) result << %Q(<simpara>#{text_marker || ''}#{item.text}</simpara>) result << item.content if item.blocks? result << '</listitem>' end result << '</itemizedlist>' end result.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 484 def convert_verse node blockquote_tag(node, (node.has_role? 'epigraph') && 'epigraph') { %Q(<literallayout>#{node.content}</literallayout>) } end
# File lib/asciidoctor/converter/docbook5.rb, line 792 def asciimath_available? (@asciimath_status ||= load_asciimath) == :loaded end
# File lib/asciidoctor/converter/docbook5.rb, line 773 def blockquote_tag node, tag_name = nil if tag_name start_tag, end_tag = %Q(<#{tag_name}), %Q(</#{tag_name}>) else start_tag, end_tag = '<blockquote', '</blockquote>' end result = [%Q(#{start_tag}#{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>' result << (node.attr 'attribution') if node.attr? 'attribution' result << %Q(<citetitle>#{node.attr 'citetitle'}</citetitle>) if node.attr? 'citetitle' result << '</attribution>' end result << yield result << end_tag result.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 632 def common_attributes id, role = nil, reftext = nil if id attrs = %Q( xml:id="#{id}"#{role ? %[ role="#{role}"] : ''}) elsif role attrs = %Q( role="#{role}") else attrs = '' end if reftext if (reftext.include? '<') && ((reftext = reftext.gsub XmlSanitizeRx, '').include? ' ') reftext = (reftext.squeeze ' ').strip end reftext = reftext.gsub '"', '"' if reftext.include? '"' %Q(#{attrs} xreflabel="#{reftext}") else attrs end end
# File lib/asciidoctor/converter/docbook5.rb, line 664 def document_info_tag doc result = ['<info>'] unless doc.notitle if (title = doc.doctitle partition: true, use_fallback: true).subtitle? result << %Q(<title>#{title.main}</title> <subtitle>#{title.subtitle}</subtitle>) else result << %Q(<title>#{title}</title>) end end if (date = (doc.attr? 'revdate') ? (doc.attr 'revdate') : ((doc.attr? 'reproducible') ? nil : (doc.attr 'docdate'))) result << %Q(<date>#{date}</date>) end if doc.attr? 'copyright' CopyrightRx =~ (doc.attr 'copyright') result << '<copyright>' result << %Q(<holder>#{$1}</holder>) result << %Q(<year>#{$2}</year>) if $2 result << '</copyright>' end if doc.header? unless (authors = doc.authors).empty? if authors.size > 1 result << '<authorgroup>' authors.each {|author| result << (author_tag doc, author) } result << '</authorgroup>' else result << (author_tag doc, (author = authors[0])) result << %Q(<authorinitials>#{author.initials}</authorinitials>) if author.initials 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 if (doc.attr? 'front-cover-image') || (doc.attr? 'back-cover-image') if (back_cover_tag = cover_tag doc, 'back') result << (cover_tag doc, 'front', true) result << back_cover_tag elsif (front_cover_tag = cover_tag doc, 'front') result << front_cover_tag end end result << %Q(<orgname>#{doc.attr 'orgname'}</orgname>) if doc.attr? 'orgname' unless (docinfo_content = doc.docinfo).empty? result << docinfo_content end end result << '</info>' result.join LF end
# File lib/asciidoctor/converter/docbook5.rb, line 723 def get_root_document node while (node = node.document).nested? node = node.parent_document end node end def generate_document_id doc %Q(__#{doc.doctype}-root__) end # FIXME this should be handled through a template mechanism def enclose_content node node.content_model == :compound ? node.content : %Q(<simpara>#{node.content}</simpara>) end def title_tag node, optional = true !optional || node.title? ? %Q(<title>#{node.title}</title>\n) : '' end def cover_tag doc, face, use_placeholder = false if (cover_image = doc.attr %Q(#{face}-cover-image)) width_attr = '' depth_attr = '' if (cover_image.include? ':') && ImageMacroRx =~ cover_image attrlist = $2 cover_image = doc.image_uri $1 if attrlist attrs = (AttributeList.new attrlist).parse ['alt', 'width', 'height'] if attrs.key? 'scaledwidth' # NOTE scalefit="1" is the default in this case width_attr = %Q( width="#{attrs['scaledwidth']}") else width_attr = %Q( contentwidth="#{attrs['width']}") if attrs.key? 'width' depth_attr = %Q( contentdepth="#{attrs['height']}") if attrs.key? 'height' end end end %Q(<cover role="#{face}"> <mediaobject> <imageobject> <imagedata fileref="#{cover_image}"#{width_attr}#{depth_attr}/> </imageobject> </mediaobject> </cover>) elsif use_placeholder %Q(<cover role="#{face}"/>) end end
# File lib/asciidoctor/converter/docbook5.rb, line 796 def load_asciimath (defined? ::AsciiMath.parse) ? :loaded : (Helpers.require_library 'asciimath', true, :warn).nil? ? :unavailable : :loaded end