doctype 5
html lang=(attr :lang, 'en' unless attr? :nolang)
  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'
    - [:description, :keywords, :author, :copyright].each do |key|
      - if attr? key
        meta name=key content=(attr key)
    title=((doctitle :sanitize => true) || (attr 'untitled-label'))
    - if Asciidoctor::DEFAULT_STYLESHEET_KEYS.include?(attr :stylesheet)
      - if @safe >= Asciidoctor::SafeMode::SECURE || (attr? :linkcss)
        link rel='stylesheet' href=normalize_web_path(Asciidoctor::DEFAULT_STYLESHEET_NAME, (attr :stylesdir, ''))
      - else
        style=Asciidoctor::HTML5.default_asciidoctor_stylesheet
    - elsif attr? :stylesheet
      - if @safe >= Asciidoctor::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)
    - if 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, ''))
    - case attr 'source-highlighter'
    - when 'coderay'
      - if (attr 'coderay-css', 'class') == 'class'
        - if @safe >= Asciidoctor::SafeMode::SECURE || (attr? :linkcss)
          link rel='stylesheet' href=normalize_web_path('asciidoctor-coderay.css', (attr :stylesdir, ''))
        - else
          style=Asciidoctor::HTML5.default_coderay_stylesheet
    - when 'pygments'
      - if (attr 'pygments-css', 'class') == 'class'
        - if @safe >= Asciidoctor::SafeMode::SECURE || (attr? :linkcss)
          link rel='stylesheet' href=normalize_web_path('asciidoctor-pygments.css', (attr :stylesdir, ''))
        - else
          style=Asciidoctor::HTML5.pygments_stylesheet(attr 'pygments-style')
    - when 'highlightjs'
      link rel='stylesheet' href="#{attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3'}/styles/#{attr 'highlightjs-theme', 'googlecode'}.min.css"
      script src="#{attr :highlightjsdir, 'http://cdnjs.cloudflare.com/ajax/libs/highlight.js/7.3'}/highlight.min.js"
      script hljs.initHighlightingOnLoad()
    - 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 document.addEventListener('DOMContentLoaded', prettyPrint)
    - if attr? 'math'
      script type='text/x-mathjax-config'
        |MathJax.Hub.Config({
           tex2jax: {
             inlineMath: [['\\(','\\)']],
             displayMath: [['\\[','\\]']],
             ignoreClass: 'nomath|nolatexmath'
           },
           asciimath2jax: {
             delimiters: [['\\$','\\$']],
             ignoreClass: 'nomath|noasciimath'
           }
         });
      script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-MML-AM_HTMLorMML'
      script type='text/javascript'
        |document.addEventListener('DOMContentLoaded', MathJax.Hub.TypeSet)
    - unless (docinfo_content = docinfo).empty?
      =docinfo_content
  body id=@id class=[(attr :doctype),((attr? 'toc-class') && (attr? :toc) && (attr? 'toc-placement', 'auto') ? "#{attr 'toc-class'} toc-#{attr 'toc-position', 'left'}" : nil)] style=("max-width: #{attr 'max-width'};" if attr? 'max-width')
    - unless noheader
      / AsciiDoc leaves an empty header div even if there's no doctitle
      #header
        - if has_header?
          - if attr? :header_image_path
            img src=image_uri(attr :header_image_path)
          - unless notitle
            h1=@header.title
          - if attr? :author
            span.author#author =(attr :author)
            br
            - if attr? :email
              span.email#email =sub_macros(attr :email)
              br
            - if (authorcount = (attr :authorcount).to_i) > 1
              - (2..authorcount).each do |idx|
                span.author id="author#{idx}" =(attr "author_#{idx}")
                br
                - if attr? "email_#{idx}"
                  span.email id="email#{idx}" =sub_macros(attr "email_#{idx}")
          - if attr? :revnumber
            span#revnumber #{((attr 'version-label') || '').downcase} #{attr :revnumber}#{',' if attr? :revdate}
            '
          - if attr? :revdate
            span#revdate=attr :revdate
          - if attr? :revremark
            br
            span#revremark=attr :revremark
        - else
          - if attr? :header_image_path
            img src=image_uri(attr :header_image_path)
        - if (attr? :toc) && (attr? 'toc-placement', 'auto')
          #toc class=(attr 'toc-class', 'toc')
            #toctitle=attr 'toc-title'
            / hackish, find a way to make the toc generator more generic
            =Asciidoctor::HTML5::DocumentTemplate.outline(self, (attr :toclevels, 2).to_i)
    #content=content
    - unless !footnotes? || attr?(:nofootnotes)
      #footnotes
        hr
        - footnotes.each do |fn|
          .footnote id='_footnote_#{fn.index}'
            <a href="#_footnoteref_#{fn.index}">#{fn.index}</a>. #{fn.text}
    - if attr? :footer_copyright
      .footer-copyright
        =attr :footer_copyright
    - unless attr? :nofooter
      #footer
        #footer-text
          - if attr? :revnumber
            | #{attr 'version-label'} #{attr :revnumber}
          - if attr? 'last-update-label'
            br
            | #{attr 'last-update-label'} #{attr :docdatetime}
        - unless (docinfo_content = (docinfo :footer)).empty?
          =docinfo_content