plurimath 0.3.9 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/lib/plurimath/latex/constants.rb +1 -0
  3. data/lib/plurimath/latex/parse.rb +11 -3
  4. data/lib/plurimath/latex/transform.rb +93 -7
  5. data/lib/plurimath/math/core.rb +16 -4
  6. data/lib/plurimath/math/formula.rb +24 -20
  7. data/lib/plurimath/math/function/abs.rb +2 -2
  8. data/lib/plurimath/math/function/bar.rb +48 -10
  9. data/lib/plurimath/math/function/base.rb +3 -3
  10. data/lib/plurimath/math/function/binary_function.rb +20 -10
  11. data/lib/plurimath/math/function/cancel.rb +2 -2
  12. data/lib/plurimath/math/function/ceil.rb +7 -2
  13. data/lib/plurimath/math/function/color.rb +2 -2
  14. data/lib/plurimath/math/function/ddot.rb +17 -12
  15. data/lib/plurimath/math/function/deg.rb +2 -2
  16. data/lib/plurimath/math/function/det.rb +2 -2
  17. data/lib/plurimath/math/function/dim.rb +2 -2
  18. data/lib/plurimath/math/function/dot.rb +26 -2
  19. data/lib/plurimath/math/function/exp.rb +2 -2
  20. data/lib/plurimath/math/function/fenced.rb +6 -7
  21. data/lib/plurimath/math/function/floor.rb +2 -2
  22. data/lib/plurimath/math/function/font_style/bold-fraktur.rb +17 -0
  23. data/lib/plurimath/math/function/font_style/bold-italic.rb +17 -0
  24. data/lib/plurimath/math/function/font_style/bold-sans-serif.rb +17 -0
  25. data/lib/plurimath/math/function/font_style/bold-script.rb +17 -0
  26. data/lib/plurimath/math/function/font_style/bold.rb +4 -0
  27. data/lib/plurimath/math/function/font_style/double_struck.rb +4 -0
  28. data/lib/plurimath/math/function/font_style/fraktur.rb +4 -0
  29. data/lib/plurimath/math/function/font_style/italic.rb +4 -0
  30. data/lib/plurimath/math/function/font_style/monospace.rb +4 -0
  31. data/lib/plurimath/math/function/font_style/normal.rb +4 -0
  32. data/lib/plurimath/math/function/font_style/sans-serif-bold-italic.rb +17 -0
  33. data/lib/plurimath/math/function/font_style/sans-serif-italic.rb +17 -0
  34. data/lib/plurimath/math/function/font_style/sans-serif.rb +4 -0
  35. data/lib/plurimath/math/function/font_style/script.rb +4 -0
  36. data/lib/plurimath/math/function/font_style.rb +24 -2
  37. data/lib/plurimath/math/function/frac.rb +3 -3
  38. data/lib/plurimath/math/function/gcd.rb +2 -2
  39. data/lib/plurimath/math/function/glb.rb +2 -2
  40. data/lib/plurimath/math/function/hat.rb +42 -9
  41. data/lib/plurimath/math/function/hom.rb +2 -2
  42. data/lib/plurimath/math/function/inf.rb +2 -2
  43. data/lib/plurimath/math/function/int.rb +4 -4
  44. data/lib/plurimath/math/function/ker.rb +2 -2
  45. data/lib/plurimath/math/function/lcm.rb +2 -2
  46. data/lib/plurimath/math/function/left.rb +1 -1
  47. data/lib/plurimath/math/function/lg.rb +2 -2
  48. data/lib/plurimath/math/function/lim.rb +2 -2
  49. data/lib/plurimath/math/function/liminf.rb +2 -2
  50. data/lib/plurimath/math/function/limits.rb +4 -4
  51. data/lib/plurimath/math/function/limsup.rb +2 -2
  52. data/lib/plurimath/math/function/ln.rb +2 -2
  53. data/lib/plurimath/math/function/log.rb +5 -3
  54. data/lib/plurimath/math/function/longdiv.rb +2 -2
  55. data/lib/plurimath/math/function/lub.rb +2 -2
  56. data/lib/plurimath/math/function/max.rb +2 -2
  57. data/lib/plurimath/math/function/mbox.rb +2 -2
  58. data/lib/plurimath/math/function/menclose.rb +2 -2
  59. data/lib/plurimath/math/function/merror.rb +1 -1
  60. data/lib/plurimath/math/function/min.rb +2 -2
  61. data/lib/plurimath/math/function/mod.rb +3 -3
  62. data/lib/plurimath/math/function/msgroup.rb +2 -2
  63. data/lib/plurimath/math/function/msline.rb +2 -2
  64. data/lib/plurimath/math/function/multiscript.rb +4 -4
  65. data/lib/plurimath/math/function/norm.rb +2 -2
  66. data/lib/plurimath/math/function/obrace.rb +40 -26
  67. data/lib/plurimath/math/function/oint.rb +4 -4
  68. data/lib/plurimath/math/function/over.rb +3 -3
  69. data/lib/plurimath/math/function/overset.rb +8 -3
  70. data/lib/plurimath/math/function/power.rb +3 -3
  71. data/lib/plurimath/math/function/power_base.rb +8 -8
  72. data/lib/plurimath/math/function/prod.rb +4 -4
  73. data/lib/plurimath/math/function/right.rb +1 -1
  74. data/lib/plurimath/math/function/root.rb +3 -3
  75. data/lib/plurimath/math/function/rule.rb +1 -1
  76. data/lib/plurimath/math/function/scarries.rb +2 -2
  77. data/lib/plurimath/math/function/semantics.rb +2 -2
  78. data/lib/plurimath/math/function/sqrt.rb +2 -2
  79. data/lib/plurimath/math/function/stackrel.rb +3 -3
  80. data/lib/plurimath/math/function/substack.rb +3 -3
  81. data/lib/plurimath/math/function/sum.rb +14 -19
  82. data/lib/plurimath/math/function/sup.rb +2 -2
  83. data/lib/plurimath/math/function/table.rb +7 -7
  84. data/lib/plurimath/math/function/td.rb +2 -2
  85. data/lib/plurimath/math/function/ternary_function.rb +13 -9
  86. data/lib/plurimath/math/function/text.rb +6 -5
  87. data/lib/plurimath/math/function/tilde.rb +27 -2
  88. data/lib/plurimath/math/function/tr.rb +2 -2
  89. data/lib/plurimath/math/function/ubrace.rb +28 -21
  90. data/lib/plurimath/math/function/ul.rb +55 -18
  91. data/lib/plurimath/math/function/unary_function.rb +13 -8
  92. data/lib/plurimath/math/function/underover.rb +10 -5
  93. data/lib/plurimath/math/function/underset.rb +8 -3
  94. data/lib/plurimath/math/function/vec.rb +25 -3
  95. data/lib/plurimath/math/number.rb +6 -2
  96. data/lib/plurimath/math/symbol.rb +6 -2
  97. data/lib/plurimath/math.rb +1 -0
  98. data/lib/plurimath/mathml/constants.rb +9 -1
  99. data/lib/plurimath/mathml/parser.rb +16 -10
  100. data/lib/plurimath/mathml/transform.rb +59 -31
  101. data/lib/plurimath/omml/parser.rb +24 -1
  102. data/lib/plurimath/omml/transform.rb +56 -41
  103. data/lib/plurimath/utility.rb +154 -9
  104. data/lib/plurimath/version.rb +1 -1
  105. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d50026941bd556b94051c14a61a081ad96dbf839ed1aa324a9451382ef512e8
