# 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
# 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
# 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 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}#{name}>)
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
##
# 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
# 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
#--
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"
def initialize(backend, opts = {})
super
basebackend "html" if respond_to? :basebackend
outfilesuffix ".html" if respond_to? :outfilesuffix
filetype "html" if respond_to? :filetype
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 = {})
transform ||= node.node_name
converter = respond_to?(transform) ? self : @delegate_converter
if opts.empty?
converter.send(transform, node)
else
converter.send(transform, node, opts)
end
end
#----------------- Begin of generated transformation methods -----------------#
def 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 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
def 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;
; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << (" ".freeze); 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); _buf << ((resolve_content).to_s);
; _buf << (" ".freeze);
; else;
; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << ("
".freeze); end; end; _buf
end
end
def paragraph(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; if has_role? 'small';
; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << (" ".freeze); else;
; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf
end
end
def verse(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << (" ".freeze); attribution = (attr? :attribution) ? (attr :attribution) : nil;
; citetitle = (attr? :citetitle) ? (attr :citetitle) : nil;
; if attribution || citetitle;
; _buf << ("
".freeze);
; if citetitle;
; _buf << ("".freeze); _buf << ((citetitle).to_s);
; _buf << (" ".freeze); end; if attribution;
; if citetitle;
; _buf << (" ".freeze);
; end; _buf << ("— ".freeze); _buf << ((attribution).to_s);
; end; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf
end
end
def dlist(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; case @style;
; when 'qanda';
; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze);
; items.each do |questions, answer|;
; _buf << ("".freeze);
; [*questions].each do |question|;
; _buf << ("".freeze); _buf << ((question.text).to_s);
; _buf << ("
".freeze); end; unless answer.nil?;
; if answer.text?;
; _buf << ("".freeze); _buf << ((answer.text).to_s);
; _buf << ("
".freeze); end; if answer.blocks?;
; _buf << ((answer.content).to_s);
; end; end; _buf << (" ".freeze); end; _buf << (" ".freeze); when 'horizontal';
; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze);
; if (attr? :labelwidth) || (attr? :itemwidth);
; _buf << (" ".freeze);
; end; items.each do |terms, dd|;
; _buf << ("".freeze);
; terms = [*terms];
; last_term = terms.last;
; terms.each do |dt|;
; _buf << ((dt.text).to_s);
; if dt != last_term;
; _buf << (" ".freeze);
; end; end; _buf << (" ".freeze);
; unless dd.nil?;
; if dd.text?;
; _buf << ("".freeze); _buf << ((dd.text).to_s);
; _buf << ("
".freeze); end; if dd.blocks?;
; _buf << ((dd.content).to_s);
; end; end; _buf << (" ".freeze); end; _buf << ("
".freeze); else;
; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze);
; items.each do |terms, dd|;
; [*terms].each do |dt|;
; _buf << ("".freeze); _buf << ((dt.text).to_s);
; _buf << (" ".freeze); end; unless dd.nil?;
; _buf << ("".freeze);
; if dd.text?;
; _buf << ("".freeze); _buf << ((dd.text).to_s);
; _buf << ("
".freeze); end; if dd.blocks?;
; _buf << ((dd.content).to_s);
; end; _buf << (" ".freeze); end; end; _buf << (" ".freeze); end; _buf
end
end
def inline_footnote(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; if @type == :xref;
; _buf << ("".freeze);
; else;
; _buf << ("".freeze);
; end; _buf
end
end
def asciidoctor_revealjs(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 image(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; width = (attr? :width) ? (attr :width) : nil;
; height = (attr? :height) ? (attr :height) : nil;
;
;
;
;
;
;
; if (has_role? 'stretch') && !((attr? :width) || (attr? :height));
; height = "100%";
;
; end; unless attributes[1] == 'background' || attributes[1] == 'canvas';
;
; _buf << ("".freeze);
; if attr? :link;
; _buf << ("
".freeze);
; else;
; _buf << ("
".freeze);
; end; _buf << ("
".freeze); if title?;
; _buf << ("".freeze); _buf << ((captioned_title).to_s);
; _buf << ("
".freeze); end; end; _buf
end
end
def 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 preamble(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = '';
;
; _buf
end
end
def 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 quote(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << (" ".freeze); attribution = (attr? :attribution) ? (attr :attribution) : nil;
; citetitle = (attr? :citetitle) ? (attr :citetitle) : nil;
; if attribution || citetitle;
; _buf << ("
".freeze);
; if citetitle;
; _buf << ("".freeze); _buf << ((citetitle).to_s);
; _buf << (" ".freeze); end; if attribution;
; if citetitle;
; _buf << (" ".freeze);
; end; _buf << ("— ".freeze); _buf << ((attribution).to_s);
; end; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf
end
end
def 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 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 table(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = '';
; _buf << ("".freeze);
; if title?;
; _buf << ("".freeze); _buf << ((captioned_title).to_s);
; _buf << (" ".freeze); end; unless (attr :rowcount).zero?;
; _buf << ("".freeze);
; if option? 'autowidth';
; @columns.each do;
; _buf << (" ".freeze);
; end; else;
; @columns.each do |col|;
; _buf << (" ".freeze);
; end; end; _buf << (" ".freeze); [:head, :foot, :body].select {|tblsec| !@rows[tblsec].empty? }.each do |tblsec|;
;
; _buf << ("".freeze);
; @rows[tblsec].each do |row|;
; _buf << ("".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_controls1 = 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_controls2 = '';
; if tblsec == :head;
; _slim_controls2 << ((cell_content).to_s);
; else;
; case cell.style;
; when :asciidoc;
; _slim_controls2 << ("".freeze); _slim_controls2 << ((cell_content).to_s);
; _slim_controls2 << ("
".freeze); when :literal;
; _slim_controls2 << ("".freeze); _slim_controls2 << ((cell_content).to_s);
; _slim_controls2 << (" ".freeze); when :header;
; cell_content.each do |text|;
; _slim_controls2 << ("".freeze); _slim_controls2 << ((text).to_s);
; _slim_controls2 << ("
".freeze); end; else;
; cell_content.each do |text|;
; _slim_controls2 << ("".freeze); _slim_controls2 << ((text).to_s);
; _slim_controls2 << ("
".freeze); end; end; end; _slim_controls2; end; _buf << ((_slim_controls1).to_s); end; _buf << (" ".freeze); end; end; end; _buf << ("
".freeze); _buf
end
end
def document(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _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; _buf << ("".freeze); _buf << (((doctitle sanitize: true, use_fallback: true)).to_s);
; _buf << (" ".freeze);
;
; if attr? :revealjs_customtheme;
; _buf << (" ".freeze);
; else;
; _buf << (" ".freeze);
; end; _buf << ("".freeze);
;
;
;
;
;
;
;
;
;
;
;
;
;
;
; if attr? :icons, 'font';
; if attr? 'iconfont-remote';
; _buf << (" ".freeze);
; else;
; _buf << (" ".freeze);
; end; end; if attr? :stem;
; eqnums_val = (attr 'eqnums', 'none');
; eqnums_val = 'AMS' if eqnums_val == '';
; eqnums_opt = %( equationNumbers: { autoNumber: "#{eqnums_val}" } );
; _buf << ("".freeze);
; end; case document.attr 'source-highlighter';
; when 'coderay';
; if (attr 'coderay-css', 'class') == 'class';
; if @safe >= Asciidoctor::SafeMode::SECURE || (attr? :linkcss);
; _buf << (" ".freeze);
; else;
; _buf << ("".freeze); end; end; when 'pygments';
; if (attr 'pygments-css', 'class') == 'class';
; if @safe >= Asciidoctor::SafeMode::SECURE || (attr? :linkcss);
; _buf << (" ".freeze);
; else;
; _buf << ("".freeze); end; end;
; end; if attr? 'highlightjs-theme';
; _buf << (" ".freeze);
; else;
; _buf << (" ".freeze);
;
; end; _buf << ("".freeze);
; unless (docinfo_content = docinfo :header, '.html').empty?;
; _buf << ((docinfo_content).to_s);
; end; if attr? :customcss;
; _buf << (" ".freeze);
; end; _buf << ("".freeze);
;
;
;
; unless notitle || !has_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; unless author.nil?;
; _buf << ("".freeze); _buf << ((author).to_s);
; _buf << ("
".freeze); end; _buf << (" ".freeze); end; _buf << ((content).to_s);
; _buf << ("
".freeze);
;
; unless (docinfo_content = (docinfo :footer, '.html')).empty?;
; _buf << ((docinfo_content).to_s);
; end; _buf << ("".freeze); _buf
end
end
def 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 notes(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze); _buf << ((resolve_content).to_s);
; _buf << (" ".freeze); _buf
end
end
def inline_image(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if @type == 'icon' && (@document.attr? :icons, 'font');
; style_class = ["fa fa-#{@target}"];
; style_class << "fa-#{attr :size}" if attr? :size;
; style_class << "fa-rotate-#{attr :rotate}" if attr? :rotate;
; style_class << "fa-flip-#{attr :flip}" if attr? :flip;
; if attr? :link;
; _buf << (" ".freeze);
; else;
; _buf << (" ".freeze);
; end; elsif @type == 'icon' && !(@document.attr? :icons);
; if attr? :link;
; _buf << ("[".freeze);
; _buf << ((attr :alt).to_s); _buf << ("] ".freeze);
; else;
; _buf << ("[".freeze); _buf << ((attr :alt).to_s); _buf << ("]".freeze);
; end; else;
; src = (@type == 'icon' ? (icon_uri @target) : (image_uri @target));
; if attr? :link;
; _buf << (" ".freeze);
; else;
; _buf << (" ".freeze);
; end; end; _buf << (" ".freeze); _buf
end
end
def 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%";
;
; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((captioned_title).to_s);
; _buf << ("
".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}loop=1" : nil;
; src = %(#{asset_uri_scheme}//player.vimeo.com/video/#{attr :target}#{start_anchor}#{loop_param});
;
;
; _buf << ("
".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 << "controls=0" if option? 'nocontrols';
; src = %(#{asset_uri_scheme}//www.youtube.com/embed/#{attr :target}?#{params * '&'});
;
;
; _buf << ("
".freeze);
; else;
;
;
;
; _buf << ("
Your browser does not support the video tag. ".freeze);
;
; end; _buf << ("
".freeze); _buf
end
end
def literal(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << (" ".freeze); _buf
end
end
def 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 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); end; _buf
end
end
def 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); _buf << ((resolve_content).to_s);
; _buf << (" ".freeze);
; else;
; _buf << ("".freeze);
;
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ((content).to_s);
; _buf << ("
".freeze); end; _buf
end
end
def 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 << ("".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 << (" ".freeze); end; _buf << (" ".freeze); end; _buf
end
end
def listing(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; if title?;
; _buf << ("".freeze); _buf << ((captioned_title).to_s);
; _buf << ("
".freeze); end; nowrap = !(@document.attr? :prewrap) || (option? 'nowrap');
;
;
; if @style == 'source' || (@style == 'listing' && attributes[1] != 'listing');
; language = attr :language;
; code_class = language ? [language, "language-#{language}"] : nil;
; pre_class = ['highlight'];
; pre_lang = nil;
; code_noescape = false;
; case document.attr 'source-highlighter';
; when 'coderay';
; pre_class = ['CodeRay'];
; when 'pygments';
; pre_class = ['pygments','highlight'];
; when 'prettify';
; pre_class = ['prettyprint'];
; pre_class << 'linenums' if attr? :linenums;
; pre_class << language if language;
; pre_class << "language-#{language}" if language;
; code_class = nil;
; when 'html-pipeline';
; pre_lang = language;
; pre_class = code_class = nil;
; nowrap = false;
; when 'highlightjs', 'highlight.js';
; code_noescape=true;
; end; pre_class << 'nowrap' if nowrap;
; pre_class << 'listingblock';
; pre_class << role if role;
; _buf << ("".freeze); _buf << ((content).to_s);
; _buf << ("
".freeze); else;
; _buf << ("".freeze); _buf << ((content).to_s);
; _buf << (" ".freeze); end; _buf
end
end
def 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;
; _buf << ("".freeze); _buf << ((keys.first).to_s);
; _buf << (" ".freeze); else;
; _buf << ("".freeze);
; keys.each_with_index do |key, idx|;
; unless idx.zero?;
; _buf << ("+".freeze);
; end; _buf << ("".freeze); _buf << ((key).to_s);
; _buf << (" ".freeze); end; _buf << (" ".freeze); end; _buf
end
end
def 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_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';
;
;
; end; if attr? 'background-image';
; data_background_image = image_uri(attr 'background-image');
;
; end; if attr? 'background-color';
; data_background_color = attr 'background-color';
;
;
;
; end; if @level == 1 && !vertical_slides.empty?;
; _buf << ("".freeze);
;
; unless hide_title;
; _buf << ("".freeze); _buf << ((title).to_s);
; _buf << (" ".freeze); end; (blocks - vertical_slides).each do |block|;
; _buf << ((block.convert).to_s);
; end; _buf << (" ".freeze); 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;
;
;
;
;
;
;
;
;
;
;
;
;
;
; _buf << ("".freeze);
;
; unless hide_title;
; _buf << ("".freeze); _buf << ((title).to_s);
; _buf << (" ".freeze); end; _buf << ((content.chomp).to_s);
; _buf << (" ".freeze); end; end; _buf
end
end
def example(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((captioned_title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf << ((content).to_s);
; _buf << ("
".freeze); _buf
end
end
def inline_button(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze); _buf << ((@text).to_s);
; _buf << (" ".freeze); _buf
end
end
def 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?;
; _buf << ("".freeze); elsif !menuitem.nil?;
; _buf << ("".freeze); else;
; _buf << ("".freeze); end; _buf
end
end
def audio(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((captioned_title).to_s);
; _buf << ("
".freeze); end; _buf << ("
Your browser does not support the audio tag. ".freeze);
;
; _buf
end
end
def 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; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf << ((equation).to_s);
; _buf << ("
".freeze); _buf
end
end
def olist(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze);
; items.each do |item|;
; _buf << ("".freeze);
; _buf << ((item.text).to_s);
; _buf << ("
".freeze); if item.blocks?;
; _buf << ((item.content).to_s);
; end; _buf << (" ".freeze); end; _buf << (" ".freeze); _buf
end
end
def 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;
; _buf << ("".freeze); _buf << (((@text || @document.references[:ids].fetch(refid, "[#{refid}]")).tr_s("\n", ' ')).to_s);
; _buf << (" ".freeze); when :ref;
; _buf << (" ".freeze);
; when :bibref;
; _buf << (" [".freeze);
; _buf << ((@target).to_s); _buf << ("]".freeze);
; else;
; _buf << ("".freeze); _buf << ((@text).to_s);
; _buf << (" ".freeze); end; _buf
end
end
def 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); _buf << ((resolve_content).to_s);
; _buf << (" ".freeze);
; else;
; _buf << ("".freeze);
;
;
; if @document.attr? :icons, 'font';
; icon_mapping = Hash['caution', 'fire', 'important', 'exclamation-circle', 'note', 'info-circle', 'tip', 'lightbulb-o', 'warning', 'warning'];
; _buf << (" ".freeze);
; elsif @document.attr? :icons;
; _buf << (" ".freeze);
; else;
; _buf << ("".freeze); _buf << (((attr :textlabel) || @caption).to_s);
; _buf << ("
".freeze); end; _buf << (" ".freeze);
; if title?;
; _buf << ("".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ((content).to_s);
; _buf << ("
".freeze); end; _buf
end
end
def inline_quoted(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; unless @id.nil?;
; _buf << (" ".freeze);
; end; case @type;
; when :emphasis;
; _buf << ("".freeze); _buf << ((@text).to_s);
; _buf << (" ".freeze); when :strong;
; _buf << ("".freeze); _buf << ((@text).to_s);
; _buf << (" ".freeze); when :monospaced;
; _buf << ("".freeze); _buf << ((@text).to_s);
; _buf << ("
".freeze); when :superscript;
; _buf << ("".freeze); _buf << ((@text).to_s);
; _buf << (" ".freeze); when :subscript;
; _buf << ("".freeze); _buf << ((@text).to_s);
; _buf << (" ".freeze); when :double;
; _buf << ((role? ? %(“#{@text}” ) : %(“#{@text}”)).to_s);
; when :single;
; _buf << ((role? ? %(‘#{@text}’ ) : %(‘#{@text}’)).to_s);
; when :asciimath, :latexmath;
; open, close = Asciidoctor::INLINE_MATH_DELIMITERS[@type];
; _buf << ((open).to_s); _buf << ((@text).to_s); _buf << ((close).to_s);
; else;
; _buf << ((role? ? %(#{@text} ) : @text).to_s);
; end; _buf
end
end
def 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; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; _buf << ("
".freeze); _buf
end
end
def 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 colist(node, opts = {})
node.extend(Helpers)
node.instance_eval do
converter.set_local_variables(binding, opts) unless opts.empty?
_buf = ''; _buf << ("".freeze);
; if title?;
; _buf << ("
".freeze); _buf << ((title).to_s);
; _buf << ("
".freeze); end; if @document.attr? :icons;
; font_icons = @document.attr? :icons, 'font';
; _buf << ("
".freeze);
; items.each_with_index do |item, i|;
; num = i + 1;
; _buf << ("".freeze);
;
; if font_icons;
; _buf << ("".freeze);
; _buf << ((num).to_s);
; _buf << (" ".freeze); else;
; _buf << (" ".freeze);
; end; _buf << (" ".freeze); _buf << ((item.text).to_s);
; _buf << (" ".freeze); end; _buf << ("
".freeze); else;
; _buf << ("
".freeze);
; items.each do |item|;
; _buf << ("".freeze); _buf << ((item.text).to_s);
; _buf << ("
".freeze); end; _buf << (" ".freeze); end; _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