plurimath 0.7.2 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. checksums.yaml +4 -4
  2. data/.gitmodules +3 -0
  3. data/Latex-Supported-Data.adoc +1 -0
  4. data/UnicodeMath-Supported-Data.adoc +1342 -0
  5. data/UnitsML-Supported-Data.adoc +444 -0
  6. data/lib/plurimath/asciimath/parse.rb +1 -1
  7. data/lib/plurimath/asciimath/transform.rb +2 -6
  8. data/lib/plurimath/latex/constants.rb +2 -0
  9. data/lib/plurimath/math/core.rb +38 -6
  10. data/lib/plurimath/math/formula.rb +60 -6
  11. data/lib/plurimath/math/function/abs.rb +4 -0
  12. data/lib/plurimath/math/function/arg.rb +22 -0
  13. data/lib/plurimath/math/function/bar.rb +4 -0
  14. data/lib/plurimath/math/function/base.rb +49 -0
  15. data/lib/plurimath/math/function/binary_function.rb +6 -0
  16. data/lib/plurimath/math/function/cancel.rb +5 -0
  17. data/lib/plurimath/math/function/ceil.rb +6 -0
  18. data/lib/plurimath/math/function/color.rb +20 -1
  19. data/lib/plurimath/math/function/ddot.rb +4 -0
  20. data/lib/plurimath/math/function/dot.rb +5 -0
  21. data/lib/plurimath/math/function/fenced.rb +98 -7
  22. data/lib/plurimath/math/function/floor.rb +6 -0
  23. data/lib/plurimath/math/function/font_style/monospace.rb +4 -0
  24. data/lib/plurimath/math/function/font_style.rb +31 -6
  25. data/lib/plurimath/math/function/frac.rb +69 -15
  26. data/lib/plurimath/math/function/hat.rb +4 -0
  27. data/lib/plurimath/math/function/inf.rb +30 -0
  28. data/lib/plurimath/math/function/int.rb +47 -1
  29. data/lib/plurimath/math/function/intent.rb +22 -0
  30. data/lib/plurimath/math/function/left.rb +4 -0
  31. data/lib/plurimath/math/function/lim.rb +6 -0
  32. data/lib/plurimath/math/function/limits.rb +28 -0
  33. data/lib/plurimath/math/function/linebreak.rb +5 -0
  34. data/lib/plurimath/math/function/log.rb +27 -20
  35. data/lib/plurimath/math/function/longdiv.rb +4 -0
  36. data/lib/plurimath/math/function/mbox.rb +4 -0
  37. data/lib/plurimath/math/function/menclose.rb +74 -5
  38. data/lib/plurimath/math/function/merror.rb +2 -0
  39. data/lib/plurimath/math/function/mglyph.rb +64 -0
  40. data/lib/plurimath/math/function/mlabeledtr.rb +29 -0
  41. data/lib/plurimath/math/function/mod.rb +4 -0
  42. data/lib/plurimath/math/function/mpadded.rb +84 -0
  43. data/lib/plurimath/math/function/ms.rb +33 -0
  44. data/lib/plurimath/math/function/msgroup.rb +4 -0
  45. data/lib/plurimath/math/function/msline.rb +2 -4
  46. data/lib/plurimath/math/function/multiscript.rb +70 -6
  47. data/lib/plurimath/math/function/nary.rb +69 -10
  48. data/lib/plurimath/math/function/none.rb +25 -0
  49. data/lib/plurimath/math/function/norm.rb +6 -0
  50. data/lib/plurimath/math/function/obrace.rb +4 -0
  51. data/lib/plurimath/math/function/oint.rb +25 -1
  52. data/lib/plurimath/math/function/over.rb +6 -0
  53. data/lib/plurimath/math/function/overset.rb +46 -1
  54. data/lib/plurimath/math/function/phantom.rb +18 -2
  55. data/lib/plurimath/math/function/power.rb +37 -0
  56. data/lib/plurimath/math/function/power_base.rb +45 -18
  57. data/lib/plurimath/math/function/prod.rb +46 -0
  58. data/lib/plurimath/math/function/right.rb +4 -0
  59. data/lib/plurimath/math/function/root.rb +9 -1
  60. data/lib/plurimath/math/function/rule.rb +4 -0
  61. data/lib/plurimath/math/function/sqrt.rb +7 -1
  62. data/lib/plurimath/math/function/stackrel.rb +6 -0
  63. data/lib/plurimath/math/function/substack.rb +4 -0
  64. data/lib/plurimath/math/function/sum.rb +45 -24
  65. data/lib/plurimath/math/function/table/bmatrix.rb +18 -5
  66. data/lib/plurimath/math/function/table/cases.rb +24 -0
  67. data/lib/plurimath/math/function/table/eqarray.rb +24 -0
  68. data/lib/plurimath/math/function/table/matrix.rb +23 -3
  69. data/lib/plurimath/math/function/table/pmatrix.rb +4 -0
  70. data/lib/plurimath/math/function/table/vmatrix.rb +10 -0
  71. data/lib/plurimath/math/function/table.rb +58 -7
  72. data/lib/plurimath/math/function/td.rb +9 -0
  73. data/lib/plurimath/math/function/ternary_function.rb +14 -1
  74. data/lib/plurimath/math/function/text.rb +6 -0
  75. data/lib/plurimath/math/function/tilde.rb +4 -0
  76. data/lib/plurimath/math/function/tr.rb +9 -0
  77. data/lib/plurimath/math/function/ubrace.rb +5 -0
  78. data/lib/plurimath/math/function/ul.rb +4 -0
  79. data/lib/plurimath/math/function/unary_function.rb +4 -0
  80. data/lib/plurimath/math/function/underover.rb +14 -0
  81. data/lib/plurimath/math/function/underset.rb +49 -1
  82. data/lib/plurimath/math/function/vec.rb +4 -0
  83. data/lib/plurimath/math/number.rb +33 -3
  84. data/lib/plurimath/math/symbol.rb +68 -3
  85. data/lib/plurimath/math.rb +3 -2
  86. data/lib/plurimath/mathml/constants.rb +16 -0
  87. data/lib/plurimath/mathml/parser.rb +42 -2
  88. data/lib/plurimath/mathml/transform.rb +80 -29
  89. data/lib/plurimath/omml/parser.rb +8 -0
  90. data/lib/plurimath/omml/transform.rb +29 -26
  91. data/lib/plurimath/unicode_math/constants.rb +1014 -0
  92. data/lib/plurimath/unicode_math/parse.rb +233 -0
  93. data/lib/plurimath/unicode_math/parser.rb +58 -0
  94. data/lib/plurimath/unicode_math/parsing_rules/absence_rules.rb +138 -0
  95. data/lib/plurimath/unicode_math/parsing_rules/common_rules.rb +114 -0
  96. data/lib/plurimath/unicode_math/parsing_rules/constants_rules.rb +102 -0
  97. data/lib/plurimath/unicode_math/parsing_rules/helper.rb +19 -0
  98. data/lib/plurimath/unicode_math/parsing_rules/masked.rb +62 -0
  99. data/lib/plurimath/unicode_math/parsing_rules/sub_sup.rb +254 -0
  100. data/lib/plurimath/unicode_math/transform.rb +3831 -0
  101. data/lib/plurimath/{unicode.rb → unicode_math.rb} +2 -2
  102. data/lib/plurimath/unitsml.rb +14 -1
  103. data/lib/plurimath/utility.rb +346 -11
  104. data/lib/plurimath/version.rb +1 -1
  105. data/lib/plurimath/xml_engine/oga.rb +5 -0
  106. data/lib/plurimath/xml_engine/ox.rb +5 -0
  107. metadata +25 -3