4
- data.tar.gz: 40bf633bf5c0286daa011bf80d90baa2d522b18b9e545035d5dd6c32593792db
3
+ metadata.gz: 0ec251305cefca33f4a6d66180a797595d43ef370d55f7b67bdeac63b37e3111
4
+ data.tar.gz: 2c041edf5748e938813a20e0d397080d2f8cedcf96b19e9e39e98edae6b47ef8
5
5
  SHA512:
6
- metadata.gz: 8cf6f394801e567d2a7b482a14fc4da5e3b4c19515ce549a00fc9c247ce4d26c565dc5ff72586648cd30c51c0361f40808fb1117ed408bd9c319156622b34640
7
- data.tar.gz: 65d1590db64f33f620ad438ae2d328eb1fe9a6bffeee9a427dba9f782bdc9b429ed5c54e9892ade8c59894ddd57d2bcc6680a4b7cb1b9cee26c67c0cab1b05d2
6
+ metadata.gz: 37065161c1a09768bbec28f0d98e5438be18a5a0affa9e6024f7027ad002324c1e66e63c22f921f43fd32fa2bf1b723ace3f08b99464a8af3b7e6d265e092df6
7
+ data.tar.gz: 596e9cb2ce7f7d41ab8f93b4c0f330ffcdfec6adba518b49086dc4792c12f7eafed799ee087ea2ea82a3753389c179fab8883445c1b804a52fe779314941280c
@@ -2853,6 +2853,7 @@ module Plurimath
2853
2853
  mathbfit: :fonts,
