Class: Plurimath::Latex::Parser

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

Constant Summary collapse

TEXT_REGEX =
%r(\\(?:mbox|text)\{[^\}]+\})

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ Parser

Returns a new instance of Parser.



13
14
15
# File 'lib/plurimath/latex/parser.rb', line 13

def initialize(text)
  @text = pre_processing(text)
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



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

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

  Math::Formula.new(formula)
end