@@ -0,0 +1,444 @@
1
+ == UnitsML Support
2
+
3
+ === UNITS
4
+
5
+ * `ton-force (2000 lb)` => `ton-force (2000 lb)`
6
+ * `fl oz (US label)` => `fl oz (US label)`
7
+ * `e^2*a_0^2*(E_h)^-1` => `𝑒²𝑎₀²/𝐸ₕ`
8
+ * `oz (US label)` => `oz (US label)`
9
+ * `liq pint (US)` => `liq pint (US)`
10
+ * `e^3a_0^3*(E_h^3)` => `𝑒³𝑎₀³𝐸ₕ³`
11
+ * `e^4a_0^4*(E_h^3)` => `𝑒⁴𝑎₀⁴𝐸ₕ⁴`
12
+ * `in^3_section_modulus` => `in³`
13
+ * `e^2*a_0^2*m_e-1` => `𝑒²𝑎₀²/𝑚ₑ`
14
+ * `h-bar*(e*a_0^2)-1` => `ℏ/𝑒𝑎₀²`
15
+ * `e^2*(a_0*E_h)-1` => `𝑒²/𝑎₀𝐸ₕ`
16
+ * `dry pt (US)` => `dry pt (US)`
17
+ * `J*mol^-1*K^-1` => `J/(mol·K)`
18
+ * `dry qt (US)` => `dry qt (US)`
19
+ * `statcoulomb` => `statcoulomb`
20
+ * `liq qt (US)` => `liq qt (US)`
21
+ * `a_0*E_h*h-bar-1` => `𝑎₀𝐸ₕ/ℏ`
22
+ * `W*m^-2*sr^-1` => `W/(m²·sr)`
23
+ * `kcal_th*s^-1` => `kcal_th/s`
24
+ * `h-bar*(m_e*c^2)` => `ℏ/𝑚ₑ𝑐²`
25
+ * `E_h*(e*a_0^2)` => `𝐸ₕ/𝑒𝑎₀²`
26
+ * `ton_refrigeration` => `ton`
27
+ * `dwt (troy)` => `dwt (troy)`
28
+ * `J*kg^-1*K^-1` => `J/(kg·K)`
29
+ * `fl oz (UK)` => `fl oz (UK)`
30
+ * `fl oz (US)` => `fl oz (US)`
31
+ * `h-bar*e*(m_e)-1` => `ℏ𝑒/𝑚ₑ`
32
+ * `dprime_Hg_60degF` => `″Hg`
33
+ * `dprime_Hg_32degF` => `″Hg`
34
+ * `ft*lbf*s^-1` => `ft·lbf/2`
35
+ * `cal_th*s^-1` => `cal_th/s`
36
+ * `N*m^2*kg^-2` => `N·m²/kg²`
37
+ * `W*m^-2*K^-1` => `W/(m²·K)`
38
+ * `eE_h*h-bar^-1` => `𝑒𝐸ₕ/ℏ`
39
+ * `ftH_2O_39degF` => `ftH₂O`
40
+ * `h-bar*(E_h)-1` => `ℏ/𝐸ₕ`
41
+ * `dr (avdp)` => `dr (avdp)`
42
+ * `scr (ap.)` => `scr (ap.)`
43
+ * `W*m^-1*K^-1` => `W/(m·K)`
44
+ * `kgf*s^2/m` => `kgf·s²m⁻¹`
45
+ * `kg*m^2*s^-1` => `kg·m²/s`
46
+ * `inH_2O_39degF` => `inH₂O`
47
+ * `inH_2O_60degF` => `inH₂O`
48
+ * `E_h*(e*a_0)` => `𝐸ₕ/𝑒𝑎₀`
49
+ * `ft^3*min^-1` => `ft³min`
50
+ * `kgf*m*s^-1` => `kgf·m/s`
51
+ * `ft*min^-1` => `ft·min⁻¹`
52
+ * `dyn*cm^-2` => `dyn·cm⁻²`
53
+ * `kgf*cm^-2` => `kgf·cm⁻²`
54
+ * `kgf*mm^-2` => `kgf·mm⁻²`
55
+ * `mi*min^-1` => `mi·min⁻¹`
56
+ * `cmH_2O_4degC` => `cmH₂O`
57
+ * `ft^3*sec^-1` => `ft³sec`
58
+ * `in^3*min^-1` => `in³min`
59
+ * `E_h*(a_0)-1` => `𝐸ₕ/𝑎₀`
60
+ * `h-bar*(a_0)-1` => `ℏ/𝑎₀`
61
+ * `a_tropical_year` => `a`
62
+ * `cwt (US)` => `cwt (US)`
63
+ * `cwt (UK)` => `cwt (UK)`
64
+ * `bbl (US)` => `bbl (US)`
65
+ * `gal (US)` => `gal (US)`
66
+ * `gal (UK)` => `gal (UK)`
67
+ * `thm (EC)` => `thm (EC)`
68
+ * `rad_radiation` => `rad`
69
+ * `thm (US)` => `thm (US)`
70
+ * `statwatt` => `statwatt`
71
+ * `a_sidereal_year` => `a`
72
+ * `mol*kg^-1` => `mol/kg`
73
+ * `pica_computer` => `pc`
74
+ * `lambda-bar_C` => `ƛ_C`
75
+ * `aW (Cardelli)` => `aW`
76
+ * `mol*m^-3` => `mol·m⁻³`
77
+ * `erg*s^-1` => `erg·s⁻¹`
78
+ * `kgf*m^-2` => `kgf·m⁻²`
79
+ * `gf*cm^-2` => `gf·cm⁻²`
80
+ * `inHg_60degF` => `inHg`
81
+ * `inHg_32degF` => `inHg`
82
+ * `min_sidereal` => `min`
83
+ * `m_e*c^2_MeV` => `𝑚ₑ𝑐²`
84
+ * `mi_US_survey` => `mi`
85
+ * `statohm` => `statohm`
86
+ * `ft^2*s^-1` => `ft²/s`
87
+ * `kat*m^-3` => `kat/m³`
88
+ * `kcal_IT` => `kcal_IT`
89
+ * `kcal_th` => `kcal_th`
90
+ * `rad*s^-2` => `rad/s²`
91
+ * `cmHg_0degC` => `cmHg`
92
+ * `lb*ft^-3` => `lb/ft³`
93
+ * `pt (UK)` => `pt (UK)`
94
+ * `bu (US)` => `bu (US)`
95
+ * `kg*m*s^-1` => `N·m/s`
96
+ * `statmho` => `statmho`
97
+ * `pica_printer` => `pc`
98
+ * `yd_US_survey` => `yd`
99
+ * `tbsp_label` => `tbsp`
100
+ * `ft_US_survey` => `ft`
101
+ * `in_US_survey` => `in`
102
+ * `qt (UK)` => `qt (UK)`
103
+ * `m_e*c_MeV/C` => `𝑚ₑ𝑐`
104
+ * `gal*min^-1` => `gpm`
105
+ * `rad*m^-1` => `rad/m`
106
+ * `hp_electric` => `hp`
107
+ * `cd*m^-2` => `cd·m⁻²`
108
+ * `ft*s^-1` => `ft·s⁻¹`
109
+ * `in*s^-1` => `in·s⁻¹`
110
+ * `mi*h^-1` => `mi·h⁻¹`
111
+ * `mi*s^-1` => `mi·s⁻¹`
112
+ * `kg*m^-3` => `kg·m⁻³`
113
+ * `J*mol^-1` => `J/mol`
114
+ * `rad*s^-1` => `rad/s`
115
+ * `"Hg_32degF` => `″Hg`
116
+ * `pt_computer` => `pt`
117
+ * `"Hg_60degF` => `″Hg`
118
+ * `Btu_39degF` => `Btu`
119
+ * `Btu_59degF` => `Btu`
120
+ * `Btu_60degF` => `Btu`
121
+ * `h-bar_atomic` => `ℏ`
122
+ * `gi_imperial` => `gi`
123
+ * `mol*L^-1` => `mol/L`
124
+ * `mol*l^-1` => `mol/l`
125
+ * `e*(a_0^3)` => `𝑒𝑎₀³`
126
+ * `m_e_atomic` => `𝑚ₑ`
127
+ * `mi/gal` => `mi/gal`
128
+ * `statWb` => `statWb`
129
+ * `tsp_label` => `tsp`
130
+ * `ft*s^-2` => `ft/s²`
131
+ * `kg*m^-2` => `kg/m²`
132
+ * `cal_IT` => `cal_IT`
133
+ * `cal_th` => `cal_th`
134
+ * `ft*lbf` => `ft·lbf`
135
+ * `m^2*s^-1` => `m²/s`
136
+ * `m^3*s^-1` => `m³/s`
137
+ * `lbf*in^-2` => `psi`
138
+ * `cup_label` => `cup`
139
+ * `dprime_Hg` => `″Hg`
140
+ * `Btu_th` => `Btu_th`
141
+ * `pt_printer` => `pt`
142
+ * `E_h*e-1` => `𝐸ₕ/𝑒`
143
+ * `mil_nato` => `mil`
144
+ * `Btu_mean` => `Btu`
145
+ * `h-bar_eV_s` => `ℏ`
146
+ * `hp_boiler` => `hp`
147
+ * `W*sr^-1` => `W/sr`
148
+ * `J*kg^-1` => `J/kg`
149
+ * `m*s^-1` => `m·s⁻¹`
150
+ * `m^3*kg` => `m³·kg`
151
+ * `m*s^-2` => `m·s⁻²`
152
+ * `A*m^-2` => `A·m⁻²`
153
+ * `A*m^-1` => `A·m⁻¹`
154
+ * `C*kg^-1` => `C/kg`
155
+ * `Gy*s^-1` => `Gy/s`
156
+ * `Np*s^-1` => `Np/s`
157
+ * `Pa*K^-1` => `Pa/K`
158
+ * `kg*s^-1` => `kg/s`
159
+ * `kg*m^-1` => `kg/m`
160
+ * `kg*m^2` => `kg·m²`
161
+ * `kg*l^-1` => `kg/l`
162
+ * `hp_metric` => `hp`
163
+ * `mmH_2O` => `mmH₂O`
164
+ * `ftH_2O` => `ftH₂O`
165
+ * `cmH_2O` => `cmH₂O`
166
+ * `inH_2O` => `inH₂O`
167
+ * `prime_Hg` => `′Hg`
168
+ * `d_sidereal` => `d`
169
+ * `h_sidereal` => `h`
170
+ * `s_sidereal` => `s`
171
+ * `m_e*c^2` => `𝑚ₑ𝑐²`
172
+ * `e*a_0^2` => `𝑒𝑎₀²`
173
+ * `gpm` => `gal/min`
174
+ * `J*m^-3` => `J/m³`
175
+ * `W*m^-2` => `W/m²`
176
+ * `kgf*m` => `kgf·m`
177
+ * `fermi` => `fermi`
178
+ * `dprime_in` => `″`
179
+ * `abS` => `(abΩ)⁻¹`
180
+ * `prime_min` => `′`
181
+ * `ton_TNT` => `ton`
182
+ * `C*m^-3` => `C/m³`
183
+ * `C*m^-2` => `C/m²`
184
+ * `barye` => `barye`
185
+ * `psi` => `lbf/in²`
186
+ * `N*m*s` => `N·m·s`
187
+ * `t*m^-3` => `t/m³`
188
+ * `ton_short` => `t`
189
+ * `lbmol` => `lbmol`
190
+ * `hp_water` => `hp`
191
+ * `statT` => `statT`
192
+ * `statF` => `statF`
193
+ * `statA` => `statA`
194
+ * `statV` => `statV`
195
+ * `statH` => `statH`
196
+ * `shake` => `shake`
197
+ * `fl dr` => `fl dr`
198
+ * `ac*ft` => `ac·ft`
199
+ * `F*m^-1` => `F/m`
200
+ * `V*m^-1` => `V/m`
201
+ * `J*K^-1` => `J/K`
202
+ * `N*m^-1` => `N/m`
203
+ * `prime_ft` => `′`
204
+ * `dprime_s` => `″`
205
+ * `H*m^-1` => `H/m`
206
+ * `ton_long` => `t`
207
+ * `Pa^-1` => `Pa⁻¹`
208
+ * `oz_troy` => `oz`
209
+ * `lb_troy` => `lb`
210
+ * `Lambert` => `L`
211
+ * `l.y.` => `l.y.`
212
+ * `cmHg` => `cmHg`
213
+ * `Torr` => `torr`
214
+ * `slug` => `slug`
215
+ * `mmHg` => `mmHg`
216
+ * `km/h` => `km/h`
217
+ * `Pa*s` => `Pa·s`
218
+ * `abohm` => `abΩ`
219
+ * `kW*h` => `kW·h`
220
+ * `thou` => `thou`
221
+ * `l.w.` => `l.w.`
222
+ * `ft.c` => `ft.c`
223
+ * `ft.L` => `ft.L`
224
+ * `fath` => `fath`
225
+ * `cmil` => `cmil`
226
+ * `tbsp` => `tbsp`
227
+ * `minim` => `min`
228
+ * `inHg` => `inHg`
229
+ * `ftHg` => `ftHg`
230
+ * `l.h.` => `l.h.`
231
+ * `l.m.` => `l.m.`
232
+ * `l.s.` => `l.s.`
233
+ * `mbar` => `mbar`
234
+ * `m_e*c` => `𝑚ₑ𝑐`
235
+ * `e*a_0` => `𝑒𝑎₀`
236
+ * `in^4` => `in⁴`
237
+ * `K^-1` => `K⁻¹`
238
+ * `yd^2` => `yd²`
239
+ * `m^-1` => `m⁻¹`
240
+ * `kayser` => `K`
241
+ * `a_year` => `a`
242
+ * `ft^2` => `ft²`
243
+ * `in^2` => `in²`
244
+ * `micron` => `μ`
245
+ * `s^-1` => `s⁻¹`
246
+ * `mi^2` => `mi²`
247
+ * `in^3` => `in³`
248
+ * `ft^3` => `ft³`
249
+ * `yd^3` => `yd³`
250
+ * `dprime` => `″`
251
+ * `byte_B` => `B`
252
+ * `hp_UK` => `hp`
253
+ * `tex` => `tex`
254
+ * `Gal` => `Gal`
255
+ * `bel_B` => `B`
256
+ * `mil` => `mil`
257
+ * `bar` => `bar`
258
+ * `'_min` => `′`
259
+ * `abA` => `abA`
260
+ * `abC` => `abC`
261
+ * `abF` => `abF`
262
+ * `abV` => `abV`
263
+ * `A*h` => `A·h`
264
+ * `erg` => `erg`
265
+ * `abH` => `abH`
266
+ * `Aring` => `Å`
267
+ * `mol` => `mol`
268
+ * `degC` => `°C`
269
+ * `min` => `min`
270
+ * `rad` => `rad`
271
+ * `degK` => `°K`
272
+ * `kat` => `kat`
273
+ * `gamma` => `γ`
274
+ * `rem` => `rem`
275
+ * `W*h` => `W·h`
276
+ * `W*s` => `W·s`
277
+ * `dyn` => `dyn`
278
+ * `kgf` => `kgf`
279
+ * `N*m` => `N·m`
280
+ * `rhe` => `rhe`
281
+ * `atm` => `atm`
282
+ * `darcy` => `d`
283
+ * `Darcy` => `D`
284
+ * `gon` => `gon`
285
+ * `prime` => `′`
286
+ * `cal` => `cal`
287
+ * `pdl` => `pdl`
288
+ * `N*s` => `N·s`
289
+ * `lbf` => `lbf`
290
+ * `J*s` => `J·s`
291
+ * `kip` => `kip`
292
+ * `h-bar` => `ℏ`
293
+ * `e_h` => `𝐸ₕ`
294
+ * `"Hg` => `″Hg`
295
+ * `degR` => `°R`
296
+ * `lnk` => `lnk`
297
+ * `fur` => `fur`
298
+ * `tsp` => `tsp`
299
+ * `'Hg` => `′Hg`
300
+ * `degF` => `°F`
301
+ * `Btu` => `Btu`
302
+ * `den` => `den`
303
+ * `bit` => `bit`
304
+ * `cup` => `cup`
305
+ * `cSt` => `cSt`
306
+ * `uin` => `μin`
307
+ * `mpg` => `mpg`
308
+ * `ppm` => `ppm`
309
+ * `var` => `var`
310
+ * `m_e` => `𝑚ₑ`
311
+ * `'_ft` => `′`
312
+ * `m^3` => `m³`
313
+ * `m^2` => `m²`
314
+ * `"_in` => `″`
315
+ * `barn` => `b`
316
+ * `m^4` => `m⁴`
317
+ * `a_0` => `𝑎₀`
318
+ * `c_0` => `𝑐₀`
319
+ * `"_s` => `″`
320
+ * `Ohm` => `Ω`
321
+ * `deg` => `º`
322
+ * `cd` => `cd`
323
+ * `kg` => `kg`
324
+ * `in` => `in`
325
+ * `sr` => `sr`
326
+ * `Pa` => `Pa`
327
+ * `Wb` => `Wb`
328
+ * `Bq` => `Bq`
329
+ * `Gy` => `Gy`
330
+ * `Sv` => `Sv`
331
+ * `Hz` => `Hz`
332
+ * `lm` => `lm`
333
+ * `lx` => `lx`
334
+ * `ha` => `ha`
335
+ * `Bi` => `Bi`
336
+ * `Mx` => `Mx`
337
+ * `kp` => `kp`
338
+ * `ft` => `ft`
339
+ * `mi` => `mi`
340
+ * `yd` => `yd`
341
+ * `ph` => `ph`
342
+ * `gr` => `gr`
343
+ * `Ci` => `Ci`
344
+ * `st` => `st`
345
+ * `Gs` => `Gs`
346
+ * `cP` => `cP`
347
+ * `sb` => `sb`
348
+ * `at` => `at`
349
+ * `St` => `St`
350
+ * `Oe` => `Oe`
351
+ * `as` => `as`
352
+ * `kn` => `kn`
353
+ * `Np` => `Np`
354
+ * `dB` => `dB`
355
+ * `ua` => `ua`
356
+ * `pc` => `pc`
357
+ * `gf` => `gf`
358
+ * `lb` => `lb`
359
+ * `oz` => `oz`
360
+ * `ct` => `ct`
361
+ * `Gi` => `Gi`
362
+ * `dr` => `dr`
363
+ * `eV` => `eV`
364
+ * `rd` => `rd`
365
+ * `hp` => `hp`
366
+ * `Da` => `Da`
367
+ * `ch` => `ch`
368
+ * `ac` => `ac`
369
+ * `pH` => `pH`
370
+ * `pk` => `pk`
371
+ * `gi` => `gi`
372
+ * `mL` => `mL`
373
+ * `ml` => `ml`
374
+ * `m` => `m`
375
+ * `s` => `s`
376
+ * `A` => `A`
377
+ * `K` => `K`
378
+ * `N` => `N`
379
+ * `J` => `J`
380
+ * `W` => `W`
381
+ * `C` => `C`
382
+ * `V` => `V`
383
+ * `F` => `F`
384
+ * `S` => `S`
385
+ * `T` => `T`
386
+ * `H` => `H`
387
+ * `g` => `g`
388
+ * `h` => `h`
389
+ * `d` => `d`
390
+ * `a` => `a`
391
+ * `t` => `t`
392
+ * `R` => `R`
393
+ * `P` => `P`
394
+ * `l` => `l`
395
+ * `L` => `L`
396
+ * `M` => `M`
397
+ * `1` => `1`
398
+ * `D` => `D`
399
+ * `u` => `u`
400
+ * `c` => `𝑐`
401
+ * `e` => `𝑒`
402
+ * `"` => `″`
403
+ * `'` => `′`
404
+
405
+ == DIMENSIONS
406
+
407
+ * `dim_Theta` => `𝝧`
408
+ * `dim_phi` => `𝞅`
409
+ * `dim_L` => `𝖫`
410
+ * `dim_M` => `𝖬`
411
+ * `dim_T` => `𝖨`
412
+ * `dim_N` => `𝖭`
413
+ * `dim_J` => `𝖩`
414
+
415
+ == PREFIX
416
+
417
+ * `da` => `da`
418
+ * `Ki` => `Ki`
419
+ * `Mi` => `Mi`
420
+ * `Gi` => `Gi`
421
+ * `Ti` => `Ti`
422
+ * `Pi` => `Pi`
423
+ * `Ei` => `Ei`
424
+ * `Zi` => `Zi`
425
+ * `Yi` => `Yi`
426
+ * `Y` => `Y`
427
+ * `Z` => `Z`
428
+ * `E` => `E`
429
+ * `P` => `P`
430
+ * `T` => `T`
431
+ * `G` => `G`
432
+ * `M` => `M`
433
+ * `k` => `k`
434
+ * `h` => `h`
435
+ * `d` => `d`
436
+ * `c` => `c`
437
+ * `m` => `m`
438
+ * `u` => `μ`
439
+ * `n` => `n`
440
+ * `p` => `p`
441
+ * `f` => `f`
442
+ * `a` => `a`
443
+ * `z` => `z`
444
+ * `y` => `y`
@@ -69,7 +69,7 @@ module Plurimath
69
69
  end
