plurimath 0.3.7 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plurimath/asciimath/constants.rb +1 -1
  3. data/lib/plurimath/asciimath/transform.rb +17 -0
  4. data/lib/plurimath/latex/constants.rb +3 -5
  5. data/lib/plurimath/math/core.rb +14 -0
  6. data/lib/plurimath/math/formula.rb +19 -6
  7. data/lib/plurimath/math/function/binary_function.rb +14 -4
  8. data/lib/plurimath/math/function/cancel.rb +4 -0
  9. data/lib/plurimath/math/function/ceil.rb +7 -0
  10. data/lib/plurimath/math/function/color.rb +4 -0
  11. data/lib/plurimath/math/function/ddot.rb +4 -3
  12. data/lib/plurimath/math/function/deg.rb +4 -0
  13. data/lib/plurimath/math/function/det.rb +4 -0
  14. data/lib/plurimath/math/function/dim.rb +4 -0
  15. data/lib/plurimath/math/function/dot.rb +18 -0
  16. data/lib/plurimath/math/function/exp.rb +4 -0
  17. data/lib/plurimath/math/function/floor.rb +8 -0
  18. data/lib/plurimath/math/function/font_style.rb +1 -3
  19. data/lib/plurimath/math/function/gcd.rb +4 -0
  20. data/lib/plurimath/math/function/glb.rb +4 -0
  21. data/lib/plurimath/math/function/hat.rb +13 -0
  22. data/lib/plurimath/math/function/hom.rb +3 -0
  23. data/lib/plurimath/math/function/inf.rb +18 -17
  24. data/lib/plurimath/math/function/int.rb +8 -8
  25. data/lib/plurimath/math/function/ker.rb +3 -0
  26. data/lib/plurimath/math/function/lcm.rb +3 -0
  27. data/lib/plurimath/math/function/lg.rb +4 -0
  28. data/lib/plurimath/math/function/lim.rb +1 -5
  29. data/lib/plurimath/math/function/liminf.rb +3 -0
  30. data/lib/plurimath/math/function/limsup.rb +3 -0
  31. data/lib/plurimath/math/function/ln.rb +4 -0
  32. data/lib/plurimath/math/function/longdiv.rb +3 -0
  33. data/lib/plurimath/math/function/lub.rb +4 -0
  34. data/lib/plurimath/math/function/max.rb +4 -0
  35. data/lib/plurimath/math/function/menclose.rb +1 -3
  36. data/lib/plurimath/math/function/merror.rb +1 -0
  37. data/lib/plurimath/math/function/min.rb +4 -0
  38. data/lib/plurimath/math/function/mod.rb +8 -0
  39. data/lib/plurimath/math/function/msline.rb +3 -0
  40. data/lib/plurimath/math/function/norm.rb +8 -0
  41. data/lib/plurimath/math/function/obrace.rb +29 -4
  42. data/lib/plurimath/math/function/oint.rb +55 -3
  43. data/lib/plurimath/math/function/over.rb +15 -1
  44. data/lib/plurimath/math/function/phantom.rb +7 -4
  45. data/lib/plurimath/math/function/power_base.rb +3 -1
  46. data/lib/plurimath/math/function/prod.rb +4 -0
  47. data/lib/plurimath/math/function/root.rb +2 -6
  48. data/lib/plurimath/math/function/scarries.rb +3 -0
  49. data/lib/plurimath/math/function/semantics.rb +4 -0
  50. data/lib/plurimath/math/function/sqrt.rb +1 -3
  51. data/lib/plurimath/math/function/stackrel.rb +15 -0
  52. data/lib/plurimath/math/function/substack.rb +45 -0
  53. data/lib/plurimath/math/function/sum.rb +8 -0
  54. data/lib/plurimath/math/function/sup.rb +4 -0
  55. data/lib/plurimath/math/function/table.rb +0 -4
  56. data/lib/plurimath/math/function/ternary_function.rb +13 -4
  57. data/lib/plurimath/math/function/tilde.rb +14 -0
  58. data/lib/plurimath/math/function/ubrace.rb +20 -0
  59. data/lib/plurimath/math/function/ul.rb +2 -0
  60. data/lib/plurimath/math/function/unary_function.rb +0 -4
  61. data/lib/plurimath/math/function/underover.rb +2 -5
  62. data/lib/plurimath/math/function/vec.rb +14 -0
  63. data/lib/plurimath/math/symbol.rb +8 -0
  64. data/lib/plurimath/math.rb +3 -1
  65. data/lib/plurimath/mathml/parser.rb +2 -2
  66. data/lib/plurimath/version.rb +1 -1
  67. metadata +2 -3
  68. data/lib/plurimath/math/function/underline.rb +0 -12
