Files

Class/Module Index [+]

Quicksearch

Asciidoctor::HTML5::DocumentTemplate

Public Class Methods

outline(node, to_depth = 2) click to toggle source
# File lib/asciidoctor/backends/html5.rb, line 7
def self.outline(node, to_depth = 2)
  toc_level_buffer = []
  sections = node.sections
  unless sections.empty?
    # FIXME the level for special sections should be set correctly in the model
    # sec_level will only be 0 if we have a book doctype with parts
    sec_level = sections.first.level
    if sec_level == 0 && sections.first.special
      sec_level = 1
    end
    toc_level_buffer << %(<ul class="sectlevel#{sec_level}">)
    sections.each do |section|
      section_num = section.numbered ? %(#{section.sectnum} ) : nil
      toc_level_buffer << %(<li><a href=\"##{section.id}\">#{section_num}#{section.captioned_title}</a></li>)
      if section.level < to_depth && (child_toc_level = outline(section, to_depth)) != ''
        toc_level_buffer << '<li>'
        toc_level_buffer << child_toc_level
        toc_level_buffer << '</li>'
      end
    end
    toc_level_buffer << '</ul>'
  end
  toc_level_buffer * EOL
end

Public Instance Methods

template() click to toggle source
# File lib/asciidoctor/backends/html5.rb, line 32
def template
  @template ||= @eruby.new <%#encoding:UTF-8%><!DOCTYPE html><html<%= (attr? 'nolang') ? nil : %( lang="\#{attr 'lang', 'en'}") %>><head><meta http-equiv="Content-Type" content="text/html; charset=<%= attr :encoding %>"><meta name="generator" content="Asciidoctor <%= attr 'asciidoctor-version' %>"><meta name="viewport" content="width=device-width, initial-scale=1.0"><%if attr? :description %><meta name="description" content="<%= attr :description %>"><%endif attr? :keywords %><meta name="keywords" content="<%= attr :keywords %>"><%end %><title><%= doctitle(:sanitize => true) || (attr 'untitled-label') %></title><%if DEFAULT_STYLESHEET_KEYS.include?(attr 'stylesheet')  if @safe >= SafeMode::SECURE || (attr? 'linkcss') %><link rel="stylesheet" href="<%= normalize_web_path(DEFAULT_STYLESHEET_NAME, (attr :stylesdir, '')) %>"><%  else %><style><%= HTML5.default_asciidoctor_stylesheet %></style><%  endelsif attr? :stylesheet  if @safe >= SafeMode::SECURE || (attr? 'linkcss') %><link rel="stylesheet" href="<%= normalize_web_path((attr :stylesheet), (attr :stylesdir, '')) %>"><%  else %><style><%= read_asset normalize_system_path((attr :stylesheet), (attr :stylesdir, '')), true %></style><%  endendif attr? 'icons', 'font'  if !(attr 'iconfont-remote', '').nil? %><link rel="stylesheet" href="<%= attr 'iconfont-cdn', 'http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.2.1/css/font-awesome.min.css' %>"><%  else %><link rel="stylesheet" href="<%= normalize_web_path(%(\#{attr 'iconfont-name', 'font-awesome'}.css), (attr 'stylesdir', '')) %>"><%  endendcase attr 'source-highlighter'when 'coderay'  if (attr 'coderay-css', 'class') == 'class'    if @safe >= SafeMode::SECURE || (attr? 'linkcss') %><link rel="stylesheet" href="<%= normalize_web_path('asciidoctor-coderay.css', (attr :stylesdir, '')) %>"><%    else %><style><%= HTML5.default_coderay_stylesheet %></style><%    end  endwhen 'pygments'  if (attr 'pygments-css', 'class') == 'class'    if @safe >= SafeMode::SECURE || (attr? 'linkcss') %><link rel="stylesheet" href="<%= normalize_web_path('asciidoctor-pygments.css', (attr :stylesdir, '')) %>"><%    else %><style><%= HTML5.pygments_stylesheet(attr 'pygments-style') %></style><%    end  endwhen 'highlightjs', 'highlight.js' %><link rel="stylesheet" href="<%= attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3' %>/styles/<%= attr 'highlightjs-theme', 'default' %>.min.css"><script src="<%= attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3' %>/highlight.min.js"></script><script>hljs.initHighlightingOnLoad()</script><%when 'prettify' %><link rel="stylesheet" href="<%= attr 'prettifydir', 'http://cdnjs.cloudflare.com/ajax/libs/prettify/r298' %>/<%= attr 'prettify-theme', 'prettify' %>.min.css"><script src="<%= attr 'prettifydir', 'http://cdnjs.cloudflare.com/ajax/libs/prettify/r298' %>/prettify.min.js"></script><script>document.addEventListener('DOMContentLoaded', prettyPrint)</script><%end %><%= (docinfo_content = docinfo).empty? ? nil : %(\#{docinfo_content}) %></head><body<%= @id ? %( id="\#{@id}") : nil %> class="<%= doctype %><%= (attr? 'toc-class') && (attr? 'toc') && (attr? 'toc-placement', 'auto') ? %( \#{attr 'toc-class'} toc-\#{attr 'toc-position', 'left'}) : nil %>"<%= (attr? 'max-width') ? %( style="max-width: \#{attr 'max-width'};") : nil %>><%unless noheader %><div id="header"><%  if doctype == 'manpage' %><h1><%= doctitle %> Manual Page</h1><%    if (attr? :toc) && (attr? 'toc-placement', 'auto') %><div id="toc" class="<%= attr 'toc-class', 'toc' %>"><div id="toctitle"><%= attr 'toc-title' %></div><%= template.class.outline(self, (attr :toclevels, 2).to_i) %></div><%    end %><h2><%= attr 'manname-title' %></h2><div class="sectionbody"><p><%= %(\#{attr 'manname'} - \#{attr 'manpurpose'}) %></p></div><%  else    if has_header?      unless notitle %><h1><%= @header.title %></h1><%      end %><%      if attr? :author %><span id="author" class="author"><%= attr :author %></span><br><%        if attr? :email %><span id="email" class="email"><%= sub_macros(attr :email) %></span><br><%        end        if (authorcount = (attr :authorcount).to_i) > 1          (2..authorcount).each do |idx| %><span id="author<%= idx %>" class="author"><%= attr "author_\#{idx}" %></span><br><%            if attr? "email_\#{idx}" %><span id="email<%= idx %>" class="email"><%= sub_macros(attr "email_\#{idx}") %></span><br><%            end          end        end      end      if attr? :revnumber %><span id="revnumber"><%= ((attr 'version-label') || '').downcase %> <%= attr :revnumber %><%= (attr? :revdate) ? ',' : '' %></span><%      end      if attr? :revdate %><span id="revdate"><%= attr :revdate %></span><%      end      if attr? :revremark %><br><span id="revremark"><%= attr :revremark %></span><%      end    end    if (attr? :toc) && (attr? 'toc-placement', 'auto') %><div id="toc" class="<%= attr 'toc-class', 'toc' %>"><div id="toctitle"><%= attr 'toc-title' %></div><%= template.class.outline(self, (attr :toclevels, 2).to_i) %></div><%    end  end %></div><%end %><div id="content"><%= content %></div><%unless !footnotes? || (attr? :nofootnotes) %><div id="footnotes"><hr><%  footnotes.each do |fn| %><div class="footnote" id="_footnote_<%= fn.index %>"><a href="#_footnoteref_<%= fn.index %>"><%= fn.index %></a>. <%= fn.text %></div><%  end %></div><%end %><div id="footer"><div id="footer-text"><%if attr? :revnumber %><%= %(\#{attr 'version-label'} \#{attr :revnumber}) %><br><%endif attr? 'last-update-label' %><%= %(\#{attr 'last-update-label'} \#{attr :docdatetime}) %><%end %></div><%= (docinfo_content = docinfo :footer).empty? ? nil : %(\#{docinfo_content}) %></div></body></html>
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.