# This file has been generated! module Asciidoctor; module Html5s; end end class Asciidoctor::Html5s::Converter < ::Asciidoctor::Converter::Base #------------------------------ Begin of Helpers ------------------------------# require 'asciidoctor/html5s' require 'asciidoctor/html5s/logger' require 'date' unless RUBY_PLATFORM == 'opal' # Add custom functions to this module that you want to use in your Slim # templates. Within the template you can invoke them as top-level functions # just like in Haml. module Helpers # URIs of external assets. FONT_AWESOME_URI = '//cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css' HIGHLIGHTJS_BASE_URI = '//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.12.0/build/' KATEX_CSS_URI = '//cdn.jsdelivr.net/npm/katex@0.9.0/dist/katex.min.css' KATEX_JS_URI = '//cdn.jsdelivr.net/npm/katex@0.9.0/dist/katex.min.js' # Defaults DEFAULT_HIGHLIGHTJS_THEME = 'github' DEFAULT_LANG = 'en' DEFAULT_SECTNUMLEVELS = 3 DEFAULT_TOCLEVELS = 2 CURLY_QUOTES = [ [%w[af en eo ga hi ia id ko mt th tr zh], ['‘', '’', '“', '”']], # ‘…’ “…” [%w[bs fi sv], ['’', '’', '”', '”']], # ’…’ ”…” [%w[cs da de is lt sl sk sr], ['‚', '‘', '„', '“']], # ‚…‘ „…“ [%w[nl], ['‚', '’', '„', '”']], # ‚…’ „…” [%w[hu pl ro], ['«', '»', '„', '”']], # «…» „…” ].reduce({}) do |hsh, (langs, codes)| langs.each { |lang| hsh[lang] = codes } hsh end CURLY_QUOTES.default = CURLY_QUOTES[DEFAULT_LANG] KATEX_RENDER_CODE = <<-JS.gsub(/\s+/, ' ') document.addEventListener("DOMContentLoaded", function() { var elements = document.getElementsByClassName("math"); for (var i = 0; i < elements.length; i++) { var el = elements[i]; if (el.getAttribute("data-lang") !== "tex") { continue; } katex.render(el.textContent.slice(2, -2), el, { "displayMode": el.nodeName.toUpperCase() !== "SPAN", "throwOnError": false, }); } }); JS VOID_ELEMENTS = %w(area base br col command embed hr img input keygen link meta param source track wbr) # @return [Logger] def log @_html5s_logger ||= ::Asciidoctor::Html5s::Logging.default_logger end ## # Captures the given block for later yield. # # @example Basic capture usage. # - capture # img src=image_uri # - if title? # figure.image # - yield_capture # figcaption =captioned_title # - else # - yield_capture # # @example Capture with passing parameters. # - capture do |id| # img src=image_uri # - if title? # figure id=@id # - yield_capture # figcaption =caption # - else # - yield_capture @id # # @see yield_capture def capture(&block) @_html5s_capture = block nil end ## # Yields the captured block (see {#capture}). # # @param *params parameters to pass to the block. # @return A content of the captured block. # @see capture def yield_capture(*params) @_html5s_capture.call(*params) if @_html5s_capture end ## # Creates an HTML tag with the given name and optionally attributes. Can take # a block that will run between the opening and closing tags. # # @param name [#to_s] the name of the tag. # @param attributes [Hash] (default: {}) # @param content [#to_s] the content; +nil+ to call the block. (default: nil). # @yield The block of Slim/HTML code within the tag (optional). # @return [String] a rendered HTML element. # def html_tag(name, attributes = {}, content = nil) attrs = attributes.inject([]) do |attrs, (k, v)| next attrs if !v || v.nil_or_empty? v = v.compact.join(' ') if v.is_a? Array attrs << (v == true ? k : %(#{k}="#{v}")) end attrs_str = attrs.empty? ? '' : ' ' + attrs.join(' ') if VOID_ELEMENTS.include? name.to_s %(<#{name}#{attrs_str}>) else content ||= yield if block_given? %(<#{name}#{attrs_str}>#{content}) end end ## # Conditionally wraps a block in an element. If condition is +true+ then it # renders the specified tag with optional attributes and the given # block inside, otherwise it just renders the block. # # For example: # # = html_tag_if link?, 'a', {class: 'image', href: (attr :link)} # img src='./img/tux.png' # # will produce: # # # # # # if +link?+ is truthy, and just # # # # otherwise. # # @param condition [Boolean] the condition to test to determine whether to # render the enclosing tag. # @param name (see #html_tag) # @param attributes (see #html_tag) # @param content (see #html_tag) # @yield (see #html_tag) # @return [String] a rendered HTML fragment. # def html_tag_if(condition, name, attributes = {}, content = nil, &block) if condition html_tag name, attributes, content, &block else content || yield end end ## # Wraps a block in a div element with the specified class and optionally # the node's +id+ and +role+(s). If the node's +title+ is not empty, then a # nested div with the class "title" and the title's content is added as well. # # @example When @id, @role and @title attributes are set. # = block_with_title :class=>['quote-block', 'center'] # blockquote =content # #
#
Block Title
#
Lorem ipsum
#
# # @example When @id, @role and @title attributes are empty. # = block_with_title :class=>'quote-block center', :style=>style_value(float: 'left') # blockquote =content # #
#
Lorem ipsum
#
# # @example When shorthand style for class attribute is used. # = block_with_title 'quote-block center' # blockquote =content # #
#
Lorem ipsum
#
# # @param attrs [Hash, String] the tag's attributes as Hash), # or the tag's class if it's not a Hash. # @param title [String, nil] the title. # @yield The block of Slim/HTML code within the tag (optional). # @return [String] a rendered HTML fragment. # def block_with_title(attrs = {}, title = @title, &block) if (klass = attrs[:class]).is_a? String klass = klass.split(' ') end attrs[:class] = [klass, role].flatten.uniq attrs[:id] = id if title.nil_or_empty? # XXX quick hack nested = is_a?(::Asciidoctor::List) && (parent.is_a?(::Asciidoctor::ListItem) || parent.is_a?(::Asciidoctor::List)) html_tag_if !nested, :div, attrs, yield else html_tag :section, attrs do [html_tag(:h6, {class: 'block-title'}, title), yield].join("\n") end end end def block_with_caption(position = :bottom, attrs = {}, &block) if (klass = attrs[:class]).is_a? String klass = klass.split(' ') end attrs[:class] = [klass, role].flatten.uniq attrs[:id] = id if title.nil_or_empty? html_tag :div, attrs, yield else html_tag :figure, attrs do ary = [yield, html_tag(:figcaption) { captioned_title }] ary.reverse! if position == :top ary.compact.join("\n") end end end ## # Delimite the given equation as a STEM of the specified type. # # Note: This is not needed nor used for KaTeX, but keep this for the case # user wants to use a different method. # # @param equation [String] the equation to delimite. # @param type [#to_sym] the type of the STEM renderer (latexmath, or asciimath). # @return [String] the delimited equation. # def delimit_stem(equation, type) if (@_html5s_stem_type ||= document.attr('html5s-force-stem-type')) type = @_html5s_stem_type end if is_a? ::Asciidoctor::Block open, close = ::Asciidoctor::BLOCK_MATH_DELIMITERS[type.to_sym] else open, close = ::Asciidoctor::INLINE_MATH_DELIMITERS[type.to_sym] end if !equation.start_with?(open) || !equation.end_with?(close) equation = [open, equation, close].join end equation end ## # Formats the given hash as CSS declarations for an inline style. # # @example # style_value(text_align: 'right', float: 'left') # => "text-align: right; float: left;" # # style_value(text_align: nil, float: 'left') # => "float: left;" # # style_value(width: [90, '%'], height: '50px') # => "width: 90%; height: 50px;" # # style_value(width: ['120px', 'px']) # => "width: 90px;" # # style_value(width: [nil, 'px']) # => nil # # @param declarations [Hash] # @return [String, nil] # def style_value(declarations) decls = [] declarations.each do |prop, value| next if value.nil? if value.is_a? Array value, unit = value next if value.nil? value = value.to_s + unit unless value.end_with? unit end prop = prop.to_s.gsub('_', '-') decls << "#{prop}: #{value}" end decls.empty? ? nil : decls.join('; ') + ';' end def urlize(*segments) path = segments * '/' if path.start_with? '//' @_html5s_uri_scheme ||= document.attr('asset-uri-scheme', 'https') path = "#{@_html5s_uri_scheme}:#{path}" unless @_html5s_uri_scheme.empty? end normalize_web_path path end ## # Gets the value of the specified attribute in this node. # # This is just an alias for +attr+ method with disabled _inherit_ to make it # more clear. # # @param name [String, Symbol] the name of the attribute to lookup. # @param default_val the value to return if the attribute is not found. # @return value of the attribute or +default_val+ if not found. # def local_attr(name, default_val = nil) attr(name, default_val, false) end ## # Checks if the attribute is defined on this node, optionally performing # a comparison of its value if +expect_val+ is not nil. # # This is just an alias for +attr?+ method with disabled _inherit_ to make it # more clear. # # @param name [String, Symbol] the name of the attribute to lookup. # @param default_val the expected value of the attribute. # @return [Boolean] whether the attribute exists and, if +expect_val+ is # specified, whether the value of the attribute matches the +expect_val+. # def local_attr?(name, expect_val = nil) attr?(name, expect_val, false) end ## # @param index [Integer] the footnote's index. # @return [String] footnote id to be used in a link. def footnote_id(index = local_attr(:index)) "_footnote_#{index}" end ## # @param index (see #footnote_id) # @return [String] footnoteref id to be used in a link. def footnoteref_id(index = local_attr(:index)) "_footnoteref_#{index}" end def nowrap? 'nowrap' if !document.attr?(:prewrap) || option?('nowrap') end def print_item_content(item) wrap = item.blocks? && !item.blocks.all? { |b| b.is_a? ::Asciidoctor::List } [ (html_tag_if(wrap, :p) { item.text } if item.text?), item.content ].join end ## # Returns corrected section level. # # @param sec [Asciidoctor::Section] the section node (default: self). # @return [Integer] # def section_level(sec = self) (sec.level == 0 && sec.special) ? 1 : sec.level end ## # Returns the captioned section's title, optionally numbered. # # @param sec [Asciidoctor::Section] the section node (default: self). # @return [String] # def section_title(sec = self) sectnumlevels = document.attr(:sectnumlevels, DEFAULT_SECTNUMLEVELS).to_i if sec.numbered && !sec.caption && sec.level <= sectnumlevels [sec.sectnum, sec.captioned_title].join(' ') else sec.captioned_title end end ## # @return [String] language of STEM block or inline node (tex or asciimath). def stem_lang value = (inline? ? type : style).to_s value == 'latexmath' ? 'tex' : value end def link_rel 'noopener' if option?('noopener') || attr(:window) == '_blank' end #-------------------------------------------------------- # block_admonition # ## # @return [Boolean] should be this admonition wrapped in aside element? def admonition_aside? %w[note tip].include? attr(:name) end ## # @return [String, nil] WAI-ARIA role of this admonition. def admonition_aria case attr(:name) when 'note' 'note' # https://www.w3.org/TR/wai-aria/roles#note when 'tip' 'doc-tip' # https://www.w3.org/TR/dpub-aria-1.0/#doc-tip when 'caution', 'important', 'warning' 'doc-notice' # https://www.w3.org/TR/dpub-aria-1.0/#doc-notice end end #-------------------------------------------------------- # block_image # ## # @return [String, nil] an URL for the image's link. def image_link @_html5s_image_link ||= case (link = attr(:link)) when 'none', 'false' return when 'self' image_uri(attr(:target)) when nil, '' image_uri(attr(:target)) if document.attr?('html5s-image-default-link', 'self') else link end end ## # @return [String, nil] a label/title of the image link. def image_link_label if image_uri(attr(:target)) == image_link document.attr('html5s-image-self-link-label', 'Open the image in full size') end end #-------------------------------------------------------- # block_listing # ## # @return [String] a canonical name of the source-highlighter to be used as # a style class. def highlighter @_html5s_highlighter ||= case (highlighter = document.attr('source-highlighter')) when 'coderay'; 'CodeRay' when 'highlight.js'; 'highlightjs' else highlighter end end ## # Returns the callout list attached to this listing node, or +nil+ if none. # # Note: This variable is set by extension # {Asciidoctor::Html5s::AttachedColistTreeprocessor}. # # @return [Asciidoctor::List, nil] def callout_list @html5s_colist end def source_lang local_attr :language, false end #-------------------------------------------------------- # block_open # ## # Returns +true+ if an abstract block is allowed in this document type, # otherwise prints warning and returns +false+. def abstract_allowed? if result = (parent == document && document.doctype == 'book') log.warn 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.' end !result end ## # Returns +true+ if a partintro block is allowed in this context, otherwise # prints warning and returns +false+. def partintro_allowed? if result = (level != 0 || parent.context != :section || document.doctype != 'book') log.warn "asciidoctor: ERROR: partintro block can only be used when doctype is book and it's a child of a book part. Excluding block content." end !result end #-------------------------------------------------------- # block_table # def autowidth? option? :autowidth end def spread? if !autowidth? || local_attr?('width') 'spread' if attr? :tablepcwidth, 100 end end #-------------------------------------------------------- # block_video # # @return [Boolean] +true+ if the video should be embedded in an iframe. def video_iframe? ['vimeo', 'youtube'].include? attr(:poster) end def video_uri case attr(:poster, '').to_sym when :vimeo params = { autoplay: (1 if option? 'autoplay'), loop: (1 if option? 'loop') } start_anchor = "#at=#{attr :start}" if attr? :start "//player.vimeo.com/video/#{attr :target}#{start_anchor}#{url_query params}" when :youtube video_id, list_id = attr(:target).split('/', 2) params = { rel: 0, start: (attr :start), end: (attr :end), list: (attr :list, list_id), autoplay: (1 if option? 'autoplay'), loop: (1 if option? 'loop'), controls: (0 if option? 'nocontrols') } "//www.youtube.com/embed/#{video_id}#{url_query params}" else anchor = [attr(:start), attr(:end)].join(',').chomp(',') anchor = '' if anchor == ',' # XXX: https://github.com/opal/opal/issues/1902 anchor = '#t=' + anchor unless anchor.empty? media_uri "#{attr :target}#{anchor}" end end # Formats URL query parameters. def url_query(params) str = params.map { |k, v| next if v.nil? || v.to_s.empty? [k, v] * '=' }.compact.join('&') '?' + str unless str.empty? end #-------------------------------------------------------- # document # ## # @return [String, nil] the revision date in ISO 8601, or nil if not # available or in invalid format. def revdate_iso ::Date.parse(revdate).iso8601 if defined? ::Date rescue ArgumentError nil end ## # Returns HTML meta tag if the given +content+ is not +nil+. # # @param name [#to_s] the name for the metadata. # @param content [#to_s, nil] the value of the metadata, or +nil+. # @return [String, nil] the meta tag, or +nil+ if the +content+ is +nil+. # def html_meta_if(name, content) %() if content end # Returns formatted style/link and script tags for header. def styles_and_scripts scripts = [] styles = [] tags = [] stylesheet = attr :stylesheet stylesdir = attr :stylesdir, '' default_style = ::Asciidoctor::DEFAULT_STYLESHEET_KEYS.include? stylesheet linkcss = attr?(:linkcss) || safe >= ::Asciidoctor::SafeMode::SECURE ss = ::Asciidoctor::Stylesheets.instance if linkcss path = default_style ? ::Asciidoctor::DEFAULT_STYLESHEET_NAME : stylesheet styles << { href: [stylesdir, path] } elsif default_style styles << { text: ss.primary_stylesheet_data } else styles << { text: read_asset(normalize_system_path(stylesheet, stylesdir), true) } end if attr? :icons, 'font' if attr? 'iconfont-remote' styles << { href: attr('iconfont-cdn', FONT_AWESOME_URI) } else styles << { href: [stylesdir, "#{attr 'iconfont-name', 'font-awesome'}.css"] } end end if attr? 'stem' styles << { href: KATEX_CSS_URI } scripts << { src: KATEX_JS_URI } scripts << { text: KATEX_RENDER_CODE } end case attr 'source-highlighter' when 'coderay' if attr('coderay-css', 'class') == 'class' if linkcss styles << { href: [stylesdir, ss.coderay_stylesheet_name] } else styles << { text: ss.coderay_stylesheet_data } end end when 'highlightjs' hjs_base = attr :highlightjsdir, HIGHLIGHTJS_BASE_URI hjs_theme = attr 'highlightjs-theme', DEFAULT_HIGHLIGHTJS_THEME scripts << { src: [hjs_base, 'highlight.min.js'] } scripts << { text: 'hljs.initHighlightingOnLoad()' } styles << { href: [hjs_base, "styles/#{hjs_theme}.min.css"] } end styles.each do |item| if item.key?(:text) tags << html_tag(:style) { item[:text] } else tags << html_tag(:link, rel: 'stylesheet', href: urlize(*item[:href])) end end scripts.each do |item| if item.key? :text tags << html_tag(:script, type: item[:type]) { item[:text] } else tags << html_tag(:script, type: item[:type], src: urlize(*item[:src])) end end tags.join("\n") end #-------------------------------------------------------- # inline_anchor # # @return [String] text of the xref anchor. def xref_text str = if text text elsif (path = local_attr :path) path elsif document.respond_to? :catalog # Asciidoctor >=1.5.6 ref = document.catalog[:refs][attr :refid] if ref.kind_of? Asciidoctor::AbstractNode ref.xreftext((@_html5s_xrefstyle ||= document.attributes['xrefstyle'])) end else # Asciidoctor < 1.5.6 document.references[:ids][attr :refid || target] end (str || "[#{attr :refid}]").tr_s("\n", ' ') end # @return [String, nil] text of the bibref anchor, or +nil+ if not found. def bibref_text if document.respond_to? :catalog # Asciidoctor >=1.5.6 if ::Asciidoctor::VERSION[0] == '1' text else # Asciidoctor >= 2.0.0 "[#{reftext || id}]" end else "[#{target}]" end end #-------------------------------------------------------- # inline_image # # @return [Array] style classes for a Font Awesome icon. def icon_fa_classes [ "fa fa-#{target}", ("fa-#{attr :size}" if attr? :size), ("fa-rotate-#{attr :rotate}" if attr? :rotate), ("fa-flip-#{attr :flip}" if attr? :flip) ].compact end #-------------------------------------------------------- # inline_quoted # # @param text [String] the text to wrap in double quotes. # @return [String] quoted *text*. def double_quoted(text) quotes = CURLY_QUOTES[attr(:lang, DEFAULT_LANG, true)] "#{quotes[2]}#{text}#{quotes[3]}" end # @param text [String] the text to wrap in single quotes. # @return [String] quoted *text*. def single_quoted(text) quotes = CURLY_QUOTES[attr(:lang, DEFAULT_LANG, true)] "#{quotes[0]}#{text}#{quotes[1]}" end end # Make Helpers' constants accessible from transform methods. Helpers.constants.each do |const| const_set(const, Helpers.const_get(const)) end #------------------------------- End of Helpers -------------------------------# register_for "html5s" def initialize(backend, opts = {}) super basebackend "html" if respond_to? :basebackend outfilesuffix ".html" if respond_to? :outfilesuffix filetype "html" if respond_to? :filetype supports_templates if respond_to? :supports_templates end def convert(node, transform = nil, opts = {}) transform ||= node.node_name converter = self if opts.empty? converter.send(transform, node) else converter.send(transform, node, opts) end end #----------------- Begin of generated transformation methods -----------------# def inline_quoted(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; unless id.nil?; ; _buf << (""); ; end; case type; ; when :emphasis; ; _buf << (""); _buf << (text); ; _buf << (""); when :strong; ; _buf << (""); _buf << (text); ; _buf << (""); when :monospaced; ; _buf << (""); _buf << (text); ; _buf << (""); when :superscript; ; _buf << (""); _buf << (text); ; _buf << (""); when :subscript; ; _buf << (""); _buf << (text); ; _buf << (""); when :mark; ; _buf << (""); _buf << (text); ; _buf << (""); when :double; ; _slim_controls1 = html_tag_if role?, :span, :class=>role do; _slim_controls2 = []; ; _slim_controls2 << ((double_quoted text)); ; _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); when :single; ; _slim_controls3 = html_tag_if role?, :span, :class=>role do; _slim_controls4 = []; ; _slim_controls4 << ((single_quoted text)); ; _slim_controls4 = _slim_controls4.join(""); end; _buf << (_slim_controls3); when :asciimath, :latexmath; ; _buf << (""); _buf << ((delimit_stem text, type)); ; _buf << (""); else; ; if role == 'line-through' || role == 'del'; ; _buf << (""); _buf << (text); ; _buf << (""); else; ; _slim_controls5 = html_tag_if role?, :span, :class=>role do; _slim_controls6 = []; ; _slim_controls6 << (text); ; _slim_controls6 = _slim_controls6.join(""); end; _buf << (_slim_controls5); end; end; _buf = _buf.join("") end end def admonition(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; capture do; ; _buf << (""); ; _buf << ("#{local_attr :textlabel}: "); ; _buf << (""); _buf << (title); ; _buf << (""); _slim_controls1 = html_tag_if !blocks?, :p do; _slim_controls2 = []; ; _slim_controls2 << (content); ; _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); end; if admonition_aside?; ; _buf << (""); ; yield_capture; ; _buf << (""); else; ; _buf << (""); ; yield_capture; ; _buf << (""); end; _buf = _buf.join("") end end def inline_footnote(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; if (index = local_attr :index); ; ; ; ; ; _buf << ("["); ; _buf << (index); _buf << ("]"); ; else; ; _buf << ("["); _buf << (text); _buf << ("]"); ; end; _buf = _buf.join("") end end def inline_menu(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; if local_attr :menuitem; ; capture do; ; _buf << (" "); ; ; end; _buf << (""); ; ; _buf << ((attr :menu)); ; yield_capture; ; _buf << (""); (attr 'submenus').each do |submenu|; ; _buf << (""); ; _buf << (submenu); ; yield_capture; ; _buf << (""); end; _buf << (""); _buf << ((local_attr :menuitem)); ; _buf << (""); else; ; _buf << (""); _buf << ((attr :menu)); ; _buf << (""); end; _buf = _buf.join("") end end def ulist(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; checklist = 'task-list' if option? 'checklist'; ; _slim_controls1 = block_with_title :class=>['ulist', style] do; _slim_controls2 = []; ; _slim_controls2 << (""); ; items.each do |item|; ; if checklist && (item.attr? :checkbox); ; _slim_controls2 << ("
  • "); ; _slim_controls2 << (item.text); ; _slim_controls2 << ("
  • "); else; ; _slim_controls2 << ("
  • "); ; _slim_controls2 << ((print_item_content item)); ; _slim_controls2 << ("
  • "); end; end; _slim_controls2 << (""); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def verse(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_title :class=>'verse-block' do; _slim_controls2 = []; ; if attr?(:attribution) || attr?(:citetitle); ; _slim_controls2 << ("
    "); 
          ; _slim_controls2 << (content); 
          ; _slim_controls2 << ("
    "); ; ; ; _slim_controls2 << ([(attr :attribution), (attr :citetitle)].compact.join(', ')); ; _slim_controls2 << ("
    "); ; else; ; _slim_controls2 << ("
    "); _slim_controls2 << (content); 
          ; _slim_controls2 << ("
    "); end; _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def thematic_break(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << ("
    "); ; _buf = _buf.join("") end end def table(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_caption :top, :class=>'table-block' do; _slim_controls2 = []; ; ; ; _slim_controls2 << (""); ; unless (attr :rowcount).zero?; ; _slim_controls2 << (""); ; if autowidth?; ; columns.each do; ; _slim_controls2 << (""); ; end; else; ; columns.each do |col|; ; _slim_controls2 << (""); ; end; end; _slim_controls2 << (""); [:head, :foot, :body].reject { |tblsec| rows[tblsec].empty? }.each do |tblsec|; ; _slim_controls2 << (""); ; rows[tblsec].each do |row|; ; _slim_controls2 << (""); ; row.each do |cell|; ; _slim_controls3 = html_tag(tblsec == :head || cell.style == :header ? 'th' : 'td', :class=>["halign-#{cell.attr :halign}", "valign-#{cell.attr :valign}"], :colspan=>cell.colspan, :rowspan=>cell.rowspan, :style=>style_value(background_color: (document.attr :cellbgcolor))) do; _slim_controls4 = []; ; if tblsec == :head; ; _slim_controls4 << (cell.text); ; else; ; case cell.style; ; when :asciidoc; ; _slim_controls4 << (cell.content); ; when :verse; ; _slim_controls4 << ("
    "); _slim_controls4 << (cell.text); 
          ; _slim_controls4 << ("
    "); when :literal; ; _slim_controls4 << ("
    "); _slim_controls4 << (cell.text); 
          ; _slim_controls4 << ("
    "); else; ; if cell.content.one?; ; _slim_controls4 << (cell.content.first); ; else; ; cell.content.each do |text|; ; _slim_controls4 << ("

    "); _slim_controls4 << (text); ; _slim_controls4 << ("

    "); end; end; end; end; _slim_controls4 = _slim_controls4.join(""); end; _slim_controls2 << (_slim_controls3); end; _slim_controls2 << (""); end; end; end; _slim_controls2 << (""); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def inline_button(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << (""); _buf << (text); ; _buf << (""); _buf = _buf.join("") end end def inline_image(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = html_tag_if((attr? :link), :a, :class=>'image', :href=>(attr :link), :target=>(attr :window), :rel=>link_rel) do; _slim_controls2 = []; ; if type == 'icon' && (document.attr? :icons, 'font'); ; _slim_controls2 << (""); ; elsif type == 'icon' && !(document.attr? :icons); ; _slim_controls2 << ("["); ; _slim_controls2 << (attr :alt); _slim_controls2 << ("]"); ; else; ; ; ; _slim_controls2 << (""); ; end; _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def document(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << (""); ; _buf << (html_meta_if 'application-name', (attr 'app-name')); ; _buf << (html_meta_if 'author', (attr :authors)); ; _buf << (html_meta_if 'copyright', (attr :copyright)); ; _buf << (html_meta_if 'description', (attr :description)); ; _buf << (html_meta_if 'keywords', (attr :keywords)); ; _buf << (""); _buf << (((doctitle sanitize: true) || (attr 'untitled-label'))); ; _buf << (""); _buf << (styles_and_scripts); ; unless (docinfo_content = docinfo).empty?; ; _buf << (docinfo_content); ; end; _buf << (""); ; unless noheader; ; _buf << ("
    "); ; if has_header?; ; unless notitle; ; _buf << ("

    "); _buf << (header.title); ; _buf << ("

    "); end; if [:author, :revnumber, :revdate, :revremark].any? {|a| attr? a }; ; _buf << ("
    "); ; if attr? :author; ; _buf << (""); _buf << ((attr :author)); ; _buf << ("
    "); ; if attr? :email; ; _buf << (""); _buf << (sub_macros(attr :email)); ; _buf << ("
    "); ; end; if (authorcount = (attr :authorcount).to_i) > 1; ; (2..authorcount).each do |idx|; ; _buf << (""); _buf << ((attr "author_#{idx}")); ; _buf << ("
    "); ; if attr? "email_#{idx}"; ; _buf << (""); _buf << (sub_macros(attr "email_#{idx}")); ; _buf << (""); end; end; end; end; if attr? :revnumber; ; _buf << (""); _buf << (((attr 'version-label') || '').downcase); _buf << (" "); _buf << (attr :revnumber); _buf << (',' if attr? :revdate); _buf << (" "); ; ; end; if attr? :revdate; ; _buf << (""); end; if attr? :revremark; ; _buf << ("
    "); ; _buf << ((attr :revremark)); ; _buf << (""); end; _buf << ("
    "); end; end; if (attr? :toc) && (attr? 'toc-placement', 'auto'); ; _buf << (""); ; end; ; _buf << ("
    "); end; _buf << ("
    "); _buf << (content); ; _buf << ("
    "); unless !footnotes? || (attr? :nofootnotes); ; _buf << ("

      "); ; ; ; footnotes.each do |fn|; ; _buf << ("
    1. "); ; _buf << ("#{fn.text} "); ; ; ; ; _buf << ("
    2. "); ; ; end; _buf << ("
    "); ; end; unless nofooter; ; _buf << ("
    "); ; ; if attr? :revnumber; ; _buf << (attr 'version-label'); _buf << (" "); _buf << (attr :revnumber); ; end; if attr? 'last-update-label'; ; _buf << ("
    "); ; _buf << (attr 'last-update-label'); _buf << (" "); _buf << (attr :docdatetime); ; end; _buf << ("
    "); unless (docinfo_content = (docinfo :footer)).empty?; ; _buf << (docinfo_content); ; end; ; _buf << ("
    "); end; _buf << (""); _buf = _buf.join("") end end def open(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; if style == 'abstract'; ; if abstract_allowed?; ; _slim_controls1 = block_with_title :class=>'quote-block abstract' do; _slim_controls2 = []; ; _slim_controls2 << ("
    "); _slim_controls2 << (content); ; _slim_controls2 << ("
    "); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); end; elsif style != 'partintro' || partintro_allowed?; ; _slim_controls3 = block_with_title :class=>['open-block', (style if style != 'open')] do; _slim_controls4 = []; ; _slim_controls4 << ("
    "); _slim_controls4 << (content); ; _slim_controls4 << ("
    "); _slim_controls4 = _slim_controls4.join(""); end; _buf << (_slim_controls3); end; _buf = _buf.join("") end end def pass(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << (content); ; _buf = _buf.join("") end end def floating_title(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_htag_filter1 = ((level + 1)).to_s; _buf << (""); ; _buf << (title); ; _buf << (""); _buf = _buf.join("") end end def example(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_caption :top, :class=>'example-block' do; _slim_controls2 = []; ; _slim_controls2 << ("
    "); ; _slim_controls2 << (content); ; _slim_controls2 << ("
    "); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def inline_anchor(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; case type; ; when :xref; ; _buf << (""); _buf << (xref_text); ; _buf << (""); when :ref; ; ; _buf << (""); ; when :bibref; ; ; _buf << (""); ; _buf << (bibref_text); ; else; ; _buf << (""); _buf << (text); ; _buf << (""); end; _buf = _buf.join("") end end def empty(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; ; _buf = _buf.join("") end end def image(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_caption(:bottom, :class=>'image-block', :style=>style_value(text_align: (attr :align), float: (attr :float))) do; _slim_controls2 = []; ; target_url = image_uri(attr :target); ; _slim_controls3 = html_tag_if(image_link, :a, :class=>['image', ('bare' if image_link == target_url)], :href=>image_link, :title=>image_link_label, 'aria-label'=>image_link_label, :target=>(attr :window), :rel=>link_rel) do; _slim_controls4 = []; ; _slim_controls4 << (""); ; _slim_controls4 = _slim_controls4.join(""); end; _slim_controls2 << (_slim_controls3); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def paragraph(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; if title?; ; _buf << ("
    "); ; _buf << (title); ; _buf << ("
    "); _buf << (content); ; _buf << ("

    "); else; ; _buf << (""); _buf << (content); ; _buf << ("

    "); end; _buf = _buf.join("") end end def embedded(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; if !notitle && has_header?; ; _buf << (""); _buf << (header.title); ; _buf << (""); end; if node.sections? && (attr? :toc) && (attr 'toc-placement', 'auto') == 'auto'; ; _buf << (""); ; end; _buf << (content); ; if footnotes? && !(attr? :nofootnotes); ; _buf << ("

      "); ; ; ; footnotes.each do |fn|; ; _buf << ("
    1. "); ; _buf << ("#{fn.text} "); ; ; ; ; _buf << ("
    2. "); ; ; end; _buf << ("
    "); ; end; _buf = _buf.join("") end end def stem(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_caption :top, :class=>'stem-block' do; _slim_controls2 = []; ; _slim_controls2 << ("
    "); _slim_controls2 << ((delimit_stem content, style)); ; _slim_controls2 << ("
    "); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def listing(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_caption :top, :class=>'listing-block' do; _slim_controls2 = []; ; if style == 'source'; ; if highlighter == 'html-pipeline'; ; _slim_controls2 << ("
    "); _slim_controls2 << (content); 
          ; _slim_controls2 << ("
    "); else; ; unless highlighter == 'CodeRay'; ; code_class = "language-#{source_lang}" if source_lang; ; end; _slim_controls2 << (""); _slim_controls2 << (content); ; _slim_controls2 << (""); end; else; ; _slim_controls2 << (""); _slim_controls2 << (content); ; _slim_controls2 << (""); ; ; end; if callout_list; ; _slim_controls2 << (converter.convert callout_list, 'colist'); ; end; _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def sidebar(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << (""); ; if title?; ; _buf << ("
    "); _buf << (title); ; _buf << ("
    "); end; _buf << (content); ; _buf << (""); _buf = _buf.join("") end end def literal(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_title :class=>'literal-block' do; _slim_controls2 = []; ; _slim_controls2 << (""); _slim_controls2 << (content); ; _slim_controls2 << (""); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def outline(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; unless sections.empty?; ; ; toclevels ||= opts[:toclevels] || (document.attr 'toclevels', DEFAULT_TOCLEVELS).to_i; ; slevel = section_level sections.first; ; _buf << ("
      "); ; sections.each do |sec|; ; _buf << ("
    1. "); _buf << (section_title sec); ; _buf << (""); if (sec.level < toclevels) && (child_toc = converter.convert sec, 'outline'); ; _buf << (child_toc); ; end; _buf << ("
    2. "); end; _buf << ("
    "); end; _buf = _buf.join("") end end def quote(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_title :class=>'quote-block' do; _slim_controls2 = []; ; _slim_controls2 << ("
    "); ; _slim_controls3 = html_tag_if !blocks?, :p do; _slim_controls4 = []; ; _slim_controls4 << (content); ; _slim_controls4 = _slim_controls4.join(""); end; _slim_controls2 << (_slim_controls3); if attr?(:attribution) || attr?(:citetitle); ; _slim_controls2 << ("
    "); ; ; ; _slim_controls2 << ([(attr :attribution), (attr :citetitle)].compact.join(', ')); ; _slim_controls2 << ("
    "); ; end; _slim_controls2 << ("
    "); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def video(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_caption :bottom, :class=>'video-block' do; _slim_controls2 = []; ; if video_iframe?; ; ; ; ; ; ; _slim_controls2 << (""); ; else; ; ; ; ; ; ; ; ; _slim_controls2 << ("Your browser does not support the video tag."); ; ; end; _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def inline_kbd(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; if (keys = attr 'keys').size == 1; ; _buf << (""); _buf << (keys.first); ; _buf << (""); else; ; _buf << (""); ; keys.each_with_index do |key, idx|; ; _buf << ("+" unless idx.zero?); ; _buf << (""); _buf << (key); ; _buf << (""); end; _buf << (""); end; _buf = _buf.join("") end end def inline_indexterm(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; if type == :visible; ; _buf << (text); ; end; _buf = _buf.join("") end end def inline_break(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << (text); ; _buf << ("
    "); ; _buf = _buf.join("") end end def section(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << (""); ; _slim_htag_filter1 = ((section_level + 1)).to_s; _buf << (""); ; if id; ; if document.attr? :sectanchors; ; _buf << (""); ; end; if document.attr? :sectlinks; ; _buf << (""); _buf << (section_title); ; _buf << (""); else; ; _buf << (section_title); ; end; else; ; _buf << (section_title); ; end; _buf << (""); _buf << (content); ; _buf << (""); _buf = _buf.join("") end end def audio(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_caption :bottom, :class=>'audio-block' do; _slim_controls2 = []; ; ; ; ; ; _slim_controls2 << ("Your browser does not support the audio tag."); ; ; _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def inline_callout(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << (""); _buf << (text); ; _buf << (""); _buf = _buf.join("") end end def colist(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; ; _buf << (""); ; items.each do |item|; ; _buf << ("
  • "); _buf << (item.text); ; _buf << ("
  • "); end; _buf << (""); _buf = _buf.join("") end end def olist(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _slim_controls1 = block_with_title :class=>['olist', style] do; _slim_controls2 = []; ; _slim_controls2 << (""); ; items.each do |item|; ; _slim_controls2 << ("
  • "); _slim_controls2 << ((print_item_content item)); ; _slim_controls2 << ("
  • "); end; _slim_controls2 << (""); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); _buf = _buf.join("") end end def preamble(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << ("
    "); ; _buf << (content); ; _buf << ("
    "); if (document.attr? :toc) && (document.attr? 'toc-placement', 'preamble'); ; _buf << (""); ; end; _buf = _buf.join("") end end def toc(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; ; ; if document.attr?(:toc) && document.sections?; ; toc_id = id || ('toc' if document.embedded? || !document.attr?('toc-placement')); ; _buf << (""); ; _slim_htag_filter1 = ((level + 2)).to_s; _buf << (""); ; _buf << ((title || (document.attr 'toc-title'))); ; _buf << (""); ; _buf << (converter.convert document, 'outline', :toclevels=>((attr :levels).to_i if attr? :levels)); ; _buf << (""); else; ; _buf << (""); ; end; _buf = _buf.join("") end end def page_break(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; _buf << ("
    "); ; _buf = _buf.join("") end end def dlist(node, opts = {}) node.extend(Helpers) node.instance_eval do _buf = []; case style; ; when 'qanda'; ; _slim_controls1 = block_with_title :class=>'qlist qanda', :role=>'doc-qna' do; _slim_controls2 = []; ; _slim_controls2 << ("
    "); ; items.each do |questions, answer|; ; [*questions].each do |question|; ; _slim_controls2 << ("
    "); _slim_controls2 << (question.text); ; _slim_controls2 << ("
    "); end; unless answer.nil?; ; _slim_controls2 << ("
    "); ; if answer.text?; ; _slim_controls3 = html_tag_if answer.blocks?, :p do; _slim_controls4 = []; ; _slim_controls4 << (answer.text); ; _slim_controls4 = _slim_controls4.join(""); end; _slim_controls2 << (_slim_controls3); end; if answer.blocks?; ; _slim_controls2 << (answer.content); ; end; _slim_controls2 << ("
    "); end; end; _slim_controls2 << ("
    "); _slim_controls2 = _slim_controls2.join(""); end; _buf << (_slim_controls1); ; when 'horizontal'; ; _slim_controls5 = block_with_title :class=>'hdlist' do; _slim_controls6 = []; ; _slim_controls6 << (""); ; if (attr? :labelwidth) || (attr? :itemwidth); ; _slim_controls6 << (""); ; end; items.each do |terms, dd|; ; _slim_controls6 << (""); ; terms = [*terms]; ; terms.each_with_index do |dt, idx|; ; _slim_controls6 << (dt.text); ; unless idx >= terms.count - 1; ; _slim_controls6 << ("
    "); ; end; end; _slim_controls6 << ("
    "); end; _slim_controls6 << ("
    "); ; unless dd.nil?; ; if dd.text?; ; _slim_controls6 << ("

    "); _slim_controls6 << (dd.text); ; _slim_controls6 << ("

    "); end; if dd.blocks?; ; _slim_controls6 << (dd.content); ; end; end; _slim_controls6 << ("
    "); _slim_controls6 = _slim_controls6.join(""); end; _buf << (_slim_controls5); ; else; ; _slim_controls7 = block_with_title :class=>['dlist', style] do; _slim_controls8 = []; ; _slim_controls8 << ("
    "); ; items.each do |terms, dd|; ; [*terms].each do |dt|; ; _slim_controls8 << ("
    "); _slim_controls8 << (dt.text); ; _slim_controls8 << ("
    "); end; unless dd.nil?; ; _slim_controls8 << ("
    "); _slim_controls8 << ((print_item_content dd)); ; _slim_controls8 << ("
    "); end; end; _slim_controls8 << ("
    "); _slim_controls8 = _slim_controls8.join(""); end; _buf << (_slim_controls7); end; _buf = _buf.join("") end end #------------------ End of generated transformation methods ------------------# end