Class: Plurimath::Html::Parser
- Inherits:
-
Object
- Object
- Plurimath::Html::Parser
- Defined in:
- lib/plurimath/html/parser.rb
Instance Attribute Summary collapse
-
#text ⇒ Object
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(text) ⇒ Parser
Returns a new instance of Parser.
13 14 15 |
# File 'lib/plurimath/html/parser.rb', line 13 def initialize(text) @text = ::CGI.unescapeHTML(text) end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
11 12 13 |
# File 'lib/plurimath/html/parser.rb', line 11 def text @text end |
Instance Method Details
#parse ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/plurimath/html/parser.rb', line 17 def parse nodes = Parse.new.parse(text) nodes = JSON.parse(nodes.to_json, symbolize_names: true) transformed_tree = Transform.new.apply(nodes) return transformed_tree if transformed_tree.is_a?(Math::Formula) Math::Formula.new(transformed_tree) end |