70
70
 
71
71
  rule(:quoted_text) do
72
- (str('"') >> str("unitsml(") >> match("[^\)\"]").repeat.as(:unitsml) >> str(')"')) |
72
+ (str('"') >> str("unitsml(") >> (str(')"').absent? >> any).repeat.as(:unitsml) >> str(')"')) |
73
73
  (str('"') >> match("[^\"]").repeat.as(:text) >> str('"')) |
74
74
  (str('"') >> str("").as(:text))
75
75
  end
@@ -29,9 +29,7 @@ module Plurimath
29
29
  rule(mod: simple(:mod), expr: simple(:expr)) { [mod, expr] }
30
30
 
31
31
  rule(unitsml: simple(:unitsml)) do
32
- Utility.filter_values(
33
- Unitsml.new(unitsml.to_s).to_formula.value,
34
- )
32
+ Unitsml.new(unitsml.to_s).to_formula
35
33
  end
36
34
 
37
35
  rule(bold_fonts: simple(:font)) do
@@ -881,9 +879,7 @@ module Plurimath
881
879
  rule(unary_class: simple(:function),
882
880
  unitsml: simple(:unitsml)) do
883
881
  Utility.get_class(function).new(
884
- Utility.filter_values(
885
- Unitsml.new(unitsml.to_s).to_formula.value,
886
- ),
882
+ Unitsml.new(unitsml.to_s).to_formula,
887
883
  )
