module Kramdown::Converter::MathEngine::MathjaxNode

Uses the mathjax-node-cli library for converting math formulas to MathML.

Constants

AVAILABLE

MathjaxNode is available if this constant is true.

Public Class Methods

call(converter, el, opts) click to toggle source
   # File lib/kramdown/converter/math_engine/mathjaxnode.rb
36 def self.call(converter, el, opts)
37   type = el.options[:category]
38 
39   cmd = [T2MPATH]
40   cmd << "--inline" unless type == :block
41   cmd << "--semantics" if converter.options[:math_engine_opts][:semantics] == true
42   cmd << "--notexhints" if converter.options[:math_engine_opts][:texhints] == false
43   result = IO.popen(cmd << el.value).read.strip
44 
45   attr = el.attr.dup
46   attr.delete('xmlns')
47   attr.delete('display')
48   result.insert("<math".length, converter.html_attributes(attr))
49 
50   (type == :block ? "#{' '*opts[:indent]}#{result}\n" : result)
51 end