diff --git a/docs/antora.yml b/docs/antora.yml index 0f5cd6c8..e4624b91 100644 --- a/docs/antora.yml +++ b/docs/antora.yml @@ -1,6 +1,6 @@ name: reveal.js-converter title: Asciidoctor reveal.js -version: '5.0' +version: '5.3' nav: - modules/ROOT/nav.adoc - modules/setup/nav.adoc diff --git a/lib/asciidoctor-revealjs/converter.rb b/lib/asciidoctor-revealjs/converter.rb deleted file mode 100644 index 202257e3..00000000 --- a/lib/asciidoctor-revealjs/converter.rb +++ /dev/null @@ -1,1857 +0,0 @@ -# This file has been generated! - -module Asciidoctor; module Revealjs; end end -class Asciidoctor::Revealjs::Converter < ::Asciidoctor::Converter::Base - - #------------------------------ Begin of Helpers ------------------------------# - - unless RUBY_ENGINE == 'opal' - # This helper file borrows from the Bespoke converter - # https://github.com/asciidoctor/asciidoctor-bespoke - require 'asciidoctor' - end - - require 'json' - - # This module gets mixed in to every node (the context of the template) at the - # time the node is being converted. The properties and methods in this module - # effectively become direct members of the template. - module Helpers - - EOL = %(\n) - SliceHintRx = / +/ - - def slice_text str, active = nil - if (active || (active.nil? && (option? :slice))) && (str.include? ' ') - (str.split SliceHintRx).map {|line| %(#{line}) }.join EOL - else - str - end - end - - def to_boolean val - val && val != 'false' && val.to_s != '0' || false - end - - # bool_data_attr - # If the AsciiDoc attribute doesn't exist, no HTML attribute is added - # If the AsciiDoc attribute exist and is a true value, HTML attribute is enabled (bool) - # If the AsciiDoc attribute exist and is a false value, HTML attribute is a false string - # Ex: a feature is enabled globally but can be disabled using a data- attribute on individual items - # :revealjs_previewlinks: True - # then link::example.com[Link text, preview=false] - # Here the template must have data-preview-link="false" not just no data-preview-link attribute - def bool_data_attr val - return false unless attr?(val) - if attr(val).downcase == 'false' || attr(val) == '0' - 'false' - else - true - end - end - - # false needs to be verbatim everything else is a string. - # Calling side isn't responsible for quoting so we are doing it here - def to_valid_slidenumber val - # corner case: empty is empty attribute which is true - return true if val == "" - # using to_s here handles both the 'false' string and the false boolean - val.to_s == 'false' ? false : "'#{val}'" - end - - ## - # These constants and functions are from the asciidictor-html5s project - # https://github.com/jirutka/asciidoctor-html5s/blob/a71db48a1dd5196b668b3a3d93693c5d877c5bf3/data/templates/helpers.rb - - # Defaults - DEFAULT_TOCLEVELS = 2 - DEFAULT_SECTNUMLEVELS = 3 - - - VOID_ELEMENTS = %w(area base br col command embed hr img input keygen link - meta param source track wbr) - - ## - # 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 unless v && (v == true || !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 - - - # - # Extracts data- attributes from the attributes. - # @param attributes [Hash] (default: {}) - # @return [Hash] a Hash that contains only data- attributes - # - def data_attrs(attributes) - # key can be an Integer (for positional attributes) - attributes.map { |key, value| (key == 'step') ? ['data-fragment-index', value] : [key, value] } - .to_h - .select { |key, _| key.to_s.start_with?('data-') } - end - - - # - # Wrap an inline text in a element if the node contains a role, an id or data- attributes. - # @param content [#to_s] the content; +nil+ to call the block. (default: nil). - # @return [String] the content or the content wrapped in a element as string - # - def inline_text_container(content = nil) - data_attrs = data_attrs(@attributes) - classes = [role, ('fragment' if (option? :step) || (attr? 'step') || (roles.include? 'step'))].compact - if !roles.empty? || !data_attrs.empty? || !@id.nil? - html_tag('span', { :id => @id, :class => classes }.merge(data_attrs), (content || (yield if block_given?))) - else - content || (yield if block_given?) - end - end - - - ## - # Returns corrected section level. - # - # @param sec [Asciidoctor::Section] the section node (default: self). - # @return [Integer] - # - def section_level(sec = self) - @_section_level ||= (sec.level == 0 && sec.special) ? 1 : sec.level - end - - ## - # Display footnotes per slide - # - @@slide_footnotes = {} - @@section_footnotes = {} - - def slide_footnote(footnote) - footnote_parent = footnote.parent - # footnotes declared on the section title are processed during the parsing/substitution. - # as a result, we need to store them to display them on the right slide/section - if footnote_parent.instance_of?(::Asciidoctor::Section) - footnote_parent_object_id = footnote_parent.object_id - section_footnotes = (@@section_footnotes[footnote_parent_object_id] || []) - footnote_index = section_footnotes.length + 1 - attributes = footnote.attributes.merge({ 'index' => footnote_index }) - inline_footnote = Asciidoctor::Inline.new(footnote_parent, footnote.context, footnote.text, :attributes => attributes) - section_footnotes << Asciidoctor::Document::Footnote.new(inline_footnote.attr(:index), inline_footnote.id, inline_footnote.text) - @@section_footnotes[footnote_parent_object_id] = section_footnotes - inline_footnote - else - parent = footnote.parent - until parent == nil || parent.instance_of?(::Asciidoctor::Section) - parent = parent.parent - end - # check if there is any footnote attached on the section title - section_footnotes = parent != nil ? @@section_footnotes[parent.object_id] || [] : [] - initial_index = footnote.attr(:index) - # reset the footnote numbering to 1 on each slide - # make sure that if a footnote is used more than once it will use the same index/number - slide_index = (existing_footnote = @@slide_footnotes[initial_index]) ? existing_footnote.index : @@slide_footnotes.length + section_footnotes.length + 1 - attributes = footnote.attributes.merge({ 'index' => slide_index }) - inline_footnote = Asciidoctor::Inline.new(footnote_parent, footnote.context, footnote.text, :attributes => attributes) - @@slide_footnotes[initial_index] = Asciidoctor::Document::Footnote.new(inline_footnote.attr(:index), inline_footnote.id, inline_footnote.text) - inline_footnote - end - end - - def clear_slide_footnotes - @@slide_footnotes = {} - end - - def slide_footnotes(section) - section_object_id = section.object_id - section_footnotes = @@section_footnotes[section_object_id] || [] - section_footnotes + @@slide_footnotes.values - 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 - - # Retrieves the built-in html5 converter. - # - # Returns the instance of the Asciidoctor::Converter::Html5Converter - # associated with this node. - def html5_converter - converter.instance_variable_get("@delegate_converter") - end - - def convert_inline_image(node = self) - target = node.target - if (node.type || 'image') == 'icon' - if (icons = node.document.attr 'icons') == 'font' - i_class_attr_val = %(#{node.attr(:set, 'fa')} fa-#{target}) - i_class_attr_val = %(#{i_class_attr_val} fa-#{node.attr 'size'}) if node.attr? 'size' - if node.attr? 'flip' - i_class_attr_val = %(#{i_class_attr_val} fa-flip-#{node.attr 'flip'}) - elsif node.attr? 'rotate' - i_class_attr_val = %(#{i_class_attr_val} fa-rotate-#{node.attr 'rotate'}) - end - attrs = (node.attr? 'title') ? %( title="#{node.attr 'title'}") : '' - img = %() - elsif icons - attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : '' - attrs = %(#{attrs} height="#{node.attr 'height'}") if node.attr? 'height' - attrs = %(#{attrs} title="#{node.attr 'title'}") if node.attr? 'title' - img = %(#{encode_attribute_value node.alt}) - else - img = %([#{node.alt}]) - end - else - html_attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : '' - html_attrs = %(#{html_attrs} height="#{node.attr 'height'}") if node.attr? 'height' - html_attrs = %(#{html_attrs} title="#{node.attr 'title'}") if node.attr? 'title' - img, src = img_tag(node, target, html_attrs) - end - img_link(node, src, img) - end - - def convert_image(node = self) - # When the stretch class is present, block images will take the most space - # they can take. Setting width and height can override that. - # We pinned the 100% to height to avoid aspect ratio breakage and since - # widescreen monitors are the most popular, chances are that height will - # be the biggest constraint - if node.has_role?('stretch') && !(node.attr?(:width) || node.attr?(:height)) - height_value = "100%" - elsif node.attr? 'height' - height_value = node.attr 'height' - else - height_value = nil - end - html_attrs = (node.attr? 'width') ? %( width="#{node.attr 'width'}") : '' - html_attrs = %(#{html_attrs} height="#{height_value}") if height_value - html_attrs = %(#{html_attrs} title="#{node.attr 'title'}") if node.attr? 'title' - html_attrs = %(#{html_attrs} style="background: #{node.attr :background}") if node.attr? 'background' - img, src = img_tag(node, node.attr('target'), html_attrs) - img_link(node, src, img) - end - - def img_tag(node = self, target, html_attrs) - if ((node.attr? 'format', 'svg') || (target.include? '.svg')) && node.document.safe < ::Asciidoctor::SafeMode::SECURE - if node.option? 'inline' - img = (html5_converter.read_svg_contents node, target) || %(#{node.alt}) - elsif node.option? 'interactive' - fallback = (node.attr? 'fallback') ? %(#{encode_attribute_value node.alt}) : %(#{node.alt}) - img = %(#{fallback}) - else - img = %(#{encode_attribute_value node.alt}) - end - else - img = %(#{encode_attribute_value node.alt}) - end - - [img, src] - end - - # Wrap the element in a element if the link attribute is defined - def img_link(node = self, src, content) - if (node.attr? 'link') && ((href_attr_val = node.attr 'link') != 'self' || (href_attr_val = src)) - if (link_preview_value = bool_data_attr :link_preview) - data_preview_attr = %( data-preview-link="#{link_preview_value == true ? "" : link_preview_value}") - end - return %(#{content}) - end - - content - end - - def revealjs_dependencies(document, node, revealjsdir) - dependencies = [] - dependencies << "{ src: '#{revealjsdir}/plugin/zoom/zoom.js', async: true, callback: function () { Reveal.registerPlugin(RevealZoom) } }" unless (node.attr? 'revealjs_plugin_zoom', 'disabled') - dependencies << "{ src: '#{revealjsdir}/plugin/notes/notes.js', async: true, callback: function () { Reveal.registerPlugin(RevealNotes) } }" unless (node.attr? 'revealjs_plugin_notes', 'disabled') - dependencies << "{ src: '#{revealjsdir}/plugin/search/search.js', async: true, callback: function () { Reveal.registerPlugin(RevealSearch) } }" if (node.attr? 'revealjs_plugin_search', 'enabled') - dependencies.join(",\n ") - end - - # Between delimiters (--) is code taken from asciidoctor-bespoke 1.0.0.alpha.1 - # Licensed under MIT, Copyright (C) 2015-2016 Dan Allen and the Asciidoctor Project - #-- - # Retrieve the converted content, wrap it in a `