2854
2854
  mathfrak: :fonts,
2855
2855
  overline: :unary,
2856
+ overset: :binary,
2856
2857
  ddagger: :symbols,
2857
2858
  trprime: :symbols,
2858
2859
  closure: :symbols,
@@ -95,11 +95,18 @@ module Plurimath
95
95
  end
96
96
 
97
97
  rule(:intermediate_exp) do
98
- (lparen.as(:left_paren) >> expression.maybe.as(:expression) >> rparen.as(:right_paren)).as(:intermediate_exp) |
98
+ (lparen.as(:left_paren) >> expression.maybe.as(:expression) >> (rparen | (str("\\") >> (match("\s") >> str(".")).maybe).as(:rparen)).maybe.as(:right_paren)).as(:intermediate_exp) |
99
99
  (str("{") >> expression.maybe.as(:expression) >> str("}")) |
100
100
  symbol_text_or_integer
101
101
  end
102
102
 
103
+ rule(:parsing_text_values) do
104
+ (str("{") >> parsing_text_values >> str("}")) >> parsing_text_values |
105
+ (str("{") >> parsing_text_values >> str("}")) |
106
+ (match("[^}]") >> parsing_text_values) |
107
+ match("[^}]").repeat
108
+ end
109
+
103
110
  rule(:power_base) do
104
111
  (subscript >> power >> intermediate_exp.as(:supscript)).as(:power_base) |
105
112
  (supscript >> base >> intermediate_exp.as(:subscript)).as(:power_base) |
@@ -130,7 +137,8 @@ module Plurimath
130
137
  (begining >> expression.as(:table_data) >> ending).as(:environment) |
131
138
  (slash >> environment >> intermediate_exp).as(:table_data) |
132
139
  power_base |
133
- intermediate_exp
140
+ intermediate_exp |
141
+ intermediate_exp.as(:intermediate_exp) >> rparen.as(:symbol)
134
142
  end
135
143
 
136
144
  rule(:left_right) do
@@ -204,7 +212,7 @@ module Plurimath
204
212
  when :binary
205
213
  (slashed_value(first_value, :binary) >> intermediate_exp.as(:first_value) >> intermediate_exp.as(:second_value)).as(:binary)
206
214
  when :text
207
- (slashed_value(first_value, :text) >> (str("{") >> match("[^}]").repeat.as(:first_value) >> str("}")))
215
+ (slashed_value(first_value, :text) >> (str("{") >> parsing_text_values.as(:first_value) >> str("}")))
208
216
  when :ternary
209
217
  (slashed_value(first_value, :ternary_functions) >> dynamic_power_base >> sequence.as(:third_value).maybe).as(:ternary_class) |
210
218
  slashed_value(first_value, :ternary)
@@ -45,13 +45,9 @@ module Plurimath
45
45
  end
46
46
 
47
47
  rule(symbols: simple(:sym)) do
48
- if sym.is_a?(Parslet::Slice)
49
- Math::Symbol.new(
50
- Constants::UNICODE_SYMBOLS[sym.to_sym] || sym,
51
- )
52
- else
53
- sym
54
- end
48
+ Math::Symbol.new(
49
+ Constants::UNICODE_SYMBOLS[sym.to_sym] || sym,
50
+ )
55
51
  end
56
52
 
57
53
  rule(lparen: simple(:lparen),
@@ -404,6 +400,16 @@ module Plurimath
404
400
  )
405
401
  end
406
402
 