@@ -9,6 +9,10 @@ module Plurimath
9
9
  def validate_function_formula
10
10
  false
11
11
  end
12
+
13
+ def to_omml_without_math_tag
14
+ [r_element("min"), omml_value]
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -38,6 +38,14 @@ module Plurimath
38
38
  second_value = "<i>#{parameter_two.to_html}</i>" if parameter_two
39
39
  "#{first_value}<i>mod</i>#{second_value}"
40
40
  end
41
+
42
+ def to_omml_without_math_tag
43
+ values = []
44
+ values << parameter_one.insert_t_tag if parameter_one
45
+ values << r_element("mod")
46
+ values << parameter_two.insert_t_tag if parameter_two
47
+ values
48
+ end
41
49
  end
42
50
  end
43
51
  end
@@ -6,6 +6,9 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Msline < UnaryFunction
9
+ def to_omml_without_math_tag
10
+ omml_value
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -26,6 +26,14 @@ module Plurimath
26
26
  ],
27
27
  )
28
28
  end
29
+
30
+ def to_omml_without_math_tag
31
+ [
32
+ r_element("∥"),
33
+ omml_value,
34
+ r_element("∥"),
35
+ ]
36
+ end
29
37
  end
30
38
  end
31
39
  end
@@ -22,13 +22,38 @@ module Plurimath
22
22
  end
23
23
  end
24
24
 
25
- def tag_name
26
- "underover"
27
- end
28
-
29
25
  def validate_function_formula
30
26
  false
31
27
  end
28
+
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]
39
+ end
40
+
41
+ protected
42
+
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" })
48
+ Utility.update_nodes(
49
+ groupchrpr,
50
+ [
51
+ chr,
52
+ pos,
53
+ vert_jc,
54
+ ],
55
+ )
56
+ end
32
57
  end
33
58
 
34
59
  Overbrace = Obrace
@@ -1,15 +1,67 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "binary_function"
3
+ require_relative "ternary_function"
4
4
 
5
5
  module Plurimath
6
6
  module Math
7
7
  module Function
8
- class Oint < BinaryFunction
8
+ class Oint < TernaryFunction
9
9
  def to_asciimath
10
10
  first_value = "_#{wrapped(parameter_one)}" if parameter_one
11
11
  second_value = "^#{wrapped(parameter_two)}" if parameter_two
12
- "oint#{first_value}#{second_value}"
12
+ "oint#{first_value}#{second_value} #{parameter_three&.to_asciimath}".strip
13
+ end
14
+
15
+ def to_latex
16
+ first_value = "_#{latex_wrapped(parameter_one)}" if parameter_one
17
+ second_value = "^#{latex_wrapped(parameter_two)}" if parameter_two
18
+ "\\#{class_name}#{first_value}#{second_value} #{parameter_three&.to_latex}".strip
19
+ end
20
+
21
+ def to_mathml_without_math_tag
22
+ mo_tag = Utility.ox_element("mo") << invert_unicode_symbols.to_s
23
+ return mo_tag unless all_values_exist?
24
+
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)
35
+ return msubsup_tag if parameter_three.nil?
36
+
37
+ Utility.update_nodes(
38
+ Utility.ox_element("mrow"),
39
+ [
40
+ msubsup_tag,
41
+ parameter_three&.to_mathml_without_math_tag,
42
+ ].compact,
43
+ )
44
+ end
45
+
46
+ def to_omml_without_math_tag
47
+ if all_values_exist?
48
+ nary = Utility.ox_element("nary", namespace: "m")
49
+ Utility.update_nodes(
50
+ nary,
51
+ [
52
+ narypr("∮", function_type: "subSup"),
53
+ omml_parameter(parameter_one, tag_name: "sub"),
54
+ omml_parameter(parameter_two, tag_name: "sup"),
55
+ omml_parameter(parameter_three, tag_name: "e"),
56
+ ],
57
+ )
58
+ [nary]
59
+ else
60
+ r_tag = Utility.ox_element("r", namespace: "m")
61
+ t_tag = Utility.ox_element("t", namespace: "m")
62
+ r_tag << (t_tag << "&#x222e;")
63
+ [r_tag]
64
+ end
13
65
  end