888
884
  end
889
885
 
@@ -883,6 +883,7 @@ module Plurimath
883
883
  supseteqq: "⫆",
884
884
  leqqslant: "⫹",
885
885
  geqqslant: "⫺",
886
+ emptyset: "∅",
886
887
  horizbar: "―",
887
888
  Question: "⁇",
888
889
  medspace: " ",
@@ -2705,6 +2706,7 @@ module Plurimath
2705
2706
  leqqslant: :symbols,
2706
2707
  geqqslant: :symbols,
2707
2708
  mbfitsans: :fonts,
2709
+ emptyset: :symbols,
2708
2710
  horizbar: :symbols,
2709
2711
  Question: :symbols,
2710
2712
  medspace: :symbols,
@@ -28,9 +28,11 @@ module Plurimath
28
28
  ""
29
29
  end
30
30
 
31
- def empty_tag(wrapper_tag)
31
+ def empty_tag(wrapper_tag = nil)
32
32
  r_tag = ox_element("r", namespace: "m")
33
33
  r_tag << (ox_element("t", namespace: "m") << "&#8203;")
34
+ return r_tag unless wrapper_tag
35
+
34
36
  wrapper_tag << r_tag
35
37
  end
36
38
 
@@ -38,10 +40,12 @@ module Plurimath
38
40
  tag = ox_element(tag_name, namespace: namespace)
