plurimath 0.6.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -0
  3. data/lib/plurimath/asciimath/parse.rb +3 -2
  4. data/lib/plurimath/asciimath/transform.rb +32 -5
  5. data/lib/plurimath/latex/constants.rb +2 -1
  6. data/lib/plurimath/latex/transform.rb +9 -13
  7. data/lib/plurimath/math/core.rb +134 -20
  8. data/lib/plurimath/math/formula.rb +88 -18
  9. data/lib/plurimath/math/function/abs.rb +28 -15
  10. data/lib/plurimath/math/function/bar.rb +5 -0
  11. data/lib/plurimath/math/function/base.rb +14 -0
  12. data/lib/plurimath/math/function/binary_function.rb +2 -8
  13. data/lib/plurimath/math/function/ceil.rb +24 -9
  14. data/lib/plurimath/math/function/ddot.rb +6 -1
  15. data/lib/plurimath/math/function/deg.rb +4 -1
  16. data/lib/plurimath/math/function/det.rb +4 -1
  17. data/lib/plurimath/math/function/dim.rb +4 -1
  18. data/lib/plurimath/math/function/dot.rb +5 -0
  19. data/lib/plurimath/math/function/exp.rb +4 -1
  20. data/lib/plurimath/math/function/fenced.rb +25 -16
  21. data/lib/plurimath/math/function/floor.rb +23 -13
  22. data/lib/plurimath/math/function/font_style.rb +18 -8
  23. data/lib/plurimath/math/function/frac.rb +32 -18
  24. data/lib/plurimath/math/function/gcd.rb +4 -1
  25. data/lib/plurimath/math/function/glb.rb +8 -1
  26. data/lib/plurimath/math/function/hat.rb +16 -5
  27. data/lib/plurimath/math/function/hom.rb +4 -1
  28. data/lib/plurimath/math/function/inf.rb +16 -0
  29. data/lib/plurimath/math/function/int.rb +28 -9
  30. data/lib/plurimath/math/function/ker.rb +4 -1
  31. data/lib/plurimath/math/function/lcm.rb +17 -1
  32. data/lib/plurimath/math/function/left.rb +1 -1
  33. data/lib/plurimath/math/function/lg.rb +4 -1
  34. data/lib/plurimath/math/function/lim.rb +10 -0
  35. data/lib/plurimath/math/function/liminf.rb +4 -1
  36. data/lib/plurimath/math/function/limits.rb +22 -9
  37. data/lib/plurimath/math/function/limsup.rb +4 -1
  38. data/lib/plurimath/math/function/linebreak.rb +95 -0
  39. data/lib/plurimath/math/function/ln.rb +4 -1
  40. data/lib/plurimath/math/function/log.rb +21 -12
  41. data/lib/plurimath/math/function/longdiv.rb +19 -0
  42. data/lib/plurimath/math/function/lub.rb +4 -1
  43. data/lib/plurimath/math/function/max.rb +4 -1
  44. data/lib/plurimath/math/function/mbox.rb +8 -7
  45. data/lib/plurimath/math/function/merror.rb +12 -3
  46. data/lib/plurimath/math/function/min.rb +4 -1
  47. data/lib/plurimath/math/function/mod.rb +42 -15
  48. data/lib/plurimath/math/function/msgroup.rb +4 -0
  49. data/lib/plurimath/math/function/msline.rb +10 -0
  50. data/lib/plurimath/math/function/multiscript.rb +20 -0
  51. data/lib/plurimath/math/function/nary.rb +39 -5
  52. data/lib/plurimath/math/function/norm.rb +24 -15
  53. data/lib/plurimath/math/function/obrace.rb +5 -0
  54. data/lib/plurimath/math/function/oint.rb +42 -20
  55. data/lib/plurimath/math/function/over.rb +23 -10
  56. data/lib/plurimath/math/function/overset.rb +13 -10
  57. data/lib/plurimath/math/function/phantom.rb +24 -6
  58. data/lib/plurimath/math/function/power.rb +13 -4
  59. data/lib/plurimath/math/function/power_base.rb +28 -6
  60. data/lib/plurimath/math/function/prod.rb +33 -14
  61. data/lib/plurimath/math/function/right.rb +1 -1
  62. data/lib/plurimath/math/function/rule.rb +1 -1
  63. data/lib/plurimath/math/function/scarries.rb +14 -0
  64. data/lib/plurimath/math/function/semantics.rb +9 -0
  65. data/lib/plurimath/math/function/sqrt.rb +5 -0
  66. data/lib/plurimath/math/function/stackrel.rb +8 -0
  67. data/lib/plurimath/math/function/substack.rb +12 -51
  68. data/lib/plurimath/math/function/sum.rb +43 -20
  69. data/lib/plurimath/math/function/sup.rb +11 -2
  70. data/lib/plurimath/math/function/table/array.rb +1 -1
  71. data/lib/plurimath/math/function/table/matrix.rb +4 -0
  72. data/lib/plurimath/math/function/table.rb +10 -2
  73. data/lib/plurimath/math/function/td.rb +14 -4
  74. data/lib/plurimath/math/function/ternary_function.rb +8 -10
  75. data/lib/plurimath/math/function/text.rb +1 -1
  76. data/lib/plurimath/math/function/tilde.rb +5 -0
  77. data/lib/plurimath/math/function/tr.rb +1 -1
  78. data/lib/plurimath/math/function/ubrace.rb +5 -0
  79. data/lib/plurimath/math/function/unary_function.rb +72 -26
  80. data/lib/plurimath/math/function/underover.rb +25 -8
  81. data/lib/plurimath/math/function/underset.rb +19 -9
  82. data/lib/plurimath/math/function/vec.rb +5 -0
  83. data/lib/plurimath/math/number.rb +3 -3
  84. data/lib/plurimath/math/symbol.rb +13 -5
  85. data/lib/plurimath/mathml/parser.rb +2 -0
  86. data/lib/plurimath/mathml/transform.rb +23 -15
  87. data/lib/plurimath/omml/transform.rb +22 -10
  88. data/lib/plurimath/unitsml.rb +2 -1
  89. data/lib/plurimath/utility.rb +29 -28
  90. data/lib/plurimath/version.rb +1 -1
  91. metadata +3 -3
  92. data/lib/plurimath/math/function/scarry.rb +0 -12