14
66
  end
15
67
  end
@@ -9,7 +9,7 @@ module Plurimath
9
9
  def to_asciimath
10
10
  first_value = wrapped(parameter_one)
11
11
  second_value = wrapped(parameter_two)
12
- "overset#{first_value}#{second_value}"
12
+ "frac#{first_value}#{second_value}"
13
13
  end
14
14
 
15
15
  def to_mathml_without_math_tag
@@ -30,6 +30,20 @@ module Plurimath
30
30
  two_value = parameter_two&.to_latex
31
31
  "{#{first_value} \\over #{two_value}}"
32
32
  end
33
+
34
+ def to_omml_without_math_tag
35
+ f_element = Utility.ox_element("f", namespace: "m")
36
+ fpr_element = Utility.ox_element("fPr", namespace: "m")
37
+ Utility.update_nodes(
38
+ f_element,
39
+ [
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"),
43
+ ],
44
+ )
45
+ [f_element]
46
+ end
33
47
  end
34
48
  end
35
49
  end
@@ -7,7 +7,7 @@ module Plurimath
7
7
  module Function
8
8
  class Phantom < UnaryFunction
9
9
  def to_asciimath
10
- "\"#{Array.new(parameter_one&.length, ' ').join}\""
10
+ "#{Array.new(parameter_one&.length, '\ ').join}"
11
11
  end
12
12
 
13
13
  def to_html
@@ -15,12 +15,15 @@ module Plurimath
15
15
  end
16
16
 
17
17
  def to_latex
18
- "<i>#{Array.new(parameter_one&.length, '\\ ').join}</i>"
18
+ Array.new(parameter_one&.length, '\\ ').join
19
19
  end
20
20
 
21
21
  def to_mathml_without_math_tag
22
- mi_tag_value = Array.new(parameter_one&.length, "&nbsp;&nbsp;").join
23
- Utility.ox_element("mi") << mi_tag_value
22
+ phantom = Utility.ox_element("mphantom")
23
+ Utility.update_nodes(
24
+ phantom,
25
+ parameter_one&.map(&:to_mathml_without_math_tag),
26
+ )
24
27
  end
25
28
  end
26
29
  end
@@ -35,7 +35,7 @@ module Plurimath
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")
@@ -47,6 +47,8 @@ module Plurimath
47
47
  end
48
48
 
49
49
  def to_omml_without_math_tag
50
+ return underover 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(
@@ -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
@@ -27,16 +27,12 @@ module Plurimath
27
27
  def to_omml_without_math_tag
28
28
  rad_element = Utility.ox_element("rad", namespace: "m")
29
29
  pr_element = Utility.ox_element("radPr", namespace: "m")
30
- deg_element = Utility.ox_element("deg", namespace: "m")
31
- e_element = Utility.ox_element("e", namespace: "m")
32
- Utility.update_nodes(e_element, parameter_one.to_omml_without_math_tag)
33
- Utility.update_nodes(deg_element, parameter_two.to_omml_without_math_tag)
34
30
  Utility.update_nodes(
35
31
  rad_element,
36
32
  [
37
33
  (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
38
- deg_element,
39
- e_element,
34
+ omml_parameter(parameter_two, tag_name: "deg"),
35
+ omml_parameter(parameter_one, tag_name: "e"),
40
36
  ],
41
37
  )
42
38
  [rad_element]
@@ -6,6 +6,9 @@ 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
11
+ end
9
12
  end
10
13
  end
11
14
  end
@@ -23,6 +23,10 @@ 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)
28
+ end
29
+
26
30
  protected
27
31
 
28
32
  def other_tags(array)
@@ -21,14 +21,12 @@ module Plurimath
21
21
  namespace: "m",
22
22
  attributes: { "m:val": "1" },
23
23
  )