39
41
  return empty_tag(tag) unless field
40
42
 
41
- Utility.update_nodes(
42
- tag,
43
- field.insert_t_tag(display_style),
44
- )
43
+ field_value = if field.is_a?(Array)
44
+ field.map { |object| object.insert_t_tag(display_style) }
45
+ else
46
+ field.insert_t_tag(display_style)
47
+ end
48
+ Utility.update_nodes(tag, field_value)
45
49
  end
46
50
 
47
51
  def validate_function_formula
@@ -127,7 +131,11 @@ module Plurimath
127
131
  end
128
132
 
129
133
  def validate_mathml_fields(field)
130
- field&.to_mathml_without_math_tag
134
+ if field.is_a?(Array)
135
+ field&.map(&:to_mathml_without_math_tag)
136
+ else
137
+ field&.to_mathml_without_math_tag
138
+ end
131
139
  end
132
140
 
133
141
  def common_math_zone_conversion(field, options = {})
@@ -266,6 +274,30 @@ module Plurimath
266
274
  def is_unary?
267
275
  is_a?(Math::Function::UnaryFunction)
268
276
  end
277
+
278
+ def is_nary_function?;end
279
+
280
+ def is_nary_symbol?;end
281
+
282
+ def is_binary_function?
283
+ is_a?(Function::BinaryFunction)
284
+ end
285
+
286
+ def is_ternary_function?
287
+ is_a?(Function::TernaryFunction)
288
+ end
289
+
290
+ def mini_sized?
291
+ false
292
+ end
293
+
294
+ def unicodemath_parens(field)
295
+ if field.is_a?(Math::Function::Fenced)
296
+ field.to_unicodemath
297
+ else
298
+ "(#{field.to_unicodemath})" if field
299
+ end
300
+ end
269
301
  end