@@ -48,6 +48,16 @@ module Plurimath
48
48
  def to_omml_without_math_tag(display_style)
49
49
  underover(display_style)
50
50
  end
51
+
52
+ def line_breaking(obj)
53
+ parameter_one.line_breaking(obj)
54
+ if obj.value_exist?
55
+ obj.update(
56
+ Underover.new(nil, Utility.filter_values(obj.value), parameter_two)
57
+ )
58
+ self.parameter_two = nil
59
+ end
60
+ end
51
61
  end
52
62
  end
53
63
  end
@@ -7,7 +7,10 @@ module Plurimath
7
7
  module Function
8
8
  class Liminf < UnaryFunction
9
9
  def to_omml_without_math_tag(display_style)
10
- [r_element("liminf", rpr_tag: false), omml_value(display_style)]
10
+ array = []
11
+ array << r_element("liminf", rpr_tag: false) unless hide_function_name
12
+ array += Array(omml_value(display_style))
13
+ array
11
14
  end
12
15
  end
13
16
  end
@@ -15,10 +15,11 @@ module Plurimath
15
15
 
16
16
  def to_mathml_without_math_tag
17
17
  underover = Utility.ox_element("munderover")
18
- value_array = []
19
- value_array << parameter_one&.to_mathml_without_math_tag
20
- value_array << parameter_two&.to_mathml_without_math_tag
21
- value_array << parameter_three&.to_mathml_without_math_tag
18
+ value_array = [
19
+ validate_mathml_fields(parameter_one),
20
+ validate_mathml_fields(parameter_two),
21
+ validate_mathml_fields(parameter_three),
22
+ ]
22
23
  Utility.update_nodes(underover, value_array)
