class Asciidoctor::Katex::Treeprocessor
Asciidoctor
processor that renders delimited latexmath expressions using the KaTeX library.
Public Class Methods
new(katex_options: {}, katex_renderer: nil, require_stem_attr: true, **)
click to toggle source
@param katex_options [Hash] default options for the KaTeX renderer.
This parameter has no effect when *katex_renderer* is provided.
@param katex_renderer [#call, nil] callable that accepts a math expression
[String] and options [Hash], and returns a rendered expression [String]. Defaults to {KatexAdapter} initialized with the *katex_options*.
@param require_stem_attr [Boolean] `true` to skip when `stem` attribute
is not declared, `false` to process anyway.
Calls superclass method
# File lib/asciidoctor/katex/treeprocessor.rb, line 25 def initialize(katex_options: {}, katex_renderer: nil, require_stem_attr: true, **) @katex_renderer = katex_renderer || KatexAdapter.new(katex_options) @require_stem_attr = require_stem_attr super end
Public Instance Methods
process(document)
click to toggle source
@param document [Asciidoctor::Document] the document to process.
# File lib/asciidoctor/katex/treeprocessor.rb, line 32 def process(document) return if skip? document converter = document.instance_variable_get(:@converter) decorator = StemConverterDecorator.new(converter, @katex_renderer) document.instance_variable_set(:@converter, decorator) nil end
Protected Instance Methods
skip?(document)
click to toggle source
@param document [Asciidoctor::Document] the document to process. @return [Boolean] whether to skip processing of the document.
# File lib/asciidoctor/katex/treeprocessor.rb, line 45 def skip?(document) @require_stem_attr && !document.attr?('stem') end