asciidoctor 0.1.4 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of asciidoctor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.adoc +209 -25
- data/{LICENSE → LICENSE.adoc} +4 -3
- data/README.adoc +392 -395
- data/Rakefile +94 -137
- data/benchmark/benchmark.rb +127 -0
- data/benchmark/sample-data/mdbasics.adoc +334 -0
- data/bin/asciidoctor +5 -8
- data/bin/asciidoctor-safe +4 -8
- data/compat/asciidoc.conf +78 -11
- data/compat/font-awesome-3-compat.css +397 -0
- data/data/stylesheets/asciidoctor-default.css +399 -0
- data/data/stylesheets/coderay-asciidoctor.css +89 -0
- data/features/open_block.feature +92 -0
- data/features/pass_block.feature +66 -0
- data/features/step_definitions.rb +42 -0
- data/features/text_formatting.feature +55 -0
- data/features/xref.feature +116 -0
- data/lib/asciidoctor.rb +1155 -605
- data/lib/asciidoctor/abstract_block.rb +157 -71
- data/lib/asciidoctor/abstract_node.rb +150 -93
- data/lib/asciidoctor/attribute_list.rb +85 -90
- data/lib/asciidoctor/block.rb +51 -24
- data/lib/asciidoctor/callouts.rb +4 -7
- data/lib/asciidoctor/cli.rb +3 -0
- data/lib/asciidoctor/cli/invoker.rb +86 -76
- data/lib/asciidoctor/cli/options.rb +111 -61
- data/lib/asciidoctor/converter.rb +232 -0
- data/lib/asciidoctor/converter/base.rb +58 -0
- data/lib/asciidoctor/converter/composite.rb +66 -0
- data/lib/asciidoctor/converter/docbook45.rb +94 -0
- data/lib/asciidoctor/converter/docbook5.rb +684 -0
- data/lib/asciidoctor/converter/factory.rb +225 -0
- data/lib/asciidoctor/converter/html5.rb +1081 -0
- data/lib/asciidoctor/converter/template.rb +296 -0
- data/lib/asciidoctor/core_ext.rb +7 -0
- data/lib/asciidoctor/core_ext/object/nil_or_empty.rb +23 -0
- data/lib/asciidoctor/core_ext/string/chr.rb +6 -0
- data/lib/asciidoctor/core_ext/symbol/length.rb +6 -0
- data/lib/asciidoctor/document.rb +590 -304
- data/lib/asciidoctor/extensions.rb +1100 -308
- data/lib/asciidoctor/helpers.rb +109 -46
- data/lib/asciidoctor/inline.rb +16 -9
- data/lib/asciidoctor/list.rb +23 -15
- data/lib/asciidoctor/opal_ext.rb +4 -0
- data/lib/asciidoctor/opal_ext/comparable.rb +38 -0
- data/lib/asciidoctor/opal_ext/dir.rb +13 -0
- data/lib/asciidoctor/opal_ext/error.rb +2 -0
- data/lib/asciidoctor/opal_ext/file.rb +125 -0
- data/lib/asciidoctor/{lexer.rb → parser.rb} +646 -455
- data/lib/asciidoctor/path_resolver.rb +141 -77
- data/lib/asciidoctor/reader.rb +257 -187
- data/lib/asciidoctor/section.rb +12 -16
- data/lib/asciidoctor/stylesheets.rb +91 -0
- data/lib/asciidoctor/substitutors.rb +1548 -0
- data/lib/asciidoctor/table.rb +73 -57
- data/lib/asciidoctor/timings.rb +39 -0
- data/lib/asciidoctor/version.rb +1 -1
- data/man/asciidoctor.1 +22 -14
- data/man/asciidoctor.adoc +18 -10
- data/test/attributes_test.rb +314 -14
- data/test/blocks_test.rb +763 -118
- data/test/converter_test.rb +352 -0
- data/test/document_test.rb +518 -199
- data/test/extensions_test.rb +273 -103
- data/test/fixtures/asciidoc_index.txt +27 -13
- data/test/fixtures/basic-docinfo.xml +1 -1
- data/test/fixtures/chapter-a.adoc +3 -0
- data/test/fixtures/custom-backends/erb/html5/block_paragraph.html.erb +6 -0
- data/test/fixtures/docinfo.xml +1 -1
- data/test/fixtures/include-file.asciidoc +2 -0
- data/test/fixtures/master.adoc +5 -0
- data/test/invoker_test.rb +173 -61
- data/test/links_test.rb +97 -21
- data/test/lists_test.rb +181 -22
- data/test/options_test.rb +86 -2
- data/test/paragraphs_test.rb +47 -5
- data/test/{lexer_test.rb → parser_test.rb} +128 -57
- data/test/paths_test.rb +36 -1
- data/test/preamble_test.rb +25 -17
- data/test/reader_test.rb +404 -249
- data/test/sections_test.rb +623 -58
- data/test/substitutions_test.rb +609 -132
- data/test/tables_test.rb +198 -24
- data/test/test_helper.rb +101 -31
- data/test/text_test.rb +88 -31
- metadata +160 -64
- data/Gemfile +0 -12
- data/Guardfile +0 -18
- data/asciidoctor.gemspec +0 -143
- data/lib/asciidoctor/backends/_stylesheets.rb +0 -466
- data/lib/asciidoctor/backends/base_template.rb +0 -114
- data/lib/asciidoctor/backends/docbook45.rb +0 -774
- data/lib/asciidoctor/backends/docbook5.rb +0 -103
- data/lib/asciidoctor/backends/html5.rb +0 -1214
- data/lib/asciidoctor/renderer.rb +0 -259
- data/lib/asciidoctor/substituters.rb +0 -1083
- data/test/fixtures/asciidoc.txt +0 -105
- data/test/fixtures/ascshort.txt +0 -32
- data/test/fixtures/list_elements.asciidoc +0 -10
- data/test/renderer_test.rb +0 -162
| @@ -1,114 +0,0 @@ | |
| 1 | 
            -
            module Asciidoctor
         | 
| 2 | 
            -
            # An abstract base class that provides methods for definining and rendering the
         | 
| 3 | 
            -
            # backend templates. Concrete subclasses must implement the template method.
         | 
| 4 | 
            -
            #
         | 
| 5 | 
            -
            # NOTE we must use double quotes for attribute values in the HTML/XML output to
         | 
| 6 | 
            -
            # prevent quote processing. This requirement seems hackish, but AsciiDoc has
         | 
| 7 | 
            -
            # this same issue.
         | 
| 8 | 
            -
            class BaseTemplate
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              attr_reader :view
         | 
| 11 | 
            -
              attr_reader :backend
         | 
| 12 | 
            -
              attr_reader :eruby
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              def initialize(view, backend, eruby)
         | 
| 15 | 
            -
                @view = view
         | 
| 16 | 
            -
                @backend = backend
         | 
| 17 | 
            -
                @eruby = eruby
         | 
| 18 | 
            -
              end
         | 
| 19 | 
            -
             | 
| 20 | 
            -
              def self.inherited(klass)
         | 
| 21 | 
            -
                if self == BaseTemplate
         | 
| 22 | 
            -
                  @template_classes ||= []
         | 
| 23 | 
            -
                  @template_classes << klass
         | 
| 24 | 
            -
                else
         | 
| 25 | 
            -
                  self.superclass.inherited(klass)
         | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
              end
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              def self.template_classes
         | 
| 30 | 
            -
                @template_classes
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              # Public: Render this template in the execution context of
         | 
| 34 | 
            -
              # the supplied concrete instance of Asciidoctor::AbstractNode.
         | 
| 35 | 
            -
              #
         | 
| 36 | 
            -
              # This method invokes the template method on this instance to retrieve the
         | 
| 37 | 
            -
              # template data and then evaluates that template in the context of the
         | 
| 38 | 
            -
              # supplied concrete instance of Asciidoctor::AbstractNode. This instance is
         | 
| 39 | 
            -
              # accessible to the template data via the local variable named 'template'.
         | 
