lib/plurimath/math/function/norm.rb in plurimath-0.6.0 vs lib/plurimath/math/function/norm.rb in plurimath-0.7.0
- old
+ new
@@ -4,36 +4,45 @@
module Plurimath
module Math
module Function
class Norm < UnaryFunction
+ attr_accessor :open_paren, :close_paren
+
def to_asciimath
parameter_one.is_a?(Table) ? "norm#{parameter_one.to_asciimath}" : super
end
def to_latex
"{\\lVert #{parameter_one&.to_latex} \\lVert}"
end
def to_mathml_without_math_tag
- first_value = parameter_one&.to_mathml_without_math_tag
- norm = Utility.ox_element("mo") << "∥"
- Utility.update_nodes(
- Utility.ox_element("mrow"),
- [
- norm,
- first_value,
- norm,
- ],
- )
+ first_value = Array(parameter_one&.to_mathml_without_math_tag)
+ norm = ox_element("mo") << "∥"
+ first_value = first_value.insert(0, norm) unless open_paren
+ first_value = first_value << norm unless close_paren
+ Utility.update_nodes(ox_element("mrow"), first_value)
end
def to_omml_without_math_tag(display_style)
- [
- r_element("∥"),
- omml_value(display_style),
- r_element("∥"),
- ]
+ array = []
+ array << r_element("∥") unless open_paren
+ array += Array(omml_value(display_style))
+ array << r_element("∥") unless close_paren
+ array
+ end
+
+ def line_breaking(obj)
+ parameter_one.line_breaking(obj)
+ if obj.value_exist?
+ norm_object = self.class.new(Utility.filter_values(obj.value))
+ norm_object.open_paren = true
+ norm_object.close_paren = false
+ obj.update(norm_object)
+ self.close_paren = true
+ self.open_paren = false unless open_paren
+ end
end
end
end
end
end