403
+ rule(number: simple(:number),
404
+ subscript: simple(:subscript),
405
+ supscript: simple(:supscript)) do
406
+ Math::Function::PowerBase.new(
407
+ Math::Number.new(number),
408
+ subscript,
409
+ supscript,
410
+ )
411
+ end
412
+
407
413
  rule(symbols: simple(:sym),
408
414
  subscript: simple(:subscript)) do
409
415
  Math::Function::Base.new(
@@ -469,6 +475,47 @@ module Plurimath
469
475
  Math::Function::Text.new(first_value)
470
476
  end
471
477
 
478
+ rule(text: simple(:text),
479
+ first_value: sequence(:first_value)) do
480
+ Math::Function::Text.new(first_value.join)
481
+ end
482
+
483
+ rule(text: simple(:text),
484
+ first_value: simple(:first_value),
485
+ supscript: simple(:supscript),) do
486
+ Math::Function::Power.new(
487
+ Math::Function::Text.new(first_value),
488
+ supscript,
489
+ )
490
+ end
491
+
492
+ rule(text: simple(:text),
493
+ first_value: sequence(:first_value),
494
+ supscript: simple(:supscript),) do
495
+ Math::Function::Power.new(
496
+ Math::Function::Text.new(first_value.join),
497
+ supscript,
498
+ )
499
+ end
500
+
501
+ rule(text: simple(:text),
502
+ first_value: sequence(:first_value),
503
+ subscript: simple(:subscript),) do
504
+ Math::Function::Base.new(
505
+ Math::Function::Text.new(first_value.join),
506
+ subscript,
507
+ )
508
+ end
509
+
510
+ rule(text: simple(:text),
511
+ first_value: simple(:first_value),
512
+ subscript: simple(:subscript),) do
513
+ Math::Function::Base.new(
514
+ Math::Function::Text.new(first_value),
515
+ subscript,
516
+ )
517
+ end
518
+
472
519
  rule(unary: simple(:unary),
473
520
  first_value: simple(:first_value)) do
474
521
  Utility.get_class(
@@ -521,6 +568,28 @@ module Plurimath
521
568
  )
522
569
  end
523
570
 
571
+ rule(fonts: simple(:fonts),
572
+ intermediate_exp: simple(:int_exp),
573
+ subscript: simple(:subscript),
574
+ supscript: simple(:supscript)) do
575
+ font_style = if Utility::FONT_STYLES[fonts.to_sym].nil?
576
+ Math::Function::FontStyle.new(
577
+ int_exp,
578
+ fonts.to_s,
579
+ )
580
+ else
581
+ Utility::FONT_STYLES[fonts.to_sym].new(
582
+ int_exp,
583
+ fonts.to_s,
584
+ )
585
+ end
586
+ Math::Function::PowerBase.new(
587
+ font_style,
588
+ subscript,
589
+ supscript,
590
+ )
591
+ end
592
+
524
593
  rule(root: simple(:root),
525
594
  first_value: simple(:first_value),
526
595
  second_value: simple(:second_value)) do
@@ -626,6 +695,23 @@ module Plurimath
626
695
  )
627
696
  end
628
697
 
698
+ rule(binary: simple(:binary),
699
+ subscript: simple(:subscript),
700
+ supscript: simple(:supscript)) do
701
+ if binary.is_a?(Parslet::Slice)
702
+ Utility.get_class(binary).new(
703
+ subscript,
704
+ supscript,
705
+ )
706
+ else
707
+ Math::Function::PowerBase.new(
708
+ binary,
709
+ subscript,
710
+ subscript,
711
+ )
712
+ end
713
+ end
714
+
629
715
  rule(binary: simple(:binary),
630
716
  subscript: simple(:subscript)) do
631
717
  if binary.is_a?(Parslet::Slice)
@@ -7,8 +7,8 @@ module Plurimath
7
7
  self.class.name.split("::").last.downcase
8
8
  end
9
9
 
10
- def insert_t_tag
11
- Array(to_omml_without_math_tag)
10
+ def insert_t_tag(display_style)
11
+ Array(to_omml_without_math_tag(display_style))
12
12
  end
13
13
 
14
14
  def tag_name
@@ -29,13 +29,13 @@ module Plurimath
29
29
  wrapper_tag << r_tag
30
30
  end
31
31
 