270
302
  end
271
303
  end
@@ -3,7 +3,7 @@
3
3
  module Plurimath
4
4
  module Math
5
5
  class Formula < Core
6
- attr_accessor :value, :left_right_wrapper, :displaystyle, :input_string
6
+ attr_accessor :value, :left_right_wrapper, :displaystyle, :input_string, :unitsml
7
7
 
8
8
  MATH_ZONE_TYPES = %i[
9
9
  omml
@@ -16,12 +16,14 @@ module Plurimath
16
16
  value = [],
17
17
  left_right_wrapper = true,
18
18
  display_style: true,
19
- input_string: nil
19
+ input_string: nil,
20
+ unitsml: false
20
21
  )
21
22
  @value = value.is_a?(Array) ? value : [value]
22
23
  left_right_wrapper = false if @value.first.is_a?(Function::Left)
23
24
  @left_right_wrapper = left_right_wrapper
24
25
  @displaystyle = boolean_display_style(display_style)
26
+ @unitsml = unitsml if unitsml
25
27
  end
26
28
 
27
29
  def ==(object)
@@ -49,6 +51,7 @@ module Plurimath
49
51
  style = ox_element("mstyle", attributes: style_attrs)
50
52
  Utility.update_nodes(style, mathml_content)
51
53
  Utility.update_nodes(math, [style])
