class Mathml2latex::MathmlLatexService
Attributes
xslt[RW]
Public Class Methods
get_service_object()
click to toggle source
# File lib/mathml2latex/mathml_latex_service.rb, line 11 def self.get_service_object # rubocop:disable Naming/AccessorMethodName setup_xslt new end
Private Class Methods
initialized?()
click to toggle source
# File lib/mathml2latex/mathml_latex_service.rb, line 32 def initialized? !@xslt.nil? end
setup_xslt()
click to toggle source
# File lib/mathml2latex/mathml_latex_service.rb, line 36 def setup_xslt return if initialized? Nokogiri::XSLT.register Mathml2latex::INSTUCTURE_NAMESPACE, XsltFunctions path = File.join(File.dirname(__FILE__), 'xslt', 'mml2latex.xsl') @xslt = Nokogiri::XSLT(File.open(path)) end
Public Instance Methods
to_latex(mathml)
click to toggle source
# File lib/mathml2latex/mathml_latex_service.rb, line 21 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)
click to toggle source
# File lib/mathml2latex/mathml_latex_service.rb, line 16 def to_latex_from_file(mathml_file) mathml = File.open(mathml_file) to_latex(mathml) end