23
24
  end
24
25
 
@@ -30,11 +31,23 @@ module Plurimath
30
31
  end
31
32
 
32
33
  def to_omml_without_math_tag(display_style)
33
- value_array = []
34
- value_array << parameter_one.insert_t_tag(display_style) if parameter_one
35
- value_array << parameter_two.insert_t_tag(display_style) if parameter_two
36
- value_array << parameter_three.insert_t_tag(display_style) if parameter_three
37
- value_array
34
+ underover(display_style)
35
+ end
36
+
37
+ def line_breaking(obj)
38
+ parameter_one&.line_breaking(obj)
39
+ if obj.value_exist?
40
+ obj.update(self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three))
41
+ self.parameter_two = nil
42
+ self.parameter_three = nil
43
+ return
44
+ end
45
+
46
+ parameter_two&.line_breaking(obj)
47
+ if obj.value_exist?
48
+ obj.update(self.class.new(nil, Utility.filter_values(obj.value), parameter_three))
49
+ self.parameter_three = nil
50
+ end
38
51
  end
39
52
  end
40
53
  end
@@ -7,7 +7,10 @@ module Plurimath
7
7
  module Function
8
8
  class Limsup < UnaryFunction
9
9
  def to_omml_without_math_tag(display_style)
10
- [r_element("limsup", rpr_tag: false), omml_value(display_style)]
10
+ array = []
11
+ array << r_element("limsup", rpr_tag: false) unless hide_function_name
12
+ array += Array(omml_value(display_style))
13
+ array
11
14
  end
12
15
  end
13
16
  end
@@ -0,0 +1,95 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "unary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Linebreak < UnaryFunction
9
+ attr_accessor :attributes
10
+
11
+ def initialize(parameter_one = nil, attributes = {})
12
+ @parameter_one = parameter_one
13
+ @attributes = attributes
14
+ Utility.validate_left_right([parameter_one])
15
+ end
16
+
17
+ def ==(object)
18
+ object.class == self.class &&
19
+ object.parameter_one == parameter_one &&
20
+ object.linebreak == linebreak
21
+ end
22
+
23
+ def to_asciimath
24
+ linebreak_character = "\\\n "
25
+ return linebreak_character unless parameter_one
26
+
27
+ case attributes[:linebreakstyle]
28
+ when "after"
29
+ "#{asciimath_value}#{linebreak_character}"
30
+ else
31
+ "#{linebreak_character}#{asciimath_value}"
32
+ end
33
+ end
34
+
35
+ def to_latex
36
+ linebreak_character = "\\\\ "
37
+ return linebreak_character unless parameter_one
38
+
39
+ case attributes[:linebreakstyle]
40
+ when "after"
41
+ "#{latex_value}#{linebreak_character}"
42
+ else
43
+ "#{linebreak_character}#{latex_value}"
44
+ end
45
+ end
46
+
47
+ def to_mathml_without_math_tag
48
+ return Utility.ox_element("mo", attributes: { linebreak: "newline" }) unless parameter_one
49
+
50
+ mo_node = parameter_one.to_mathml_without_math_tag
51
+ mo_node.name = "mo" unless mo_node.name == "mo"
52
+ mo_node.attributes.merge!(attributes) unless attributes.empty?
53
+ mo_node
54
+ end
55
+
56
+ def to_html
57
+ br_tag = "<br/>"
58
+ return br_tag unless parameter_one
59
+
60
+ case attributes[:linebreakstyle]
61
+ when "after"
62
+ "#{parameter_one.to_html}#{br_tag}"
63
+ else
64
+ "#{br_tag}#{parameter_one.to_html}"
65
+ end
66
+ end
67
+
68
+ def to_omml_without_math_tag(display_style)
69
+ parameter_one&.insert_t_tag(display_style)
70
+ end
71
+
72
+ def omml_line_break(result)
73
+ result.first.pop
74
+ return result unless exist?
75
+
76
+ case attributes[:linebreakstyle]
77
+ when "after"
78
+ result[0] << parameter_one
79
+ else
80
+ result[1].insert(0, parameter_one)
81
+ end
82
+ result
83
+ end
84
+
85
+ def separate_table
86
+ true
87
+ end
88
+
89
+ def linebreak
90
+ true
91
+ end
92
+ end
93
+ end
94
+ end
95
+ end
@@ -11,7 +11,10 @@ module Plurimath
11
11
  end
