Class: Jekyll::Tags::LatexBlock
- Inherits:
-
Liquid::Block
- Object
- Liquid::Block
- Jekyll::Tags::LatexBlock
- Defined in:
- lib/jekyll/tags/latex_block.rb
Overview
LaTeX tag, HTML rendering via KaTeX
Instance Method Summary collapse
-
#initialize(tag_name, markup, options) ⇒ LatexBlock
constructor
A new instance of LatexBlock.
- #katex_js ⇒ Object
- #katex_path ⇒ Object
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, markup, options) ⇒ LatexBlock
Returns a new instance of LatexBlock.
10 11 12 13 |
# File 'lib/jekyll/tags/latex_block.rb', line 10 def initialize(tag_name, markup, ) = Liquid::Tag::Parser.new(markup).args super end |
Instance Method Details
#katex_js ⇒ Object
15 16 17 18 19 |
# File 'lib/jekyll/tags/latex_block.rb', line 15 def katex_js # rubocop:disable Style/ClassVars @@katex ||= ExecJS.compile(File.read(katex_path)) # rubocop:enable Style/ClassVars end |
#katex_path ⇒ Object
21 22 23 |
# File 'lib/jekyll/tags/latex_block.rb', line 21 def katex_path File.('../../js/katex.js', File.dirname(__FILE__)) end |
#render(context) ⇒ Object
25 26 27 28 |
# File 'lib/jekyll/tags/latex_block.rb', line 25 def render(context) latex_source = super katex_js.call('katex.renderToString', latex_source, ) end |