` 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/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 %( ) 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