class Asciidoctor::BaseTemplate # create template matter to insert a style class from the role attribute if specified def style_class attrvalue(:role) end end module Asciidoctor::HTML5 class DocumentTemplate < ::Asciidoctor::BaseTemplate def render_outline(node, to_depth = 2) toc_level = nil sections = node.sections unless sections.empty? toc_level, indent = '' unless node.is_a?(::Asciidoctor::Document) indent = ' ' * (node.document.doctype == 'book' ? node.level + 1 : node.level) end toc_level << "#{indent}
    \n" sections.each do |section| toc_level << "#{indent}
  1. #{section.sectnum} #{section.title}
  2. \n" if section.level < to_depth && (child_toc_level = render_outline(section, to_depth)) toc_level << "#{indent}
  3. \n#{child_toc_level}\n#{indent}
  4. \n" end end toc_level << "#{indent}
" end toc_level end # Internal: Generate the default stylesheet for CodeRay # # returns the default CodeRay stylesheet as a String def default_coderay_stylesheet Asciidoctor.require_library 'coderay' ::CodeRay::Encoders[:html]::CSS.new(:default).stylesheet end def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% if attr? :description %><% end %> <% if attr? :keywords %><% end %> <%= doctitle %> <% if attr? :toc %> <% end %> <% unless attr(:stylesheet, '').empty? %> <% end %> <% case attr 'source-highlighter' %><% when 'coderay' %> <% when 'highlightjs' %> <% end %> style="max-width: <%= attr 'max-width' %>;"<% end %>> <% unless noheader %> <% end %>
<%= content %>
EOS end end class EmbeddedTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <%= content %> EOS end end class BlockPreambleTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%>
<%= content %>
EOS end end class SectionTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% if level == 0 %> <%= title %> <%= content %> <% else %>
#{id}><% if attr? :numbered %><%= sectnum %> <% end %><%= title %>> <% if @level == 1 %>
<%= content %>
<% else %> <%= content %> <% end %>
<% end %> EOS end end class BlockDlistTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% if title %>
<%= title %>
<% end %>
<% content.each do |dt, dd| %>
<%= dt.text %>
<% unless dd.nil? %>
<% if dd.text? %>

<%= dd.text %>

<% end %> <% if dd.blocks? %> <%= dd.content %> <% end %>
<% end %> <% end %>
EOS end end class BlockListingTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% if title %>
<%= title %>
<% end %>
<% if (attr :style) == 'source' %>
<%= template.preserve_endlines(content, self) %>
<% else %>
<%= template.preserve_endlines(content, self) %>
<% end %>
EOS end end class BlockLiteralTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% if title %>
<%= title %>
<% end %>
<%= template.preserve_endlines(content, self) %>
EOS end end class BlockAdmonitionTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%>
<% if attr? :icons %> <%= attr :caption %> <% else %>
<%= attr :caption %>
<% end %>
<% unless title.nil? %>
<%= title %>
<% end %> <%= content %>
EOS end end class BlockParagraphTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% unless title.nil? %>
<%= title %>
<% end %>

<%= content %>

EOS end end class BlockSidebarTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%>
<% unless title.nil? %>
<%= title %>
<% end %> <%= content %>
EOS end end class BlockExampleTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%>
<% unless title.nil? %>
<%= title %>
<% end %> <%= content %>
EOS end end class BlockOpenTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% unless title.nil? %>
<%= title %>
<% end %>
<%= content %>
EOS end end class BlockPassTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <%= content %> EOS end end class BlockQuoteTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% unless title.nil? %>
<%= title %>
<% end %>
<%= content %>
<% if attr? :citetitle %> <%= attr :citetitle %> <% end %> <% if attr? :attribution %> <% if attr? :citetitle %>
<% end %> <%= '— ' + attr(:attribution) %> <% end %>
EOS end end class BlockVerseTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% unless title.nil? %>
<%= title %>
<% end %>
<%= template.preserve_endlines(content, self) %>
<% if attr? :citetitle %> <%= attr :citetitle %> <% end %> <% if attr? :attribution %> <% if attr? :citetitle %>
<% end %> <%= '— ' + attr(:attribution) %> <% end %>
EOS end end class BlockUlistTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% unless title.nil? %>
<%= title %>
<% end %>
    <% content.each do |li| %>
  • <%= li.text %>

    <% if li.blocks? %> <%= li.content %> <% end %>
  • <% end %>
