@wiris/mathtype-viewer 8.9.1 → 8.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -4
- package/babel.config.js +3 -2
- package/dist/WIRISplugins.js +1 -1
- package/dist/WIRISplugins.js.LICENSE.txt +1 -1
- package/dist/app.d.ts +1 -1
- package/dist/app.d.ts.map +1 -1
- package/dist/latex.d.ts +1 -1
- package/dist/latex.d.ts.map +1 -1
- package/dist/mathml.d.ts +1 -0
- package/dist/mathml.d.ts.map +1 -1
- package/dist/properties.d.ts +18 -17
- package/dist/properties.d.ts.map +1 -1
- package/dist/services.d.ts +1 -1
- package/dist/services.d.ts.map +1 -1
- package/docs/spec.md +25 -25
- package/index.html +19 -21
- package/jest.config.js +4 -0
- package/package.json +7 -2
- package/project.json +4 -12
- package/src/app.ts +11 -12
- package/src/latex.ts +19 -24
- package/src/mathml.spec.ts +189 -0
- package/src/mathml.ts +90 -43
- package/src/properties.ts +116 -89
- package/src/retro.ts +49 -44
- package/src/services.ts +65 -48
- package/tsconfig.json +26 -22
- package/typings/module-name.d.ts +1 -1
- package/webpack.config.js +10 -10
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +0 -1
- package/src/utils.ts +0 -45
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { JSDOM } from "jsdom";
|
|
2
|
+
import { serializeHtmlToXml } from "./mathml"; // adjust the import path as needed
|
|
3
|
+
|
|
4
|
+
describe("serializeHtmlToXml", () => {
|
|
5
|
+
const testCases = [
|
|
6
|
+
`<math />`,
|
|
7
|
+
`<math><mn>10</mn></math>`,
|
|
8
|
+
`<math><mi>x</mi></math>`,
|
|
9
|
+
`<math><mn>4</mn><mi>x</mi></math>`,
|
|
10
|
+
`<math><mi mathvariant="normal">sin</mi><mi>x</mi></math>`,
|
|
11
|
+
`<math><mn>4</mn><mo>+</mo><mi>x</mi></math>`,
|
|
12
|
+
`<math><mn>3</mn><mo>≤</mo><mn>8</mn><mo>.</mo><mn>3</mn></math>`,
|
|
13
|
+
`<math><mfrac><mn>1</mn><mn>2</mn></mfrac></math>`,
|
|
14
|
+
`<math><mfrac bevelled="true"><mn>2</mn><mn>4</mn></mfrac></math>`,
|
|
15
|
+
`<math><mfrac><mrow><mo>-</mo><mi>x</mi></mrow><mn>2</mn></mfrac></math>`,
|
|
16
|
+
`<math><msup><mi>x</mi><mn>2</mn></msup><mo>-</mo><mn>1</mn></math>`,
|
|
17
|
+
`<math><msub><mi>A</mi><mi>j</mi></msub></math>`,
|
|
18
|
+
`<math><msqrt><mi>x</mi></msqrt></math>`,
|
|
19
|
+
`<math><mroot><mn>8</mn><mn>3</mn></mroot><mo>=</mo><mn>2</mn></math>`,
|
|
20
|
+
`<math><mfenced><mrow><mn>1</mn><mo>,</mo><mn>2</mn></mrow></mfenced></math>`,
|
|
21
|
+
`<math><mfenced open="|" close="|"><mrow><mi>x</mi><mo>-</mo><mn>1</mn></mrow></mfenced><mo><</mo><mi>ε</mi></math>`,
|
|
22
|
+
`<math><mo>±</mo><mo>∞</mo></math>`,
|
|
23
|
+
`<math><mo>∅</mo><mo>=</mo><mo>{</mo><mo> </mo><mo>}</mo></math>`,
|
|
24
|
+
`<math><mi>A</mi><mo>∩</mo><mi>B</mi><mo>∪</mo><mi>C</mi></math>`,
|
|
25
|
+
`<math><msub><mi>a</mi><mn>1</mn></msub><mo>×</mo><msub><mi>a</mi><mn>2</mn></msub></math>`,
|
|
26
|
+
`<math><mn>4</mn><mo>∈</mo><mfenced open="{" close="}"><mrow><mn>2</mn><mo>,</mo><mn>4</mn><mo>,</mo><mn>6</mn></mrow></mfenced></math>`,
|
|
27
|
+
`<math><msup><mfenced open="{" close="}"><mrow><mfrac><mn>1</mn><mn>2</mn></mfrac><mfenced><mrow><msup><mi>x</mi><mn>4</mn></msup><mo>-</mo><mn>3</mn></mrow></mfenced></mrow></mfenced><mfrac><mn>1</mn><mn>2</mn></mfrac></msup></math>`,
|
|
28
|
+
`<math><mi>f</mi><mfenced><mi>x</mi></mfenced><mo>=</mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn><mspace linebreak="newline"/><mi>f</mi><mo>'</mo><mo>(</mo><mi>x</mi><mo>)</mo><mo>=</mo><mn>2</mn><mi>x</mi></math>`,
|
|
29
|
+
`<math><mi mathvariant="bold">z</mi><mo>=</mo><mi mathvariant="bold">u</mi><mo>+</mo><mi mathvariant="bold">v</mi></math>`,
|
|
30
|
+
`<math><mn>1</mn><mo mathcolor="#FF0000">+</mo><mn>2</mn><mo mathcolor="#0000FF">=</mo><mn>3</mn></math>`,
|
|
31
|
+
`<math><mn mathvariant="bold">4</mn><mi mathvariant="normal">x</mi><mo>+</mo><mn mathvariant="bold">2</mn><mi mathvariant="normal">y</mi></math>`,
|
|
32
|
+
`<math style="font-size:24px"><mn mathvariant="italic" mathcolor="#007F00">2</mn><mo mathcolor="#007F00">-</mo><mfrac mathcolor="#007F00"><mn mathvariant="italic">1</mn><mn mathvariant="italic">3</mn></mfrac></math>`,
|
|
33
|
+
`<math style="font-family:'Times New Roman'"><mi>f</mi><mo>'</mo><mo>(</mo><mi>x</mi><mo>)</mo><mo>=</mo><mstyle displaystyle="false"><mfrac><mn>1</mn><mn>2</mn></mfrac></mstyle><msup><mi>x</mi><mn>2</mn></msup></math>`,
|
|
34
|
+
`<math style="font-family:'Courier New'"><msup><mi>a</mi><mn>2</mn></msup><mo>-</mo><msup><mi>b</mi><mn>2</mn></msup></math>`,
|
|
35
|
+
`<math><mi>a</mi><mo>⇒</mo><mi>b</mi></math>`,
|
|
36
|
+
`<math><mi>x</mi><mover><mo>↦</mo><mtext>maps to</mtext></mover><mi>y</mi></math>`,
|
|
37
|
+
`<math><msub><mi>a</mi><mn>1</mn></msub><mo>×</mo><mo>⋯</mo><mo>×</mo><msub><mi>a</mi><mi>n</mi></msub></math>`,
|
|
38
|
+
`<math><mover><mrow><mi>A</mi><mi>B</mi></mrow><mo>⇀</mo></mover><mo>=</mo><mo>-</mo><mover><mrow><mi>B</mi><mi>A</mi></mrow><mo>⇀</mo></mover></math>`,
|
|
39
|
+
`<math><mi>A</mi><munderover><mo>⥂</mo><mrow><mi>r</mi><mi>e</mi><mi>l</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo> </mo><mn>2</mn></mrow><mrow><mi>r</mi><mi>e</mi><mi>l</mi><mi>a</mi><mi>t</mi><mi>i</mi><mi>o</mi><mi>n</mi><mo> </mo><mn>1</mn></mrow></munderover><mi>B</mi></math>`,
|
|
40
|
+
`<math><mn>1</mn><mo>+</mo><mn>2</mn><mo>×</mo><mn>3</mn><mo>-</mo><mn>4</mn><mo>÷</mo><mn>5</mn></math>`,
|
|
41
|
+
`<math><mn>8</mn><mo>±</mo><mn>0</mn><mo>.</mo><mn>001</mn></math>`,
|
|
42
|
+
`<math><mi>f</mi><mo>*</mo><mo>(</mo><mi>x</mi><mo>)</mo></math>`,
|
|
43
|
+
`<math><mo>(</mo><mi>f</mi><mo>∘</mo><mi>g</mi><mo>)</mo><mo>(</mo><mi>x</mi><mo>·</mo><mi>y</mi><mo>)</mo></math>`,
|
|
44
|
+
`<math><mn>2</mn><mi>p</mi><msup><mi>r</mi><mn>2</mn></msup></math>`,
|
|
45
|
+
`<math><mn>15</mn><mo>°</mo><mn>30</mn><mo>'</mo><mn>60</mn><mo>'</mo><mo>'</mo></math>`,
|
|
46
|
+
`<math><mi>f</mi><mo>'</mo><mo>(</mo><mi>x</mi><mo>)</mo><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo><mo>+</mo><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo><mi>g</mi><mo>'</mo><mo>(</mo><mi>x</mi><mo>)</mo></math>`,
|
|
47
|
+
`<math><mi>x</mi><mo>+</mo><mn>1</mn><mo>=</mo><mn>1</mn><mo>-</mo><mi>x</mi></math>`,
|
|
48
|
+
`<math><mi>A</mi><mo>≡</mo><mi>B</mi></math>`,
|
|
49
|
+
`<math><mn>4</mn><mo>.</mo><mn>99</mn><mo>∼</mo><mn>5</mn></math>`,
|
|
50
|
+
`<math><mi>π</mi><mo>≈</mo><mn>3</mn><mo>.</mo><mn>1415</mn></math>`,
|
|
51
|
+
`<math><mn>0</mn><mo>≤</mo><mi>x</mi><mo>,</mo><mo> </mo><mn>0</mn><mo>⩽</mo><mi>x</mi></math>`,
|
|
52
|
+
`<math><mn>5</mn><mo>⪇</mo><mn>6</mn></math>`,
|
|
53
|
+
`<math><mi>x</mi><mo>∈</mo><mi>A</mi><mo>∩</mo><mi>B</mi></math>`,
|
|
54
|
+
`<math><mo>{</mo><mn>2</mn><mo>,</mo><mn>4</mn><mo>}</mo><mo>⊂</mo><mo>{</mo><mn>1</mn><mo>,</mo><mn>2</mn><mo>,</mo><mn>3</mn><mo>,</mo><mn>4</mn><mo>}</mo></math>`,
|
|
55
|
+
`<math><mo>∀</mo><mi>ε</mi><mo>∃</mo><mi>δ</mi></math>`,
|
|
56
|
+
`<math><mo>¬</mo><mi>p</mi><mo>∨</mo><mi>p</mi></math>`,
|
|
57
|
+
`<math><mo>(</mo><mi>a</mi><mo>∨</mo><mi>b</mi><mo>)</mo><mo>∧</mo><mo>(</mo><mi>c</mi><mo>∨</mo><mi>d</mi><mo>)</mo></math>`,
|
|
58
|
+
`<math><mo>∠</mo><mi>a</mi></math>`,
|
|
59
|
+
`<math><mi>r</mi><mo>∥</mo><mi>s</mi></math>`,
|
|
60
|
+
`<math><mi>r</mi><mo>⊥</mo><mi>s</mi></math>`,
|
|
61
|
+
`<math><mn>3</mn><mo>∈</mo><mi mathvariant="normal">ℕ</mi></math>`,
|
|
62
|
+
`<math><mi>π</mi><mo>∈</mo><mi mathvariant="normal">ℝ</mi><mo>∖</mo><mi mathvariant="normal">ℚ</mi></math>`,
|
|
63
|
+
`<math><mo>ℜ</mo><mo>(</mo><mn>4</mn><mo>+</mo><mn>3</mn><mi>i</mi><mo>)</mo><mo>=</mo><mn>4</mn></math>`,
|
|
64
|
+
`<math><mi mathvariant="double-struck">D</mi><mo> </mo><mo>=</mo><mo> </mo><mo>{</mo><mo> </mo><mi>z</mi><mo>∈</mo><mi mathvariant="normal">ℂ</mi><mo> </mo><mo> </mo><mo>:</mo><mo> </mo><mo> </mo><mo>|</mo><mi>z</mi><mo>|</mo><mo><</mo><mn>1</mn><mo> </mo><mo>}</mo></math>`,
|
|
65
|
+
`<math><msub><mi mathvariant="double-struck">A</mi><mi mathvariant="normal">ℚ</mi></msub><mo>=</mo><mi mathvariant="normal">ℚ</mi><mo> </mo><msub><mo>⊗</mo><mi mathvariant="normal">ℤ</mi></msub><mo> </mo><msub><mi mathvariant="double-struck">A</mi><mi mathvariant="normal">ℤ</mi></msub></math>`,
|
|
66
|
+
`<math><mi mathvariant="script">H</mi><mo>=</mo><munder><mo>∑</mo><mi>i</mi></munder><msub><mover><mi>q</mi><mo>˙</mo></mover><mi>i</mi></msub><mfrac><mrow><mo>∂</mo><mi mathvariant="script">L</mi></mrow><mrow><mo>∂</mo><msub><mover><mi>q</mi><mo>˙</mo></mover><mi>i</mi></msub></mrow></mfrac><mo>-</mo><mi mathvariant="script">L</mi></math>`,
|
|
67
|
+
`<math><msub><mi mathvariant="script">R</mi><mi mathvariant="script">Q</mi></msub><mo> </mo><mo>≅</mo><mo> </mo><msub><mi>T</mi><mi mathvariant="script">Q</mi></msub></math>`,
|
|
68
|
+
`<math><mi mathvariant="fraktur">p</mi><mo> </mo><mo>⊃</mo><mo> </mo><mi mathvariant="fraktur">ab</mi><mo> </mo><mo>⇒</mo><mi mathvariant="fraktur">p</mi><mo>⊃</mo><mi mathvariant="fraktur">a</mi><mo> </mo><mo>∨</mo><mo> </mo><mi mathvariant="fraktur">p</mi><mo> </mo><mo>⊃</mo><mi mathvariant="fraktur">b</mi></math>`,
|
|
69
|
+
`<math><mi mathvariant="script">B</mi><mo>=</mo><mo>{</mo><msub><mi>B</mi><mi>α</mi></msub><mo>∈</mo><mi mathvariant="script">T</mi><mo> </mo><mo>|</mo><mo> </mo><mi>U</mi><mo>=</mo><mo largeop="true">∪</mo><msub><mi>B</mi><mi>α</mi></msub><mo>∀</mo><mi>U</mi><mo>∈</mo><mi mathvariant="script">T</mi><mo>}</mo></math>`,
|
|
70
|
+
`<math><mi>A</mi><mo>⊕</mo><mi>B</mi></math>`,
|
|
71
|
+
`<math><mi>i</mi><mo>←</mo><mi>i</mi><mo>+</mo><mn>1</mn></math>`,
|
|
72
|
+
`<math><mi>x</mi><mo>↦</mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></math>`,
|
|
73
|
+
`<math><mi>x</mi><mo><</mo><mn>3</mn><mo>∧</mo><mi>x</mi><mo>⇒</mo><mo>-</mo><mn>2</mn><mo>⇒</mo><mi>x</mi><mo>⩽</mo><mo>-</mo><mn>2</mn></math>`,
|
|
74
|
+
`<math><mo>□</mo><mo>≠</mo><mo>○</mo></math>`,
|
|
75
|
+
`<math><mi>a</mi><mo>∦</mo><mi>b</mi><mo>,</mo><mo> </mo><mi>A</mi><mo>∌</mo><mi>x</mi></math>`,
|
|
76
|
+
`<math><mi mathvariant="normal">cos</mi><mo>(</mo><mi>α</mi><mo>±</mo><mi>β</mi><mo>)</mo><mo>=</mo><mi mathvariant="normal">cos</mi><mi>α</mi><mi mathvariant="normal">cos</mi><mi>β</mi><mo>∓</mo><mi mathvariant="normal">sin</mi><mi>α</mi><mi mathvariant="normal">sin</mi><mi>β</mi></math>`,
|
|
77
|
+
`<math><mi mathvariant="normal">sin</mi><mo>(</mo><mi>θ</mi><mo>+</mo><mfrac><mi>π</mi><mn>2</mn></mfrac><mo>)</mo><mo>=</mo><mi mathvariant="normal">cos</mi><mi>θ</mi></math>`,
|
|
78
|
+
`<math><mi mathvariant="normal">Ω</mi><mo>=</mo><mfrac><mi mathvariant="normal">V</mi><mi mathvariant="normal">A</mi></mfrac></math>`,
|
|
79
|
+
`<math><mi>φ</mi><mo>(</mo><mi>x</mi><mo>)</mo><mo>+</mo><mi>ψ</mi><mo>(</mo><mi>y</mi><mo>)</mo><mo>+</mo><mi>ξ</mi><mo>(</mo><mi>z</mi><mo>)</mo></math>`,
|
|
80
|
+
`<math><mfenced open="[" close="]"><mtable><mtr><mtd><mn>1</mn></mtd></mtr><mtr><mtd><mn>2</mn></mtd></mtr></mtable></mfenced></math>`,
|
|
81
|
+
`<math><mfenced><mtable><mtr><mtd><mi>x</mi></mtd></mtr><mtr><mtd><mi>y</mi></mtd></mtr></mtable></mfenced></math>`,
|
|
82
|
+
`<math><mfenced><mtable><mtr><mtd><mn>1</mn></mtd><mtd><mo> </mo></mtd><mtd><mo> </mo></mtd></mtr><mtr><mtd><mo> </mo></mtd><mtd><mn>1</mn></mtd><mtd><mo> </mo></mtd></mtr><mtr><mtd><mo> </mo></mtd><mtd><mo> </mo></mtd><mtd><mn>1</mn></mtd></mtr></mtable></mfenced></math>`,
|
|
83
|
+
`<math><mfenced open="|" close="|"><mtable><mtr><mtd><mi mathvariant="normal">sin</mi><mo>(</mo><mi>x</mi><mo>)</mo></mtd><mtd><mi mathvariant="normal">cos</mi><mo>(</mo><mi>x</mi><mo>)</mo></mtd></mtr><mtr><mtd><mo>-</mo><mi mathvariant="normal">cos</mi><mo>(</mo><mi>x</mi><mo>)</mo></mtd><mtd><mi mathvariant="normal">sin</mi><mo>(</mo><mi>x</mi><mo>)</mo></mtd></mtr></mtable></mfenced><mo>=</mo><mn>1</mn></math>`,
|
|
84
|
+
`<math><mfenced open="{" close=""><mtable><mtr><mtd><mi>x</mi><mo>+</mo><mn>1</mn></mtd></mtr><mtr><mtd><mi>x</mi><mo>-</mo><mn>1</mn></mtd></mtr></mtable></mfenced></math>`,
|
|
85
|
+
`<math><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo><mo>=</mo><mfenced open="{" close=""><mtable columnspacing="1.4ex" columnalign="left"><mtr><mtd><mi>x</mi><mo>,</mo></mtd><mtd><mtext>if </mtext><mi>x</mi><mo>⩽</mo><mn>0</mn></mtd></mtr><mtr><mtd><mi mathvariant="normal">sin</mi><mo>(</mo><mi>x</mi><mo>)</mo><mo>,</mo></mtd><mtd><mtext>if </mtext><mi>x</mi><mo>></mo><mn>0</mn></mtd></mtr></mtable></mfenced></math>`,
|
|
86
|
+
`<math><mtable columnspacing="2px" columnalign="right center left"><mtr><mtd><msup><mi>x</mi><mn>5</mn></msup><mo>+</mo><mn>1</mn></mtd><mtd><mo>=</mo></mtd><mtd><msup><mi>x</mi><mn>4</mn></msup><mo>-</mo><mi>y</mi></mtd></mtr><mtr><mtd><mi>x</mi></mtd><mtd><mo>=</mo></mtd><mtd><mstyle displaystyle="false"><mfrac><mn>1</mn><mn>2</mn></mfrac></mstyle><mi>y</mi><mo>+</mo><mn>3</mn></mtd></mtr></mtable></math>`,
|
|
87
|
+
`<math><mtable columnspacing="2px" columnalign="right center left"><mtr><mtd><mo>(</mo><mn>2</mn><mo>+</mo><mn>3</mn><msup><mo>)</mo><mn>2</mn></msup></mtd><mtd><mo>=</mo></mtd><mtd><mo>(</mo><mn>5</mn><msup><mo>)</mo><mn>2</mn></msup></mtd></mtr><mtr><mtd><mo> </mo></mtd><mtd><mo>=</mo></mtd><mtd><mn>25</mn></mtd></mtr></mtable></math>`,
|
|
88
|
+
`<math><mstyle displaystyle="false"><mfrac bevelled="true"><mn>1</mn><mn>2</mn></mfrac></mstyle><mo> </mo><mn>5</mn></math>`,
|
|
89
|
+
`<math><mn>3</mn><mo>+</mo><mfrac><mn>1</mn><mrow><mn>7</mn><mo>+</mo><mfrac><mn>1</mn><mrow><mo>.</mo><mo>.</mo><mo>.</mo></mrow></mfrac></mrow></mfrac></math>`,
|
|
90
|
+
`<math><msqrt><mn>1</mn><mo>-</mo><mi>x</mi></msqrt></math>`,
|
|
91
|
+
`<math><mroot><mn>2</mn><mn>3</mn></mroot></math>`,
|
|
92
|
+
`<math><mroot><mrow><msup><mi>x</mi><mi>n</mi></msup><mo>+</mo><msup><mi>y</mi><mi>n</mi></msup></mrow><mi>n</mi></mroot></math>`,
|
|
93
|
+
`<math><mroot><mi>a</mi><mrow><mi>n</mi><mo>+</mo><mn>1</mn></mrow></mroot></math>`,
|
|
94
|
+
`<math><mo>(</mo><mi mathvariant="normal">OH</mi><msubsup><mo>)</mo><mn>4</mn><mo>-</mo></msubsup></math>`,
|
|
95
|
+
`<math><msubsup><mi>V</mi><mi>m</mi><mi>n</mi></msubsup><mo>=</mo><mfrac><mrow><mi>m</mi><mo>!</mo></mrow><mrow><mfenced><mrow><mi>m</mi><mo>-</mo><mi>n</mi></mrow></mfenced><mo>!</mo></mrow></mfrac><mspace linebreak="newline"/><msubsup><mi>V</mi><mn>3</mn><mn>2</mn></msubsup><mo>=</mo><mn>6</mn></math>`,
|
|
96
|
+
`<math><mmultiscripts><mi mathvariant="normal">U</mi><mprescripts/><mn>92</mn><mn>235</mn></mmultiscripts></math>`,
|
|
97
|
+
`<math><mo>(</mo><mi>A</mi><mi>B</mi><msubsup><mo>)</mo><mi>i</mi><mi>j</mi></msubsup><mo>=</mo><msubsup><mi>A</mi><mi>i</mi><mi>k</mi></msubsup><msubsup><mi>B</mi><mi>k</mi><mi>j</mi></msubsup></math>`,
|
|
98
|
+
`<math><mi mathvariant="normal">Zn</mi><mo>+</mo><mn>2</mn><msup><mi mathvariant="normal">H</mi><mo>+</mo></msup><mo>→</mo><msup><mi mathvariant="normal">Zn</mi><mrow><mn>2</mn><mo>+</mo></mrow></msup><mo>+</mo><msub><mi mathvariant="normal">H</mi><mn>2</mn></msub></math>`,
|
|
99
|
+
`<math><mover><mrow><mn>3</mn><mo>+</mo><mn>5</mn></mrow><mn>8</mn></mover></math>`,
|
|
100
|
+
`<math><munder><mrow><mn>3</mn><msup><mi>x</mi><mn>2</mn></msup><mo>-</mo><mn>2</mn></mrow><mrow><mo>(</mo><mn>2</mn><mo> </mo><mi mathvariant="normal">degree</mi><mo>)</mo></mrow></munder></math>`,
|
|
101
|
+
`<math><munder><munder><mrow><mn>1</mn><mo>+</mo><mn>2</mn></mrow><mo>⏟</mo></munder><mn>3</mn></munder></math>`,
|
|
102
|
+
`<math><mover><mover><mrow><munder><munder><mrow><mn>1</mn><mo>+</mo><mn>2</mn></mrow><mo>⏟</mo></munder><mn>3</mn></munder><mo>+</mo><mn>3</mn></mrow><mo>⏞</mo></mover><mn>5</mn></mover></math>`,
|
|
103
|
+
`<math><mfenced open="<" close=">"><mfrac><mn>1</mn><mn>2</mn></mfrac></mfenced></math>`,
|
|
104
|
+
`<math><mstyle displaystyle="false"><mfrac><mn>4</mn><mn>3</mn></mfrac></mstyle><mo>=</mo><mn>1</mn><mo>'</mo><mover><mn>3</mn><mo>⏜</mo></mover></math>`,
|
|
105
|
+
`<math><mover><mi>u</mi><mo>→</mo></mover><mo>+</mo><mover><mi>v</mi><mo>→</mo></mover></math>`,
|
|
106
|
+
`<math><mover><mrow><mi>x</mi><mo>+</mo><mover><mi>y</mi><mo>¯</mo></mover></mrow><mo>¯</mo></mover></math>`,
|
|
107
|
+
`<math><msup><mi>x</mi><menclose notation="circle"><mn>5</mn></menclose></msup><mo>-</mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><menclose notation="box"><mn>3</mn></menclose></math>`,
|
|
108
|
+
`<math><mfrac><mrow><mi>a</mi><mo>·</mo><menclose mathcolor="#FF0000" notation="updiagonalstrike"><mi mathcolor="#191919">b</mi></menclose><mo>·</mo><menclose mathcolor="#0000FF" notation="downdiagonalstrike"><mi mathcolor="#191919">d</mi></menclose><mo>·</mo><menclose mathcolor="#007F00" notation="verticalstrike"><mi mathcolor="#191919">e</mi></menclose></mrow><mrow><menclose mathcolor="#FF0000" notation="updiagonalstrike"><mi mathcolor="#191919">b</mi></menclose><mo>·</mo><mi>c</mi><mo>·</mo><menclose mathcolor="#0000FF" notation="downdiagonalstrike"><mi mathcolor="#191919">d</mi></menclose><mo>·</mo><mi>f</mi><mo>·</mo><menclose mathcolor="#007F00" notation="verticalstrike"><mi mathcolor="#191919">e</mi></menclose></mrow></mfrac></math>`,
|
|
109
|
+
`<math><munderover><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mi>n</mi></munderover><msup><mn>2</mn><mi>i</mi></msup></math>`,
|
|
110
|
+
`<math><munder><munder><mo>âˆ</mo><mrow><mi>p</mi><mo>(</mo><mi>α</mi><mo>)</mo><mo>=</mo><mn>0</mn></mrow></munder><mrow><mi>q</mi><mo>(</mo><mi>β</mi><mo>)</mo><mo>=</mo><mn>0</mn></mrow></munder><mo>(</mo><mi>α</mi><mo>-</mo><mi>β</mi><mo>)</mo></math>`,
|
|
111
|
+
`<math><msubsup><mo>∑</mo><mrow><mi>i</mi><mo>=</mo><mn>1</mn></mrow><mo>∞</mo></msubsup><mfrac><mn>1</mn><msup><mi>i</mi><mn>2</mn></msup></mfrac></math>`,
|
|
112
|
+
`<math><munder><mo largeop="true">∩</mo><mrow><mi>x</mi><mo>∈</mo><mi>A</mi></mrow></munder><mi>A</mi></math>`,
|
|
113
|
+
`<math><msubsup><mo>∫</mo><mn>0</mn><mn>1</mn></msubsup><msup><mi>x</mi><mn>2</mn></msup><mo>-</mo><mn>2</mn><mi>d</mi><mi>x</mi></math>`,
|
|
114
|
+
`<math><msub><mo>∫</mo><mi>w</mi></msub><mi>d</mi><mi>f</mi><mo>=</mo><msub><mo>∫</mo><mrow><mo>∂</mo><mi>w</mi></mrow></msub><mi>f</mi></math>`,
|
|
115
|
+
`<math><mfrac><mrow><msup><mo>∂</mo><mn>2</mn></msup><mi>f</mi></mrow><mrow><mo>∂</mo><mi>x</mi><mo>∂</mo><mi>y</mi></mrow></mfrac></math>`,
|
|
116
|
+
`<math><mfrac><mrow><mi>d</mi><mi mathvariant="normal">sin</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mrow><mi>d</mi><mi>x</mi></mrow></mfrac><mo>=</mo><mo>-</mo><mi mathvariant="normal">cos</mi><mo>(</mo><mi>x</mi><mo>)</mo></math>`,
|
|
117
|
+
`<math><munder><mi mathvariant="normal">lim</mi><mrow><mi>n</mi><mo>→</mo><mo>∞</mo></mrow></munder><msup><mfenced><mrow><mn>1</mn><mo>+</mo><mfrac><mn>1</mn><mi>n</mi></mfrac></mrow></mfenced><mi>n</mi></msup></math>`,
|
|
118
|
+
`<math><munder><mi mathvariant="normal">lim</mi><mrow><mi>x</mi><mo>↗</mo><mi>a</mi></mrow></munder><mo> </mo><mi>f</mi><mo>(</mo><mi>a</mi><mo>)</mo></math>`,
|
|
119
|
+
`<math><mo>∆</mo><mi>u</mi><mo>=</mo><msub><mi>u</mi><mrow><mi>x</mi><mi>x</mi></mrow></msub><mo>+</mo><msub><mi>u</mi><mrow><mi>y</mi><mi>y</mi></mrow></msub><mo>+</mo><msub><mi>u</mi><mrow><mi>z</mi><mi>z</mi></mrow></msub></math>`,
|
|
120
|
+
`<math><msub><mo>∮</mo><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>y</mi><mn>2</mn></msup><mo>=</mo><mi>r</mi></mrow></msub><mi>g</mi><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo><mi>d</mi><mi>x</mi><mo>+</mo><mi>h</mi><mo>(</mo><mi>x</mi><mo>,</mo><mi>y</mi><mo>)</mo><mi>d</mi><mi>y</mi></math>`,
|
|
121
|
+
`<math><msub><mi>log</mi><mn>10</mn></msub><mi>x</mi></math>`,
|
|
122
|
+
`<math><mstack charalign="center" stackalign="right"><mscarries><mn>1</mn><none/></mscarries><mn>35</mn><msrow><mo>+</mo><mn>89</mn></msrow><msline/><mn>124</mn></mstack></math>`,
|
|
123
|
+
`<math><mstack charalign="center" stackalign="right"><mscarries><mn>1</mn><none/></mscarries><mn>24</mn><msrow><mo>×</mo><mn>23</mn></msrow><msline/><mscarries><mn>1</mn><none/><none/></mscarries><mn>72</mn><msrow><mn>48</mn><none/></msrow><msline/><mn>552</mn></mstack><mspace linebreak="newline"/></math>`,
|
|
124
|
+
`<math><mlongdiv charalign="center" charspacing="0px" stackalign="left"><mstack charalign="center" stackalign="right"><mn>5</mn></mstack><mn>69</mn><msgroup><msrow><none/><mn>346</mn></msrow><msrow><mo>-</mo><mn>30</mn></msrow><msline length="3"/><msrow><none/><none/><mn>46</mn></msrow><msrow><none/><mo>-</mo><mn>45</mn></msrow><msline length="3" position="1"/><msrow><none/><none/><none/><mn>1</mn></msrow></msgroup></mlongdiv><mspace linebreak="newline"/></math>`,
|
|
125
|
+
`<math><mlongdiv longdivstyle="shortstackedrightright" charalign="center" charspacing="0px" stackalign="left"><mn>7</mn><mn>17</mn><msgroup><mn>123</mn><msrow><mo>-</mo><mn>7</mn></msrow><msline length="2"/><msrow><none/><mn>53</mn></msrow><msrow><mo>-</mo><mn>49</mn></msrow><msline/><msrow><none/><none/><mn>4</mn></msrow></msgroup></mlongdiv><mspace linebreak="newline"/></math>`,
|
|
126
|
+
`<math><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><msqrt><mi>x</mi></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></msqrt></math>`,
|
|
127
|
+
`<math><mfenced open="{" close=""><mtable><mtr><mtd><mn>3</mn><mi>x</mi><mo>+</mo><mn>2</mn><mi>y</mi><mo>-</mo><mi>z</mi><mo>=</mo><mn>1</mn></mtd></mtr><mtr><mtd><mn>5</mn><mi>x</mi><mo>-</mo><mi>y</mi><mo>+</mo><mn>4</mn><mi>z</mi><mo>=</mo><mo>-</mo><mn>4</mn></mtd></mtr><mtr><mtd><mi>x</mi><mo>-</mo><mn>3</mn><mi>y</mi><mo>+</mo><mn>2</mn><mi>z</mi><mo>=</mo><mn>0</mn></mtd></mtr></mtable></mfenced></math>`,
|
|
128
|
+
`<math><mrow><munderover><mmultiscripts><mo>∏</mo><mmultiscripts><mi>A</mi><mi>υ</mi><mi>τ</mi><mprescripts /><mi>ρ</mi><mi>σ</mi></mmultiscripts><mmultiscripts><mi>B</mi><mi>π</mi><mi>ο</mi><mprescripts /><mi>ν</mi><mi>ξ</mi></mmultiscripts><mprescripts /><mmultiscripts><mi>C</mi><mi>δ</mi><mi>γ</mi><mprescripts /><mi>α</mi><mi>β</mi></mmultiscripts><mmultiscripts><mi>D</mi><mi>θ</mi><mi>η</mi><mprescripts /><mi>ε</mi><mi>ζ</mi></mmultiscripts></mmultiscripts><mmultiscripts><mi>E</mi><mi>ω</mi><mi>ψ</mi><mprescripts /><mi>ϕ</mi><mi>χ</mi></mmultiscripts><mmultiscripts><mi>F</mi><mi>μ</mi><mi>λ</mi><mprescripts /><mi>ι</mi><mi>κ</mi></mmultiscripts></munderover></mrow></math>`,
|
|
129
|
+
`<math><mtable columnspacing="2px" columnalign="right center left"><mtr><mtd><mo>(</mo><mi>a</mi><mo>+</mo><mi>b</mi><msup><mo>)</mo><mn>2</mn></msup></mtd><mtd><mo>=</mo></mtd><mtd><mo>(</mo><mi>a</mi><mo>+</mo><mi>b</mi><mo>)</mo><mo>(</mo><mi>a</mi><mo>+</mo><mi>b</mi><mo>)</mo></mtd></mtr><mtr><mtd><mo> </mo></mtd><mtd><mo>=</mo></mtd><mtd><mi>a</mi><mo>(</mo><mi>a</mi><mo>+</mo><mi>b</mi><mo>)</mo><mo>+</mo><mi>b</mi><mo>(</mo><mi>a</mi><mo>+</mo><mi>b</mi><mo>)</mo></mtd></mtr><mtr><mtd><mo> </mo></mtd><mtd><mo>=</mo></mtd><mtd><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><mi>a</mi><mi>b</mi><mo>+</mo><mi>b</mi><mi>a</mi><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mtd></mtr><mtr><mtd><mo> </mo></mtd><mtd><mo>=</mo></mtd><mtd><msup><mi>a</mi><mn>2</mn></msup><mo>+</mo><mn>2</mn><mi>a</mi><mi>b</mi><mo>+</mo><msup><mi>b</mi><mn>2</mn></msup></mtd></mtr></mtable></math>`,
|
|
130
|
+
`<math><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><mi mathvariant="normal">O</mi></mfenced><mn>1</mn></msup></mfenced><mn>2</mn></msup></mfenced><mn>3</mn></msup></mfenced><mn>4</mn></msup></mfenced><mn>5</mn></msup></mfenced><mn>6</mn></msup></mfenced><mn>7</mn></msup></mfenced><mn>8</mn></msup></mfenced><mn>9</mn></msup></mfenced></math>`,
|
|
131
|
+
`<math><mtable><mtr><mtd><mn>0</mn></mtd><mtd><mo>←</mo></mtd><mtd><mn>3</mn></mtd></mtr><mtr><mtd><mo>↓</mo></mtd><mtd><mtable><mtr><mtd/><mtd/></mtr><mtr><mtd/><mtd/></mtr></mtable><mo> </mo></mtd><mtd><mo>↑</mo></mtd></mtr><mtr><mtd><mn>1</mn></mtd><mtd><mo>→</mo></mtd><mtd><mn>2</mn></mtd></mtr></mtable><mspace linebreak="newline"/></math>`,
|
|
132
|
+
`<math><mi>f</mi><mo>(</mo><mi>a</mi><mo>,</mo><mi>b</mi><mo>,</mo><mi>c</mi><mo>)</mo><mo>=</mo><mi>a</mi><mi>b</mi><mi>c</mi></math>`,
|
|
133
|
+
`<math><mtext>WIRIS rules</mtext></math>`,
|
|
134
|
+
`<math><mi>x</mi><mo>=</mo><mfrac><mn>1</mn><mn>2</mn></mfrac><mo>+</mo><mfrac><mi>x</mi><mi>n</mi></mfrac><mo>-</mo><mfrac><mrow><mn>2</mn><mi>x</mi><mo>-</mo><mn>1</mn></mrow><mn>2</mn></mfrac></math>`,
|
|
135
|
+
`<math><msqrt><mn>2</mn></msqrt><mo>+</mo><mn>3</mn><msqrt><mi>x</mi></msqrt></math>`,
|
|
136
|
+
`<math><msqrt><mfrac><mi>x</mi><mn>2</mn></mfrac></msqrt><mo>+</mo><msqrt><msup><mi>x</mi><mn>2</mn></msup></msqrt><mo>+</mo><msqrt><msub><mi>x</mi><mi>i</mi></msub></msqrt><mo>+</mo><msqrt><mfenced><mrow><mi>x</mi><mo>-</mo><mn>1</mn></mrow></mfenced></msqrt></math>`,
|
|
137
|
+
`<math><mroot><mn>8</mn><mn>3</mn></mroot><mo>+</mo><mroot><mn>2</mn><mi>n</mi></mroot><mo>+</mo><mroot><mi>x</mi><mrow><mn>2</mn><mi>p</mi></mrow></mroot></math>`,
|
|
138
|
+
`<math><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><msup><mi>x</mi><mi>n</mi></msup><mo>+</mo><msup><mn>2</mn><mn>3</mn></msup><mo>-</mo><msup><mn>2</mn><mi>n</mi></msup></math>`,
|
|
139
|
+
`<math><msub><mi>x</mi><mi>i</mi></msub><mo>+</mo><msub><mi>x</mi><mn>2</mn></msub><mo>+</mo><msub><mi>x</mi><mi>n</mi></msub></math>`,
|
|
140
|
+
`<math><msubsup><mi>x</mi><mi>n</mi><mi>m</mi></msubsup><mo>+</mo><msubsup><mi>x</mi><mi>i</mi><mi>j</mi></msubsup><mo>+</mo><msubsup><mi>x</mi><mi>t</mi><mi>p</mi></msubsup><mo>+</mo><msubsup><mi>x</mi><mn>2</mn><mn>3</mn></msubsup></math>`,
|
|
141
|
+
`<math><mover><mi>u</mi><mo>→</mo></mover><mo>+</mo><mover><mi>k</mi><mo>⇀</mo></mover><mo>+</mo><mover><mrow><mi>A</mi><mi>B</mi></mrow><mo>¯</mo></mover></math>`,
|
|
142
|
+
`<math><munderover><mo>∑</mo><mrow><mi>n</mi><mo>=</mo><mn>0</mn></mrow><mo>∞</mo></munderover><msub><mi>x</mi><mi>n</mi></msub></math>`,
|
|
143
|
+
`<math><menclose notation="top"><mi>x</mi></menclose><mo>+</mo><menclose notation="updiagonalstrike"><mn>2</mn><mi>n</mi></menclose><mo>+</mo><menclose notation="bottom"><mi>p</mi></menclose></math>`,
|
|
144
|
+
`<math><msubsup><mo>∫</mo><mn>0</mn><mn>1</mn></msubsup><mi>x</mi><mo>d</mo><mi>x</mi><mo>+</mo><msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo><mo>d</mo><mi>x</mi></math>`,
|
|
145
|
+
`<math><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo><mo>+</mo><mi>f</mi><mo>'</mo><mo>(</mo><mi>a</mi><mo>)</mo><mo>+</mo><mi>g</mi><mo>(</mo><mi>y</mi><mo>)</mo></math>`,
|
|
146
|
+
`<math><mfenced><mrow><msqrt><mi>x</mi></msqrt><mo>-</mo><msqrt><mi>y</mi></msqrt></mrow></mfenced><mfenced><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>-</mo><msup><mi>y</mi><mn>2</mn></msup></mrow></mfenced><mfenced><mrow><msub><mi>x</mi><mi>n</mi></msub><mo>-</mo><msub><mi>x</mi><mi>m</mi></msub></mrow></mfenced></math>`,
|
|
147
|
+
`<math><mfenced><mfrac><mrow><mi>x</mi><mo>+</mo><mn>1</mn></mrow><mfrac><mn>1</mn><mn>2</mn></mfrac></mfrac></mfenced><mo>+</mo><mfenced><mfrac><mrow><mi>x</mi><mo>-</mo><mn>1</mn></mrow><mrow><mi>x</mi><mo>-</mo><mn>2</mn></mrow></mfrac></mfenced></math>`,
|
|
148
|
+
`<math><mfenced><msup><mfenced><msup><mfenced><msup><mfenced><mi>x</mi></mfenced><mn>2</mn></msup></mfenced><mn>3</mn></msup></mfenced><mn>4</mn></msup></mfenced></math>`,
|
|
149
|
+
`<math><mfenced><mfenced open="<" close=">"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="⌊" close="⌋"><mfenced open="⟦" close="⟧"><mi>x</mi></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced><mo> </mo><mo>(</mo><mo>[</mo><mo>|</mo><mo>{</mo><mo>}</mo><mo>|</mo><mo>]</mo><mo>)</mo></math>`,
|
|
150
|
+
`<math><mfenced><mfenced open="|" close="|"><mfenced open="<" close=">"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="⌊" close="⌋"><mfenced open="⟦" close="⟧"><mfrac><mn>1</mn><mn>2</mn></mfrac></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></math>`,
|
|
151
|
+
`<math><mfrac><mrow><mi>f</mi><mo>∘</mo><mi>g</mi></mrow><mrow><mi>f</mi><mo>∘</mo><mi>h</mi></mrow></mfrac><mo> </mo><mfrac><mn>1</mn><msqrt><mn>2</mn></msqrt></mfrac><mo> </mo><mfrac><msub><mi>x</mi><mi>j</mi></msub><msup><mi>x</mi><mi>t</mi></msup></mfrac><mo> </mo><mfrac><menclose notation="bottom"><mi>x</mi></menclose><mover><mi>x</mi><mo>→</mo></mover></mfrac><mo> </mo><mfrac><mn>1</mn><mover><mi>k</mi><mo>→</mo></mover></mfrac><mo> </mo><mfrac><mn>1</mn><mrow><mn>2</mn><mo>.</mo><mover><mn>3</mn><mo>⏜</mo></mover></mrow></mfrac></math>`,
|
|
152
|
+
`<math><mfrac><mfenced><mfenced open="|" close="|"><mfenced open="<" close=">"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="⌊" close="⌋"><mfenced open="⌈" close="⌉"><mrow/></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced><mfenced><mfenced open="|" close="|"><mfenced open="<" close=">"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="⌊" close="⌋"><mfenced open="⌈" close="⌉"><mrow/></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfrac><mo> </mo><mfrac><mrow><mo>(</mo><mo>|</mo><mo>[</mo><mo>{</mo><mo>}</mo><mo>]</mo><mo>|</mo><mo>)</mo></mrow><mrow><mo>(</mo><mo>|</mo><mo>[</mo><mo>{</mo><mo>}</mo><mo>]</mo><mo>|</mo><mo>)</mo></mrow></mfrac></math>`,
|
|
153
|
+
`<math><msqrt><mi>f</mi><mo>∘</mo><mi>g</mi></msqrt><mo> </mo><msqrt><msqrt><msqrt><mi>x</mi></msqrt></msqrt></msqrt><mo> </mo><msqrt><msup><mi>x</mi><mi>t</mi></msup></msqrt><mo> </mo></math>`,
|
|
154
|
+
`<math><msqrt><mover><mi>x</mi><mo>→</mo></mover></msqrt><mo> </mo><msqrt><mover><mi>t</mi><mo>→</mo></mover></msqrt><mo> </mo><msqrt><menclose notation="top"><mi>x</mi></menclose></msqrt><mo> </mo><msqrt><menclose notation="top"><mn>2</mn></menclose></msqrt><mo> </mo><msqrt><mn>2</mn><mo>.</mo><mover><mn>3</mn><mo>⏜</mo></mover></msqrt></math>`,
|
|
155
|
+
`<math><mroot><mn>2</mn><mrow><mi>j</mi><mi>j</mi><mi>j</mi><mi>j</mi></mrow></mroot><mo> </mo><mroot><mn>2</mn><mrow><mi>p</mi><mi>p</mi><mi>p</mi></mrow></mroot></math>`,
|
|
156
|
+
`<math><msqrt><mfenced><mfenced open="|" close="|"><mfenced open="<" close=">"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="⌊" close="⌋"><mfenced open="⌈" close="⌉"><mrow/></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></msqrt><mo> </mo><msqrt><mo>(</mo><mo>|</mo><mo>[</mo><mo>{</mo><mo>}</mo><mo>]</mo><mo>|</mo><mo>)</mo></msqrt></math>`,
|
|
157
|
+
`<math><msub><mi>Q</mi><mi>n</mi></msub><mo> </mo><msup><mi>P</mi><mi>j</mi></msup><mo> </mo><mmultiscripts><mi>W</mi><none/><mi>j</mi><mprescripts/><mi>p</mi><mi>p</mi></mmultiscripts><mo> </mo><msup><mi>f</mi><mi>g</mi></msup></math>`,
|
|
158
|
+
`<math><mo>(</mo><mi>f</mi><mo>+</mo><mi>f</mi><mo>)</mo><mfenced><mrow><mi>W</mi><mo>,</mo><mi>T</mi></mrow></mfenced><mfenced><mmultiscripts><mi>U</mi><mi>Q</mi><mi>T</mi><mprescripts/><mi>M</mi><mi>N</mi></mmultiscripts></mfenced></math>`,
|
|
159
|
+
`<math><msub><mfenced><mi>x</mi></mfenced><mi>w</mi></msub><mo>(</mo><mi>x</mi><msup><mo>)</mo><mi>j</mi></msup></math>`,
|
|
160
|
+
`<math><munder><munder><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mo>⏟</mo></munder><mrow><mi>y</mi><mo>=</mo><msup><mi>x</mi><mn>2</mn></msup></mrow></munder><mo>∘</mo><mover><mover><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mo>⏞</mo></mover><mrow><mi>y</mi><mo>=</mo><msub><mi>a</mi><mi>j</mi></msub></mrow></mover><mo> </mo><mo> </mo></math>`,
|
|
161
|
+
`<math xmlns="http://www.w3.org/1998/Math/MathML"><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">«</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px"><</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">»</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">></mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">§</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">¨</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">"</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">'</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">'</mo></math>`,
|
|
162
|
+
];
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* This test suite validates the functionality of the `serializeHtmlToXml` function.
|
|
166
|
+
* The function is expected to convert valid HTML into valid XML.
|
|
167
|
+
*
|
|
168
|
+
* Each test case follows these steps:
|
|
169
|
+
* 1. An input HTML string is passed to the `serializeHtmlToXml` function, which returns an XML string.
|
|
170
|
+
* 2. The XML string is parsed as text/xml using the DOMParser's.
|
|
171
|
+
* 3. The parsed XML document is checked for `parsererror` nodes.
|
|
172
|
+
*
|
|
173
|
+
* If the XML document contains any `parsererror` nodes, it indicates that the `serializeHtmlToXml` function
|
|
174
|
+
* did not correctly convert the HTML to valid XML, causing the DOMParser to encounter errors during parsing.
|
|
175
|
+
* In this case, the test will fail.
|
|
176
|
+
*
|
|
177
|
+
* If no `parsererror` nodes are found, it indicates that the `serializeHtmlToXml` function correctly converted
|
|
178
|
+
* the HTML to valid XML, and the test will pass.
|
|
179
|
+
*/
|
|
180
|
+
testCases.forEach((input, index) => {
|
|
181
|
+
it(`Test ${index}: ${input.slice(0, 40)} ...`, () => {
|
|
182
|
+
const parser = new global.DOMParser();
|
|
183
|
+
const output = serializeHtmlToXml(input);
|
|
184
|
+
const parsed = parser.parseFromString(output, "text/xml");
|
|
185
|
+
let errorNodes = parsed.getElementsByTagName("parsererror");
|
|
186
|
+
expect(errorNodes.length).toBe(0);
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
});
|
package/src/mathml.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { Properties } from "./properties";
|
|
2
|
-
import { showImage, createImage, mathml2accessible
|
|
3
|
-
import
|
|
4
|
-
import MathML from '@wiris/mathtype-html-integration-devkit/src/mathml';
|
|
2
|
+
import { showImage, createImage, mathml2accessible } from "./services";
|
|
3
|
+
import MathML from "@wiris/mathtype-html-integration-devkit/src/mathml";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* Data obtained when rendering image. Data needed to set the formula image parameters.
|
|
8
7
|
*/
|
|
9
8
|
interface FormulaData {
|
|
10
|
-
content: string
|
|
11
|
-
baseline: string
|
|
12
|
-
height: string
|
|
13
|
-
width: string
|
|
14
|
-
alt?: string
|
|
9
|
+
content: string;
|
|
10
|
+
baseline: string;
|
|
11
|
+
height: string;
|
|
12
|
+
width: string;
|
|
13
|
+
alt?: string;
|
|
15
14
|
}
|
|
16
15
|
|
|
17
16
|
/**
|
|
@@ -19,15 +18,13 @@ interface FormulaData {
|
|
|
19
18
|
* @param {HTMLElement} root - Any DOM element that can contain MathML.
|
|
20
19
|
*/
|
|
21
20
|
function findSafeMathMLTextNodes(root: HTMLElement): Node[] {
|
|
22
|
-
const nodeIterator: NodeIterator = document.createNodeIterator(
|
|
23
|
-
|
|
24
|
-
NodeFilter.SHOW_TEXT,
|
|
25
|
-
node => /«math(.*?)«\/math»/g.test(node.nodeValue || '') ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT
|
|
21
|
+
const nodeIterator: NodeIterator = document.createNodeIterator(root, NodeFilter.SHOW_TEXT, (node) =>
|
|
22
|
+
/«math(.*?)«\/math»/g.test(node.nodeValue || "") ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT,
|
|
26
23
|
);
|
|
27
|
-
const safeNodes
|
|
24
|
+
const safeNodes: Node[] = [];
|
|
28
25
|
|
|
29
26
|
let currentNode: Node | null;
|
|
30
|
-
while (currentNode = nodeIterator.nextNode()) {
|
|
27
|
+
while ((currentNode = nodeIterator.nextNode())) {
|
|
31
28
|
safeNodes.push(currentNode);
|
|
32
29
|
}
|
|
33
30
|
|
|
@@ -42,7 +39,7 @@ function decodeSafeMathML(root: HTMLElement) {
|
|
|
42
39
|
const safeNodes = findSafeMathMLTextNodes(root);
|
|
43
40
|
|
|
44
41
|
for (const safeNode of safeNodes) {
|
|
45
|
-
const mathml = MathML.safeXmlDecode(safeNode.textContent);
|
|
42
|
+
const mathml = MathML.safeXmlDecode(safeNode.textContent ?? "");
|
|
46
43
|
// Insert mathml node.
|
|
47
44
|
const fragment = document.createRange().createContextualFragment(mathml);
|
|
48
45
|
|
|
@@ -57,53 +54,63 @@ function decodeSafeMathML(root: HTMLElement) {
|
|
|
57
54
|
* @param {HTMLElement} root - Any DOM element that can contain MathML.
|
|
58
55
|
*/
|
|
59
56
|
export async function renderMathML(properties: Properties, root: HTMLElement): Promise<void> {
|
|
60
|
-
|
|
61
|
-
if (properties.viewer !== 'image' && properties.viewer !== 'mathml') {
|
|
57
|
+
if (properties.viewer !== "image" && properties.viewer !== "mathml") {
|
|
62
58
|
return;
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
decodeSafeMathML(root);
|
|
66
62
|
|
|
67
|
-
for(const mathElement of [...root.getElementsByTagName(
|
|
68
|
-
const mml =
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
for (const mathElement of [...root.getElementsByTagName("math")]) {
|
|
64
|
+
const mml = serializeHtmlToXml(mathElement.outerHTML);
|
|
65
|
+
try {
|
|
66
|
+
let imgSource;
|
|
67
|
+
|
|
68
|
+
// Transform mml to img.
|
|
69
|
+
if (properties.wirispluginperformance === "true") {
|
|
70
|
+
imgSource = await showImage(
|
|
71
|
+
mml,
|
|
72
|
+
properties.lang,
|
|
73
|
+
properties.editorServicesRoot,
|
|
74
|
+
properties.editorServicesExtension,
|
|
75
|
+
);
|
|
76
|
+
} else {
|
|
77
|
+
imgSource = await createImage(
|
|
78
|
+
mml,
|
|
79
|
+
properties.lang,
|
|
80
|
+
properties.editorServicesRoot,
|
|
81
|
+
properties.editorServicesExtension,
|
|
82
|
+
);
|
|
83
|
+
}
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
85
|
+
// Set img properties.
|
|
86
|
+
const img = await setImageProperties(properties, imgSource, mml);
|
|
87
|
+
// Replace the MathML for the generated formula image.
|
|
88
|
+
mathElement.parentNode?.replaceChild(img, mathElement);
|
|
89
|
+
} catch {
|
|
90
|
+
console.error(`Cannot render ${mml}: invalid MathML format.`);
|
|
91
|
+
continue;
|
|
77
92
|
}
|
|
78
|
-
|
|
79
|
-
// Set img properties.
|
|
80
|
-
const img = await setImageProperties(properties, result, mml);
|
|
81
|
-
// const fragment = document.createRange().createContextualFragment(data.result.content);
|
|
82
|
-
|
|
83
|
-
// Replace the MathML for the generated formula image.
|
|
84
|
-
mathElement.parentNode?.replaceChild(img, mathElement);
|
|
85
93
|
}
|
|
86
|
-
}
|
|
94
|
+
}
|
|
87
95
|
|
|
88
96
|
/**
|
|
89
97
|
* Returns an image formula containing all MathType properties.
|
|
90
98
|
* @param {Properties} properties - Properties of the viewer.
|
|
91
99
|
* @param {FormulaData} data - Object containing image values.
|
|
92
|
-
* @param {string} mml - The MathML of the formula image
|
|
100
|
+
* @param {string} mml - The MathML of the formula image being created.
|
|
93
101
|
* @returns {Promise<HTMLImageElement>} - Formula image.
|
|
94
102
|
*/
|
|
95
103
|
async function setImageProperties(properties: Properties, data: FormulaData, mml: string): Promise<HTMLImageElement> {
|
|
96
|
-
|
|
97
104
|
// Create imag element.
|
|
98
|
-
let img = document.createElement(
|
|
105
|
+
let img = document.createElement("img");
|
|
99
106
|
|
|
100
107
|
// Set image src. Encode the result svg.
|
|
101
108
|
img.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(data.content)}`;
|
|
102
109
|
|
|
103
110
|
// Set other image properties.
|
|
104
111
|
img.setAttribute(properties.wiriseditormathmlattribute, mml);
|
|
105
|
-
img.setAttribute(
|
|
106
|
-
img.setAttribute(
|
|
112
|
+
img.setAttribute("class", "Wirisformula");
|
|
113
|
+
img.setAttribute("role", "math");
|
|
107
114
|
|
|
108
115
|
// If the render returns dimensions properties, set them to the image.
|
|
109
116
|
if (+data.height > 0) {
|
|
@@ -113,18 +120,58 @@ async function setImageProperties(properties: Properties, data: FormulaData, mml
|
|
|
113
120
|
}
|
|
114
121
|
|
|
115
122
|
// Set the alt text whenever there's a translation for the characters and MathML on the mml.
|
|
116
|
-
if (!corruptMathML.some(corruptMathML => mml.includes(corruptMathML))) {
|
|
123
|
+
if (!corruptMathML.some((corruptMathML) => mml.includes(corruptMathML))) {
|
|
117
124
|
try {
|
|
118
125
|
if (!data.alt) {
|
|
119
|
-
const { text } = await mathml2accessible(
|
|
126
|
+
const { text } = await mathml2accessible(
|
|
127
|
+
mml,
|
|
128
|
+
properties.lang,
|
|
129
|
+
properties.editorServicesRoot,
|
|
130
|
+
properties.editorServicesExtension,
|
|
131
|
+
);
|
|
120
132
|
data.alt = text;
|
|
121
133
|
}
|
|
122
|
-
img.alt = data.alt;
|
|
134
|
+
img.alt = data.alt ?? "";
|
|
123
135
|
} catch {
|
|
124
|
-
img.alt =
|
|
136
|
+
img.alt = "Alternative text not available";
|
|
125
137
|
}
|
|
126
138
|
}
|
|
127
139
|
|
|
128
140
|
return img;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* ! --------------- IMPORTANT CONTEXT --------------- !
|
|
145
|
+
*
|
|
146
|
+
* 1. **Attribute Context**: When the HTML parser encounters entities within attribute values, it automatically decodes them. So, `<` becomes `<` in your `open` attribute.
|
|
147
|
+
* 2. **Text Context**: However, within text nodes (the content between tags), entities are preserved to prevent potential issues with HTML syntax. For example, if `<` were not encoded as `<` in a text node, it could be mistaken for the start of a new tag.
|
|
148
|
+
*
|
|
149
|
+
* So, when you call `outerHTML`, it generates a string representation of the element's opening tag (including attributes), content, and closing tag. The attributes have their entities decoded, but the text nodes keep their entities encoded.
|
|
150
|
+
* This is standard behavior for HTML parsers and is not specific to any particular browser or JavaScript environment.
|
|
151
|
+
*/
|
|
129
152
|
|
|
153
|
+
/**
|
|
154
|
+
* Serializes text representing an HTML document to text representing an XML document (encoding/decoding Html Entities when needed).
|
|
155
|
+
* @param {string} text - the string encoded as HTML
|
|
156
|
+
* @returns the same string encoded as XML
|
|
157
|
+
*/
|
|
158
|
+
export function serializeHtmlToXml(text: string): string {
|
|
159
|
+
const serializer = new XMLSerializer();
|
|
160
|
+
text = serializer.serializeToString(document.createRange().createContextualFragment(text));
|
|
161
|
+
return text;
|
|
130
162
|
}
|
|
163
|
+
|
|
164
|
+
// Set of mathml and characters which don't have an accessible text associated
|
|
165
|
+
// and can not be translated or transformed to LaTeX.
|
|
166
|
+
const corruptMathML = [
|
|
167
|
+
"⟦",
|
|
168
|
+
"⟦",
|
|
169
|
+
"⟧",
|
|
170
|
+
"⟧",
|
|
171
|
+
"mscarries",
|
|
172
|
+
"mscarry",
|
|
173
|
+
"msgroup",
|
|
174
|
+
"mstack",
|
|
175
|
+
"msline",
|
|
176
|
+
"msrow",
|
|
177
|
+
];
|