12
12
 
13
13
  def to_omml_without_math_tag(display_style)
14
- [r_element("ln", rpr_tag: false), omml_value(display_style)]
14
+ array = []
15
+ array = r_element("ln", rpr_tag: false) unless hide_function_name
16
+ array += Array(omml_value(display_style))
17
+ array
15
18
  end
16
19
  end
17
20
  end
@@ -35,9 +35,7 @@ module Plurimath
35
35
 
36
36
  ssubsup = Utility.ox_element("sSubSup", namespace: "m")
37
37
  ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
38
- ssubsuppr << hide_tags(
39
- Utility.pr_element("ctrl", true, namespace: "m"),
40
- )
38
+ ssubsuppr << hide_tags(Utility.pr_element("ctrl", true, namespace: "m"))
41
39
  Utility.update_nodes(
42
40
  ssubsup,
43
41
  [
@@ -51,25 +49,36 @@ module Plurimath
51
49
  end
52
50
 
53
51
  def to_mathml_without_math_tag
54
- subsup_tag = Utility.ox_element("msubsup")
55
- first_value = (Utility.ox_element("mi") << "log")
52
+ first_value = ox_element("mi")
53
+ first_value << "log" unless hide_function_name
56
54
  if parameter_one || parameter_two
57
- new_arr = [first_value]
58
- new_arr << parameter_one&.to_mathml_without_math_tag
59
- new_arr << parameter_two&.to_mathml_without_math_tag
60
- Utility.update_nodes(
61
- subsup_tag,
62
- new_arr,
63
- )
55
+ new_arr = [
56
+ first_value,
57
+ validate_mathml_fields(parameter_one),
58
+ validate_mathml_fields(parameter_two),
59
+ ]
60
+ Utility.update_nodes(ox_element("msubsup"), new_arr)
64
61
  else
65
62
  first_value
66
63
  end
67
64
  end
68
65
 
66
+ def line_breaking(obj)
67
+ parameter_one&.line_breaking(obj)
68
+ if obj.value_exist?
69
+ log = self.class.new(Utility.filter_values(obj.value), parameter_two)
70
+ self.parameter_two = nil
71
+ log.hide_function_name = true
72
+ obj.update(log)
73
+ end
74
+ end
75
+
69
76
  protected
70
77
 
71
78
  def e_parameter
72
79
  e_tag = Utility.ox_element("e", namespace: "m")
80
+ return e_tag if hide_function_name
81
+
73
82
  e_tag << rpr_tag
74
83
  end
75
84
 
@@ -6,9 +6,28 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Longdiv < UnaryFunction
9
+ def to_asciimath
10
+ asciimath_value
11
+ end
12
+
13
+ def to_latex
14
+ latex_value
15
+ end
16
+
17
+ def to_mathml_without_math_tag
18
+ Utility.update_nodes(
19
+ ox_element("m#{class_name}"),
20
+ mathml_value,
21
+ )
22
+ end
23
+
9
24
  def to_omml_without_math_tag(display_style)
10
25
  omml_value(display_style)
11
26
  end
27
+
28
+ def line_breaking(obj)
29
+ custom_array_line_breaking(obj)
30
+ end
12
31
  end
13
32
  end
14
33
  end
@@ -11,7 +11,10 @@ module Plurimath
11
11
  end
12
12
 
13
13
  def to_omml_without_math_tag(display_style)
14
- [r_element("lub", rpr_tag: false), omml_value(display_style)]
14
+ array = []
15
+ array << r_element("lub", rpr_tag: false) unless hide_function_name
16
+ array += Array(omml_value(display_style))
17
+ array
15
18
  end
16
19
  end
17
20
  end
@@ -11,7 +11,10 @@ module Plurimath
11
11
  end
12
12
 
13
13
  def to_omml_without_math_tag(display_style)
14
- [r_element("max", rpr_tag: false), omml_value(display_style)]
14
+ array = []
15
+ array << r_element("max", rpr_tag: false) unless hide_function_name
16
+ array += Array(omml_value(display_style))
17
+ array
15
18
  end
16
19
  end
17
20
  end
@@ -5,23 +5,24 @@ module Plurimath
5
5
  module Math
6
6
  module Function
7
7
  class Mbox < UnaryFunction
8
+ def to_asciimath
9
+ Text.new(parameter_one).to_asciimath
10
+ end
11
+
8
12
  def to_mathml_without_math_tag
9
- text = Utility.ox_element("mtext")
10
- text << (parameter_one.to_mathml_without_math_tag) if parameter_one
11
- text
13
+ Text.new(parameter_one).to_mathml_without_math_tag
12
14
  end
13
15
 
14
16
  def to_latex
15
- first_value = parameter_one&.to_latex
16
- "\\mbox{#{first_value}}"
17
+ "\\mbox{#{parameter_one}}"
17
18
  end
18
19
 
19
20
  def to_html
20
- parameter_one&.to_html
21
+ parameter_one
21
22
  end
22
23
 
23
24
  def to_omml_without_math_tag(display_style)
24
- omml_value(display_style)
25
+ Text.new(parameter_one).to_omml_without_math_tag(display_style)
25
26
  end
26
27
  end
27
28
  end
@@ -1,12 +1,21 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
3
+ require_relative "unary_function"
4
4
 
5
5
  module Plurimath
6
6
  module Math
7
7
  module Function
8
- class Merror < BinaryFunction
9
- def to_omml_without_math_tag(display_style); end
8
+ class Merror < UnaryFunction
9
+ def to_asciimath;end
10
+
11
+ def to_latex;end
12
+
13
+ def to_mathml_without_math_tag
14
+ merror = Utility.ox_element("merror")
15
+ Utility.update_nodes(merror, mathml_value)
16
+ end
17
+
18
+ def to_omml_without_math_tag(_); end
10
19
  end
11
20
  end
12
21
  end
@@ -11,7 +11,10 @@ module Plurimath
11
11
  end
12
12
 
13
13
  def to_omml_without_math_tag(display_style)
14
- [r_element("min", rpr_tag: false), omml_value(display_style)]
14
+ array = []
15
+ array << r_element("min", rpr_tag: false) unless hide_function_name
16
+ array += Array(omml_value(display_style))
17
+ array
15
18
  end
16
19
  end
17
20
  end
@@ -19,18 +19,12 @@ module Plurimath
19
19
  end
20
20
 
21
21
  def to_mathml_without_math_tag
22
- mrow_tag = Utility.ox_element("mrow")
23
- mo_tag = Utility.ox_element("mi") << "mod"
24
- first_value = parameter_one&.to_mathml_without_math_tag if parameter_one
25
- second_value = parameter_two&.to_mathml_without_math_tag if parameter_two
26
- Utility.update_nodes(
27
- mrow_tag,
28
- [
29
- first_value,
30
- mo_tag,
31
- second_value,
32
- ],
33
- )
22
+ mi_tag = ox_element("mi")
23
+ mi_tag << "mod" unless hide_function_name
24
+ value_array = [mi_tag]
25
+ value_array.insert(0, parameter_one&.to_mathml_without_math_tag) if parameter_one
26
+ value_array << parameter_two&.to_mathml_without_math_tag if parameter_two
27
+ Utility.update_nodes(ox_element("mrow"), value_array)
34
28
  end
35
29
 
36
30
  def to_latex
@@ -47,11 +41,44 @@ module Plurimath
47
41
 
48
42
  def to_omml_without_math_tag(display_style)
49
43
  values = []
50
- values << parameter_one.insert_t_tag(display_style) if parameter_one
51
- values << r_element("mod")
52
- values << parameter_two.insert_t_tag(display_style) if parameter_two
44
+ first_value(display_style, values)
45
+ values << r_element("mod") unless hide_function_name
46
+ second_value(display_style, values)
53
47
  values
54
48
  end
49
+
50
+ def line_breaking(obj)
51
+ parameter_one&.line_breaking(obj)
52
+ if obj.value_exist?
53
+ mod = self.class.new(Utility.filter_values(obj.value), parameter_two)
54
+ mod.hide_function_name = false
55
+ self.hide_function_name = true
56
+ obj.update(mod)
57
+ self.parameter_two = nil
58
+ return
59
+ end
60
+
61
+ parameter_two&.line_breaking(obj)
62
+ if obj.value_exist?
63
+ mod = self.class.new(nil, Utility.filter_values(obj.value))
64
+ mod.hide_function_name = true
65
+ obj.update(mod)
66
+ end
67
+ end
68
+
69
+ protected
70
+
71
+ def first_value(display_style, values)
72
+ return unless parameter_one
73
+
74
+ values << parameter_one.insert_t_tag(display_style)
75
+ end
76
+
77
+ def second_value(display_style, values)
78
+ return unless parameter_two
79
+
80
+ values << parameter_two.insert_t_tag(display_style)
81
+ end
55
82
  end
56
83
  end
57
84
  end
@@ -56,6 +56,10 @@ module Plurimath
56
56
  Formula.new(parameter_one).to_omml_math_zone(gsub_spacing(spacing, last), last, indent, display_style: display_style),
57
57
  ]
58
58
  end
59
+
60
+ def line_breaking(obj)
61
+ custom_array_line_breaking(obj)
62
+ end
59
63
  end
60
64
  end
61
65
  end
@@ -6,9 +6,19 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Msline < UnaryFunction
9
+ def to_asciimath;end
10
+
11
+ def to_latex;end
12
+
13
+ def to_mathml_without_math_tag
14
+ ox_element("msline")
15
+ end
16
+
9
17
  def to_omml_without_math_tag(display_style)
10
18
  omml_value(display_style)
11
19
  end
20
+
21
+ def to_omml_without_math_tag(display_style);end
12
22
  end
13
23
  end
14
24
  end
@@ -26,6 +26,26 @@ module Plurimath
26
26
  )