32
- def omml_parameter(field, tag_name: , namespace: "m")
32
+ def omml_parameter(field, display_style, tag_name: , namespace: "m")
33
33
  tag = Utility.ox_element(tag_name, namespace: namespace)
34
34
  return empty_tag(tag) unless field
35
35
 
36
36
  Utility.update_nodes(
37
37
  tag,
38
- field&.insert_t_tag,
38
+ field&.insert_t_tag(display_style),
39
39
  )
40
40
  end
41
41
 
@@ -52,6 +52,18 @@ module Plurimath
52
52
  r_tag << (Utility.ox_element("t", namespace: "m") << string)
53
53
  Array(r_tag)
54
54
  end
55
+
56
+ def extractable?
57
+ false
58
+ end
59
+
60
+ def extract_class_from_text
61
+ ""
62
+ end
63
+
64
+ def font_style_t_tag(display_style)
65
+ to_omml_without_math_tag(display_style)
66
+ end
55
67
  end
56
68
  end
57
69
  end
@@ -8,13 +8,13 @@ module Plurimath
8
8
  def initialize(
9
9
  value = [],
10
10
  left_right_wrapper = true,
11
- displaystyle: true,
11
+ display_style: true,
12
12
  input_string: nil
13
13
  )
14
14
  @value = value.is_a?(Array) ? value : [value]
15
15
  left_right_wrapper = false if @value.first.is_a?(Function::Left)
16
16
  @left_right_wrapper = left_right_wrapper
17
- @displaystyle = displaystyle
17
+ @displaystyle = boolean_display_style(display_style)
18
18
  end
19
19
 
20
20
  def ==(object)
@@ -33,7 +33,7 @@ module Plurimath
33
33
  xmlns: "http://www.w3.org/1998/Math/MathML",
34
34
  display: "block",
35
35
  }
36
- style_attrs = { displaystyle: display_style }
36
+ style_attrs = { displaystyle: boolean_display_style(display_style) }
37
37
  math = Utility.ox_element("math", attributes: math_attrs)
38
38
  style = Utility.ox_element("mstyle", attributes: style_attrs)
39
39
  Utility.update_nodes(style, mathml_content)
@@ -91,39 +91,39 @@ module Plurimath
91
91
  }
92
92
  end
93
93
 
94
- def to_omml
94
+ def to_omml(display_style: displaystyle)
95
95
  para_element = Utility.ox_element(
96
96
  "oMathPara",
97
97
  attributes: omml_math_attrs,
98
98
  namespace: "m",
99
99
  )
100
100
  math_element = Utility.ox_element("oMath", namespace: "m")
101
- Utility.update_nodes(math_element, omml_content)
102
- Utility.update_nodes(para_element, Array(math_element))
101
+ content = omml_content(boolean_display_style(display_style))
102
+ para_element << Utility.update_nodes(math_element, content)
103
103
  Ox.dump(para_element, indent: 2).gsub("&amp;", "&").lstrip
104
104
  rescue
105
105
  parse_error!(:omml)
106
106
  end
107
107
 
108
- def omml_content
109
- value&.map(&:insert_t_tag)
108
+ def omml_content(display_style)
109
+ value&.map { |val| val.insert_t_tag(display_style) }
110
110
  end
111
111
 
112
- def to_omml_without_math_tag
113
- return nary_tag if nary_tag_able?
112
+ def to_omml_without_math_tag(display_style)
113
+ return nary_tag(display_style) if nary_tag_able?(display_style)
114
114
 
115
- omml_content
115
+ omml_content(display_style)
116
116
  end
117
117
 
118
- def nary_tag
119
- nary_tag = Utility.ox_element("nary", namespace: "m")
118
+ def nary_tag(display_style)
119
+ nary_element = Utility.ox_element("nary", namespace: "m")
120
120
  e_tag = Utility.ox_element("e", namespace: "m")
121
- Utility.update_nodes(e_tag, value.last.insert_t_tag)
121
+ Utility.update_nodes(e_tag, value.last.insert_t_tag(display_style))
122
122
  Utility.update_nodes(
123
- nary_tag,
124
- (value.first.omml_nary_tag << e_tag),
123
+ nary_element,
124
+ (value.first.omml_nary_tag(display_style) << e_tag),
125
125
  )
