Class: Plurimath::Latex::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/plurimath/latex/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Parser

Returns a new instance of Parser.



11
12
13
# File 'lib/plurimath/latex/parser.rb', line 11

def initialize(text)
  @text = text.gsub(" ", "").gsub("\n", "")
end

Instance Attribute Details

#textObject

Returns the value of attribute text.



9
10
11
# File 'lib/plurimath/latex/parser.rb', line 9

def text
  @text
end

Instance Method Details

#parseObject



15
16
17
18
19
20
21
# File 'lib/plurimath/latex/parser.rb', line 15

def parse
  tree_t = Plurimath::Latex::Parse.new.parse(text)
  formula = Plurimath::Latex::Transform.new.apply(tree_t)
  formula = [formula] unless formula.is_a?(Array)

  Plurimath::Math::Formula.new(formula)
end