27
27
  [pre_element]
28
28
  end
29
+
30
+ def line_breaking(obj)
31
+ parameter_one&.line_breaking(obj)
32
+ if obj.value_exist?
33
+ obj.update(
34
+ self.class.new(Utility.filter_values(obj.value), parameter_two, parameter_three)
35
+ )
36
+ self.parameter_two = nil
37
+ self.parameter_three = nil
38
+ return
39
+ end
40
+
41
+ parameter_two.line_breaking(obj)
42
+ if obj.value_exist?
43
+ obj.update(
44
+ self.class.new(nil, Utility.filter_values(obj.value), parameter_three)
45
+ )
46
+ self.parameter_three = nil
47
+ end
48
+ end
29
49
  end
30
50
  end
31
51
  end
@@ -46,12 +46,22 @@ module Plurimath
46
46
 
47
47
  def to_mathml_without_math_tag
48
48
  tag_name = options[:type] == "undOvr" ? "munderover" : "msubsup"
49
- subsup_tag = Utility.ox_element(tag_name)
50
- new_arr = []
51
- new_arr << validate_mathml_fields(parameter_one)
52
- new_arr << validate_mathml_fields(parameter_two)
53
- new_arr << validate_mathml_fields(parameter_three)
49
+ subsup_tag = ox_element(tag_name)
50
+ new_arr = [
51
+ validate_mathml_fields(parameter_one),
52
+ validate_mathml_fields(parameter_two),
53
+ validate_mathml_fields(parameter_three),
54
+ ]
54
55
  Utility.update_nodes(subsup_tag, new_arr)
