plurimath 0.3.8 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plurimath/asciimath/transform.rb +17 -0
  3. data/lib/plurimath/math/core.rb +20 -4
  4. data/lib/plurimath/math/formula.rb +42 -25
  5. data/lib/plurimath/math/function/abs.rb +2 -2
  6. data/lib/plurimath/math/function/bar.rb +43 -12
  7. data/lib/plurimath/math/function/base.rb +3 -3
  8. data/lib/plurimath/math/function/binary_function.rb +21 -5
  9. data/lib/plurimath/math/function/cancel.rb +2 -2
  10. data/lib/plurimath/math/function/ceil.rb +7 -2
  11. data/lib/plurimath/math/function/color.rb +2 -2
  12. data/lib/plurimath/math/function/ddot.rb +10 -12
  13. data/lib/plurimath/math/function/deg.rb +2 -2
  14. data/lib/plurimath/math/function/det.rb +2 -2
  15. data/lib/plurimath/math/function/dim.rb +2 -2
  16. data/lib/plurimath/math/function/dot.rb +21 -4
  17. data/lib/plurimath/math/function/exp.rb +2 -2
  18. data/lib/plurimath/math/function/fenced.rb +2 -1
  19. data/lib/plurimath/math/function/floor.rb +2 -2
  20. data/lib/plurimath/math/function/font_style/bold-fraktur.rb +17 -0
  21. data/lib/plurimath/math/function/font_style/bold-italic.rb +17 -0
  22. data/lib/plurimath/math/function/font_style/bold-sans-serif.rb +17 -0
  23. data/lib/plurimath/math/function/font_style/bold-script.rb +17 -0
  24. data/lib/plurimath/math/function/font_style/bold.rb +4 -0
  25. data/lib/plurimath/math/function/font_style/double_struck.rb +4 -0
  26. data/lib/plurimath/math/function/font_style/fraktur.rb +4 -0
  27. data/lib/plurimath/math/function/font_style/italic.rb +4 -0
  28. data/lib/plurimath/math/function/font_style/monospace.rb +4 -0
  29. data/lib/plurimath/math/function/font_style/normal.rb +4 -0
  30. data/lib/plurimath/math/function/font_style/sans-serif-bold-italic.rb +17 -0
  31. data/lib/plurimath/math/function/font_style/sans-serif-italic.rb +17 -0
  32. data/lib/plurimath/math/function/font_style/sans-serif.rb +4 -0
  33. data/lib/plurimath/math/function/font_style/script.rb +4 -0
  34. data/lib/plurimath/math/function/font_style.rb +22 -4
  35. data/lib/plurimath/math/function/frac.rb +3 -3
  36. data/lib/plurimath/math/function/gcd.rb +2 -2
  37. data/lib/plurimath/math/function/glb.rb +2 -2
  38. data/lib/plurimath/math/function/hat.rb +37 -11
  39. data/lib/plurimath/math/function/hom.rb +2 -2
  40. data/lib/plurimath/math/function/inf.rb +3 -9
  41. data/lib/plurimath/math/function/int.rb +4 -4
  42. data/lib/plurimath/math/function/ker.rb +2 -2
  43. data/lib/plurimath/math/function/lcm.rb +2 -2
  44. data/lib/plurimath/math/function/left.rb +1 -1
  45. data/lib/plurimath/math/function/lg.rb +2 -2
  46. data/lib/plurimath/math/function/lim.rb +2 -8
  47. data/lib/plurimath/math/function/liminf.rb +2 -2
  48. data/lib/plurimath/math/function/limits.rb +4 -4
  49. data/lib/plurimath/math/function/limsup.rb +2 -2
  50. data/lib/plurimath/math/function/ln.rb +2 -2
  51. data/lib/plurimath/math/function/log.rb +5 -3
  52. data/lib/plurimath/math/function/longdiv.rb +2 -2
  53. data/lib/plurimath/math/function/lub.rb +2 -2
  54. data/lib/plurimath/math/function/max.rb +2 -2
  55. data/lib/plurimath/math/function/mbox.rb +2 -2
  56. data/lib/plurimath/math/function/menclose.rb +2 -2
  57. data/lib/plurimath/math/function/merror.rb +1 -1
  58. data/lib/plurimath/math/function/min.rb +2 -2
  59. data/lib/plurimath/math/function/mod.rb +3 -3
  60. data/lib/plurimath/math/function/msgroup.rb +2 -2
  61. data/lib/plurimath/math/function/msline.rb +2 -2
  62. data/lib/plurimath/math/function/multiscript.rb +4 -4
  63. data/lib/plurimath/math/function/norm.rb +2 -2
  64. data/lib/plurimath/math/function/obrace.rb +35 -28
  65. data/lib/plurimath/math/function/oint.rb +15 -16
  66. data/lib/plurimath/math/function/over.rb +3 -3
  67. data/lib/plurimath/math/function/overset.rb +8 -3
  68. data/lib/plurimath/math/function/power.rb +3 -3
  69. data/lib/plurimath/math/function/power_base.rb +10 -8
  70. data/lib/plurimath/math/function/prod.rb +8 -4
  71. data/lib/plurimath/math/function/right.rb +1 -1
  72. data/lib/plurimath/math/function/root.rb +3 -3
  73. data/lib/plurimath/math/function/rule.rb +1 -1
  74. data/lib/plurimath/math/function/scarries.rb +2 -2
  75. data/lib/plurimath/math/function/semantics.rb +2 -2
  76. data/lib/plurimath/math/function/sqrt.rb +2 -2
  77. data/lib/plurimath/math/function/stackrel.rb +3 -3
  78. data/lib/plurimath/math/function/substack.rb +3 -3
  79. data/lib/plurimath/math/function/sum.rb +22 -19
  80. data/lib/plurimath/math/function/sup.rb +2 -2
  81. data/lib/plurimath/math/function/table.rb +7 -11
  82. data/lib/plurimath/math/function/td.rb +2 -2
  83. data/lib/plurimath/math/function/ternary_function.rb +11 -0
  84. data/lib/plurimath/math/function/text.rb +6 -5
  85. data/lib/plurimath/math/function/tilde.rb +22 -4
  86. data/lib/plurimath/math/function/tr.rb +2 -2
  87. data/lib/plurimath/math/function/ubrace.rb +27 -23
  88. data/lib/plurimath/math/function/ul.rb +50 -20
  89. data/lib/plurimath/math/function/unary_function.rb +7 -5
  90. data/lib/plurimath/math/function/underover.rb +10 -8
  91. data/lib/plurimath/math/function/underset.rb +8 -3
  92. data/lib/plurimath/math/function/vec.rb +20 -5
  93. data/lib/plurimath/math/number.rb +6 -2
  94. data/lib/plurimath/math/symbol.rb +14 -2
  95. data/lib/plurimath/math.rb +4 -1
  96. data/lib/plurimath/mathml/constants.rb +9 -1
  97. data/lib/plurimath/mathml/parser.rb +4 -2
  98. data/lib/plurimath/mathml/transform.rb +51 -22
  99. data/lib/plurimath/omml/parser.rb +24 -1
  100. data/lib/plurimath/omml/transform.rb +43 -36
  101. data/lib/plurimath/utility.rb +114 -9
  102. data/lib/plurimath/version.rb +1 -1
  103. metadata +8 -2
