@wiris/mathtype-viewer 1.5.0 → 8.9.2

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.
@@ -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>&le;</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>&lt;</mo><mi>&epsi;</mi></math>`,
22
+ `<math><mo>&#177;</mo><mo>&#8734;</mo></math>`,
23
+ `<math><mo>&#8709;</mo><mo>=</mo><mo>{</mo><mo>&#160;</mo><mo>}</mo></math>`,
24
+ `<math><mi>A</mi><mo>&#8745;</mo><mi>B</mi><mo>&#8746;</mo><mi>C</mi></math>`,
25
+ `<math><msub><mi>a</mi><mn>1</mn></msub><mo>&#215;</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>&#8658;</mo><mi>b</mi></math>`,
36
+ `<math><mi>x</mi><mover><mo>&#8614;</mo><mtext>maps&#160;to</mtext></mover><mi>y</mi></math>`,
37
+ `<math><msub><mi>a</mi><mn>1</mn></msub><mo>&#215;</mo><mo>&#8943;</mo><mo>&#215;</mo><msub><mi>a</mi><mi>n</mi></msub></math>`,
38
+ `<math><mover><mrow><mi>A</mi><mi>B</mi></mrow><mo>&#8640;</mo></mover><mo>=</mo><mo>-</mo><mover><mrow><mi>B</mi><mi>A</mi></mrow><mo>&#8640;</mo></mover></math>`,
39
+ `<math><mi>A</mi><munderover><mo>&#x2942;</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>&#xA0;</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>&#xA0;</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>&#8728;</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>&sim;</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>&nbsp;</mo><mn>0</mn><mo>&LessSlantEqual;</mo><mi>x</mi></math>`,
52
+ `<math><mn>5</mn><mo>&lneq;</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>&in;</mo><mi mathvariant="normal">&naturals;</mi></math>`,
62
+ `<math><mi>&pi;</mi><mo>&in;</mo><mi mathvariant="normal">&Ropf;</mi><mo>&Backslash;</mo><mi mathvariant="normal">&Qopf;</mi></math>`,
63
+ `<math><mo>&realpart;</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>&#x000A0;</mo><mo>=</mo><mo>&#x000A0;</mo><mo>{</mo><mo>&#x000A0;</mo><mi>z</mi><mo>&#x02208;</mo><mi mathvariant="normal">&#x02102;</mi><mo>&#x000A0;</mo><mo>&#x000A0;</mo><mo>:</mo><mo>&#x000A0;</mo><mo>&#x02009;</mo><mo>|</mo><mi>z</mi><mo>|</mo><mo>&lt;</mo><mn>1</mn><mo>&#x000A0;</mo><mo>}</mo></math>`,
65
+ `<math><msub><mi mathvariant="double-struck">A</mi><mi mathvariant="normal">&#x0211A;</mi></msub><mo>=</mo><mi mathvariant="normal">&#x0211A;</mi><mo>&#x000A0;</mo><msub><mo>&#x02297;</mo><mi mathvariant="normal">&#x02124;</mi></msub><mo>&#x000A0;</mo><msub><mi mathvariant="double-struck">A</mi><mi mathvariant="normal">&#x02124;</mi></msub></math>`,
66
+ `<math><mi mathvariant="script">H</mi><mo>=</mo><munder><mo>&#x02211;</mo><mi>i</mi></munder><msub><mover><mi>q</mi><mo>&#x002D9;</mo></mover><mi>i</mi></msub><mfrac><mrow><mo>&#x02202;</mo><mi mathvariant="script">L</mi></mrow><mrow><mo>&#x02202;</mo><msub><mover><mi>q</mi><mo>&#x002D9;</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>&#x000A0;</mo><mo>&#x02245;</mo><mo>&#x000A0;</mo><msub><mi>T</mi><mi mathvariant="script">Q</mi></msub></math>`,
68
+ `<math><mi mathvariant="fraktur">p</mi><mo>&#x000A0;</mo><mo>&#x02283;</mo><mo>&#x000A0;</mo><mi mathvariant="fraktur">ab</mi><mo>&#x000A0;</mo><mo>&#x021D2;</mo><mi mathvariant="fraktur">p</mi><mo>&#x02283;</mo><mi mathvariant="fraktur">a</mi><mo>&#x000A0;</mo><mo>&#x02228;</mo><mo>&#x000A0;</mo><mi mathvariant="fraktur">p</mi><mo>&#x000A0;</mo><mo>&#x02283;</mo><mi mathvariant="fraktur">b</mi></math>`,
69
+ `<math><mi mathvariant="script">B</mi><mo>=</mo><mo>{</mo><msub><mi>B</mi><mi>&#x003B1;</mi></msub><mo>&#x02208;</mo><mi mathvariant="script">T</mi><mo>&#x0200A;</mo><mo>|</mo><mo>&#x0200A;</mo><mi>U</mi><mo>=</mo><mo largeop="true">&#x0222A;</mo><msub><mi>B</mi><mi>&#x003B1;</mi></msub><mo>&#x02200;</mo><mi>U</mi><mo>&#x02208;</mo><mi mathvariant="script">T</mi><mo>}</mo></math>`,
70
+ `<math><mi>A</mi><mo>&CirclePlus;</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>&map;</mo><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></math>`,
73
+ `<math><mi>x</mi><mo>&lt;</mo><mn>3</mn><mo>∧</mo><mi>x</mi><mo>&Implies;</mo><mo>-</mo><mn>2</mn><mo>⇒</mo><mi>x</mi><mo>⩽</mo><mo>-</mo><mn>2</mn></math>`,
74
+ `<math><mo>&#9633;</mo><mo>&#8800;</mo><mo>&#9675;</mo></math>`,
75
+ `<math><mi>a</mi><mo>&#8742;</mo><mi>b</mi><mo>,</mo><mo>&#160;</mo><mi>A</mi><mo>&#8716;</mo><mi>x</mi></math>`,
76
+ `<math><mi mathvariant="normal">cos</mi><mo>(</mo><mi>&alpha;</mi><mo>&pm;</mo><mi>&beta;</mi><mo>)</mo><mo>=</mo><mi mathvariant="normal">cos</mi><mi>&alpha;</mi><mi mathvariant="normal">cos</mi><mi>&beta;</mi><mo>&mp;</mo><mi mathvariant="normal">sin</mi><mi>&alpha;</mi><mi mathvariant="normal">sin</mi><mi>&beta;</mi></math>`,
77
+ `<math><mi mathvariant="normal">sin</mi><mo>(</mo><mi>&theta;</mi><mo>+</mo><mfrac><mi>&pi;</mi><mn>2</mn></mfrac><mo>)</mo><mo>=</mo><mi mathvariant="normal">cos</mi><mi>&theta;</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>&nbsp;</mo></mtd><mtd><mo>&nbsp;</mo></mtd></mtr><mtr><mtd><mo>&nbsp;</mo></mtd><mtd><mn>1</mn></mtd><mtd><mo>&nbsp;</mo></mtd></mtr><mtr><mtd><mo>&nbsp;</mo></mtd><mtd><mo>&nbsp;</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&#160;</mtext><mi>x</mi><mo>&#10877;</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&#160;</mtext><mi>x</mi><mo>&#62;</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>&#160;</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>&#160;</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>&nbsp;</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>&#9183;</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>&#9183;</mo></munder><mn>3</mn></munder><mo>+</mo><mn>3</mn></mrow><mo>&#9182;</mo></mover><mn>5</mn></mover></math>`,
103
+ `<math><mfenced open="&lt;" close="&#62;"><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>&#9180;</mo></mover></math>`,
105
+ `<math><mover><mi>u</mi><mo>&#8594;</mo></mover><mo>+</mo><mover><mi>v</mi><mo>&#8594;</mo></mover></math>`,
106
+ `<math><mover><mrow><mi>x</mi><mo>+</mo><mover><mi>y</mi><mo>&#175;</mo></mover></mrow><mo>&#175;</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>&#183;</mo><menclose mathcolor="#FF0000" notation="updiagonalstrike"><mi mathcolor="#191919">b</mi></menclose><mo>&#183;</mo><menclose mathcolor="#0000FF" notation="downdiagonalstrike"><mi mathcolor="#191919">d</mi></menclose><mo>&#183;</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>&#183;</mo><mi>c</mi><mo>&#183;</mo><menclose mathcolor="#0000FF" notation="downdiagonalstrike"><mi mathcolor="#191919">d</mi></menclose><mo>&#183;</mo><mi>f</mi><mo>&#183;</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">&cap;</mo><mrow><mi>x</mi><mo>&isin;</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>&nbsp;</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>&oint;</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>&#215;</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>&#x220F;</mo><mmultiscripts><mi>A</mi><mi>&#x03C5;</mi><mi>&#x03C4;</mi><mprescripts /><mi>&#x03C1;</mi><mi>&#x03C3;</mi></mmultiscripts><mmultiscripts><mi>B</mi><mi>&#x03C0;</mi><mi>&#x03BF;</mi><mprescripts /><mi>&#x03BD;</mi><mi>&#x03BE;</mi></mmultiscripts><mprescripts /><mmultiscripts><mi>C</mi><mi>&#x03B4;</mi><mi>&#x03B3;</mi><mprescripts /><mi>&#x03B1;</mi><mi>&#x03B2;</mi></mmultiscripts><mmultiscripts><mi>D</mi><mi>&#x03B8;</mi><mi>&#x03B7;</mi><mprescripts /><mi>&#x03B5;</mi><mi>&#x03B6;</mi></mmultiscripts></mmultiscripts><mmultiscripts><mi>E</mi><mi>&#x03C9;</mi><mi>&#x03C8;</mi><mprescripts /><mi>&#x03D5;</mi><mi>&#x03C7;</mi></mmultiscripts><mmultiscripts><mi>F</mi><mi>&#x03BC;</mi><mi>&#x03BB;</mi><mprescripts /><mi>&#x03B9;</mi><mi>&#x03BA;</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>&#160;</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>&#160;</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>&#160;</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>&#8592;</mo></mtd><mtd><mn>3</mn></mtd></mtr><mtr><mtd><mo>&#8595;</mo></mtd><mtd><mtable><mtr><mtd/><mtd/></mtr><mtr><mtd/><mtd/></mtr></mtable><mo>&#160;</mo></mtd><mtd><mo>&#8593;</mo></mtd></mtr><mtr><mtd><mn>1</mn></mtd><mtd><mo>&#8594;</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&#xA0;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>&#x2192;</mo></mover><mo>+</mo><mover><mi>k</mi><mo>&#x21C0;</mo></mover><mo>+</mo><mover><mrow><mi>A</mi><mi>B</mi></mrow><mo>&#xAF;</mo></mover></math>`,
142
+ `<math><munderover><mo>&#x2211;</mo><mrow><mi>n</mi><mo>=</mo><mn>0</mn></mrow><mo>&#x221E;</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>&#x222B;</mo><mn>0</mn><mn>1</mn></msubsup><mi>x</mi><mo>d</mo><mi>x</mi><mo>+</mo><msubsup><mo>&#x222B;</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="&lt;" close="&gt;"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="&#x230A;" close="&#x230B;"><mfenced open="&#x27E6;" close="&#x27E7;"><mi>x</mi></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced><mo>&#xA0;</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="&lt;" close="&gt;"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="&#x230A;" close="&#x230B;"><mfenced open="&#x27E6;" close="&#x27E7;"><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>&#x2218;</mo><mi>g</mi></mrow><mrow><mi>f</mi><mo>&#x2218;</mo><mi>h</mi></mrow></mfrac><mo>&#xA0;</mo><mfrac><mn>1</mn><msqrt><mn>2</mn></msqrt></mfrac><mo>&#xA0;</mo><mfrac><msub><mi>x</mi><mi>j</mi></msub><msup><mi>x</mi><mi>t</mi></msup></mfrac><mo>&#xA0;</mo><mfrac><menclose notation="bottom"><mi>x</mi></menclose><mover><mi>x</mi><mo>&#x2192;</mo></mover></mfrac><mo>&#xA0;</mo><mfrac><mn>1</mn><mover><mi>k</mi><mo>&#x2192;</mo></mover></mfrac><mo>&#xA0;</mo><mfrac><mn>1</mn><mrow><mn>2</mn><mo>.</mo><mover><mn>3</mn><mo>&#x23DC;</mo></mover></mrow></mfrac></math>`,
152
+ `<math><mfrac><mfenced><mfenced open="|" close="|"><mfenced open="&lt;" close="&gt;"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="&#x230A;" close="&#x230B;"><mfenced open="&#x2308;" close="&#x2309;"><mrow/></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced><mfenced><mfenced open="|" close="|"><mfenced open="&lt;" close="&gt;"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="&#x230A;" close="&#x230B;"><mfenced open="&#x2308;" close="&#x2309;"><mrow/></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfrac><mo>&#xA0;</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>&#x2218;</mo><mi>g</mi></msqrt><mo>&#xA0;</mo><msqrt><msqrt><msqrt><mi>x</mi></msqrt></msqrt></msqrt><mo>&#xA0;</mo><msqrt><msup><mi>x</mi><mi>t</mi></msup></msqrt><mo>&#xA0;</mo></math>`,
154
+ `<math><msqrt><mover><mi>x</mi><mo>&#x2192;</mo></mover></msqrt><mo>&#xA0;</mo><msqrt><mover><mi>t</mi><mo>&#x2192;</mo></mover></msqrt><mo>&#xA0;</mo><msqrt><menclose notation="top"><mi>x</mi></menclose></msqrt><mo>&#xA0;</mo><msqrt><menclose notation="top"><mn>2</mn></menclose></msqrt><mo>&#xA0;</mo><msqrt><mn>2</mn><mo>.</mo><mover><mn>3</mn><mo>&#x23DC;</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>&#xA0;</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="&lt;" close="&gt;"><mfenced open="[" close="]"><mfenced open="||" close="||"><mfenced open="{" close="}"><mfenced open="&#x230A;" close="&#x230B;"><mfenced open="&#x2308;" close="&#x2309;"><mrow/></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></mfenced></msqrt><mo>&#xA0;</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>&#xA0;</mo><msup><mi>P</mi><mi>j</mi></msup><mo>&#xA0;</mo><mmultiscripts><mi>W</mi><none/><mi>j</mi><mprescripts/><mi>p</mi><mi>p</mi></mmultiscripts><mo>&#xA0;</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>&#x23DF;</mo></munder><mrow><mi>y</mi><mo>=</mo><msup><mi>x</mi><mn>2</mn></msup></mrow></munder><mo>&#x2218;</mo><mover><mover><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mo>&#x23DE;</mo></mover><mrow><mi>y</mi><mo>=</mo><msub><mi>a</mi><mi>j</mi></msub></mrow></mover><mo>&#xA0;</mo><mo>&#xA0;</mo></math>`,
161
+ `<math xmlns="http://www.w3.org/1998/Math/MathML"><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&#xAB;</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&lt;</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&#xBB;</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&gt;</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&#xA7;</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&amp;</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&#xA8;</mo><mo mathvariant="bold" mathcolor="#7F0000" mathsize="48px">&quot;</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, processJsonResponse } from './services';
3
- import { htmlEntitiesToXmlEntities, corruptMathML } from './utils';
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
- root,
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 : Node[] = [];
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,58 +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('math')]) {
68
- const mml = htmlEntitiesToXmlEntities(mathElement.outerHTML);
69
-
70
- let result;
63
+ for (const mathElement of [...root.getElementsByTagName("math")]) {
64
+ const mml = serializeHtmlToXml(mathElement.outerHTML);
65
+ try {
66
+ let imgSource;
71
67
 
72
- if (properties.wirispluginperformance === 'true') {
73
68
  // Transform mml to img.
74
- result = await showImage(mml, properties.lang, properties.editorServicesRoot, properties.editorServicesExtension);
75
- } else {
76
- // createimage returns the URL to showimage of the corresponding image
77
- let url = await createImage(mml, properties.lang, properties.editorServicesRoot, properties.editorServicesExtension);
78
- // This line is necessary due to a bug in how the services interoperate.
79
- // TODO fix the causing bug
80
- url = url.replace('pluginsapp', 'plugins/app');
81
- result = await processJsonResponse(fetch(url));
82
- }
83
-
84
- // Set img properties.
85
- const img = await setImageProperties(properties, result, mml);
86
- // const fragment = document.createRange().createContextualFragment(data.result.content);
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
+ }
87
84
 
88
- // Replace the MathML for the generated formula image.
89
- mathElement.parentNode?.replaceChild(img, mathElement);
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;
92
+ }
90
93
  }
91
- };
94
+ }
92
95
 
93
96
  /**
94
97
  * Returns an image formula containing all MathType properties.
95
98
  * @param {Properties} properties - Properties of the viewer.
96
99
  * @param {FormulaData} data - Object containing image values.
97
- * @param {string} mml - The MathML of the formula image beeing created.
100
+ * @param {string} mml - The MathML of the formula image being created.
98
101
  * @returns {Promise<HTMLImageElement>} - Formula image.
99
102
  */
100
103
  async function setImageProperties(properties: Properties, data: FormulaData, mml: string): Promise<HTMLImageElement> {
101
-
102
104
  // Create imag element.
103
- let img = document.createElement('img');
105
+ let img = document.createElement("img");
104
106
 
105
107
  // Set image src. Encode the result svg.
106
108
  img.src = `data:image/svg+xml;charset=utf8,${encodeURIComponent(data.content)}`;
107
109
 
108
110
  // Set other image properties.
109
111
  img.setAttribute(properties.wiriseditormathmlattribute, mml);
110
- img.setAttribute('class', 'Wirisformula');
111
- img.setAttribute('role', 'math');
112
+ img.setAttribute("class", "Wirisformula");
113
+ img.setAttribute("role", "math");
112
114
 
113
115
  // If the render returns dimensions properties, set them to the image.
114
116
  if (+data.height > 0) {
@@ -118,18 +120,58 @@ async function setImageProperties(properties: Properties, data: FormulaData, mml
118
120
  }
119
121
 
120
122
  // Set the alt text whenever there's a translation for the characters and MathML on the mml.
121
- if (!corruptMathML.some(corruptMathML => mml.includes(corruptMathML))) {
123
+ if (!corruptMathML.some((corruptMathML) => mml.includes(corruptMathML))) {
122
124
  try {
123
125
  if (!data.alt) {
124
- const { text } = await mathml2accessible(mml, properties.lang, properties.editorServicesRoot, properties.editorServicesExtension);
126
+ const { text } = await mathml2accessible(
127
+ mml,
128
+ properties.lang,
129
+ properties.editorServicesRoot,
130
+ properties.editorServicesExtension,
131
+ );
125
132
  data.alt = text;
126
133
  }
127
- img.alt = data.alt;
134
+ img.alt = data.alt ?? "";
128
135
  } catch {
129
- img.alt = 'Alternative text not available';
136
+ img.alt = "Alternative text not available";
130
137
  }
131
138
  }
132
139
 
133
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, `&lt;` 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 `&lt;` 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
+ */
134
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;
135
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
+ "&#10214;",
169
+ "⟧",
170
+ "&#10215;",
171
+ "mscarries",
172
+ "mscarry",
173
+ "msgroup",
174
+ "mstack",
175
+ "msline",
176
+ "msrow",
177
+ ];