| 40 | 
            -
              #
         | 
| 41 | 
            -
              # If the compact flag on the document's renderer is true and the view context is
         | 
| 42 | 
            -
              # document or embedded, then blank lines in the output are compacted. Otherwise,
         | 
| 43 | 
            -
              # the rendered output is returned unprocessed.
         | 
| 44 | 
            -
              #
         | 
| 45 | 
            -
              # node   - The concrete instance of AsciiDoctor::AbstractNode to render
         | 
| 46 | 
            -
              # locals - A Hash of additional variables. Not currently in use.
         | 
| 47 | 
            -
              def render(node = Object.new, locals = {})
         | 
| 48 | 
            -
                tmpl = template
         | 
| 49 | 
            -
                case tmpl
         | 
| 50 | 
            -
                when :invoke_result
         | 
| 51 | 
            -
                  return result(node)
         | 
| 52 | 
            -
                when :content
         | 
| 53 | 
            -
                  result = node.content
         | 
| 54 | 
            -
                else
         | 
| 55 | 
            -
                  result = tmpl.result(node.get_binding(self))
         | 
| 56 | 
            -
                end
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                if (@view == 'document' || @view == 'embedded') &&
         | 
| 59 | 
            -
                    node.renderer.compact && !node.document.nested?
         | 
| 60 | 
            -
                  compact result
         | 
| 61 | 
            -
                else
         | 
| 62 | 
            -
                  result
         | 
| 63 | 
            -
                end
         | 
| 64 | 
            -
              end
         | 
| 65 | 
            -
             | 
| 66 | 
            -
              # Public: Compact blank lines in the provided text. This method also restores
         | 
| 67 | 
            -
              # every HTML line feed entity found with an endline character.
         | 
| 68 | 
            -
              #
         | 
| 69 | 
            -
              # text  - the String to process
         | 
| 70 | 
            -
              #
         | 
| 71 | 
            -
              # returns the text with blank lines removed and HTML line feed entities
         | 
| 72 | 
            -
              # converted to an endline character.
         | 
| 73 | 
            -
              def compact(str)
         | 
| 74 | 
            -
                str.gsub(BLANK_LINE_PATTERN, '').gsub(LINE_FEED_ENTITY, EOL)
         | 
| 75 | 
            -
              end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
              # Public: Preserve endlines by replacing them with the HTML line feed entity.
         | 
| 78 | 
            -
              #
         | 
| 79 | 
            -
              # If the compact flag on the document's renderer is true, perform the
         | 
| 80 | 
            -
              # replacement. Otherwise, return the text unprocessed.
         | 
| 81 | 
            -
              #
         | 
| 82 | 
            -
              # text  - the String to process
         | 
| 83 | 
            -
              # node  - the concrete instance of Asciidoctor::AbstractNode being rendered
         | 
| 84 | 
            -
              def preserve_endlines(str, node)
         | 
| 85 | 
            -
                node.renderer.compact ? str.gsub(EOL, LINE_FEED_ENTITY) : str
         | 
| 86 | 
            -
              end
         | 
| 87 | 
            -
             | 
| 88 | 
            -
              def template
         | 
| 89 | 
            -
                raise "You chilluns need to make your own template"
         | 
| 90 | 
            -
              end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
              # create template matter to insert an attribute if the variable has a value
         | 
| 93 | 
            -
              def attribute(name, key)
         | 
| 94 | 
            -
                type = key.is_a?(Symbol) ? :attr : :var
         | 
| 95 | 
            -
                if type == :attr
         | 
| 96 | 
            -
                  # example: <% if attr? 'foo' %> bar="<%= attr 'foo' %>"<% end %>
         | 