@@ -5,16 +5,16 @@ module Plurimath
5
5
  module Math
6
6
  module Function
7
7
  class Multiscript < TernaryFunction
8
- def to_omml_without_math_tag
8
+ def to_omml_without_math_tag(display_style)
9
9
  pre_element = Utility.ox_element("sPre", namespace: "m")
10
10
  pr_element = Utility.ox_element("sPrePr", namespace: "m")
11
11
  Utility.update_nodes(
12
12
  pre_element,
13
13
  [
14
14
  pr_element << Utility.pr_element("ctrl", true, namespace: "m"),
15
- omml_parameter(parameter_two, tag_name: "sub"),
16
- omml_parameter(parameter_three, tag_name: "sup"),
17
- omml_parameter(parameter_one, tag_name: "e"),
15
+ omml_parameter(parameter_two, display_style, tag_name: "sub"),
16
+ omml_parameter(parameter_three, display_style, tag_name: "sup"),
17
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
18
18
  ],
19
19
  )
20
20
  [pre_element]
@@ -27,10 +27,10 @@ module Plurimath
27
27
  )
28
28
  end
29
29
 
30
- def to_omml_without_math_tag
30
+ def to_omml_without_math_tag(display_style)
31
31
  [
32
32
  r_element("∥"),
33
- omml_value,
33
+ omml_value(display_style),
34
34
  r_element("∥"),
35
35
  ]