54
+ unitsml_post_processing(math)
52
55
  dump_nodes(math, indent: 2)
53
56
  rescue
54
57
  parse_error!(:mathml)
@@ -63,10 +66,9 @@ module Plurimath
63
66
  def to_mathml_without_math_tag
64
67
  return mathml_content unless left_right_wrapper
65
68
 
66
- Utility.update_nodes(
67
- Utility.ox_element("mrow"),
68
- mathml_content,
69
- )
69
+ mrow = ox_element("mrow")
70
+ mrow.attributes[:unitsml] = true if unitsml
71
+ Utility.update_nodes(mrow, mathml_content)
70
72
  end
71
73
 
72
74
  def mathml_content
@@ -134,6 +136,12 @@ module Plurimath
134
136
  omml_content(display_style)
135
137
  end
136
138
 
139
+ def to_unicodemath
140
+ Utility.html_entity_to_unicode(unicodemath_value).gsub(/\s\/\s/, "/")
141
+ rescue
142
+ parse_error!(:unicodemath)
143
+ end
144
+
137
145
  def to_display(type = nil)
138
146
  return type_error! unless MATH_ZONE_TYPES.include?(type.downcase.to_sym)
139
147
 
@@ -247,6 +255,10 @@ module Plurimath
247
255
  end