126
- [nary_tag]
126
+ [nary_element]
127
127
  end
128
128
 
129
129
  def extract_class_from_text
@@ -136,12 +136,12 @@ module Plurimath
136
136
  value.first.nary_attr_value
137
137
  end
138
138
 
139
- def nary_tag_able?
139
+ def nary_tag_able?(display_style)
140
140
  value.length == 2 &&
141
141
  ["underover", "powerbase"].include?(value&.first&.class_name) &&
142
142
  (
143
- value&.first&.parameter_one&.to_omml_without_math_tag&.length == 1 ||
144
- value&.first&.parameter_one.to_omml_without_math_tag.match?(/^&#x\w*\d*;$/)
143
+ value&.first&.parameter_one&.to_omml_without_math_tag(display_style)&.length == 1 ||
144
+ value&.first&.parameter_one.to_omml_without_math_tag(display_style).match?(/^&#x\w*\d*;$/)
145
145
  )
146
146
  end
147
147
 
@@ -151,6 +151,10 @@ module Plurimath
151
151
 
152
152
  protected
153
153
 
154
+ def boolean_display_style(display_style = displaystyle)
155
+ YAML.load(display_style.to_s)
156
+ end
157
+
154
158
  def parse_error!(type)
155
159
  Math.parse_error!(input_string, type)
156
160
  end
@@ -15,10 +15,10 @@ module Plurimath
15
15
  )
16
16
  end
17
17
 
18
- def to_omml_without_math_tag
18
+ def to_omml_without_math_tag(display_style)
19
19
  md = (Utility.ox_element("d", namespace: "m") << mdpr_tag)
20
20
  me = Utility.ox_element("e", namespace: "m")
21
- Utility.update_nodes(me, omml_value)
21
+ Utility.update_nodes(me, omml_value(display_style))
22
22
  Utility.update_nodes(md, Array(me))
23
23
  [md]
24
24
  end
@@ -6,38 +6,76 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Bar < UnaryFunction
9
+ attr_accessor :attributes
10
+
11
+ def initialize(parameter_one = nil, attributes = {})
12
+ super(parameter_one)
13
+ @attributes = attributes
14
+ end
15
+
16
+ def to_asciimath
17
+ first_value = "(#{parameter_one.to_asciimath})" if parameter_one
18
+ "bar#{first_value}"
19
+ end
20
+
9
21
  def to_latex
10
22
  first_value = "{#{parameter_one.to_latex}}" if parameter_one
11
23
  "\\overline#{first_value}"
12
24
  end
13
25
 
14
26
  def to_mathml_without_math_tag
15
- first_value = parameter_one&.to_mathml_without_math_tag
27
+ mo_tag = Utility.ox_element("mo") << "&#xaf;"
28
+ return mo_tag unless parameter_one
29
+
30
+ mover_tag = Utility.ox_element("mover")
31
+ mover_tag.attributes.merge!(attributes) if attributes && !attributes.empty?
16
32
  Utility.update_nodes(
17
- Utility.ox_element("mover"),
33
+ mover_tag,
18
34
  [
19
- first_value,
20
- Utility.ox_element("mo") << "&#xaf;",
35
+ parameter_one&.to_mathml_without_math_tag,
36
+ mo_tag,
21
37
  ],
22
38
  )
23
39
  end
24
40
 
25
- def to_omml_without_math_tag
41
+ def to_omml_without_math_tag(display_style)
42
+ return r_element("&#xaf;", rpr_tag: false) unless parameter_one
43
+
44
+ attributes && attributes[:accent] ? acc_tag(display_style) : bar_tag(display_style)
45
+ end
46
+
47
+ def swap_class
48
+ Ul.new(parameter_one, attributes)
49
+ end
50
+
51
+ protected
52
+
53
+ def acc_tag(display_style)
54
+ acc = Utility.ox_element("acc", namespace: "m")
55
+ chr = Utility.ox_element("chr", namespace: "m", attributes: { "m:val": "‾" } )
56
+ acc_pr = (Utility.ox_element("accPr", namespace: "m") << chr)
57
+ Utility.update_nodes(
58
+ acc,
59
+ [
60
+ acc_pr,
61
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
62
+ ],
63
+ )
64
+ [acc]
65
+ end
66
+
67
+ def bar_tag(display_style)
26
68
  bar = Utility.ox_element("bar", namespace: "m")
27
- me = Utility.ox_element("e", namespace: "m")
28
- Utility.update_nodes(me, omml_value) if parameter_one
29
69
  Utility.update_nodes(
30
70
  bar,
31
71
  [
32
72
  bar_pr,
33
- me,
73
+ omml_parameter(parameter_one, display_style, tag_name: "e", namespace: "m"),
34
74
  ],
35
75
  )
36
76
  [bar]
37
77
  end
38
78
 
39
- protected
40
-
41
79
  def bar_pr
42
80
  attrs = { "m:val": "top" }
43
81
  barpr = Utility.ox_element("barPr", namespace: "m")
@@ -34,7 +34,7 @@ module Plurimath
34
34
  "#{first_value}#{second_value}"
35
35
  end
36
36
 
37
- def to_omml_without_math_tag
37
+ def to_omml_without_math_tag(display_style)
38
38
  ssub_element = Utility.ox_element("sSub", namespace: "m")
39
39
  subpr_element = Utility.ox_element("sSubPr", namespace: "m")
40
40
  subpr_element << Utility.pr_element("ctrl", true, namespace: "m")
@@ -42,8 +42,8 @@ module Plurimath
42
42
  ssub_element,
43
43
  [
44
44
  subpr_element,
45
- omml_parameter(parameter_one, tag_name: "e"),
46
- omml_parameter(parameter_two, tag_name: "sub"),
45
+ omml_parameter(parameter_one, display_style, tag_name: "e"),
46
+ omml_parameter(parameter_two, display_style, tag_name: "sub"),
47
47
  ],
48
48
  )