36
36
  end
@@ -1,11 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "unary_function"
3
+ require_relative "binary_function"
4
4
 
5
5
  module Plurimath
6
6
  module Math
7
7
  module Function
8
- class Obrace < UnaryFunction
8
+ class Obrace < BinaryFunction
9
+ def to_asciimath
10
+ first_value = "(#{parameter_one.to_asciimath})" if parameter_one
11
+ "obrace#{first_value}"
12
+ end
13
+
9
14
  def to_latex
10
15
  first_value = "{#{parameter_one.to_latex}}" if parameter_one
11
16
  "\\overbrace#{first_value}"
@@ -13,46 +18,48 @@ module Plurimath
13
18
 
14
19
  def to_mathml_without_math_tag
15
20
  mo_tag = (Utility.ox_element("mo") << "&#x23de;")
16
- if parameter_one
17
- over_tag = Utility.ox_element("mover")
18
- arr_value = mathml_value
19
- Utility.update_nodes(over_tag, (arr_value << mo_tag))
20
- else
21
- mo_tag
22
- end
21
+ return mo_tag unless parameter_one
22
+
23
+ over_tag = Utility.ox_element("mover")
24
+ over_tag.attributes.merge!(parameter_two) if parameter_two && !parameter_two.empty?
25
+ Utility.update_nodes(
26
+ over_tag,
27
+ [
28
+ parameter_one.to_mathml_without_math_tag,
29
+ mo_tag,
30
+ ],
31
+ )
23
32
  end
24
33
 
25
34
  def validate_function_formula
26
35
  false
27
36
  end
28
37
 
29
- def to_omml_without_math_tag
30
- groupchr = Utility.ox_element("groupChr", namespace: "m")
31
- Utility.update_nodes(
32
- groupchr,
33
- [
34
- group_chr_pr,
35
- omml_parameter(parameter_one, tag_name: "e"),
36
- ],
37
- )
38
- [groupchr]
38
+ def to_omml_without_math_tag(display_style)
39
+ return r_element("", rpr_tag: false) unless all_values_exist?
40
+
41
+ if parameter_two && parameter_two[:accent]
42
+ acc_tag(display_style)
43
+ else
44
+ symbol = Symbol.new("")
45
+ Overset.new(parameter_one, symbol).to_omml_without_math_tag(true)
46
+ end
39
47
  end
40
48
 
41
49
  protected
42
50
 
43
- def group_chr_pr
44
- groupchrpr = Utility.ox_element("groupChrPr", namespace: "m")
45
- vert_jc = Utility.ox_element("vertJc", namespace: "m", attributes: { "m:val": "bot" })
46
- chr = Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "⏞" })
47
- pos = Utility.ox_element("pos", namespace: "m", attributes: { "m:val": "top" })
51
+ def acc_tag(display_style)
52
+ acc_tag = Utility.ox_element("acc", namespace: "m")
53
+ acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
54
+ acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "⏞" }))
48
55
  Utility.update_nodes(
49
- groupchrpr,
56
+ acc_tag,
50
57
  [
51
- chr,
52
- pos,
53
- vert_jc,
58
+ acc_pr_tag,
59
+ omml_parameter(parameter_one, display_style, tag_name: "e", namespace: "m"),
54
60
  ],
55
61
  )
62
+ [acc_tag]
56
63
  end
57
64
  end
58
65
 
@@ -22,17 +22,16 @@ module Plurimath
22
22
  mo_tag = Utility.ox_element("mo") << invert_unicode_symbols.to_s
23
23
  return mo_tag unless all_values_exist?