` element if - # the content_model equals :simple and return the result. - # - # Returns the block content as a String, wrapped inside a `

` element if - # the content_model equals `:simple`. - def resolve_content - @content_model == :simple ? %(

#{content}

) : content - end - - # Capture nested template content and register it with the specified key, to - # be executed at a later time. - # - # This method must be invoked using the control code directive (i.e., -). By - # using a control code directive, the block is set up to append the result - # directly to the output buffer. (Integrations often hide the distinction - # between a control code directive and an output directive in this context). - # - # key - The Symbol under which to save the template block. - # opts - A Hash of options to control processing (default: {}): - # * :append - A Boolean that indicates whether to append this block - # to others registered with this key (default: false). - # * :content - String content to be used if template content is not - # provided (optional). - # block - The template content (in Slim template syntax). - # - # Examples - # - # - content_for :body - # p content - # - content_for :body, append: true - # p more content - # - # Returns nothing. - def content_for key, opts = {}, &block - @content = {} unless defined? @content - (opts[:append] ? (@content[key] ||= []) : (@content[key] = [])) << (block_given? ? block : lambda { opts[:content] }) - nil - end - - # Checks whether deferred template content has been registered for the specified key. - # - # key - The Symbol under which to look for saved template blocks. - # - # Returns a Boolean indicating whether content has been registered for this key. - def content_for? key - (defined? @content) && (@content.key? key) - end - - # Evaluates the deferred template content registered with the specified key. - # - # When the corresponding content_for method is invoked using a control code - # directive, the block is set up to append the result to the output buffer - # directly. - # - # key - The Symbol under which to look for template blocks to yield. - # opts - A Hash of options to control processing (default: {}): - # * :drain - A Boolean indicating whether to drain the key of blocks - # after calling them (default: true). - # - # Examples - # - # - yield_content :body - # - # Returns nothing (assuming the content has been captured in the context of control code). - def yield_content key, opts = {} - if (defined? @content) && (blks = (opts.fetch :drain, true) ? (@content.delete key) : @content[key]) - blks.map {|b| b.call }.join - end - nil - end - - # Copied from asciidoctor/lib/asciidoctor/converter/html5.rb (method is private) - def append_link_constraint_attrs node, attrs = [] - rel = 'nofollow' if node.option? 'nofollow' - if (window = node.attributes['window']) - attrs << %( target="#{window}") - attrs << (rel ? %( rel="#{rel} noopener") : ' rel="noopener"') if window == '_blank' || (node.option? 'noopener') - elsif rel - attrs << %( rel="#{rel}") - end - attrs - end - - # Copied from asciidoctor/lib/asciidoctor/converter/html5.rb (method is private) - def encode_attribute_value val - (val.include? '"') ? (val.gsub '"', '"') : val - end - - # Copied from asciidoctor/lib/asciidoctor/converter/semantic-html5.rb which is not yet shipped - # @todo remove this code when the new converter becomes available in the main gem - def generate_authors node - return if node.authors.empty? - - if node.authors.length == 1 - %() - else - result = ['' - result.join Asciidoctor::LF - end - end - - # Copied from asciidoctor/lib/asciidoctor/converter/semantic-html5.rb which is not yet shipped - # @todo remove this code when the new converter becomes available in the main gem - def format_author node, author - in_context 'author' do - %(#{node.sub_replacements author.name}#{author.email ? %( #{node.sub_macros author.email}) : ''}) - end - end - - # Copied from asciidoctor/lib/asciidoctor/converter/semantic-html5.rb which is not yet shipped - # @todo remove this code when the new converter becomes available in the main gem - def in_context name - (@convert_context ||= []).push name - result = yield - @convert_context.pop - result - end - - STEM_EQNUMS_AMS = 'ams' - STEM_EQNUMS_NONE = 'none' - STEM_EQNUMS_VALID_VALUES = [ - STEM_EQNUMS_NONE, - STEM_EQNUMS_AMS, - 'all' - ] - - MATHJAX_VERSION = '3.2.0' - - # Generate the Mathjax markup to process STEM expressions - # @param cdn_base [String] - # @return [String] - def generate_stem(cdn_base) - if attr?(:stem) - eqnums_val = attr('eqnums', STEM_EQNUMS_NONE).downcase - unless STEM_EQNUMS_VALID_VALUES.include?(eqnums_val) - eqnums_val = STEM_EQNUMS_AMS - end - mathjax_configuration = { - tex: { - inlineMath: [Asciidoctor::INLINE_MATH_DELIMITERS[:latexmath]], - displayMath: [Asciidoctor::BLOCK_MATH_DELIMITERS[:latexmath]], - processEscapes: false, - tags: eqnums_val, - }, - options: { - ignoreHtmlClass: 'nostem|nolatexmath' - }, - asciimath: { - delimiters: [Asciidoctor::BLOCK_MATH_DELIMITERS[:asciimath]], - }, - loader: { - load: ['input/asciimath', 'output/chtml', 'ui/menu'] - } - } - mathjaxdir = attr('mathjaxdir', "#{cdn_base}/mathjax/#{MATHJAX_VERSION}/es5") - %() + - %() - end - end - #-- - end - - # More custom functions can be added in another namespace if required - #module Helpers - #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 "revealjs", "reveal.js" - - 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 - - delegate_backend = (opts[:delegate_backend] || "html5").to_s - factory = ::Asciidoctor::Converter::Factory - - converter = factory.create(delegate_backend, backend_info) - @delegate_converter = if converter == self - factory.new.create(delegate_backend, backend_info) - else - converter - end - end - - def convert(node, transform = nil, opts = {}) - meth_name = "convert_#{transform || node.node_name}" - opts ||= {} - converter = respond_to?(meth_name) ? self : @delegate_converter - - if opts.empty? - converter.send(meth_name, node) - else - converter.send(meth_name, node, opts) - end - end - - #----------------- Begin of generated transformation methods -----------------# - - - def convert_notes(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _buf << ("".freeze); _buf - end - end - - def convert_inline_anchor(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; case @type; - ; when :xref; - ; refid = (attr :refid) || @target; - ; _slim_controls1 = html_tag('a', { :href => @target, :class => [role, ('fragment' if (option? :step) || (attr? 'step'))].compact }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << (((@text || @document.references[:ids].fetch(refid, "[#{refid}]")).tr_s("\n", ' ')).to_s); - ; _slim_controls2; end; _buf << ((_slim_controls1).to_s); when :ref; - ; _buf << ((html_tag('a', { :id => @target }.merge(data_attrs(@attributes)))).to_s); - ; when :bibref; - ; _buf << ((html_tag('a', { :id => @target }.merge(data_attrs(@attributes)))).to_s); - ; _buf << ("[".freeze); _buf << ((@target).to_s); _buf << ("]".freeze); - ; else; - ; _slim_controls3 = html_tag('a', { :href => @target, :class => [role, ('fragment' if (option? :step) || (attr? 'step'))].compact, :target => (attr :window), 'data-preview-link' => (bool_data_attr :preview) }.merge(data_attrs(@attributes))) do; _slim_controls4 = ''; - ; _slim_controls4 << ((@text).to_s); - ; _slim_controls4; end; _buf << ((_slim_controls3).to_s); end; _buf - end - end - - def convert_ruler(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _buf << ("
".freeze); - ; _buf - end - end - - def convert_stem(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; open, close = Asciidoctor::BLOCK_MATH_DELIMITERS[@style.to_sym]; - ; equation = content.strip; - ; if (@subs.nil? || @subs.empty?) && !(attr? 'subs'); - ; equation = sub_specialcharacters equation; - ; end; unless (equation.start_with? open) && (equation.end_with? close); - ; equation = %(#{open}#{equation}#{close}); - ; end; _slim_controls1 = html_tag('div', { :id => @id, :class => ['stemblock', role, ('fragment' if (option? :step) || (has_role? 'step') || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); _slim_controls2 << ((equation).to_s); - ; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_embedded(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; unless notitle || !has_header?; - ; _buf << ("".freeze); _buf << ((@header.title).to_s); - ; _buf << ("".freeze); end; _buf << ((content).to_s); - ; unless !footnotes? || attr?(:nofootnotes); - ; _buf << ("

".freeze); - ; - ; footnotes.each do |fn|; - ; _buf << ("
".freeze); _buf << ((fn.index).to_s); _buf << (". ".freeze); _buf << ((fn.text).to_s); - ; _buf << ("
".freeze); end; _buf << ("
".freeze); end; _buf - end - end - - def convert_ulist(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; if (checklist = (option? :checklist) ? 'checklist' : nil); - ; if option? :interactive; - ; marker_checked = ''; - ; marker_unchecked = ''; - ; else; - ; if @document.attr? :icons, 'font'; - ; marker_checked = ''; - ; marker_unchecked = ''; - ; else; - ; - ; marker_checked = ''; - ; marker_unchecked = ''; - ; end; end; end; _slim_controls1 = html_tag('div', { :id => @id, :class => ['ulist', checklist, @style, role] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("".freeze); - ; items.each do |item|; - ; _slim_controls2 << ("

".freeze); - ; - ; if checklist && (item.attr? :checkbox); - ; _slim_controls2 << ((%(#{(item.attr? :checked) ? marker_checked : marker_unchecked}#{item.text})).to_s); - ; else; - ; _slim_controls2 << ((item.text).to_s); - ; end; _slim_controls2 << ("

".freeze); if item.blocks?; - ; _slim_controls2 << ((item.content).to_s); - ; end; _slim_controls2 << ("".freeze); end; _slim_controls2 << ("".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_paragraph(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => @id, :class => ['paragraph', role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; if has_role? 'small'; - ; _slim_controls2 << ("".freeze); _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("".freeze); else; - ; _slim_controls2 << ("

".freeze); _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("

".freeze); end; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_dlist(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; case @style; - ; when 'qanda'; - ; _slim_controls1 = html_tag('div', { :id => @id, :class => ['qlist', @style, role] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
    ".freeze); - ; items.each do |questions, answer|; - ; _slim_controls2 << ("
  1. ".freeze); - ; [*questions].each do |question|; - ; _slim_controls2 << ("

    ".freeze); _slim_controls2 << ((question.text).to_s); - ; _slim_controls2 << ("

    ".freeze); end; unless answer.nil?; - ; if answer.text?; - ; _slim_controls2 << ("

    ".freeze); _slim_controls2 << ((answer.text).to_s); - ; _slim_controls2 << ("

    ".freeze); end; if answer.blocks?; - ; _slim_controls2 << ((answer.content).to_s); - ; end; end; _slim_controls2 << ("
  2. ".freeze); end; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); when 'horizontal'; - ; _slim_controls3 = html_tag('div', { :id => @id, :class => ['hdlist', role] }.merge(data_attrs(@attributes))) do; _slim_controls4 = ''; - ; if title?; - ; _slim_controls4 << ("
".freeze); _slim_controls4 << ((title).to_s); - ; _slim_controls4 << ("
".freeze); end; _slim_controls4 << ("".freeze); - ; if (attr? :labelwidth) || (attr? :itemwidth); - ; _slim_controls4 << ("".freeze); - ; end; items.each do |terms, dd|; - ; _slim_controls4 << ("".freeze); - ; terms = [*terms]; - ; last_term = terms.last; - ; terms.each do |dt|; - ; _slim_controls4 << ((dt.text).to_s); - ; if dt != last_term; - ; _slim_controls4 << ("
".freeze); - ; end; end; _slim_controls4 << ("
".freeze); end; _slim_controls4 << ("
".freeze); - ; unless dd.nil?; - ; if dd.text?; - ; _slim_controls4 << ("

".freeze); _slim_controls4 << ((dd.text).to_s); - ; _slim_controls4 << ("

".freeze); end; if dd.blocks?; - ; _slim_controls4 << ((dd.content).to_s); - ; end; end; _slim_controls4 << ("
".freeze); _slim_controls4; end; _buf << ((_slim_controls3).to_s); else; - ; _slim_controls5 = html_tag('div', { :id => @id, :class => ['dlist', @style, role] }.merge(data_attrs(@attributes))) do; _slim_controls6 = ''; - ; if title?; - ; _slim_controls6 << ("
".freeze); _slim_controls6 << ((title).to_s); - ; _slim_controls6 << ("
".freeze); end; _slim_controls6 << ("
".freeze); - ; items.each do |terms, dd|; - ; [*terms].each do |dt|; - ; _slim_controls6 << ("".freeze); _slim_controls6 << ((dt.text).to_s); - ; _slim_controls6 << ("".freeze); end; unless dd.nil?; - ; _slim_controls6 << ("
".freeze); - ; if dd.text?; - ; _slim_controls6 << ("

".freeze); _slim_controls6 << ((dd.text).to_s); - ; _slim_controls6 << ("

".freeze); end; if dd.blocks?; - ; _slim_controls6 << ((dd.content).to_s); - ; end; _slim_controls6 << ("
".freeze); end; end; _slim_controls6 << ("
".freeze); _slim_controls6; end; _buf << ((_slim_controls5).to_s); end; _buf - end - end - - def convert_audio(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => @id, :class => ['audioblock', @style, role] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((captioned_title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
Your browser does not support the audio tag.
".freeze); - ; - ; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_image(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; unless attributes[1] == 'background' || attributes[1] == 'canvas'; - ; inline_style = [("text-align: #{attr :align}" if attr? :align),("float: #{attr :float}" if attr? :float)].compact.join('; '); - ; _slim_controls1 = html_tag('div', { :id => @id, :class => ['imageblock', role, ('fragment' if (option? :step) || (attr? 'step'))], :style => inline_style }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << ((convert_image).to_s); - ; _slim_controls2; end; _buf << ((_slim_controls1).to_s); if title?; - ; _buf << ("
".freeze); _buf << ((captioned_title).to_s); - ; _buf << ("
".freeze); end; end; _buf - end - end - - def convert_toc(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; _buf << ("
".freeze); - ; _buf << (((document.attr 'toc-title')).to_s); - ; _buf << ("
".freeze); - ; _buf << ((converter.convert document, 'outline').to_s); - ; _buf << ("
".freeze); _buf - end - end - - def convert_inline_kbd(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; if (keys = attr 'keys').size == 1; - ; _slim_controls1 = html_tag('kbd', data_attrs(@attributes)) do; _slim_controls2 = ''; - ; _slim_controls2 << ((keys.first).to_s); - ; _slim_controls2; end; _buf << ((_slim_controls1).to_s); else; - ; _slim_controls3 = html_tag('span', { :class => ['keyseq'] }.merge(data_attrs(@attributes))) do; _slim_controls4 = ''; - ; keys.each_with_index do |key, idx|; - ; unless idx.zero?; - ; _slim_controls4 << ("+".freeze); - ; end; _slim_controls4 << ("".freeze); _slim_controls4 << ((key).to_s); - ; _slim_controls4 << ("".freeze); end; _slim_controls4; end; _buf << ((_slim_controls3).to_s); end; _buf - end - end - - def convert_title_slide(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; bg_image = (attr? 'title-slide-background-image') ? (image_uri(attr 'title-slide-background-image')) : nil; - ; bg_video = (attr? 'title-slide-background-video') ? (media_uri(attr 'title-slide-background-video')) : nil; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; _buf << ("".freeze); - ; if (_title_obj = doctitle partition: true, use_fallback: true).subtitle?; - ; _buf << ("

".freeze); _buf << ((slice_text _title_obj.title, (_slice = header.option? :slice)).to_s); - ; _buf << ("

".freeze); _buf << ((slice_text _title_obj.subtitle, _slice).to_s); - ; _buf << ("

".freeze); else; - ; _buf << ("

".freeze); _buf << ((@header.title).to_s); - ; _buf << ("

".freeze); end; preamble = @document.find_by context: :preamble; - ; unless preamble.nil? or preamble.length == 0; - ; _buf << ("
".freeze); _buf << ((preamble.pop.content).to_s); - ; _buf << ("
".freeze); end; _buf << ((generate_authors(@document)).to_s); - ; _buf << ("".freeze); _buf - end - end - - def convert_inline_quoted(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; quote_tags = { emphasis: 'em', strong: 'strong', monospaced: 'code', superscript: 'sup', subscript: 'sub' }; - ; if (quote_tag = quote_tags[@type]); - ; _buf << ((html_tag(quote_tag, { :id => @id, :class => [role, ('fragment' if (option? :step) || (attr? 'step'))].compact }.merge(data_attrs(@attributes)), @text)).to_s); - ; else; - ; case @type; - ; when :double; - ; _buf << ((inline_text_container("“#{@text}”")).to_s); - ; when :single; - ; _buf << ((inline_text_container("‘#{@text}’")).to_s); - ; when :asciimath, :latexmath; - ; open, close = Asciidoctor::INLINE_MATH_DELIMITERS[@type]; - ; _buf << ((inline_text_container("#{open}#{@text}#{close}")).to_s); - ; else; - ; _buf << ((inline_text_container(@text)).to_s); - ; end; end; _buf - end - end - - def convert_inline_callout(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; if @document.attr? :icons, 'font'; - ; _buf << ("".freeze); - ; _buf << (("(#{@text})").to_s); - ; _buf << ("".freeze); elsif @document.attr? :icons; - ; _buf << ("".freeze); - ; else; - ; _buf << ("".freeze); _buf << (("(#{@text})").to_s); - ; _buf << ("".freeze); end; _buf - end - end - - def convert_floating_title(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_htag_filter1 = ((level + 1)).to_s; _buf << ("".freeze); - ; _buf << ((title).to_s); - ; _buf << ("".freeze); _buf - end - end - - def convert_table(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; classes = ['tableblock', "frame-#{attr :frame, 'all'}", "grid-#{attr :grid, 'all'}", role, ('fragment' if (option? :step) || (attr? 'step'))]; - ; styles = [("width:#{attr :tablepcwidth}%" unless option? 'autowidth'), ("float:#{attr :float}" if attr? :float)].compact.join('; '); - ; _slim_controls1 = html_tag('table', { :id => @id, :class => classes, :style => styles }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("".freeze); _slim_controls2 << ((captioned_title).to_s); - ; _slim_controls2 << ("".freeze); end; unless (attr :rowcount).zero?; - ; _slim_controls2 << ("".freeze); - ; if option? 'autowidth'; - ; @columns.each do; - ; _slim_controls2 << ("".freeze); - ; end; else; - ; @columns.each do |col|; - ; _slim_controls2 << ("".freeze); - ; end; end; _slim_controls2 << ("".freeze); [:head, :foot, :body].select {|tblsec| !@rows[tblsec].empty? }.each do |tblsec|; - ; - ; _slim_controls2 << ("".freeze); - ; @rows[tblsec].each do |row|; - ; _slim_controls2 << ("".freeze); - ; row.each do |cell|; - ; - ; if tblsec == :head; - ; cell_content = cell.text; - ; else; - ; case cell.style; - ; when :literal; - ; cell_content = cell.text; - ; else; - ; cell_content = cell.content; - ; end; end; _slim_controls3 = html_tag(tblsec == :head || cell.style == :header ? 'th' : 'td', - :class=>['tableblock', "halign-#{cell.attr :halign}", "valign-#{cell.attr :valign}"], - :colspan=>cell.colspan, :rowspan=>cell.rowspan, - :style=>((@document.attr? :cellbgcolor) ? %(background-color:#{@document.attr :cellbgcolor};) : nil)) do; _slim_controls4 = ''; - ; if tblsec == :head; - ; _slim_controls4 << ((cell_content).to_s); - ; else; - ; case cell.style; - ; when :asciidoc; - ; _slim_controls4 << ("
".freeze); _slim_controls4 << ((cell_content).to_s); - ; _slim_controls4 << ("
".freeze); when :literal; - ; _slim_controls4 << ("
".freeze); _slim_controls4 << ((cell_content).to_s); 
-      ; _slim_controls4 << ("
".freeze); when :header; - ; cell_content.each do |text|; - ; _slim_controls4 << ("

".freeze); _slim_controls4 << ((text).to_s); - ; _slim_controls4 << ("

".freeze); end; else; - ; cell_content.each do |text|; - ; _slim_controls4 << ("

".freeze); _slim_controls4 << ((text).to_s); - ; _slim_controls4 << ("

".freeze); end; end; end; _slim_controls4; end; _slim_controls2 << ((_slim_controls3).to_s); end; _slim_controls2 << ("".freeze); end; end; end; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_outline(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; unless sections.empty?; - ; toclevels ||= (document.attr 'toclevels', DEFAULT_TOCLEVELS).to_i; - ; slevel = section_level sections.first; - ; _buf << ("
    ".freeze); - ; sections.each do |sec|; - ; _buf << ("
  1. ".freeze); _buf << ((section_title sec).to_s); - ; _buf << ("".freeze); if (sec.level < toclevels) && (child_toc = converter.convert sec, 'outline'); - ; _buf << ((child_toc).to_s); - ; end; _buf << ("
  2. ".freeze); end; _buf << ("
".freeze); end; _buf - end - end - - def convert_inline_button(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('b', { :class => ['button'] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << ((@text).to_s); - ; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_document(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; slides_content = self.content; - ; content_for :slides do; - ; unless noheader; - ; unless (header_docinfo = docinfo :header, '-revealjs.html').empty?; - ; _buf << ((header_docinfo).to_s); - ; end; if header?; - ; bg_image = (attr? 'title-slide-background-image') ? (image_uri(attr 'title-slide-background-image')) : nil; - ; bg_video = (attr? 'title-slide-background-video') ? (media_uri(attr 'title-slide-background-video')) : nil; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; _buf << ("".freeze); - ; if (_title_obj = doctitle partition: true, use_fallback: true).subtitle?; - ; _buf << ("

".freeze); _buf << ((slice_text _title_obj.title, (_slice = header.option? :slice)).to_s); - ; _buf << ("

".freeze); _buf << ((slice_text _title_obj.subtitle, _slice).to_s); - ; _buf << ("

".freeze); else; - ; _buf << ("

".freeze); _buf << ((@header.title).to_s); - ; _buf << ("

".freeze); end; preamble = @document.find_by context: :preamble; - ; unless preamble.nil? or preamble.length == 0; - ; _buf << ("
".freeze); _buf << ((preamble.pop.content).to_s); - ; _buf << ("
".freeze); end; _buf << ((generate_authors(@document)).to_s); - ; _buf << ("".freeze); - ; end; end; _buf << ((slides_content).to_s); - ; unless (footer_docinfo = docinfo :footer, '-revealjs.html').empty?; - ; _buf << ((footer_docinfo).to_s); - ; - ; end; end; _buf << ("".freeze); - ; - ; - ; - ; - ; _buf << (((doctitle sanitize: true, use_fallback: true)).to_s); - ; - ; _buf << ("".freeze); if RUBY_ENGINE == 'opal' && JAVASCRIPT_PLATFORM == 'node'; - ; revealjsdir = (attr :revealjsdir, 'node_modules/reveal.js'); - ; else; - ; revealjsdir = (attr :revealjsdir, 'reveal.js'); - ; end; unless (asset_uri_scheme = (attr 'asset-uri-scheme', 'https')).empty?; - ; asset_uri_scheme = %(#{asset_uri_scheme}:); - ; end; cdn_base = %(#{asset_uri_scheme}//cdnjs.cloudflare.com/ajax/libs); - ; [:description, :keywords, :author, :copyright].each do |key|; - ; if attr? key; - ; _buf << ("".freeze); - ; end; end; if attr? 'favicon'; - ; if (icon_href = attr 'favicon').empty?; - ; icon_href = 'favicon.ico'; - ; icon_type = 'image/x-icon'; - ; elsif (icon_ext = File.extname icon_href); - ; icon_type = icon_ext == '.ico' ? 'image/x-icon' : %(image/#{icon_ext.slice 1, icon_ext.length}); - ; else; - ; icon_type = 'image/x-icon'; - ; end; _buf << ("".freeze); - ; end; linkcss = (attr? 'linkcss'); - ; _buf << ("".freeze); - ; - ; - ; - ; if attr? :icons, 'font'; - ; - ; if attr? 'iconfont-remote'; - ; if (iconfont_cdn = (attr 'iconfont-cdn')); - ; _buf << ("".freeze); - ; else; - ; - ; font_awesome_version = (attr 'font-awesome-version', '5.15.1'); - ; _buf << ("".freeze); - ; end; else; - ; _buf << ("".freeze); - ; end; end; _buf << ((generate_stem(cdn_base)).to_s); - ; syntax_hl = self.syntax_highlighter; - ; if syntax_hl && (syntax_hl.docinfo? :head); - ; _buf << ((syntax_hl.docinfo :head, self, cdn_base_url: cdn_base, linkcss: linkcss, self_closing_tag_slash: '/').to_s); - ; end; if attr? :customcss; - ; _buf << ("".freeze); - ; end; unless (_docinfo = docinfo :head, '-revealjs.html').empty?; - ; _buf << ((_docinfo).to_s); - ; end; _buf << ("
".freeze); - ; - ; - ; - ; yield_content :slides; - ; _buf << ("
".freeze); - ; - ; - ; if syntax_hl && (syntax_hl.docinfo? :footer); - ; _buf << ((syntax_hl.docinfo :footer, self, cdn_base_url: cdn_base, linkcss: linkcss, self_closing_tag_slash: '/').to_s); - ; - ; end; unless (docinfo_content = (docinfo :footer, '.html')).empty?; - ; _buf << ((docinfo_content).to_s); - ; end; _buf << ("".freeze); _buf - end - end - - def convert_inline_menu(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; menu = attr 'menu'; - ; menuitem = attr 'menuitem'; - ; if !(submenus = attr 'submenus').empty?; - ; _slim_controls1 = html_tag('span', { :class => ['menuseq'] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << ("".freeze); _slim_controls2 << ((menu).to_s); - ; _slim_controls2 << (" ▸ ".freeze); - ; _slim_controls2 << ((submenus.map {|submenu| %(#{submenu} ▸ ) }.join).to_s); - ; _slim_controls2 << ("".freeze); _slim_controls2 << ((menuitem).to_s); - ; _slim_controls2 << ("".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); elsif !menuitem.nil?; - ; _slim_controls3 = html_tag('span', { :class => ['menuseq'] }.merge(data_attrs(@attributes))) do; _slim_controls4 = ''; - ; _slim_controls4 << ("".freeze); _slim_controls4 << ((menu).to_s); - ; _slim_controls4 << (" ▸ ".freeze); - ; _slim_controls4 << ((menuitem).to_s); - ; _slim_controls4 << ("".freeze); _slim_controls4; end; _buf << ((_slim_controls3).to_s); else; - ; _slim_controls5 = html_tag('span', { :class => ['menu'] }.merge(data_attrs(@attributes))) do; _slim_controls6 = ''; - ; _slim_controls6 << ((menu).to_s); - ; _slim_controls6; end; _buf << ((_slim_controls5).to_s); end; _buf - end - end - - def convert_admonition(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; if (has_role? 'aside') or (has_role? 'speaker') or (has_role? 'notes'); - ; _buf << ("".freeze); - ; else; - ; _slim_controls1 = html_tag('div', { :id => @id, :class => ['admonitionblock', (attr :name), role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << ("
".freeze); - ; - ; if @document.attr? :icons, 'font'; - ; icon_mapping = Hash['caution', 'fire', 'important', 'exclamation-circle', 'note', 'info-circle', 'tip', 'lightbulb-o', 'warning', 'warning']; - ; _slim_controls2 << ("".freeze); - ; elsif @document.attr? :icons; - ; _slim_controls2 << ("".freeze); - ; else; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << (((attr :textlabel) || @caption).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); end; _buf - end - end - - def convert_open(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; if @style == 'abstract'; - ; if @parent == @document && @document.doctype == 'book'; - ; puts 'asciidoctor: WARNING: abstract block cannot be used in a document without a title when doctype is book. Excluding block content.'; - ; else; - ; _slim_controls1 = html_tag('div', { :id => @id, :class => ['quoteblock', 'abstract', role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); end; elsif @style == 'partintro' && (@level != 0 || @parent.context != :section || @document.doctype != 'book'); - ; puts 'asciidoctor: ERROR: partintro block can only be used when doctype is book and it\'s a child of a book part. Excluding block content.'; - ; else; - ; if (has_role? 'aside') or (has_role? 'speaker') or (has_role? 'notes'); - ; _buf << ("".freeze); - ; else; - ; _slim_controls3 = html_tag('div', { :id => @id, :class => ['openblock', (@style != 'open' ? @style : nil), role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls4 = ''; - ; if title?; - ; _slim_controls4 << ("
".freeze); _slim_controls4 << ((title).to_s); - ; _slim_controls4 << ("
".freeze); end; _slim_controls4 << ("
".freeze); _slim_controls4 << ((content).to_s); - ; _slim_controls4 << ("
".freeze); _slim_controls4; end; _buf << ((_slim_controls3).to_s); end; end; _buf - end - end - - def convert_inline_footnote(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; footnote = slide_footnote(self); - ; index = footnote.attr(:index); - ; id = footnote.id; - ; if @type == :xref; - ; _slim_controls1 = html_tag('sup', { :class => ['footnoteref'] }.merge(data_attrs(footnote.attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << ("[".freeze); - ; _slim_controls2 << ((index).to_s); - ; _slim_controls2 << ("]".freeze); - ; _slim_controls2; end; _buf << ((_slim_controls1).to_s); else; - ; _slim_controls3 = html_tag('sup', { :id => ("_footnote_#{id}" if id), :class => ['footnote'] }.merge(data_attrs(footnote.attributes))) do; _slim_controls4 = ''; - ; _slim_controls4 << ("[".freeze); - ; _slim_controls4 << ((index).to_s); - ; _slim_controls4 << ("]".freeze); - ; _slim_controls4; end; _buf << ((_slim_controls3).to_s); end; _buf - end - end - - def convert_verse(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => @id, :class => ['verseblock', role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); _slim_controls2 << ((content).to_s); 
-      ; _slim_controls2 << ("
".freeze); attribution = (attr? :attribution) ? (attr :attribution) : nil; - ; citetitle = (attr? :citetitle) ? (attr :citetitle) : nil; - ; if attribution || citetitle; - ; _slim_controls2 << ("
".freeze); - ; if citetitle; - ; _slim_controls2 << ("".freeze); _slim_controls2 << ((citetitle).to_s); - ; _slim_controls2 << ("".freeze); end; if attribution; - ; if citetitle; - ; _slim_controls2 << ("
".freeze); - ; end; _slim_controls2 << ("— ".freeze); _slim_controls2 << ((attribution).to_s); - ; end; _slim_controls2 << ("
".freeze); end; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_quote(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => @id, :class => ['quoteblock', role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("
".freeze); attribution = (attr? :attribution) ? (attr :attribution) : nil; - ; citetitle = (attr? :citetitle) ? (attr :citetitle) : nil; - ; if attribution || citetitle; - ; _slim_controls2 << ("
".freeze); - ; if citetitle; - ; _slim_controls2 << ("".freeze); _slim_controls2 << ((citetitle).to_s); - ; _slim_controls2 << ("".freeze); end; if attribution; - ; if citetitle; - ; _slim_controls2 << ("
".freeze); - ; end; _slim_controls2 << ("— ".freeze); _slim_controls2 << ((attribution).to_s); - ; end; _slim_controls2 << ("
".freeze); end; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_video(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; - ; - ; no_stretch = ((attr? :width) || (attr? :height)); - ; width = (attr? :width) ? (attr :width) : "100%"; - ; height = (attr? :height) ? (attr :height) : "100%"; - ; - ; _slim_controls1 = html_tag('div', { :id => @id, :class => ['videoblock', @style, role, (no_stretch ? nil : 'stretch'), ('fragment' if (option? :step) || (has_role? 'step') || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((captioned_title).to_s); - ; _slim_controls2 << ("
".freeze); end; case attr :poster; - ; when 'vimeo'; - ; unless (asset_uri_scheme = (attr :asset_uri_scheme, 'https')).empty?; - ; asset_uri_scheme = %(#{asset_uri_scheme}:); - ; end; start_anchor = (attr? :start) ? "#at=#{attr :start}" : nil; - ; delimiter = ['?']; - ; loop_param = (option? 'loop') ? %(#{delimiter.pop || '&'}loop=1) : ''; - ; muted_param = (option? 'muted') ? %(#{delimiter.pop || '&'}muted=1) : ''; - ; src = %(#{asset_uri_scheme}//player.vimeo.com/video/#{attr :target}#{loop_param}#{muted_param}#{start_anchor}); - ; - ; - ; - ; - ; - ; _slim_controls2 << ("".freeze); - ; when 'youtube'; - ; unless (asset_uri_scheme = (attr :asset_uri_scheme, 'https')).empty?; - ; asset_uri_scheme = %(#{asset_uri_scheme}:); - ; end; params = ['rel=0']; - ; params << "start=#{attr :start}" if attr? :start; - ; params << "end=#{attr :end}" if attr? :end; - ; params << "loop=1" if option? 'loop'; - ; params << "mute=1" if option? 'muted'; - ; params << "controls=0" if option? 'nocontrols'; - ; src = %(#{asset_uri_scheme}//www.youtube.com/embed/#{attr :target}?#{params * '&'}); - ; - ; - ; - ; - ; - ; _slim_controls2 << ("".freeze); - ; else; - ; - ; - ; - ; _slim_controls2 << ("Your browser does not support the video tag.".freeze); - ; - ; end; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_thematic_break(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _buf << ("
".freeze); - ; _buf - end - end - - def convert_preamble(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; - ; - ; _buf - end - end - - def convert_sidebar(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; if (has_role? 'aside') or (has_role? 'speaker') or (has_role? 'notes'); - ; _buf << ("".freeze); - ; else; - ; _slim_controls1 = html_tag('div', { :id => @id, :class => ['sidebarblock', role, ('fragment' if (option? :step) || (has_role? 'step') || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << ("
".freeze); - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); end; _buf - end - end - - def convert_listing(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; nowrap = (option? 'nowrap') || !(document.attr? 'prewrap'); - ; if @style == 'source'; - ; syntax_hl = document.syntax_highlighter; - ; lang = attr :language; - ; if syntax_hl; - ; doc_attrs = document.attributes; - ; css_mode = (doc_attrs[%(#{syntax_hl.name}-css)] || :class).to_sym; - ; style = doc_attrs[%(#{syntax_hl.name}-style)]; - ; opts = syntax_hl.highlight? ? { css_mode: css_mode, style: style } : {}; - ; opts[:nowrap] = nowrap; - ; end; - ; end; _slim_controls1 = html_tag('div', { :id => id, :class => ['listingblock', role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes.reject {|key, _| key == 'data-id' }))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((captioned_title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); - ; if syntax_hl; - ; _slim_controls2 << (((syntax_hl.format self, lang, opts)).to_s); - ; else; - ; if @style == 'source'; - ; _slim_controls2 << ("".freeze); - ; _slim_controls2 << ((content || '').to_s); - ; _slim_controls2 << ("".freeze); else; - ; _slim_controls2 << ("".freeze); - ; _slim_controls2 << ((content || '').to_s); - ; _slim_controls2 << ("".freeze); end; end; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_inline_indexterm(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; if @type == :visible; - ; _buf << ((@text).to_s); - ; end; _buf - end - end - - def convert_olist(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => @id, :class => ['olist', @style, role] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("".freeze); - ; items.each do |item|; - ; _slim_controls2 << ("

".freeze); - ; _slim_controls2 << ((item.text).to_s); - ; _slim_controls2 << ("

".freeze); if item.blocks?; - ; _slim_controls2 << ((item.content).to_s); - ; end; _slim_controls2 << ("".freeze); end; _slim_controls2 << ("".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_pass(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _buf << ((content).to_s); - ; _buf - end - end - - def convert_colist(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => @id, :class => ['colist', @style, role] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; if @document.attr? :icons; - ; font_icons = @document.attr? :icons, 'font'; - ; _slim_controls2 << ("".freeze); - ; items.each_with_index do |item, i|; - ; num = i + 1; - ; _slim_controls2 << ("".freeze); end; _slim_controls2 << ("
".freeze); - ; - ; if font_icons; - ; _slim_controls2 << ("".freeze); - ; _slim_controls2 << ((num).to_s); - ; _slim_controls2 << ("".freeze); else; - ; _slim_controls2 << ("".freeze); - ; end; _slim_controls2 << ("".freeze); _slim_controls2 << ((item.text).to_s); - ; _slim_controls2 << ("
".freeze); else; - ; _slim_controls2 << ("
    ".freeze); - ; items.each do |item|; - ; _slim_controls2 << ("

    ".freeze); - ; _slim_controls2 << ((item.text).to_s); - ; _slim_controls2 << ("

    ".freeze); end; _slim_controls2 << ("
".freeze); end; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_stretch_nested_elements(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _buf << ("".freeze); - ; - ; _buf - end - end - - def convert_section(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; - ; - ; titleless = (title = self.title) == '!'; - ; hide_title = (titleless || (option? :notitle) || (option? :conceal)); - ; - ; vertical_slides = find_by(context: :section) {|section| section.level == 2 }; - ; - ; - ; - ; data_background_image, data_background_size, data_background_repeat, - data_background_position, data_background_transition = nil; - ; - ; - ; section_images = blocks.map do |block|; - ; if (ctx = block.context) == :image; - ; ['background', 'canvas'].include?(block.attributes[1]) ? block : []; - ; elsif ctx == :section; - ; []; - ; else; - ; block.find_by(context: :image) {|image| ['background', 'canvas'].include?(image.attributes[1]) } || []; - ; end; end; if (bg_image = section_images.flatten.first); - ; data_background_image = image_uri(bg_image.attr 'target'); - ; - ; data_background_size = bg_image.attr 'size'; - ; data_background_repeat = bg_image.attr 'repeat'; - ; data_background_transition = bg_image.attr 'transition'; - ; data_background_position = bg_image.attr 'position'; - ; - ; - ; end; if attr? 'background-image'; - ; data_background_image = image_uri(attr 'background-image'); - ; - ; end; if attr? 'background-video'; - ; data_background_video = media_uri(attr 'background-video'); - ; - ; end; if attr? 'background-color'; - ; data_background_color = attr 'background-color'; - ; - ; end; parent_section_with_vertical_slides = @level == 1 && !vertical_slides.empty?; - ; - ; content_for :footnotes do; - ; slide_footnotes = slide_footnotes(self); - ; if document.footnotes? && !(parent.attr? 'nofootnotes') && !slide_footnotes.empty?; - ; _buf << ("
".freeze); - ; slide_footnotes.each do |footnote|; - ; _buf << ("
".freeze); - ; _buf << (("#{footnote.index}. #{footnote.text}").to_s); - ; - ; _buf << ("
".freeze); end; _buf << ("
".freeze); end; end; content_for :section do; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; - ; _buf << ("".freeze); - ; unless hide_title; - ; _buf << ("

".freeze); _buf << ((section_title).to_s); - ; _buf << ("

".freeze); end; if parent_section_with_vertical_slides; - ; unless (_blocks = blocks - vertical_slides).empty?; - ; _buf << ("
".freeze); - ; _blocks.each do |block|; - ; _buf << ((block.convert).to_s); - ; end; _buf << ("
".freeze); end; yield_content :footnotes; - ; - ; else; - ; unless (_content = content.chomp).empty?; - ; _buf << ("
".freeze); - ; _buf << ((_content).to_s); - ; _buf << ("
".freeze); end; yield_content :footnotes; - ; - ; end; clear_slide_footnotes; - ; - ; _buf << ("".freeze); - ; - ; end; if parent_section_with_vertical_slides; - ; _buf << ("
".freeze); - ; yield_content :section; - ; vertical_slides.each do |subsection|; - ; _buf << ((subsection.convert).to_s); - ; - ; end; _buf << ("
".freeze); - ; else; - ; if @level >= 3; - ; - ; _slim_htag_filter1 = ((@level)).to_s; _buf << ("".freeze); _buf << ((title).to_s); - ; _buf << ("".freeze); _buf << ((content.chomp).to_s); - ; else; - ; yield_content :section; - ; end; end; _buf - end - end - - def convert_inline_image(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('span', { :class => [@type, role, ('fragment' if (option? :step) || (attr? 'step'))], :style => ("float: #{attr :float}" if attr? :float) }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; _slim_controls2 << ((convert_inline_image).to_s); - ; _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_example(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => @id, :class => ['exampleblock', role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((captioned_title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_inline_break(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _buf << ((@text).to_s); - ; _buf << ("
".freeze); - ; _buf - end - end - - def convert_literal(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _slim_controls1 = html_tag('div', { :id => id, :class => ['literalblock', role, ('fragment' if (option? :step) || (attr? 'step'))] }.merge(data_attrs(@attributes))) do; _slim_controls2 = ''; - ; if title?; - ; _slim_controls2 << ("
".freeze); _slim_controls2 << ((title).to_s); - ; _slim_controls2 << ("
".freeze); end; _slim_controls2 << ("
".freeze); _slim_controls2 << ((content).to_s); - ; _slim_controls2 << ("
".freeze); _slim_controls2; end; _buf << ((_slim_controls1).to_s); _buf - end - end - - def convert_page_break(node, opts = {}) - node.extend(Helpers) - node.instance_eval do - converter.set_local_variables(binding, opts) unless opts.empty? - _buf = ''; _buf << ("
".freeze); - ; _buf - end - end - #------------------ End of generated transformation methods ------------------# - - def set_local_variables(binding, vars) - vars.each do |key, val| - binding.local_variable_set(key.to_sym, val) - end - end - -end diff --git a/lib/asciidoctor-revealjs/version.rb b/lib/asciidoctor-revealjs/version.rb index 1a21935f..0214b15c 100644 --- a/lib/asciidoctor-revealjs/version.rb +++ b/lib/asciidoctor-revealjs/version.rb @@ -1,5 +1,5 @@ module Asciidoctor module Revealjs - VERSION = '5.2.0' + VERSION = '5.3.0-dev' end end diff --git a/package.json b/package.json index a5ea0e5d..fe614555 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@asciidoctor/reveal.js", - "version": "5.2.0", + "version": "5.3.0-dev", "description": "A reveal.js converter for Asciidoctor.js. Write your slides in AsciiDoc!", "main": "dist/main.js", "engines": {