lib/plurimath/math/formula.rb in plurimath-0.3.0 vs lib/plurimath/math/formula.rb in plurimath-0.3.1
- old
+ new
@@ -1,18 +1,21 @@
# frozen_string_literal: true
module Plurimath
module Math
class Formula
- attr_accessor :value
+ attr_accessor :value, :left_right_wrapper
- def initialize(value = [])
+ def initialize(value = [], left_right_wrapper = true)
@value = value.is_a?(Array) ? value : [value]
+ left_right_wrapper = false if @value.first.is_a?(Function::Left)
+ @left_right_wrapper = left_right_wrapper
end
def ==(object)
- object.value == value
+ object.value == value &&
+ object.left_right_wrapper == left_right_wrapper
end
def to_asciimath
value.map(&:to_asciimath).join(" ")
end
@@ -29,9 +32,11 @@
Utility.update_nodes(math, [style])
Ox.dump(math, indent: 2).gsub("&", "&")
end
def to_mathml_without_math_tag
+ return mathml_content unless left_right_wrapper
+
Utility.update_nodes(
Utility.ox_element("mrow"),
mathml_content,
)
end