24
- e_element = Utility.ox_element("e", namespace: "m")
25
- Utility.update_nodes(e_element, omml_value)
26
24
  Utility.update_nodes(
27
25
  rad_element,
28
26
  [
29
27
  (pr_element << Utility.pr_element("ctrl", true, namespace: "m")),
30
28
  Utility.ox_element("deg", namespace: "m"),
31
- e_element,
29
+ omml_parameter(parameter_one, tag_name: "e"),
32
30
  ],
33
31
  )
34
32
  [rad_element]
@@ -27,6 +27,21 @@ module Plurimath
27
27
  "#{first_value}#{second_value}"
28
28
  end
29
29
 
30
+ def to_omml_without_math_tag
31
+ limupp = Utility.ox_element("limUpp", namespace: "m")
32
+ limupppr = Utility.ox_element("limUppPr", namespace: "m")
33
+ limupppr << Utility.pr_element("ctrl", true, namespace: "m")
34
+ Utility.update_nodes(
35
+ limupp,
36
+ [
37
+ limupppr,
38
+ omml_parameter(parameter_two, tag_name: "e"),
39
+ omml_parameter(parameter_one, tag_name: "lim"),
40
+ ],
41
+ )
42
+ [limupp]
43
+ end
44
+
30
45
  protected
31
46
 
32
47
  def wrapped(field)
@@ -18,6 +18,51 @@ module Plurimath
18
18
  value_array << parameter_two.to_mathml_without_math_tag if parameter_two
19
19
  Utility.update_nodes(Utility.ox_element("mtable"), value_array)
20
20
  end
21
+
22
+ def to_omml_without_math_tag
23
+ Array(
24
+ Utility.update_nodes(
25
+ mm_element,
26
+ [
27
+ omml_parameter(parameter_one, tag_name: "mr"),
28
+ omml_parameter(parameter_two, tag_name: "mr"),
29
+ ],
30
+ ),
31
+ )
32
+ end
33
+
34
+ protected
35
+
36
+ def mm_element
37
+ mcjc = Utility.ox_element(
38
+ "mcJc",
39
+ namespace: "m",
40
+ attributes: { "m:val": "center" },
41
+ )
42
+ mcount = Utility.ox_element(
43
+ "count",
44
+ namespace: "m",
45
+ attributes: { "m:val": "1" },
46
+ )
47
+ mbasejc = Utility.ox_element(
48
+ "baseJc",
49
+ namespace: "m",
50
+ attributes: { "m:val": "center", },
51
+ )
52
+ mplchide = Utility.ox_element(
53
+ "plcHide",
54
+ namespace: "m",
55
+ attributes: { "m:val": "1" },
56
+ )
57
+ mm = Utility.ox_element("m", namespace: "m")
58
+ mc = Utility.ox_element("mc", namespace: "m")
59
+ mpr = Utility.ox_element("mpr", namespace: "m")
60
+ mcs = Utility.ox_element("mcs", namespace: "m")
61
+ mcpr = Utility.ox_element("mcPr", namespace: "m")
62
+ mc << Utility.update_nodes(mcpr, [mcjc, mcount])
63
+ mcs << mc
64
+ Utility.update_nodes(mm, [mpr])
65
+ end
21
66
  end
22
67
  end
23
68
  end
@@ -74,6 +74,14 @@ module Plurimath
74
74
  [r_tag]