24
24
 
25
- msubsup_tag = Utility.ox_element("msubsup")
26
- first_value = parameter_one&.to_mathml_without_math_tag if parameter_one
27
- second_value = parameter_two&.to_mathml_without_math_tag if parameter_two
28
- Utility.update_nodes(
29
- msubsup_tag,
30
- [
31
- mo_tag,
32
- first_value,
33
- second_value,
34
- ],
35
- )
25
+ value_array = [mo_tag]
26
+ value_array << parameter_one&.to_mathml_without_math_tag
27
+ value_array << parameter_two&.to_mathml_without_math_tag
28
+ tag_name = if parameter_one && parameter_two
29
+ "subsup"
30
+ else
31
+ parameter_one ? "sub" : "sup"
32
+ end
33
+ msubsup_tag = Utility.ox_element("m#{tag_name}")
34
+ Utility.update_nodes(msubsup_tag, value_array)
36
35
  return msubsup_tag if parameter_three.nil?
37
36
 
38
37
  Utility.update_nodes(
@@ -40,20 +39,20 @@ module Plurimath
40
39
  [
41
40
  msubsup_tag,
42
41
  parameter_three&.to_mathml_without_math_tag,
43
- ].flatten.compact,
42
+ ].compact,
44
43
  )
45
44
  end
46
45
 
47
- def to_omml_without_math_tag
46
+ def to_omml_without_math_tag(display_style)
48
47
  if all_values_exist?
49
48
  nary = Utility.ox_element("nary", namespace: "m")
50
49
  Utility.update_nodes(
51
50
  nary,
52
51
  [
53
52
  narypr("∮", function_type: "subSup"),
54
- omml_parameter(parameter_one, tag_name: "sub"),
55
- omml_parameter(parameter_two, tag_name: "sup"),
56
- omml_parameter(parameter_three, tag_name: "e"),
53
+ omml_parameter(parameter_one, display_style, tag_name: "sub"),
54
+ omml_parameter(parameter_two, display_style, tag_name: "sup"),
55
+ omml_parameter(parameter_three, display_style, tag_name: "e"),
57
56
  ],
58
57
  )
59
58
  [nary]
@@ -31,15 +31,15 @@ module Plurimath
31
31
  "{#{first_value} \\over #{two_value}}"
32
32
  end
33
33
 
34
- def to_omml_without_math_tag
34
+ def to_omml_without_math_tag(display_style)
35
35
  f_element = Utility.ox_element("f", namespace: "m")
36
36
  fpr_element = Utility.ox_element("fPr", namespace: "m")
37
37
  Utility.update_nodes(
38
38
  f_element,
39
39
  [
40
40
  fpr_element << Utility.pr_element("ctrl", true, namespace: "m"),
41
- omml_parameter(parameter_one, tag_name: "num"),
42
- omml_parameter(parameter_two, tag_name: "den"),
41
+ omml_parameter(parameter_one, display_style, tag_name: "num"),
42
+ omml_parameter(parameter_two, display_style, tag_name: "den"),
43
43
  ],
44
44
  )
45
45
  [f_element]
@@ -19,7 +19,12 @@ module Plurimath
19
19
  )
20
20
  end
21
21
 
22
- def to_omml_without_math_tag
22
+ def to_omml_without_math_tag(display_style)
23
+ if !display_style
24
+ power = Power.new(parameter_one, parameter_two)
25
+ return power.to_omml_without_math_tag(display_style)
26
+ end
27
+
23
28
  limupp = Utility.ox_element("limUpp", namespace: "m")
24
29
  limupppr = Utility.ox_element("limUppPr", namespace: "m")
25
30
  limupppr << Utility.pr_element("ctrl", true, namespace: "m")
@@ -27,8 +32,8 @@ module Plurimath
27
32
  limupp,
28
33
  [
29
34
  limupppr,
30
- omml_parameter(parameter_one, tag_name: "e"),
31
- omml_parameter(parameter_two, tag_name: "lim"),
35
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
36
+ omml_parameter(parameter_two, display_style, tag_name: "lim"),
32
37
  ],
33
38
  )
34
39
  [limupp]