49
49
  [ssub_element]
@@ -49,13 +49,21 @@ module Plurimath
49
49
  "#{first_value}#{second_value}"
50
50
  end
51
51
 
52
- def to_omml_without_math_tag
52
+ def to_omml_without_math_tag(display_style)
53
53
  r_tag = Utility.ox_element("r", namespace: "m")
54
- Utility.update_nodes(r_tag, [parameter_one.insert_t_tag]) if parameter_one
55
- Utility.update_nodes(r_tag, [parameter_two.insert_t_tag]) if parameter_two
54
+ Utility.update_nodes(r_tag, [parameter_one.insert_t_tag(display_style)]) if parameter_one
55
+ Utility.update_nodes(r_tag, [parameter_two.insert_t_tag(display_style)]) if parameter_two
56
56
  [r_tag]
57
57
  end
58
58
 
59
+ def any_value_exist?
60
+ !(parameter_one.nil? || parameter_two.nil?)
61
+ end
62
+
63
+ def all_values_exist?
64
+ !(parameter_one.nil? && parameter_two.nil?)
65
+ end
66
+
59
67
  protected
60
68
 
61
69
  def latex_wrapped(field)
@@ -82,18 +90,20 @@ module Plurimath
82
90
  wrapper_tag << r_tag
83
91
  end
84
92
 
85
- def all_values_exist?
86
- !(parameter_one.nil? && parameter_two.nil?)
87
- end
88
-
89
- def underover
93
+ def underover(display_style)
90
94
  return r_element(class_name, rpr_tag: false) unless all_values_exist?
91
95
 
92
96
  first_value = Symbol.new(class_name)
97
+ if !display_style
98
+ power_base = PowerBase.new(first_value, parameter_one, parameter_two)
99
+ return power_base.to_omml_without_math_tag(display_style)
100
+ end
101
+
93
102
  overset = Overset.new(first_value, parameter_two)
94
- return Array(overset.to_omml_without_math_tag) unless parameter_one
103
+ return Array(overset.to_omml_without_math_tag(display_style)) unless parameter_one
95
104
 
96
- Array(Underset.new(overset, parameter_one)&.to_omml_without_math_tag)
105
+ underset = Underset.new(overset, parameter_one)
106
+ Array(underset.to_omml_without_math_tag(display_style))
97
107
  end
98
108
  end
99
109
  end
@@ -15,8 +15,8 @@ module Plurimath
15
15
  Utility.update_nodes(cancel_tag, [first_value])
