Class: Jekyll::Tags::Katex

Inherits:
Liquid::Block
  • Object
show all
Defined in:
lib/jekyll/tags/katex.rb

Overview

Defines the custom Liquid tag for compile-time rendering of KaTeX math

{% katex %}
<latex math>
{% endkatex %}

Constant Summary collapse

LOG_TOPIC =
'Katex Block:'

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, tokens) ⇒ Katex

Returns a new instance of Katex.



16
17
18
19
20
21
# File 'lib/jekyll/tags/katex.rb', line 16

def initialize(tag_name, markup, tokens)
  super
  @markup = markup
  @tokens = tokens
  @display = markup.include? 'display'
end

Instance Method Details

#render(context) ⇒ Object



23
24
25
26
27
# File 'lib/jekyll/tags/katex.rb', line 23

def render(context)
  latex_source = super
  rendering_options = Jekyll::Katex::Configuration.global_rendering_options.merge(displayMode: @display)
  KATEX.call('katex.renderToString', latex_source, rendering_options)
end