Class: Mathml2latex::Converter

Inherits:
Object
  • Object
show all
Defined in:
lib/mathml2latex.rb

Instance Method Summary collapse

Constructor Details

#initializeConverter

Returns a new instance of Converter.



11
12
13
# File 'lib/mathml2latex.rb', line 11

def initialize
  @service_object = Mathml2latex::MathmlLatexService.get_service_object
end

Instance Method Details

#replace_with_latex(xml_doc) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/mathml2latex.rb', line 19

def replace_with_latex(xml_doc)
  nodes = xml_doc.xpath('//mm:math', 'mm' => Mathml2latex::MATHML_NAMESPACE)
  nodes.each do |node|
    node.replace(<<~XML)
      <latex xmlns="#{Mathml2latex::INSTUCTURE_LATEX_NS}">#{@service_object.to_latex(node.dup.to_xml)}</latex>
    XML
  end
end

#to_latex(mathml) ⇒ Object



15
16
17
# File 'lib/mathml2latex.rb', line 15

def to_latex(mathml)
  @service_object.to_latex(mathml)
end