56
+ return subsup_tag unless parameter_four
57
+
58
+ Utility.update_nodes(
59
+ ox_element("mrow"),
60
+ [
61
+ subsup_tag,
62
+ parameter_four&.to_mathml_without_math_tag,
63
+ ],
64
+ )
55
65
  end
56
66
 
57
67
  def to_omml_without_math_tag(display_style)
@@ -60,6 +70,30 @@ module Plurimath
60
70
  Array(nary_element)
61
71
  end
62
72
 
73
+ def line_breaking(obj)
74
+ parameter_one&.line_breaking(obj)
75
+ if obj.value_exist?
76
+ obj.update(self.class.new(Utility.filter_values(obj.value), self.parameter_two, self.parameter_three, self.parameter_four))
77
+ self.parameter_two = nil
78
+ self.parameter_three = nil
79
+ self.parameter_four = nil
80
+ return
81
+ end
82
+
83
+ parameter_two&.line_breaking(obj)
84
+ if obj.value_exist?
85
+ obj.update(self.class.new(nil, Utility.filter_values(obj.value), self.parameter_three, self.parameter_four))
86
+ self.parameter_three = nil
87
+ self.parameter_four = nil
88
+ return
89
+ end
90
+
91
+ parameter_four&.line_breaking(obj)
92
+ if obj.value_exist?
93
+ obj.update(Utility.filter_values(obj.value))
94
+ end
95
+ end
96
+
63
97
  protected