75
75
  end
76
76
  end
77
+
78
+ def omml_tag_name
79
+ "undOvr"
80
+ end
81
+
82
+ def nary_attr_value
83
+ "∑"
84
+ end
77
85
  end
78
86
  end
79
87
  end
@@ -9,6 +9,10 @@ module Plurimath
9
9
  def to_mathml_without_math_tag
10
10
  Utility.ox_element("mo") << "sup"
11
11
  end
12
+
13
+ def to_omml_without_math_tag
14
+ [r_element("sup"), omml_value]
15
+ end
12
16
  end
13
17
  end
14
18
  end
@@ -77,10 +77,6 @@ module Plurimath
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)
@@ -51,10 +51,6 @@ module Plurimath
51
51
  "#{first_value}#{second_value}#{third_value}"
52
52
  end
53
53
 
54
- def class_name
55
- self.class.name.split("::").last.downcase
56
- end
57
-
58
54
  protected
59
55
 
60
56
  def latex_wrapped(field)
@@ -129,6 +125,19 @@ module Plurimath
129
125
  def all_values_exist?
130
126
  !(parameter_one.nil? && parameter_two.nil? && parameter_three.nil?)
131
127
  end
128
+
129
+ def validate_mathml_tag(parameter)
130
+ return Array(Utility.ox_element("mrow")) unless parameter
131
+
132
+ Array(parameter.to_mathml_without_math_tag)
133
+ end
134
+
135
+ def underover
136
+ overset = Overset.new(parameter_one, parameter_three)
137
+ return overset unless parameter_two
138
+
139
+ Underset.new(overset, parameter_two)&.to_omml_without_math_tag
140
+ end
132
141
  end
133
142
  end
134
143
  end
@@ -12,6 +12,20 @@ module Plurimath
12
12
  second_value = parameter_one.to_mathml_without_math_tag if parameter_one
13
13
  Utility.update_nodes(mover, [second_value, first_value])
14
14
  end
15
+
16
+ def to_omml_without_math_tag
17
+ acc_tag = Utility.ox_element("acc", namespace: "m")
18
+ acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
19
+ acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "˜" }))
20
+ Utility.update_nodes(
21
+ acc_tag,
22
+ [
23
+ acc_pr_tag,
24
+ omml_parameter(parameter_one, tag_name: "e"),
25
+ ],
26
+ )
27
+ [acc_tag]
28
+ end
15
29
  end
16
30
  end
17
31
  end
@@ -26,9 +26,29 @@ module Plurimath
26
26
  "underover"
27
27
  end
28
28
 
29
+ def omml_tag_name
30
+ "undOvr"
31
+ end
32
+
29
33
  def validate_function_formula
30
34
  false
31
35
  end
36
+
37
+ def to_omml_without_math_tag
38
+ limlow = Utility.ox_element("limLow", namespace: "m")
39
+ limlowpr = Utility.ox_element("limLowPr", namespace: "m")
40
+ limlowpr << Utility.pr_element("ctrl", true, namespace: "m")
41
+ lim = Utility.ox_element("lim", namespace: "m")
42
+ Utility.update_nodes(
43
+ limlow,
44
+ [
45
+ limlowpr,
46
+ omml_parameter(parameter_one, tag_name: "e"),
47
+ Utility.update_nodes(lim, r_element("⏟")),
48
+ ],
49
+ )
50
+ [limlow]
51
+ end
32
52
  end
33
53
 
34
54
  Underbrace = Ubrace
@@ -37,6 +37,8 @@ module Plurimath
37
37
  "underline"
38
38
  end
39
39
  end
40
+
41
+ Underline = Ul
40
42
  end
41
43
  end
42
44
  end
@@ -74,10 +74,6 @@ module Plurimath
74
74
  [func]
75
75
  end
76
76
 
77
- def class_name
78
- self.class.name.split("::").last.downcase
79
- end
80
-
81
77
  protected
82
78
 
83
79
  def asciimath_value