| 97 | 
            -
                  %(<% if attr? '#{key}' %> #{name}="<%= attr '#{key}' %>"<% end %>)
         | 
| 98 | 
            -
                else
         | 
| 99 | 
            -
                  # example: <% if foo %> bar="<%= foo %>"<% end %>
         | 
| 100 | 
            -
                  %(<% if #{key} %> #{name}="<%= #{key} %>"<% end %>)
         | 
| 101 | 
            -
                end
         | 
| 102 | 
            -
              end
         | 
| 103 | 
            -
            end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
            module EmptyTemplate
         | 
| 106 | 
            -
              def result(node)
         | 
| 107 | 
            -
                ''
         | 
| 108 | 
            -
              end
         | 
| 109 | 
            -
             | 
| 110 | 
            -
              def template
         | 
| 111 | 
            -
                :invoke_result
         | 
| 112 | 
            -
              end
         | 
| 113 | 
            -
            end
         | 
| 114 | 
            -
            end
         | 
| @@ -1,774 +0,0 @@ | |
| 1 | 
            -
            module Asciidoctor
         | 
| 2 | 
            -
              class BaseTemplate
         | 
| 3 | 
            -
                def tag(name, key, dynamic = false)
         | 
| 4 | 
            -
                  type = key.is_a?(Symbol) ? :attr : :var
         | 
| 5 | 
            -
                  key = key.to_s
         | 
| 6 | 
            -
                  if type == :attr
         | 
| 7 | 
            -
                    key_str = dynamic ? %("#{key}") : "'#{key}'"
         | 
| 8 | 
            -
                    # example: <% if attr? 'foo' %><bar><%= attr 'foo' %></bar><% end %>
         | 
| 9 | 
            -
                    %(<% if attr? #{key_str} %><#{name}><%= attr #{key_str} %></#{name}><% end %>)
         | 
| 10 | 
            -
                  else
         | 
| 11 | 
            -
                    # example: <% unless foo.to_s.empty? %><bar><%= foo %></bar><% end %>
         | 
| 12 | 
            -
                    %(<% unless #{key}.to_s.empty? %><#{name}><%= #{key} %></#{name}><% end %>)
         | 
| 13 | 
            -
                  end
         | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                def title_tag(optional = true)
         | 
| 17 | 
            -
                  if optional
         | 
| 18 | 
            -
                    %(<%= title? ? "\n<title>\#{title}</title>" : nil %>)
         | 
| 19 | 
            -
                  else
         | 
| 20 | 
            -
                    %(\n<title><%= title %></title>)
         | 
| 21 | 
            -
                  end
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                def common_attrs(id, role, reftext)
         | 
| 25 | 
            -
                  %(#{id && " #{@backend == 'docbook5' ? 'xml:id' : 'id'}=\"#{id}\""}#{role && " role=\"#{role}\""}#{reftext && " xreflabel=\"#{reftext}\""})
         | 
| 26 | 
            -
                end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
                def common_attrs_erb
         | 
| 29 | 
            -
                  %q(<%= template.common_attrs(@id, role, reftext) %>)
         | 
| 30 | 
            -
                end
         | 
| 31 | 
            -
             | 
| 32 | 
            -
                def content(node)
         | 
| 33 | 
            -
                  node.blocks? ? node.content : "<simpara>#{node.content}</simpara>"
         | 
| 34 | 
            -
                end
         | 
| 35 | 
            -
             | 
| 36 | 
            -
                def content_erb
         | 
| 37 | 
            -
                  %q(<%= blocks? ? content : "<simpara>#{content}</simpara>" %>)
         | 
| 38 | 
            -
                end
         | 
| 39 | 
            -
              end
         | 
| 40 | 
            -
             | 
| 41 | 
            -
            module DocBook45
         | 
| 42 | 
            -
            class DocumentTemplate < BaseTemplate
         | 
| 43 | 
            -
              def title_tags(str)
         | 
| 44 | 
            -
                if str.include?(': ')
         | 
| 45 | 
            -
                  title, _, subtitle = str.rpartition(': ')
         | 
| 46 | 
            -
                  %(<title>#{title}</title>
         | 
| 47 | 
            -
            <subtitle>#{subtitle}</subtitle>)
         | 
| 48 | 
            -
                else
         | 
| 49 | 
            -
                  %(<title>#{str}</title>)
         | 
| 50 | 
            -
                end
         | 
| 51 | 
            -
              end
         | 
| 52 | 
            -
             | 
| 53 | 
            -
              def docinfo
         | 
| 54 | 
            -
                <<-EOF
         | 
| 55 | 
            -
            <% unless notitle %><%= has_header? ? template.title_tags(@header.title) : %(<title>\#{attr 'untitled-label'}</title>) %><% end
         | 
| 56 | 
            -
            if attr? :revdate %>
         | 
| 57 | 
            -
            <date><%= attr :revdate %></date><%
         | 
| 58 | 
            -
            else %>
         | 
| 59 | 
            -
            <date><%= attr :docdate %></date><%
         | 
| 60 | 
            -
            end
         | 
| 61 | 
            -
            if has_header?
         | 
| 62 | 
            -
              if attr? :author
         | 
| 63 | 
            -
                if (attr :authorcount).to_i < 2 %>
         | 
| 64 | 
            -
            #{author}
         | 
| 65 | 
            -
            #{tag 'authorinitials', :authorinitials}<%
         | 
| 66 | 
            -
                else %>
         | 
| 67 | 
            -
            <authorgroup><%
         | 
| 68 | 
            -
                  (1..((attr :authorcount).to_i)).each do |idx| %>
         | 
| 69 | 
            -
            #{author true}<%
         | 
| 70 | 
            -
                  end %>
         | 
| 71 | 
            -
            </authorgroup><%
         | 
| 72 | 
            -
                end
         | 
| 73 | 
            -
              end
         | 
| 74 | 
            -
              if (attr? :revnumber) || (attr? :revremark) %>
         | 
| 75 | 
            -
            <revhistory>
         | 
| 76 | 
            -
            <revision>
         | 
| 77 | 
            -
            #{tag 'revnumber', :revnumber}
         | 
| 78 | 
            -
            #{tag 'date', :revdate}
         | 
| 79 | 
            -
            #{tag 'authorinitials', :authorinitials}
         | 
| 80 | 
            -
            #{tag 'revremark', :revremark}
         | 
| 81 | 
            -
            </revision>
         | 
| 82 | 
            -
            </revhistory><%
         | 
| 83 | 
            -
              end %>
         | 
| 84 | 
            -
            <%= docinfo %>
         | 
| 85 | 
            -
            #{tag 'orgname', :orgname}<%
         | 
| 86 | 
            -
            end %>
         | 
| 87 | 
            -
                EOF
         | 
| 88 | 
            -
              end
         | 
| 89 | 
            -
             | 
| 90 | 
            -
              def author indexed = false
         | 
| 91 | 
            -
                <<-EOF
         | 
| 92 | 
            -
            <author>
         | 
| 93 | 
            -
            #{tag 'firstname', indexed ? :"firstname_\#{idx}" : :firstname, indexed}
         | 
| 94 | 
            -
            #{tag 'othername', indexed ? :"middlename_\#{idx}" : :middlename, indexed}
         | 
| 95 | 
            -
            #{tag 'surname', indexed ? :"lastname_\#{idx}" : :lastname, indexed}
         | 
| 96 | 
            -
            #{tag 'email', indexed ? :"email_\#{idx}" : :email, indexed}
         | 
| 97 | 
            -
            </author>
         | 
| 98 | 
            -
                EOF
         | 
| 99 | 
            -
              end
         | 
| 100 | 
            -
             | 
| 101 | 
            -
              def template
         | 
| 102 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 103 | 
            -
            <%#encoding:UTF-8%><?xml version="1.0" encoding="UTF-8"?>
         | 
| 104 | 
            -
            <!DOCTYPE <%= doctype %> PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"><%
         | 
| 105 | 
            -
            if attr? :toc %>
         | 
| 106 | 
            -
            <?asciidoc-toc?><%
         | 
| 107 | 
            -
            end
         | 
| 108 | 
            -
            if attr? :numbered %>
         | 
| 109 | 
            -
            <?asciidoc-numbered?><%
         | 
| 110 | 
            -
            end
         | 
| 111 | 
            -
            if doctype == 'book' %>
         | 
| 112 | 
            -
            <book<% unless attr? :noxmlns %> xmlns="http://docbook.org/ns/docbook"<% end %><% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
         | 
| 113 | 
            -
            <bookinfo>
         | 
| 114 | 
            -
            #{docinfo}
         | 
| 115 | 
            -
            </bookinfo>
         | 
| 116 | 
            -
            <%= content %><%= (docinfo_content = docinfo :footer).empty? ? nil : %(
         | 
| 117 | 
            -
            \#{docinfo_content}) %>
         | 
| 118 | 
            -
            </book><%
         | 
| 119 | 
            -
            else %>
         | 
| 120 | 
            -
            <article<% unless attr? :noxmlns %> xmlns="http://docbook.org/ns/docbook"<% end %><% unless attr? :nolang %> lang="<%= attr :lang, 'en' %>"<% end %>>
         | 
| 121 | 
            -
            <articleinfo>
         | 
| 122 | 
            -
            #{docinfo}
         | 
| 123 | 
            -
            </articleinfo>
         | 
| 124 | 
            -
            <%= content %><%= (docinfo_content = docinfo :footer).empty? ? nil : %(
         | 
| 125 | 
            -
            \#{docinfo_content}) %>
         | 
| 126 | 
            -
            </article><%
         | 
| 127 | 
            -
            end %>
         | 
| 128 | 
            -
                EOF
         | 
| 129 | 
            -
              end
         | 
| 130 | 
            -
            end
         | 
| 131 | 
            -
             | 
| 132 | 
            -
            class EmbeddedTemplate < BaseTemplate
         | 
| 133 | 
            -
              def template
         | 
| 134 | 
            -
                :content
         | 
| 135 | 
            -
              end
         | 
| 136 | 
            -
            end
         | 
| 137 | 
            -
             | 
| 138 | 
            -
            class BlockTocTemplate < BaseTemplate
         | 
| 139 | 
            -
              def result(node)
         | 
| 140 | 
            -
                ''
         | 
| 141 | 
            -
              end
         | 
| 142 | 
            -
             | 
| 143 | 
            -
              def template
         | 
| 144 | 
            -
                :invoke_result
         | 
| 145 | 
            -
              end
         | 
| 146 | 
            -
            end
         | 
| 147 | 
            -
             | 
| 148 | 
            -
            class BlockPreambleTemplate < BaseTemplate
         | 
| 149 | 
            -
              def template
         | 
| 150 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 151 | 
            -
            <%#encoding:UTF-8%><%
         | 
| 152 | 
            -
            if @document.doctype == 'book' %><preface#{common_attrs_erb}>#{title_tag false}
         | 
| 153 | 
            -
            <%= content %>
         | 
| 154 | 
            -
            </preface><%
         | 
| 155 | 
            -
            else %>
         | 
| 156 | 
            -
            <%= content %><%
         | 
| 157 | 
            -
            end %>
         | 
| 158 | 
            -
                EOF
         | 
| 159 | 
            -
              end
         | 
| 160 | 
            -
            end
         | 
| 161 | 
            -
             | 
| 162 | 
            -
            class SectionTemplate < BaseTemplate
         | 
| 163 | 
            -
              def result(sec)
         | 
| 164 | 
            -
                if sec.special
         | 
| 165 | 
            -
                  tag = sec.level <= 1 ? sec.sectname : 'section'
         | 
| 166 | 
            -
                else
         | 
| 167 | 
            -
                  tag = sec.document.doctype == 'book' && sec.level <= 1 ? (sec.level == 0 ? 'part' : 'chapter') : 'section'
         | 
| 168 | 
            -
                end
         | 
| 169 | 
            -
                %(<#{tag}#{common_attrs(sec.id, sec.role, sec.reftext)}>
         | 
| 170 | 
            -
            #{sec.title? ? "<title>#{sec.title}</title>" : nil}
         | 
| 171 | 
            -
            #{sec.content}
         | 
| 172 | 
            -
            </#{tag}>)
         | 
| 173 | 
            -
              end
         | 
| 174 | 
            -
             | 
| 175 | 
            -
              def template
         | 
| 176 | 
            -
                :invoke_result
         | 
| 177 | 
            -
              end
         | 
| 178 | 
            -
            end
         | 
| 179 | 
            -
             | 
| 180 | 
            -
            class BlockFloatingTitleTemplate < BaseTemplate
         | 
| 181 | 
            -
              def template
         | 
| 182 | 
            -
                @template ||= @eruby.new <<-EOS
         | 
| 183 | 
            -
            <%#encoding:UTF-8%><bridgehead#{common_attrs_erb} renderas="sect<%= @level %>"><%= title %></bridgehead>
         | 
| 184 | 
            -
                EOS
         | 
| 185 | 
            -
              end
         | 
| 186 | 
            -
            end
         | 
| 187 | 
            -
             | 
| 188 | 
            -
            class BlockParagraphTemplate < BaseTemplate
         | 
| 189 | 
            -
              def paragraph(id, style, role, reftext, title, content)
         | 
| 190 | 
            -
                if !title.nil?
         | 
| 191 | 
            -
                  %(<formalpara#{common_attrs(id, role, reftext)}>
         | 
| 192 | 
            -
            <title>#{title}</title>
         | 
| 193 | 
            -
            <para>#{content}</para>
         | 
| 194 | 
            -
            </formalpara>)
         | 
| 195 | 
            -
                else
         | 
| 196 | 
            -
                  %(<simpara#{common_attrs(id, role, reftext)}>#{content}</simpara>)
         | 
| 197 | 
            -
                end
         | 
| 198 | 
            -
              end
         | 
| 199 | 
            -
             | 
| 200 | 
            -
              def result(node)
         | 
| 201 | 
            -
                paragraph(node.id, node.style, node.role, node.reftext, (node.title? ? node.title : nil), node.content)
         | 
| 202 | 
            -
              end
         | 
| 203 | 
            -
             | 
| 204 | 
            -
              def template
         | 
| 205 | 
            -
                :invoke_result
         | 
| 206 | 
            -
              end
         | 
| 207 | 
            -
            end
         | 
| 208 | 
            -
             | 
| 209 | 
            -
            class BlockAdmonitionTemplate < BaseTemplate
         | 
| 210 | 
            -
              def template
         | 
| 211 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 212 | 
            -
            <%#encoding:UTF-8%><<%= attr :name %>#{common_attrs_erb}>#{title_tag}
         | 
| 213 | 
            -
            #{content_erb}
         | 
| 214 | 
            -
            </<%= attr :name %>>
         | 
| 215 | 
            -
                EOF
         | 
| 216 | 
            -
              end
         | 
| 217 | 
            -
            end
         | 
| 218 | 
            -
             | 
| 219 | 
            -
            class BlockUlistTemplate < BaseTemplate
         | 
| 220 | 
            -
              def template
         | 
| 221 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 222 | 
            -
            <%#encoding:UTF-8%><%
         | 
| 223 | 
            -
            if @style == 'bibliography'
         | 
| 224 | 
            -
            %><bibliodiv#{common_attrs_erb}>#{title_tag}<%
         | 
| 225 | 
            -
              items.each do |li| %>
         | 
| 226 | 
            -
            <bibliomixed>
         | 
| 227 | 
            -
            <bibliomisc><%= li.text %></bibliomisc><%
         | 
| 228 | 
            -
                if li.blocks? %>
         | 
| 229 | 
            -
            <%= li.content %><%
         | 
| 230 | 
            -
                end %>
         | 
| 231 | 
            -
            </bibliomixed><%
         | 
| 232 | 
            -
              end %>
         | 
| 233 | 
            -
            </bibliodiv><%
         | 
| 234 | 
            -
            else
         | 
| 235 | 
            -
            checklist = (option? 'checklist')
         | 
| 236 | 
            -
            mark = checklist ? 'none' : @style
         | 
| 237 | 
            -
            %><itemizedlist#{common_attrs_erb}<%= mark ? %( mark="\#{mark}") : nil %>>#{title_tag}<%
         | 
| 238 | 
            -
              items.each do |li| %>
         | 
| 239 | 
            -
            <listitem>
         | 
| 240 | 
            -
            <simpara><%= checklist && (li.attr? 'checkbox') ? ((li.attr? 'checked') ? '■ ' : '□ ') : nil %><%= li.text %></simpara><%
         | 
| 241 | 
            -
                if li.blocks? %>
         | 
| 242 | 
            -
            <%= li.content %><%
         | 
| 243 | 
            -
                end %>
         | 
| 244 | 
            -
            </listitem><%
         | 
| 245 | 
            -
              end %>
         | 
| 246 | 
            -
            </itemizedlist><%
         | 
| 247 | 
            -
            end %>
         | 
| 248 | 
            -
                EOF
         | 
| 249 | 
            -
              end
         | 
| 250 | 
            -
            end
         | 
| 251 | 
            -
             | 
| 252 | 
            -
            class BlockOlistTemplate < BaseTemplate
         | 
| 253 | 
            -
              def template
         | 
| 254 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 255 | 
            -
            <%#encoding:UTF-8%><orderedlist#{common_attrs_erb}#{attribute('numeration', '@style')}>#{title_tag}<%
         | 
| 256 | 
            -
              items.each do |li| %>
         | 
| 257 | 
            -
            <listitem>
         | 
| 258 | 
            -
            <simpara><%= li.text %></simpara><%
         | 
| 259 | 
            -
                if li.blocks? %>
         | 
| 260 | 
            -
            <%= li.content %><%
         | 
| 261 | 
            -
                end %>
         | 
| 262 | 
            -
            </listitem><%
         | 
| 263 | 
            -
            end %>
         | 
| 264 | 
            -
            </orderedlist>
         | 
| 265 | 
            -
                EOF
         | 
| 266 | 
            -
              end
         | 
| 267 | 
            -
            end
         | 
| 268 | 
            -
             | 
| 269 | 
            -
            class BlockColistTemplate < BaseTemplate
         | 
| 270 | 
            -
              def template
         | 
| 271 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 272 | 
            -
            <%#encoding:UTF-8%><calloutlist#{common_attrs_erb}>#{title_tag}
         | 
| 273 | 
            -
              <% items.each do |li| %>
         | 
| 274 | 
            -
              <callout arearefs="<%= li.attr :coids %>">
         | 
| 275 | 
            -
                <para><%= li.text %></para>
         | 
| 276 | 
            -
                <% if li.blocks? %>
         | 
| 277 | 
            -
            <%= li.content %>
         | 
| 278 | 
            -
                <% end %>
         | 
| 279 | 
            -
              </callout>
         | 
| 280 | 
            -
              <% end %>
         | 
| 281 | 
            -
            </calloutlist>
         | 
| 282 | 
            -
                EOF
         | 
| 283 | 
            -
              end
         | 
| 284 | 
            -
            end
         | 
| 285 | 
            -
             | 
| 286 | 
            -
            class BlockDlistTemplate < BaseTemplate
         | 
| 287 | 
            -
              LIST_TAGS = {
         | 
| 288 | 
            -
                'labeled' => {
         | 
| 289 | 
            -
                  :list => 'variablelist',
         | 
| 290 | 
            -
                  :entry => 'varlistentry',
         | 
| 291 | 
            -
                  :term => 'term',
         | 
| 292 | 
            -
                  :item => 'listitem'
         | 
| 293 | 
            -
                },
         | 
| 294 | 
            -
                'qanda' => {
         | 
| 295 | 
            -
                  :list => 'qandaset',
         | 
| 296 | 
            -
                  :entry => 'qandaentry',
         | 
| 297 | 
            -
                  :label => 'question',
         | 
| 298 | 
            -
                  :term => 'simpara',
         | 
| 299 | 
            -
                  :item => 'answer'
         | 
| 300 | 
            -
                },
         | 
| 301 | 
            -
                'glossary' => {
         | 
| 302 | 
            -
                  :list => nil,
         | 
| 303 | 
            -
                  :entry => 'glossentry',
         | 
| 304 | 
            -
                  :term => 'glossterm',
         | 
| 305 | 
            -
                  :item => 'glossdef'
         | 
| 306 | 
            -
                }
         | 
| 307 | 
            -
              }
         | 
| 308 | 
            -
             | 
| 309 | 
            -
              def template
         | 
| 310 | 
            -
                # TODO may want to refactor ListItem content to hold multiple terms
         | 
| 311 | 
            -
                # that change would drastically simplify this template
         | 
| 312 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 313 | 
            -
            <%#encoding:UTF-8%><%
         | 
| 314 | 
            -
            if @style == 'horizontal'
         | 
| 315 | 
            -
            %><<%= (tag = title? ? 'table' : 'informaltable') %>#{common_attrs_erb} tabstyle="horizontal" frame="none" colsep="0" rowsep="0">#{title_tag}
         | 
| 316 | 
            -
            <tgroup cols="2">
         | 
| 317 | 
            -
            <colspec colwidth="<%= attr :labelwidth, 15 %>*"/>
         | 
| 318 | 
            -
            <colspec colwidth="<%= attr :labelwidth, 85 %>*"/>
         | 
| 319 | 
            -
            <tbody valign="top"><%
         | 
| 320 | 
            -
              items.each do |terms, dd| %>
         | 
| 321 | 
            -
            <row>
         | 
| 322 | 
            -
            <entry><%
         | 
| 323 | 
            -
                [*terms].each do |dt| %>
         | 
| 324 | 
            -
            <simpara><%= dt.text %></simpara><%
         | 
| 325 | 
            -
                end %>
         | 
| 326 | 
            -
            </entry>
         | 
| 327 | 
            -
            <entry><%
         | 
| 328 | 
            -
                unless dd.nil?
         | 
| 329 | 
            -
                  if dd.text? %>
         | 
| 330 | 
            -
            <simpara><%= dd.text %></simpara><%
         | 
| 331 | 
            -
                  end
         | 
| 332 | 
            -
                  if dd.blocks? %>
         | 
| 333 | 
            -
            <%= dd.content %><%
         | 
| 334 | 
            -
                  end
         | 
| 335 | 
            -
                end %>
         | 
| 336 | 
            -
            </entry>
         | 
| 337 | 
            -
            </row><%
         | 
| 338 | 
            -
              end %>
         | 
| 339 | 
            -
            </tbody>
         | 
| 340 | 
            -
            </tgroup>
         | 
| 341 | 
            -
            </<%= tag %>><%
         | 
| 342 | 
            -
            else
         | 
| 343 | 
            -
              tags = (template.class::LIST_TAGS[@style] || template.class::LIST_TAGS['labeled'])
         | 
| 344 | 
            -
              if tags[:list]
         | 
| 345 | 
            -
            %><<%= tags[:list] %>#{common_attrs_erb}>#{title_tag}<%
         | 
| 346 | 
            -
              end
         | 
| 347 | 
            -
              items.each do |terms, dd| %>
         | 
| 348 | 
            -
            <<%= tags[:entry] %>><%
         | 
| 349 | 
            -
                if tags.has_key? :label %>
         | 
| 350 | 
            -
            <<%= tags[:label] %>><%
         | 
| 351 | 
            -
                end
         | 
| 352 | 
            -
                [*terms].each do |dt| %>
         | 
| 353 | 
            -
            <<%= tags[:term] %>><%= dt.text %></<%= tags[:term] %>><%
         | 
| 354 | 
            -
                end
         | 
| 355 | 
            -
                if tags.has_key? :label %>
         | 
| 356 | 
            -
            </<%= tags[:label] %>><%
         | 
| 357 | 
            -
                end %>
         | 
| 358 | 
            -
            <<%= tags[:item] %>><%
         | 
| 359 | 
            -
                unless dd.nil?
         | 
| 360 | 
            -
                  if dd.text? %>
         | 
| 361 | 
            -
            <simpara><%= dd.text %></simpara><%
         | 
| 362 | 
            -
                  end
         | 
| 363 | 
            -
                  if dd.blocks? %>
         | 
| 364 | 
            -
            <%= dd.content %><%
         | 
| 365 | 
            -
                  end
         | 
| 366 | 
            -
                end %>
         | 
| 367 | 
            -
            </<%= tags[:item] %>>
         | 
| 368 | 
            -
            </<%= tags[:entry] %>><%
         | 
| 369 | 
            -
              end
         | 
| 370 | 
            -
              if tags[:list] %>
         | 
| 371 | 
            -
            </<%= tags[:list] %>><%
         | 
| 372 | 
            -
              end
         | 
| 373 | 
            -
            end %>
         | 
| 374 | 
            -
                EOF
         | 
| 375 | 
            -
              end
         | 
| 376 | 
            -
            end
         | 
| 377 | 
            -
             | 
| 378 | 
            -
            class BlockOpenTemplate < BaseTemplate
         | 
| 379 | 
            -
              def result(node)
         | 
| 380 | 
            -
                open_block(node, node.id, node.style, node.role, node.reftext, node.title? ? node.title : nil)
         | 
| 381 | 
            -
              end
         | 
| 382 | 
            -
             | 
| 383 | 
            -
              def open_block(node, id, style, role, reftext, title)
         | 
| 384 | 
            -
                case style
         | 
| 385 | 
            -
                when 'abstract'
         | 
| 386 | 
            -
                  if node.parent == node.document && node.document.attr?('doctype', 'book')
         | 
| 387 | 
            -
                    warn 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'
         | 
| 388 | 
            -
                    ''
         | 
| 389 | 
            -
                  else
         | 
| 390 | 
            -
                    %(<abstract>#{title && "\n<title>#{title}</title>"}
         | 
| 391 | 
            -
            #{content node}
         | 
| 392 | 
            -
            </abstract>)
         | 
| 393 | 
            -
                  end
         | 
| 394 | 
            -
                when 'partintro'
         | 
| 395 | 
            -
                  unless node.document.attr?('doctype', 'book') && node.parent.is_a?(Asciidoctor::Section) && node.level == 0
         | 
| 396 | 
            -
                    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.'
         | 
| 397 | 
            -
                    ''
         | 
| 398 | 
            -
                  else
         | 
| 399 | 
            -
                    %(<partintro#{common_attrs id, role, reftext}>#{title && "\n<title>#{title}</title>"}
         | 
| 400 | 
            -
            #{content node}
         | 
| 401 | 
            -
            </partintro>)
         | 
| 402 | 
            -
                  end
         | 
| 403 | 
            -
                else
         | 
| 404 | 
            -
                  node.content
         | 
| 405 | 
            -
                end
         | 
| 406 | 
            -
              end
         | 
| 407 | 
            -
             | 
| 408 | 
            -
              def template
         | 
| 409 | 
            -
                :invoke_result
         | 
| 410 | 
            -
              end
         | 
| 411 | 
            -
            end
         | 
| 412 | 
            -
             | 
| 413 | 
            -
            class BlockListingTemplate < BaseTemplate
         | 
| 414 | 
            -
              def template
         | 
| 415 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 416 | 
            -
            <%#encoding:UTF-8%><%
         | 
| 417 | 
            -
            if !title?
         | 
| 418 | 
            -
              if @style == 'source' && (attr? 'language')
         | 
| 419 | 
            -
            %><programlisting#{common_attrs_erb}#{attribute('language', :language)} linenumbering="<%= (attr? :linenums) ? 'numbered' : 'unnumbered' %>"><%= template.preserve_endlines(content, self) %></programlisting><%
         | 
| 420 | 
            -
              else
         | 
| 421 | 
            -
            %><screen#{common_attrs_erb}><%= template.preserve_endlines(content, self) %></screen><%
         | 
| 422 | 
            -
              end
         | 
| 423 | 
            -
            else
         | 
| 424 | 
            -
            %><formalpara#{common_attrs_erb}>#{title_tag false}
         | 
| 425 | 
            -
            <para><%
         | 
| 426 | 
            -
              if @style == 'source' && (attr? 'language') %>
         | 
| 427 | 
            -
            <programlisting language="<%= attr 'language' %>" linenumbering="<%= (attr? :linenums) ? 'numbered' : 'unnumbered' %>"><%= template.preserve_endlines(content, self) %></programlisting><%
         | 
| 428 | 
            -
              else %>
         | 
| 429 | 
            -
            <screen><%= template.preserve_endlines(content, self) %></screen><%
         | 
| 430 | 
            -
              end %>
         | 
| 431 | 
            -
            </para>
         | 
| 432 | 
            -
            </formalpara><%
         | 
| 433 | 
            -
            end %>
         | 
| 434 | 
            -
                EOF
         | 
| 435 | 
            -
              end
         | 
| 436 | 
            -
            end
         | 
| 437 | 
            -
             | 
| 438 | 
            -
            class BlockLiteralTemplate < BaseTemplate
         | 
| 439 | 
            -
              def template
         | 
| 440 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 441 | 
            -
            <%#encoding:UTF-8%><% if !title? %>
         | 
| 442 | 
            -
            <literallayout#{common_attrs_erb} class="monospaced"><%= template.preserve_endlines(content, self) %></literallayout>
         | 
| 443 | 
            -
            <% else %>
         | 
| 444 | 
            -
            <formalpara#{common_attrs_erb}>#{title_tag false}
         | 
| 445 | 
            -
              <para>
         | 
| 446 | 
            -
                <literallayout class="monospaced"><%= template.preserve_endlines(content, self) %></literallayout>
         | 
| 447 | 
            -
              </para>
         | 
| 448 | 
            -
            </formalpara>
         | 
| 449 | 
            -
            <% end %>
         | 
| 450 | 
            -
                EOF
         | 
| 451 | 
            -
              end
         | 
| 452 | 
            -
            end
         | 
| 453 | 
            -
             | 
| 454 | 
            -
            class BlockExampleTemplate < BaseTemplate
         | 
| 455 | 
            -
              def template
         | 
| 456 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 457 | 
            -
            <%#encoding:UTF-8%><<%= (tag_name = title? ? 'example' : 'informalexample') %>#{common_attrs_erb}>#{title_tag}
         | 
| 458 | 
            -
            #{content_erb}
         | 
| 459 | 
            -
            </<%= tag_name %>>
         | 
| 460 | 
            -
                EOF
         | 
| 461 | 
            -
              end
         | 
| 462 | 
            -
            end
         | 
| 463 | 
            -
             | 
| 464 | 
            -
            class BlockSidebarTemplate < BaseTemplate
         | 
| 465 | 
            -
              def template
         | 
| 466 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 467 | 
            -
            <%#encoding:UTF-8%><sidebar#{common_attrs_erb}>#{title_tag}
         | 
| 468 | 
            -
            #{content_erb}
         | 
| 469 | 
            -
            </sidebar>
         | 
| 470 | 
            -
                EOF
         | 
| 471 | 
            -
              end
         | 
| 472 | 
            -
            end
         | 
| 473 | 
            -
             | 
| 474 | 
            -
            class BlockQuoteTemplate < BaseTemplate
         | 
| 475 | 
            -
              def template
         | 
| 476 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 477 | 
            -
            <%#encoding:UTF-8%><blockquote#{common_attrs_erb}>#{title_tag}
         | 
| 478 | 
            -
              <% if (attr? :attribution) || (attr? :citetitle) %>
         | 
| 479 | 
            -
              <attribution>
         | 
| 480 | 
            -
                <% if attr? :attribution %>
         | 
| 481 | 
            -
                <%= (attr :attribution) %>
         | 
| 482 | 
            -
                <% end %>
         | 
| 483 | 
            -
                #{tag 'citetitle', :citetitle}
         | 
| 484 | 
            -
              </attribution>
         | 
| 485 | 
            -
              <% end %>
         | 
| 486 | 
            -
            #{content_erb}
         | 
| 487 | 
            -
            </blockquote>
         | 
| 488 | 
            -
                EOF
         | 
| 489 | 
            -
              end
         | 
| 490 | 
            -
            end
         | 
| 491 | 
            -
             | 
| 492 | 
            -
            class BlockVerseTemplate < BaseTemplate
         | 
| 493 | 
            -
              def template
         | 
| 494 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 495 | 
            -
            <%#encoding:UTF-8%><blockquote#{common_attrs_erb}>#{title_tag}
         | 
| 496 | 
            -
              <% if (attr? :attribution) || (attr? :citetitle) %>
         | 
| 497 | 
            -
              <attribution>
         | 
| 498 | 
            -
                <% if attr? :attribution %>
         | 
| 499 | 
            -
                <%= (attr :attribution) %>
         | 
| 500 | 
            -
                <% end %>
         | 
| 501 | 
            -
                #{tag 'citetitle', :citetitle}
         | 
| 502 | 
            -
              </attribution>
         | 
| 503 | 
            -
              <% end %>
         | 
| 504 | 
            -
              <literallayout><%= content %></literallayout>
         | 
| 505 | 
            -
            </blockquote>
         | 
| 506 | 
            -
                EOF
         | 
| 507 | 
            -
              end
         | 
| 508 | 
            -
            end
         | 
| 509 | 
            -
             | 
| 510 | 
            -
            class BlockPassTemplate < BaseTemplate
         | 
| 511 | 
            -
              def template
         | 
| 512 | 
            -
                :content
         | 
| 513 | 
            -
              end
         | 
| 514 | 
            -
            end
         | 
| 515 | 
            -
             | 
| 516 | 
            -
            class BlockTableTemplate < BaseTemplate
         | 
| 517 | 
            -
              def template
         | 
| 518 | 
            -
                @template ||= @eruby.new <<-EOS
         | 
| 519 | 
            -
            <%#encoding:UTF-8%><<%= (tag_name = title? ? 'table' : 'informaltable') %>#{common_attrs_erb} frame="<%= attr :frame, 'all'%>"
         | 
| 520 | 
            -
                rowsep="<%= ['none', 'cols'].include?(attr :grid) ? 0 : 1 %>" colsep="<%= ['none', 'rows'].include?(attr :grid) ? 0 : 1 %>">#{title_tag}
         | 
| 521 | 
            -
              <% if attr? :width %>
         | 
| 522 | 
            -
              <?dbhtml table-width="<%= attr :width %>"?>
         | 
| 523 | 
            -
              <?dbfo table-width="<%= attr :width %>"?>
         | 
| 524 | 
            -
              <?dblatex table-width="<%= attr :width %>"?>
         | 
| 525 | 
            -
              <% end %>
         | 
| 526 | 
            -
              <tgroup cols="<%= attr :colcount %>">
         | 
| 527 | 
            -
                <% @columns.each do |col| %>
         | 
| 528 | 
            -
                <colspec colname="col_<%= col.attr :colnumber %>" colwidth="<%= col.attr((attr? :width) ? :colabswidth : :colpcwidth) %>*"/>
         | 
| 529 | 
            -
                <% end %>
         | 
| 530 | 
            -
                <% [:head, :foot, :body].select {|tblsec| !rows[tblsec].empty? }.each do |tblsec| %>
         | 
| 531 | 
            -
                <t<%= tblsec %>>
         | 
| 532 | 
            -
                  <% @rows[tblsec].each do |row| %>
         | 
| 533 | 
            -
                  <row>
         | 
| 534 | 
            -
                    <% row.each do |cell| %>
         | 
| 535 | 
            -
                    <entry#{attribute('align', 'cell.attr :halign')}#{attribute('valign', 'cell.attr :valign')}<%
         | 
| 536 | 
            -
                    if cell.colspan %> namest="col_<%= cell.column.attr :colnumber %>" nameend="col_<%= (cell.column.attr :colnumber) + cell.colspan - 1 %>"<%
         | 
| 537 | 
            -
                    end %><% if cell.rowspan %> morerows="<%= cell.rowspan - 1 %>"<% end %>><%
         | 
| 538 | 
            -
                    cell_content = ''
         | 
| 539 | 
            -
                    if tblsec == :head %><% cell_content = cell.text %><%
         | 
| 540 | 
            -
                    else %><%
         | 
| 541 | 
            -
                    case cell.style
         | 
| 542 | 
            -
                      when :asciidoc %><% cell_content = cell.content %><%
         | 
| 543 | 
            -
                      when :verse %><% cell_content = %(<literallayout>\#{template.preserve_endlines(cell.text, self)}</literallayout>) %><%
         | 
| 544 | 
            -
                      when :literal %><% cell_content = %(<literallayout class="monospaced">\#{template.preserve_endlines(cell.text, self)}</literallayout>) %><%
         | 
| 545 | 
            -
                      when :header %><% cell.content.each do |text| %><% cell_content = %(\#{cell_content\}<simpara><emphasis role="strong">\#{text}</emphasis></simpara>) %><% end %><%
         | 
| 546 | 
            -
                      else %><% cell.content.each do |text| %><% cell_content = %(\#{cell_content}<simpara>\#{text}</simpara>) %><% end %><%
         | 
| 547 | 
            -
                    %><% end %><% end %><%= (@document.attr? 'cellbgcolor') ? %(<?dbfo bgcolor="\#{@document.attr 'cellbgcolor'}"?>) : nil %><%= cell_content %></entry>
         | 
| 548 | 
            -
                    <% end %>
         | 
| 549 | 
            -
                  </row>
         | 
| 550 | 
            -
                  <% end %>
         | 
| 551 | 
            -
                </t<%= tblsec %>>
         | 
| 552 | 
            -
                <% end %>
         | 
| 553 | 
            -
              </tgroup>
         | 
| 554 | 
            -
            </<%= tag_name %>>
         | 
| 555 | 
            -
                EOS
         | 
| 556 | 
            -
              end
         | 
| 557 | 
            -
            end
         | 
| 558 | 
            -
             | 
| 559 | 
            -
            class BlockImageTemplate < BaseTemplate
         | 
| 560 | 
            -
              def template
         | 
| 561 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 562 | 
            -
            <%#encoding:UTF-8%><%#encoding:UTF-8%><figure#{common_attrs_erb}>#{title_tag}
         | 
| 563 | 
            -
              <mediaobject>
         | 
| 564 | 
            -
                <imageobject>
         | 
| 565 | 
            -
                  <imagedata fileref="<%= image_uri(attr :target) %>"#{attribute('contentwidth', :width)}#{attribute('contentdepth', :height)}/>
         | 
| 566 | 
            -
                </imageobject>
         | 
| 567 | 
            -
                <textobject><phrase><%= attr :alt %></phrase></textobject>
         | 
| 568 | 
            -
              </mediaobject>
         | 
| 569 | 
            -
            </figure>
         | 
| 570 | 
            -
                EOF
         | 
| 571 | 
            -
              end
         | 
| 572 | 
            -
            end
         | 
| 573 | 
            -
             | 
| 574 | 
            -
            class BlockAudioTemplate < BaseTemplate
         | 
| 575 | 
            -
              include EmptyTemplate
         | 
| 576 | 
            -
            end
         | 
| 577 | 
            -
             | 
| 578 | 
            -
            class BlockVideoTemplate < BaseTemplate
         | 
| 579 | 
            -
              include EmptyTemplate
         | 
| 580 | 
            -
            end
         | 
| 581 | 
            -
             | 
| 582 | 
            -
            class BlockRulerTemplate < BaseTemplate
         | 
| 583 | 
            -
              def template
         | 
| 584 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 585 | 
            -
            <%#encoding:UTF-8%><simpara><?asciidoc-hr?></simpara>
         | 
| 586 | 
            -
                EOF
         | 
| 587 | 
            -
              end
         | 
| 588 | 
            -
            end
         | 
| 589 | 
            -
             | 
| 590 | 
            -
            class BlockPageBreakTemplate < BaseTemplate
         | 
| 591 | 
            -
              def template
         | 
| 592 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 593 | 
            -
            <%#encoding:UTF-8%><simpara><?asciidoc-pagebreak?></simpara>
         | 
| 594 | 
            -
                EOF
         | 
| 595 | 
            -
              end
         | 
| 596 | 
            -
            end
         | 
| 597 | 
            -
             | 
| 598 | 
            -
            class InlineBreakTemplate < BaseTemplate
         | 
| 599 | 
            -
              def template
         | 
| 600 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 601 | 
            -
            <%#encoding:UTF-8%><%= @text %><?asciidoc-br?>
         | 
| 602 | 
            -
                EOF
         | 
| 603 | 
            -
              end
         | 
| 604 | 
            -
            end
         | 
| 605 | 
            -
             | 
| 606 | 
            -
            class InlineQuotedTemplate < BaseTemplate
         | 
| 607 | 
            -
              NO_TAGS = [nil, nil]
         | 
| 608 | 
            -
             | 
| 609 | 
            -
              QUOTED_TAGS = {
         | 
| 610 | 
            -
                :emphasis => ['<emphasis>', '</emphasis>'],
         | 
| 611 | 
            -
                :strong => ['<emphasis role="strong">', '</emphasis>'],
         | 
| 612 | 
            -
                :monospaced => ['<literal>', '</literal>'],
         | 
| 613 | 
            -
                :superscript => ['<superscript>', '</superscript>'],
         | 
| 614 | 
            -
                :subscript => ['<subscript>', '</subscript>'],
         | 
| 615 | 
            -
                :double => ['“', '”'],
         | 
| 616 | 
            -
                :single => ['‘', '’']
         | 
| 617 | 
            -
              }
         | 
| 618 | 
            -
             | 
| 619 | 
            -
              def quote_text(text, type, id, role)
         | 
| 620 | 
            -
                start_tag, end_tag = QUOTED_TAGS[type] || NO_TAGS
         | 
| 621 | 
            -
                anchor = id.nil? ? nil : %(<anchor#{common_attrs id, nil, text}/>)
         | 
| 622 | 
            -
                if role
         | 
| 623 | 
            -
                  quoted_text = "#{start_tag}<phrase role=\"#{role}\">#{text}</phrase>#{end_tag}"
         | 
| 624 | 
            -
                elsif start_tag.nil?
         | 
| 625 | 
            -
                  quoted_text = text
         | 
| 626 | 
            -
                else
         | 
| 627 | 
            -
                  quoted_text = "#{start_tag}#{text}#{end_tag}"
         | 
| 628 | 
            -
                end
         | 
| 629 | 
            -
             | 
| 630 | 
            -
                anchor.nil? ? quoted_text : %(#{anchor}#{quoted_text})
         | 
| 631 | 
            -
              end
         | 
| 632 | 
            -
             | 
| 633 | 
            -
              def result(node)
         | 
| 634 | 
            -
                quote_text(node.text, node.type, node.id, node.role)
         | 
| 635 | 
            -
              end
         | 
| 636 | 
            -
             | 
| 637 | 
            -
              def template
         | 
| 638 | 
            -
                :invoke_result
         | 
| 639 | 
            -
              end
         | 
| 640 | 
            -
            end
         | 
| 641 | 
            -
             | 
| 642 | 
            -
            class InlineButtonTemplate < BaseTemplate
         | 
| 643 | 
            -
              def result(node)
         | 
| 644 | 
            -
                %(<guibutton>#{node.text}</guibutton>)
         | 
| 645 | 
            -
              end
         | 
| 646 | 
            -
             | 
| 647 | 
            -
              def template
         | 
| 648 | 
            -
                :invoke_result
         | 
| 649 | 
            -
              end
         | 
| 650 | 
            -
            end
         | 
| 651 | 
            -
             | 
| 652 | 
            -
            class InlineKbdTemplate < BaseTemplate
         | 
| 653 | 
            -
              def result(node)
         | 
| 654 | 
            -
                keys = node.attr 'keys'
         | 
| 655 | 
            -
                if keys.size == 1
         | 
| 656 | 
            -
                  %(<keycap>#{keys.first}</keycap>)
         | 
| 657 | 
            -
                else
         | 
| 658 | 
            -
                  key_combo = keys.map{|key| %(<keycap>#{key}</keycap>) }.join
         | 
| 659 | 
            -
                  %(<keycombo>#{key_combo}</keycombo>)
         | 
| 660 | 
            -
                end
         | 
| 661 | 
            -
              end
         | 
| 662 | 
            -
             | 
| 663 | 
            -
              def template
         | 
| 664 | 
            -
                :invoke_result
         | 
| 665 | 
            -
              end
         | 
| 666 | 
            -
            end
         | 
| 667 | 
            -
             | 
| 668 | 
            -
            class InlineMenuTemplate < BaseTemplate
         | 
| 669 | 
            -
              def menu(menu, submenus, menuitem)
         | 
| 670 | 
            -
                if !submenus.empty?
         | 
| 671 | 
            -
                  submenu_path = submenus.map{|submenu| %(<guisubmenu>#{submenu}</guisubmenu> ) }.join.chop
         | 
| 672 | 
            -
                  %(<menuchoice><guimenu>#{menu}</guimenu> #{submenu_path} <guimenuitem>#{menuitem}</guimenuitem></menuchoice>)
         | 
| 673 | 
            -
                elsif !menuitem.nil?
         | 
| 674 | 
            -
                  %(<menuchoice><guimenu>#{menu}</guimenu> <guimenuitem>#{menuitem}</guimenuitem></menuchoice>)
         | 
| 675 | 
            -
                else
         | 
| 676 | 
            -
                  %(<guimenu>#{menu}</guimenu>)
         | 
| 677 | 
            -
                end
         | 
| 678 | 
            -
              end
         | 
| 679 | 
            -
             | 
| 680 | 
            -
              def result(node)
         | 
| 681 | 
            -
                menu(node.attr('menu'), node.attr('submenus'), node.attr('menuitem'))
         | 
| 682 | 
            -
              end
         | 
| 683 | 
            -
             | 
| 684 | 
            -
              def template
         | 
| 685 | 
            -
                :invoke_result
         | 
| 686 | 
            -
              end
         | 
| 687 | 
            -
            end
         | 
| 688 | 
            -
             | 
| 689 | 
            -
            class InlineAnchorTemplate < BaseTemplate
         | 
| 690 | 
            -
              def anchor(target, text, type, node)
         | 
| 691 | 
            -
                case type
         | 
| 692 | 
            -
                when :ref
         | 
| 693 | 
            -
                  %(<anchor#{common_attrs target, nil, text}/>)
         | 
| 694 | 
            -
                when :xref
         | 
| 695 | 
            -
                  if node.attr? 'path', nil
         | 
| 696 | 
            -
                    linkend = (node.attr 'fragment') || target
         | 
| 697 | 
            -
                    text.nil? ? %(<xref linkend="#{linkend}"/>) : %(<link linkend="#{linkend}">#{text}</link>)
         | 
| 698 | 
            -
                  else
         | 
| 699 | 
            -
                    text = text || (node.attr 'path')
         | 
| 700 | 
            -
                    %(<ulink url="#{target}">#{text}</ulink>)
         | 
| 701 | 
            -
                  end
         | 
| 702 | 
            -
                when :link
         | 
| 703 | 
            -
                  %(<ulink url="#{target}">#{text}</ulink>)
         | 
| 704 | 
            -
                when :bibref
         | 
| 705 | 
            -
                  %(<anchor#{common_attrs target, nil, "[#{target}]"}/>[#{target}])
         | 
| 706 | 
            -
                end
         | 
| 707 | 
            -
              end
         | 
| 708 | 
            -
             | 
| 709 | 
            -
              def result(node)
         | 
| 710 | 
            -
                anchor(node.target, node.text, node.type, node)
         | 
| 711 | 
            -
              end
         | 
| 712 | 
            -
             | 
| 713 | 
            -
              def template
         | 
| 714 | 
            -
                :invoke_result
         | 
| 715 | 
            -
              end
         | 
| 716 | 
            -
            end
         | 
| 717 | 
            -
             | 
| 718 | 
            -
            class InlineImageTemplate < BaseTemplate
         | 
| 719 | 
            -
              def template
         | 
| 720 | 
            -
                @template ||= @eruby.new <<-EOF
         | 
| 721 | 
            -
            <%#encoding:UTF-8%><inlinemediaobject>
         | 
| 722 | 
            -
              <imageobject>
         | 
| 723 | 
            -
                <imagedata fileref="<%= @type == 'icon' ? icon_uri(@target) : image_uri(@target) %>"#{attribute('width', :width)}#{attribute('depth', :height)}/>
         | 
| 724 | 
            -
              </imageobject>
         | 
| 725 | 
            -
              <textobject><phrase><%= attr :alt %></phrase></textobject>
         | 
| 726 | 
            -
            </inlinemediaobject>
         | 
| 727 | 
            -
                EOF
         | 
| 728 | 
            -
              end
         | 
| 729 | 
            -
            end
         | 
| 730 | 
            -
             | 
| 731 | 
            -
            class InlineFootnoteTemplate < BaseTemplate
         | 
| 732 | 
            -
              def template
         | 
| 733 | 
            -
                @template ||= @eruby.new <<-EOS
         | 
| 734 | 
            -
            <%#encoding:UTF-8%><%
         | 
| 735 | 
            -
            if @type == :xref
         | 
| 736 | 
            -
            %><footnoteref linkend="<%= @target %>"/><%
         | 
| 737 | 
            -
            else
         | 
| 738 | 
            -
            %><footnote<%= template.common_attrs(@id, nil, nil) %>><simpara><%= @text %></simpara></footnote><%
         | 
| 739 | 
            -
            end %>
         | 
| 740 | 
            -
                EOS
         | 
| 741 | 
            -
              end
         | 
| 742 | 
            -
            end
         | 
| 743 | 
            -
             | 
| 744 | 
            -
            class InlineCalloutTemplate < BaseTemplate
         | 
| 745 | 
            -
              def result(node)
         | 
| 746 | 
            -
                %(<co#{common_attrs node.id, nil, nil}/>)
         | 
| 747 | 
            -
              end
         | 
| 748 | 
            -
             | 
| 749 | 
            -
              def template
         | 
| 750 | 
            -
                :invoke_result
         | 
| 751 | 
            -
              end
         | 
| 752 | 
            -
            end
         | 
| 753 | 
            -
             | 
| 754 | 
            -
            class InlineIndextermTemplate < BaseTemplate
         | 
| 755 | 
            -
              def template
         | 
| 756 | 
            -
                @template ||= @eruby.new <<-EOS
         | 
| 757 | 
            -
            <%#encoding:UTF-8%><% if @type == :visible %><indexterm><primary><%= @text %></primary></indexterm><%= @text %><%
         | 
| 758 | 
            -
            else %><% terms = (attr :terms); numterms = terms.size %><%
         | 
| 759 | 
            -
            if numterms > 2 %><indexterm>
         | 
| 760 | 
            -
              <primary><%= terms[0] %></primary><secondary><%= terms[1] %></secondary><tertiary><%= terms[2] %></tertiary>
         | 
| 761 | 
            -
            </indexterm>
         | 
| 762 | 
            -
            <% end %><%
         | 
| 763 | 
            -
            if numterms > 1 %><indexterm>
         | 
| 764 | 
            -
              <primary><%= terms[-2] %></primary><secondary><%= terms[-1] %></secondary>
         | 
| 765 | 
            -
            </indexterm>
         | 
| 766 | 
            -
            <% end %><indexterm>
         | 
| 767 | 
            -
              <primary><%= terms[-1] %></primary>
         | 
| 768 | 
            -
            </indexterm><% end %>
         | 
| 769 | 
            -
                EOS
         | 
| 770 | 
            -
              end
         | 
| 771 | 
            -
            end
         | 
| 772 | 
            -
             | 
| 773 | 
            -
            end # module DocBook45
         | 
| 774 | 
            -
            end # module Asciidoctor
         |