@@ -31,7 +31,7 @@ module Plurimath
31
31
  "#{first_value}#{second_value}"
32
32
  end
33
33
 
34
- def to_omml_without_math_tag
34
+ def to_omml_without_math_tag(display_style)
35
35
  ssup_element = Utility.ox_element("sSup", namespace: "m")
36
36
  suppr_element = Utility.ox_element("sSupPr", namespace: "m")
37
37
  suppr_element << Utility.pr_element("ctrl", true, namespace: "m")
@@ -39,8 +39,8 @@ module Plurimath
39
39
  ssup_element,
40
40
  [
41
41
  suppr_element,
42
- omml_parameter(parameter_one, tag_name: "e"),
43
- omml_parameter(parameter_two, tag_name: "sup"),
42
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
43
+ omml_parameter(parameter_two, display_style, tag_name: "sup"),
44
44
  ],
45
45
  )
46
46
  [ssup_element]
@@ -29,24 +29,26 @@ module Plurimath
29
29
  "#{first_value}#{second_value}#{third_value}"
30
30
  end
31
31
 
32
- def omml_nary_tag
32
+ def omml_nary_tag(display_style)
33
33
  narypr = Utility.ox_element("naryPr", namespace: "m")
34
34
  chr_value(narypr)
35
35
  narypr << Utility.ox_element(
36
36
  "limLoc",
37
37
  namespace: "m",
38
- attributes: { "m:val": "subSup" },
38
+ attributes: { "m:val": parameter_one.omml_tag_name },
39
39
  )
40
40
  hide_tags(narypr)
41
41
  narypr << Utility.pr_element("ctrl", true, namespace: "m")
42
42
  [
43
43
  narypr,
44
- omml_parameter(parameter_two, tag_name: "sub"),
45
- omml_parameter(parameter_three, tag_name: "sup"),
44
+ omml_parameter(parameter_two, display_style, tag_name: "sub"),
45
+ omml_parameter(parameter_three, display_style, tag_name: "sup"),
46
46
  ]
47
47
  end
48
48
 
49
- def to_omml_without_math_tag
49
+ def to_omml_without_math_tag(display_style)
50
+ return underover(display_style) if parameter_one.omml_tag_name == "undOvr"
51
+
50
52
  ssubsup = Utility.ox_element("sSubSup", namespace: "m")
51
53
  ssubsuppr = Utility.ox_element("sSubSupPr", namespace: "m")
52
54
  ssubsuppr << hide_tags(
@@ -56,9 +58,9 @@ module Plurimath
56
58
  ssubsup,
57
59
  [
58
60
  ssubsuppr,
59
- omml_parameter(parameter_one, tag_name: "e"),
60
- omml_parameter(parameter_two, tag_name: "sub"),
61
- omml_parameter(parameter_three, tag_name: "sup"),
61
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
62
+ omml_parameter(parameter_two, display_style, tag_name: "sub"),
63
+ omml_parameter(parameter_three, display_style, tag_name: "sup"),
62
64
  ],
63
65
  )
64
66
  [ssubsup]
@@ -54,16 +54,16 @@ module Plurimath
54
54
  "<i>&prod;</i>#{first_value}#{second_value}"
55
55
  end
56
56
 
57
- def to_omml_without_math_tag
57
+ def to_omml_without_math_tag(display_style)
58
58
  if all_values_exist?
59
59
  nary = Utility.ox_element("nary", namespace: "m")
60
60
  Utility.update_nodes(
61
61
  nary,
62
62
  [
63
63
  narypr("∏"),
64
- omml_parameter(parameter_one, tag_name: "sub"),
65
- omml_parameter(parameter_two, tag_name: "sup"),
66
- omml_parameter(parameter_three, tag_name: "e"),
64
+ omml_parameter(parameter_one, display_style, tag_name: "sub"),
65
+ omml_parameter(parameter_two, display_style, tag_name: "sup"),
66
+ omml_parameter(parameter_three, display_style, tag_name: "e"),
67
67
  ],
68
68
  )
69
69
  [nary]
@@ -74,6 +74,10 @@ module Plurimath
74
74
  [r_tag]