@@ -36,10 +36,7 @@ module Plurimath
36
36
  end
37
37
 
38
38
  def to_omml_without_math_tag
39
- overset = Overset.new(parameter_one, parameter_three)
40
- return overset unless parameter_two
41
-
42
- Underset.new(overset, parameter_two)&.to_omml_without_math_tag
39
+ underover
43
40
  end
44
41
 
45
42
  def omml_nary_tag
@@ -86,7 +83,7 @@ module Plurimath
86
83
  end
87
84
 
88
85
  def first_value(pr_element)
89
- first_value = parameter_one.is_a?(Number) ? parameter_one.value : parameter_one.to_omml_without_math_tag
86
+ first_value = parameter_one.nary_attr_value
90
87
  first_value = Utility.html_entity_to_unicode(first_value)
91
88
  unless first_value == "∫"
92
89
  pr_element << Utility.ox_element(
@@ -16,6 +16,20 @@ module Plurimath
16
16
  ],
17
17
  )
18
18
  end
19
+
20
+ def to_omml_without_math_tag
21
+ acc_tag = Utility.ox_element("acc", namespace: "m")
22
+ acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
23
+ acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "→" }))
24
+ Utility.update_nodes(
25
+ acc_tag,
26
+ [
27
+ acc_pr_tag,
28
+ omml_parameter(parameter_one, tag_name: "e"),
29
+ ],
30
+ )
31
+ [acc_tag]
32
+ end
19
33
  end
20
34
  end
21
35
  end
@@ -72,6 +72,14 @@ module Plurimath
72
72
  ["&#x22c0;", "&#x22c1;", "&#x22c2;", "&#x22c3;"].include?(value) ? "underover" : "subsup"
73
73
  end
74
74
 
75
+ def omml_tag_name
76
+ if ["&#x22c0;", "&#x22c1;", "&#x22c2;", "&#x22c3;", "&#x22c3;", "&#x2211;", "&#x220f;"].include?(value)
77
+ return "undOvr"
78
+ end
79
+
80
+ "subSup"
81
+ end
82
+
75
83
  def nary_attr_value
76
84
  value
77
85
  end
@@ -42,7 +42,9 @@ module Plurimath
42
42
 
43
43
  begin
44
44
  klass = klass_from_type(type)
45
- klass.new(text).to_formula
45
+ formula = klass.new(text).to_formula
46
+ formula.input_string = text
47
+ formula
46
48
  rescue => ee
47
49
  parse_error!(text, type.to_sym)
48
50
  end
@@ -22,11 +22,11 @@ module Plurimath
22
22
 
23
23
  def parse
24
24
  ox_nodes = Ox.load(text, strip_namespace: true)
25
- display_style = ox_nodes&.locate("*/mstyle/@displaystyle")&.first
25
+ display_style = ox_nodes&.locate("*/mstyle/@displaystyle")&.first || true
26
26
  nodes = parse_nodes(ox_nodes.nodes)
27
27
  Math::Formula.new(
28
28
  Transform.new.apply(nodes).flatten.compact,
29
- displaystyle: display_style
29
+ displaystyle: display_style,
30
30
  )
31
31
  end
32
32
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Plurimath
4
- VERSION = "0.3.7"
4
+ VERSION = "0.3.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plurimath
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.7
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-08-02 00:00:00.000000000 Z
11
+ date: 2023-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parslet
@@ -183,7 +183,6 @@ files:
183
183
  - lib/plurimath/math/function/ubrace.rb
184
184
  - lib/plurimath/math/function/ul.rb
185
185
  - lib/plurimath/math/function/unary_function.rb
186
- - lib/plurimath/math/function/underline.rb
187
186
  - lib/plurimath/math/function/underover.rb
188
187
  - lib/plurimath/math/function/underset.rb
189
188
  - lib/plurimath/math/function/vec.rb
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "unary_function"
4
-
5
- module Plurimath
6
- module Math
7
- module Function
8
- class Underline < UnaryFunction
9
- end
10
- end
11
- end
12
- end