Class: Mathml2latex::MathmlLatexService

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

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.xsltObject

Returns the value of attribute xslt.



26
27
28
# File 'lib/mathml2latex/mathml_latex_service.rb', line 26

def xslt
  @xslt
end

Class Method Details

.get_service_objectObject



9
10
11
12
# File 'lib/mathml2latex/mathml_latex_service.rb', line 9

def self.get_service_object
  setup_xslt
  new
end

Instance Method Details

#to_latex(mathml) ⇒ Object



19
20
21
22
23
# File 'lib/mathml2latex/mathml_latex_service.rb', line 19

def to_latex(mathml)
  doc = Nokogiri::XML(mathml)
  result = self.class.xslt.transform(doc)
  result.at_xpath('//text()').text
end

#to_latex_from_file(mathml_file) ⇒ Object



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

def to_latex_from_file(mathml_file)
  mathml = File.open(mathml_file)
  to_latex(mathml)
end