75
75
  end
76
76
  end
77
+
78
+ def nary_attr_value
79
+ "∏"
80
+ end
77
81
  end
78
82
  end
79
83
  end
@@ -16,7 +16,7 @@ module Plurimath
16
16
  mo
17
17
  end
18
18
 
19
- def to_omml_without_math_tag
19
+ def to_omml_without_math_tag(display_style)
20
20
  mr = Utility.ox_element("m:r")
21
21
  if parameter_one
22
22
  mt = Utility.ox_element("m:t")
@@ -24,15 +24,15 @@ module Plurimath
24
24
  "\\sqrt[#{first_value}]{#{second_value}}"
25
25
  end
26
26
 
27
- def to_omml_without_math_tag
27
+ def to_omml_without_math_tag(display_style)
28
28
  rad_element = Utility.ox_element("rad", namespace: "m")
29
29
  pr_element = Utility.ox_element("radPr", namespace: "m")
30
30
  Utility.update_nodes(
31
31
  rad_element,
32
32
  [
33
33
  (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
34
- omml_parameter(parameter_two, tag_name: "deg"),
35
- omml_parameter(parameter_one, tag_name: "e"),
34
+ omml_parameter(parameter_two, display_style, tag_name: "deg"),
35
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
36
36
  ],
37
37
  )
38
38
  [rad_element]
@@ -20,7 +20,7 @@ module Plurimath
20
20
  Utility.ox_element("mi")
21
21
  end
22
22
 
23
- def to_omml_without_math_tag
23
+ def to_omml_without_math_tag(display_style)
24
24
  [Utility.ox_element("m:r") << Utility.ox_element("m:t")]
25
25
  end
26
26
 
@@ -6,8 +6,8 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Scarries < UnaryFunction
9
- def to_omml_without_math_tag
10
- omml_value
9
+ def to_omml_without_math_tag(display_style)
10
+ omml_value(display_style)
11
11
  end
12
12
  end
13
13
  end
@@ -23,8 +23,8 @@ module Plurimath
23
23
  parameter_one&.to_asciimath
24
24
  end
25
25
 
26
- def to_omml_without_math_tag
27
- Array(parameter_one.insert_t_tag)
26
+ def to_omml_without_math_tag(display_style)
27
+ Array(parameter_one.insert_t_tag(display_style))
28
28
  end
29
29
 
30
30
  protected
@@ -13,7 +13,7 @@ module Plurimath
13
13
  sqrt_tag
14
14
  end
15
15
 
16
- def to_omml_without_math_tag
16
+ def to_omml_without_math_tag(display_style)
17
17
  rad_element = Utility.ox_element("rad", namespace: "m")
18
18
  pr_element = Utility.ox_element("radPr", namespace: "m")
19
19
  pr_element << Utility.ox_element(
@@ -26,7 +26,7 @@ module Plurimath
26
26
  [
27
27
  (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
28
28
  Utility.ox_element("deg", namespace: "m"),
29
- omml_parameter(parameter_one, tag_name: "e"),
29
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
30
30
  ],
31
31
  )
32
32
  [rad_element]
@@ -27,7 +27,7 @@ module Plurimath
27
27
  "#{first_value}#{second_value}"
28
28
  end
29
29
 
30
- def to_omml_without_math_tag
30
+ def to_omml_without_math_tag(display_style)
31
31
  limupp = Utility.ox_element("limUpp", namespace: "m")
32
32
  limupppr = Utility.ox_element("limUppPr", namespace: "m")
33
33
  limupppr << Utility.pr_element("ctrl", true, namespace: "m")
@@ -35,8 +35,8 @@ module Plurimath
35
35
  limupp,
36
36
  [
37
37
  limupppr,
38
- omml_parameter(parameter_two, tag_name: "e"),
39
- omml_parameter(parameter_one, tag_name: "lim"),
38
+ omml_parameter(parameter_two, display_style, tag_name: "e"),
39
+ omml_parameter(parameter_one, display_style, tag_name: "lim"),
40
40
  ],
41
41
  )
42
42
  [limupp]
@@ -19,13 +19,13 @@ module Plurimath
19
19
  Utility.update_nodes(Utility.ox_element("mtable"), value_array)
20
20
  end
21
21
 
22
- def to_omml_without_math_tag
22
+ def to_omml_without_math_tag(display_style)
23
23
  Array(
24
24
  Utility.update_nodes(
25
25
  mm_element,
26
26
  [
27
- omml_parameter(parameter_one, tag_name: "mr"),
28
- omml_parameter(parameter_two, tag_name: "mr"),
27
+ omml_parameter(parameter_one, display_style, tag_name: "mr"),
28
+ omml_parameter(parameter_two, display_style, tag_name: "mr"),
29
29
  ],
30
30
  ),
31
31
  )
@@ -54,25 +54,28 @@ module Plurimath
54
54
  "<i>&sum;</i>#{first_value}#{second_value}"
55
55
  end
56
56
 
57
- def to_omml_without_math_tag
58
- if all_values_exist?
59
- nary = Utility.ox_element("nary", namespace: "m")
60
- Utility.update_nodes(
61
- nary,
62
- [
63
- narypr("∑"),
64
- omml_parameter(parameter_one, tag_name: "sub"),
65
- omml_parameter(parameter_two, tag_name: "sup"),
66
- omml_parameter(parameter_three, tag_name: "e"),
67
- ],
68
- )
69
- [nary]
70
- else
71
- r_tag = Utility.ox_element("r", namespace: "m")
72
- t_tag = Utility.ox_element("t", namespace: "m")
73
- r_tag << (t_tag << "&#x2211;")
74
- [r_tag]
75
- end
57
+ def to_omml_without_math_tag(display_style)
58
+ return r_element("&#x2211;", rpr_tag: false) unless all_values_exist?
59
+
60
+ nary = Utility.ox_element("nary", namespace: "m")
61
+ Utility.update_nodes(
62
+ nary,
63
+ [
64
+ narypr(""),
65
+ omml_parameter(parameter_one, display_style, tag_name: "sub"),
66
+ omml_parameter(parameter_two, display_style, tag_name: "sup"),
67
+ omml_parameter(parameter_three, display_style, tag_name: "e"),
68
+ ],
69
+ )
70
+ [nary]
71
+ end
72
+
73
+ def omml_tag_name
74
+ "undOvr"
75
+ end
76
+
77
+ def nary_attr_value
78
+ "∑"
76
79
  end
77
80
  end
78
81
  end
@@ -10,8 +10,8 @@ module Plurimath
10
10
  Utility.ox_element("mo") << "sup"
11
11
  end
12
12
 
13
- def to_omml_without_math_tag
14
- [r_element("sup"), omml_value]
13
+ def to_omml_without_math_tag(display_style)
14
+ [r_element("sup", rpr_tag: false), omml_value(display_style)]
15
15
  end
16
16
  end
17
17
  end
@@ -69,18 +69,14 @@ module Plurimath
69
69
  "<table>#{first_value}</table>"
70
70
  end
71
71
 
72
- def to_omml_without_math_tag
72
+ def to_omml_without_math_tag(display_style)
73
73
  if value.map { |d| d.parameter_one.length == 1 }.all?
74
- single_td_table
74
+ single_td_table(display_style)
75
75
  else
76
- fenced_table(multiple_td_table)
76
+ fenced_table(multiple_td_table(display_style))
77
77
  end
78
78
  end
79
79
 
80
- def class_name
81
- self.class.name.split("::").last.downcase
82
- end
83
-
84
80
  protected
85
81
 
86
82
  def present?(field)
@@ -164,17 +160,17 @@ module Plurimath
164
160
  matrices_hash.invert[open_paren].to_s if matric_value
165
161
  end
166
162
 
167
- def single_td_table
163
+ def single_td_table(display_style)
168
164
  eqarr = Utility.ox_element("eqArr", namespace: "m")
169
165
  eqarrpr = Utility.ox_element("eqArrPr", namespace: "m")
170
166
  eqarrpr << Utility.pr_element("ctrl", true, namespace: "m")
171
167
  eqarr << eqarrpr
172
- tr_value = value.map(&:to_omml_without_math_tag).flatten
168
+ tr_value = value.map { |obj| obj.to_omml_without_math_tag(display_style) }.flatten
173
169
  Utility.update_nodes(eqarr, tr_value.compact)
174
170
  [eqarr]
175
171
  end
176
172
 
177
- def multiple_td_table
173
+ def multiple_td_table(display_style)
178
174
  count = { "m:val": value&.first&.parameter_one&.count }
179
175
  mcjc = { "m:val": "center" }
180
176
  mm = Utility.ox_element("m", namespace: "m")
@@ -198,7 +194,7 @@ module Plurimath
198
194
  mcs << mc
199
195
  mpr << mcs
200
196
  mpr << ctrlpr
201
- mm_value = value&.map(&:to_omml_without_math_tag)
197
+ mm_value = value&.map { |obj| obj.to_omml_without_math_tag(display_style) }
202
198
  Utility.update_nodes(
203
199
  mm,
204
200
  mm_value.insert(0, mpr).flatten,
@@ -32,13 +32,13 @@ module Plurimath
32
32
  "<td>#{first_value}</td>"
33
33
  end
34
34
 
35
- def to_omml_without_math_tag
35
+ def to_omml_without_math_tag(display_style)
36
36
  me = Utility.ox_element("e", namespace: "m")
37
37
  return [me] if parameter_one&.empty?
38
38
 
39
39
  Utility.update_nodes(
40
40
  me,
41
- Formula.new(parameter_one).omml_content,
41
+ Formula.new(parameter_one).omml_content(display_style),
42
42
  )
43
43
  [me]
44
44
  end
@@ -51,6 +51,10 @@ module Plurimath
51
51
  "#{first_value}#{second_value}#{third_value}"
52
52
  end
53
53
 
54
+ def any_value_exist?
55
+ !(parameter_one.nil? || parameter_two.nil? || parameter_three.nil?)
56
+ end
57
+
54
58
  protected
55
59
 
56
60
  def latex_wrapped(field)
@@ -131,6 +135,13 @@ module Plurimath
131
135
 
132
136
  Array(parameter.to_mathml_without_math_tag)
133
137
  end
138
+
139
+ def underover(display_style)
140
+ overset = Overset.new(parameter_one, parameter_three)
141
+ return overset.to_omml_without_math_tag(display_style) unless parameter_two
142
+
143
+ Underset.new(overset, parameter_two)&.to_omml_without_math_tag(display_style)
144
+ end
134
145
  end
135
146
  end
136
147
  end
@@ -27,15 +27,15 @@ module Plurimath
27
27
  parse_text("html") || parameter_one
28
28
  end
29
29
 
30
- def to_omml_without_math_tag
30
+ def to_omml_without_math_tag(_display_style)
31
31
  text = Utility.ox_element("t", namespace: "m")
32
32
  text << (parse_text("omml") || parameter_one)
33
33
  [text]
34
34
  end
35
35
 
36
- def insert_t_tag
36
+ def insert_t_tag(display_style)
37
37
  r_tag = Utility.ox_element("r", namespace: "m")
38
- Utility.update_nodes(r_tag, to_omml_without_math_tag)
38
+ Utility.update_nodes(r_tag, to_omml_without_math_tag(display_style))
39
39
  [r_tag]
40
40
  end
41
41
 
@@ -54,7 +54,8 @@ module Plurimath
54
54
  html_value = first_value(lang).dup
55
55
  html_value&.gsub!(PARSER_REGEX) do |_text|
56
56
  last_match = Regexp.last_match
57
- if ["mathml", "html"].include?(lang)
57
+ case lang
58
+ when "mathml", "html"
58
59
  symbol_value(last_match[:unicode])
59
60
  else
60
61
  last_match[:unicode]
@@ -67,7 +68,7 @@ module Plurimath
67
68
  if lang == "omml"
68
69
  entities = HTMLEntities.new
69
70
  entities.encode(
70
- entities.decode(parameter_one),
71
+ entities.decode(parameter_one.gsub(/ /, "&nbsp;")),
71
72
  :named,
72
73
  )
73
74
  else