64
98
 
65
99
  def chr_value(narypr)
@@ -6,6 +6,8 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Norm < UnaryFunction
9
+ attr_accessor :open_paren, :close_paren
10
+
9
11
  def to_asciimath
10
12
  parameter_one.is_a?(Table) ? "norm#{parameter_one.to_asciimath}" : super
11
13
  end
@@ -15,24 +17,31 @@ module Plurimath
15
17
  end
16
18
 
17
19
  def to_mathml_without_math_tag
18
- first_value = parameter_one&.to_mathml_without_math_tag
19
- norm = Utility.ox_element("mo") << "&#x2225;"
20
- Utility.update_nodes(
21
- Utility.ox_element("mrow"),
22
- [
23
- norm,
24
- first_value,
25
- norm,
26
- ],
27
- )
20
+ first_value = Array(parameter_one&.to_mathml_without_math_tag)
21
+ norm = ox_element("mo") << "&#x2225;"
22
+ first_value = first_value.insert(0, norm) unless open_paren
23
+ first_value = first_value << norm unless close_paren
24
+ Utility.update_nodes(ox_element("mrow"), first_value)
28
25
  end
29
26
 
30
27
  def to_omml_without_math_tag(display_style)
31
- [
32
- r_element("∥"),
33
- omml_value(display_style),
34
- r_element("∥"),
35
- ]
28
+ array = []
29
+ array << r_element("∥") unless open_paren
30
+ array += Array(omml_value(display_style))
31
+ array << r_element("∥") unless close_paren
32
+ array
33
+ end
34
+
35
+ def line_breaking(obj)
36
+ parameter_one.line_breaking(obj)
37
+ if obj.value_exist?
38
+ norm_object = self.class.new(Utility.filter_values(obj.value))
39
+ norm_object.open_paren = true
40
+ norm_object.close_paren = false
41
+ obj.update(norm_object)
42
+ self.close_paren = true
43
+ self.open_paren = false unless open_paren
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -53,6 +53,11 @@ module Plurimath
53
53
  end
54
54
  end
55
55
 
56
+ def line_breaking(obj)
57
+ parameter_one&.line_breaking(obj)
58
+ obj.update(Utility.filter_values(obj.value)) if obj.value_exist?
59
+ end
60
+
56
61
  protected
57
62
 
58
63
  def acc_tag(display_style)