16
16
  end
17
17
 
18
- def to_omml_without_math_tag
19
- omml_value
18
+ def to_omml_without_math_tag(display_style)
19
+ omml_value(display_style)
20
20
  end
21
21
  end
22
22
  end
@@ -20,11 +20,16 @@ module Plurimath
20
20
  )
21
21
  end
22
22
 
23
- def to_omml_without_math_tag
23
+ def to_omml_without_math_tag(display_style)
24
24
  lceil = Symbol.new("⌈")
25
25
  rceil = Symbol.new("⌉")
26
26
  fenced = Fenced.new(lceil, Array(parameter_one), rceil)
27
- Array(fenced.to_omml_without_math_tag)
27
+ Array(fenced.to_omml_without_math_tag(display_style))
28
+ end
29
+
30
+ def to_html
31
+ first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
32
+ "<i>&#x2308;</i>#{first_value}<i>&#x2309;</i>"
28
33
  end
29
34
  end
30
35
  end
@@ -28,8 +28,8 @@ module Plurimath
28
28
  "{\\#{class_name}{#{first_value}} #{second_value}}"
29
29
  end
30
30
 
31
- def to_omml_without_math_tag
32
- Array(parameter_two.insert_t_tag)
31
+ def to_omml_without_math_tag(display_style)
32
+ Array(parameter_two.insert_t_tag(display_style))
33
33
  end
34
34
  end
35
35
  end
@@ -6,6 +6,13 @@ module Plurimath
6
6
  module Math
7
7
  module Function
8
8
  class Ddot < UnaryFunction
9
+ attr_accessor :attributes
10
+
11
+ def initialize(parameter_one = nil, attributes = {})
12
+ super(parameter_one)
13
+ @attributes = attributes
14
+ end
15
+
9
16
  def to_mathml_without_math_tag
10
17
  second_value = Utility.ox_element("mo") << ".."
11
18
  Utility.update_nodes(
@@ -14,18 +21,16 @@ module Plurimath
14
21
  )
15
22
  end
16
23
 
17
- def to_omml_without_math_tag
18
- acc_tag = Utility.ox_element("acc", namespace: "m")
19
- acc_pr_tag = Utility.ox_element("accPr", namespace: "m")
20
- acc_pr_tag << (Utility.ox_element("chr", namespace: "m", attributes: { "m:val": ".." }))
21
- Utility.update_nodes(
22
- acc_tag,
23
- [
24
- acc_pr_tag,
25
- omml_parameter(parameter_one, tag_name: "e"),
26
- ],
27
- )
28
- [acc_tag]
24
+ def to_omml_without_math_tag(display_style)
25
+ return r_element("..", rpr_tag: false) unless parameter_one
26
+
27
+ symbol = Symbol.new("..")
28
+ Overset.new(parameter_one, symbol).to_omml_without_math_tag(true)
29
+ end
30
+
31
+ def to_html
32
+ first_value = "<i>#{parameter_one.to_html}</i>" if parameter_one
33
+ "#{first_value}<i>..</i>"
29
34
  end
30
35
  end
31
36
  end
@@ -10,8 +10,8 @@ module Plurimath
10
10
  false
11
11
  end
12
12
 
13
- def to_omml_without_math_tag
14
- [r_element("deg"), omml_value]
13
+ def to_omml_without_math_tag(display_style)
14
+ [r_element("deg", rpr_tag: false), omml_value(display_style)]
15
15
  end
16
16
  end
17
17
  end
@@ -10,8 +10,8 @@ module Plurimath
10
10
  false
11
11
  end
12
12
 
13
- def to_omml_without_math_tag
14
- [r_element("det"), omml_value]
13
+ def to_omml_without_math_tag(display_style)
14
+ [r_element("det", rpr_tag: false), omml_value(display_style)]
15
15
  end
16
16
  end
17
17
  end
@@ -10,8 +10,8 @@ module Plurimath
10
10
  false
11
11
  end
12
12
 
13
- def to_omml_without_math_tag
14
- [r_element("dim"), omml_value]
13
+ def to_omml_without_math_tag(display_style)
14
+ [r_element("dim", rpr_tag: false), omml_value(display_style)]
15
15
  end
16
16
  end
17
17
  end