Class: MathTypeToMathML::Converter

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

Instance Method Summary collapse

Constructor Details

#initialize(mathtype) ⇒ Converter

Returns a new instance of Converter.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/mathtype_to_mathml.rb', line 10

def initialize(mathtype)
  @xslt = Nokogiri::XSLT(File.open(path_to_xslt))

  @mathtype = Mathtype::Converter.new(mathtype).xml.doc

  # Addresses lack of scaning mode in our translator. See "Mover" for more.
  mover = Mover.new(@mathtype)
  mover.move

  # Character ranges are tricky in XSLT 1.0, so we deal with them in Ruby
  char_replacer = CharReplacer.new(@mathtype)
  char_replacer.replace
end

Instance Method Details

#convertObject



24
25
26
# File 'lib/mathtype_to_mathml.rb', line 24

def convert
  @xslt.transform(@mathtype).to_s
end

#path_to_xsltObject



28
29
30
# File 'lib/mathtype_to_mathml.rb', line 28

def path_to_xslt
  File.join(File.dirname(File.expand_path(__FILE__)), "transform.xsl")
end