EOS end end class BlockOlistTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% unless title.nil? %>
<%= title %>
<% end %>
    <% content.each do |li| %>
  1. <%= li.text %>

    <% if li.blocks? %> <%= li.content %> <% end %>
  2. <% end %>
EOS end end class BlockColistTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% unless title.nil? %>
<%= title %>
<% end %>
    <% content.each do |li| %>
  1. <%= li.text %>

  2. <% end %>
EOS end end class BlockTableTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%> <% if title? %> <%= title %> <% end %> <% if (attr :rowcount) >= 0 %> <% if attr? 'autowidth-option' %> <% @columns.each do |col| %> <% end %> <% else %> <% @columns.each do |col| %> <% end %> <% end %> <% [:head, :foot, :body].select {|tsec| !rows[tsec].empty? }.each do |tsec| %> > <% @rows[tsec].each do |row| %> <% row.each do |cell| %> <<%= tsec == :head ? 'th' : 'td' %> class="tableblock halign-<%= cell.attr :halign %> valign-<%= cell.attr :valign %>"#{attribute('colspan', 'cell.colspan')}#{attribute('rowspan', 'cell.rowspan')}><% if tsec == :head %><%= cell.text %><% else %><% case cell.attr(:style) when :asciidoc %>
<%= cell.content %>
<% when :verse %>
<%= template.preserve_endlines(cell.text, self) %>
<% when :literal %>
<%= template.preserve_endlines(cell.text, self) %>
<% when :header %><% cell.content.each do |text| %>

<%= text %>

<% end %><% else %><% cell.content.each do |text| %>

<%= text %>

<% end %><% end %><% end %>> <% end %> <% end %>
> <% end %> <% end %> EOS end end class BlockImageTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%#encoding:UTF-8%>
<% if attr :link %> <%= attr :alt %> <% else %> <%= attr :alt %> <% end %>
<% if title %>
<%= title %>
<% end %> EOS end end class BlockRulerTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS
EOS end end class InlineBreakTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%= text %>
EOS end end class InlineCalloutTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <%= text %> EOS end end class InlineQuotedTemplate < ::Asciidoctor::BaseTemplate QUOTED_TAGS = { :emphasis => ['', ''], :strong => ['', ''], :monospaced => ['', ''], :superscript => ['', ''], :subscript => ['', ''], :double => [Asciidoctor::INTRINSICS['ldquo'], Asciidoctor::INTRINSICS['rdquo']], :single => [Asciidoctor::INTRINSICS['lsquo'], Asciidoctor::INTRINSICS['rsquo']], :none => ['', ''] } def template @template ||= @eruby.new <<-EOS <% tags = template.class::QUOTED_TAGS[@type] %><%= tags.first %><% if attr? :role %><% end %><%= @text %><% if attr? :role %><% end %><%= tags.last %> EOS end end class InlineAnchorTemplate < ::Asciidoctor::BaseTemplate def template @template ||= @eruby.new <<-EOS <% if type == :xref %><%= @text || @document.references[:ids].fetch(@target, '[' + @target + ']') %><% elsif @type == :ref %><% else %><%= @text %><% end %> EOS end end class InlineImageTemplate < ::Asciidoctor::BaseTemplate def template # care is taken here to avoid a space inside the optional tag @template ||= @eruby.new <<-EOS <% if attr :link %><% end %><%= attr :alt %><% if attr :link%><% end %> EOS end end end