248
256
 
249
257
 
258
+ def mini_sized?
259
+ true if value&.first&.mini_sized?
260
+ end
261
+
250
262
  protected
251
263
 
252
264
  def boolean_display_style(display_style = displaystyle)
@@ -273,6 +285,48 @@ module Plurimath
273
285
  r_tag = ox_element("r", namespace: "m")
274
286
  r_tag << ox_element("br")
275
287
  end
288
+
289
+ def unitsml_post_processing(nodes)
290
+ nodes.each.with_index do |node, index|
291
+ if node.is_a?(Ox::Element) && node.attributes&.dig(:unitsml)
292
+ previous = nodes[index-1]
293
+ if previous && ["mi", "mn"].include?(previous.name)
294
+ if text_in_tag?(node.nodes)
295
+ nodes.insert(index, space_element(attributes: true))
296
+ else
297
+ nodes.insert(index, space_element)
298
+ end
299
+ end
300
+
301
+ node.attributes.delete_if {|k, v| k == :unitsml }
302
+ end
303
+
304
+ unitsml_post_processing(node.nodes) if !node.nodes.any?(String)
305
+ end
306
+ end
307
+
308
+ def space_element(attributes: false)
309
+ element = (ox_element("mo") << "&#x2062;")
310
+ element.attributes[:rspace] = "thickmathspace" if attributes
311
+ element
312
+ end
313
+
314
+ def text_in_tag?(nodes)
315
+ next_nodes = nodes.first.nodes
316
+ if next_nodes.all?(String)
317
+ Utility.html_entity_to_unicode(next_nodes.first).match?(/\p{L}|\p{N}/)
318
+ else
319
+ text_in_tag?(next_nodes)
320
+ end
321
+ end
322
+
323
+ def negated_value?
324
+ value.last.is_a?(Math::Symbol) && value.last.value == "&#x338;"
325
+ end
326
+
327
+ def unicodemath_value
328
+ (negated_value? || mini_sized?) ? value&.map(&:to_unicodemath)&.join : value&.map(&:to_unicodemath)&.join(" ")
329
+ end
276
330
  end
277
331
  end
278
332
  end
@@ -34,6 +34,10 @@ module Plurimath
34
34
  end
35
35
  end
36
36
 
37
+ def to_unicodemath
38
+ "⒜#{unicodemath_parens(parameter_one)}"
39
+ end
40
+
37
41
  protected
38
42
 
39
43
  def md_tag
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "binary_function"
4
+
5
+ module Plurimath
6
+ module Math
7
+ module Function
8
+ class Arg < BinaryFunction
9
+ def to_mathml_without_math_tag
10
+ first_value = parameter_one.to_mathml_without_math_tag
11
+ first_value.attributes[:arg] = Utility.html_entity_to_unicode(parameter_two.value)
12
+ first_value
13
+ end
14
+
15
+ def to_unicodemath
16
+ first_value = "(#{parameter_two&.to_unicodemath} #{parameter_one&.to_unicodemath})" if parameter_one || parameter_two
17
+ "ⓐ#{first_value}"
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end