Class: Plurimath::Mathml::Parser
- Inherits:
-
Object
- Object
- Plurimath::Mathml::Parser
- Defined in:
- lib/plurimath/mathml/parser.rb
Constant Summary collapse
- SUPPORTED_ATTRS =
%w[ linebreakstyle linethickness columnlines mathvariant accentunder separators linebreak mathcolor notation bevelled rowlines intent accent height frame depth height width index close alt src open ].freeze
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.
36 37 38 |
# File 'lib/plurimath/mathml/parser.rb', line 36 def initialize(text) @text = text end |
Instance Attribute Details
#text ⇒ Object
Returns the value of attribute text.
8 9 10 |
# File 'lib/plurimath/mathml/parser.rb', line 8 def text @text end |
Instance Method Details
#parse ⇒ Object
40 41 42 43 44 45 46 47 48 |
# File 'lib/plurimath/mathml/parser.rb', line 40 def parse ox_nodes = Plurimath.xml_engine.load(text) display_style = ox_nodes&.locate("mstyle/@displaystyle")&.first nodes = parse_nodes(Array(ox_nodes)) Math::Formula.new( Transform.new.apply(nodes).flatten.compact, display_style: (display_style || true), ) end |