Skip to content

Commit 963e082

Browse files
committed
Update math formula sanitizer config
1 parent bc6485b commit 963e082

24 files changed

+106
-30
lines changed
Loading
Loading

__tests__/html2/markdown/math/layout.3.html

+1-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,7 @@
9191

9292
15. LLM generation error:
9393
\[
94-
\
95-
\]
94+
\\]
9695
</x-message>
9796
</template>
9897
<main id="webchat"></main>
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

packages/component/src/providers/HTMLContentTransformCOR/useTransformHTMLContent.ts

+105-28
Original file line numberDiff line numberDiff line change
@@ -51,35 +51,112 @@ const DEFAULT_ALLOWED_TAGS: ReadonlyMap<string, Readonly<{ attributes: ReadonlyS
5151
['ul', []],
5252

5353
// Followings are for MathML elements, from https://developer.mozilla.org/en-US/docs/Web/MathML.
54-
['annotation-xml', []],
55-
['annotation', []],
56-
['math', []],
57-
['merror', []],
58-
['mfrac', []],
59-
['mi', []],
60-
['mmultiscripts', []],
61-
['mn', []],
62-
['mo', []],
63-
['mover', []],
64-
['mpadded', []],
65-
['mphantom', []],
54+
['annotation-xml', ['encoding', 'src', 'name', 'definitionURL']],
55+
['annotation', ['encoding', 'src', 'name', 'definitionURL']],
56+
['math', ['display', 'xmlns', 'mode', 'overflow', 'alttext', 'mathbackground', 'mathcolor']],
57+
['merror', ['mathbackground', 'mathcolor']],
58+
['mfenced', ['close', 'open', 'separators']],
59+
['mfrac', ['linethickness', 'numalign', 'denomalign', 'bevelled']],
60+
['mi', ['mathvariant', 'mathsize', 'mathbackground', 'mathcolor']],
61+
['mmultiscripts', ['subscriptshift', 'superscriptshift']],
62+
['mn', ['mathvariant', 'mathsize', 'mathbackground', 'mathcolor']],
63+
[
64+
'mo',
65+
[
66+
'form',
67+
'fence',
68+
'separator',
69+
'lspace',
70+
'rspace',
71+
'stretchy',
72+
'symmetric',
73+
'maxsize',
74+
'minsize',
75+
'largeop',
76+
'movablelimits',
77+
'accent',
78+
'linebreak',
79+
'mathvariant',
80+
'mathsize',
81+
'mathbackground',
82+
'mathcolor'
83+
]
84+
],
85+
['mover', ['accent', 'align']],
86+
['mpadded', ['height', 'width', 'depth', 'lspace', 'voffset']],
87+
['mphantom', ['mathbackground']],
6688
['mprescripts', []],
67-
['mroot', []],
68-
['mrow', []],
69-
['ms', []],
70-
['mspace', []],
71-
['msqrt', []],
72-
['mstyle', []],
73-
['msub', []],
74-
['msubsup', []],
75-
['msup', []],
76-
['mtable', []],
77-
['mtd', []],
78-
['mtext', []],
79-
['mtr', []],
80-
['munder', []],
81-
['munderover', []],
82-
['semantics', []]
89+
['mroot', ['mathbackground', 'mathcolor']],
90+
['mrow', ['dir', 'mathbackground', 'mathcolor']],
91+
['ms', ['lquote', 'rquote', 'mathvariant', 'mathsize', 'mathbackground', 'mathcolor']],
92+
[
93+
'mspace',
94+
[
95+
'linebreak',
96+
'width',
97+
'height',
98+
'depth',
99+
'mediummathspace',
100+
'negativemediummathspace',
101+
'negativethickmathspace',
102+
'negativethinmathspace',
103+
'negativeverythickmathspace',
104+
'negativeverythinmathspace',
105+
'thickmathspace',
106+
'thinmathspace',
107+
'verythickmathspace',
108+
'verythinmathspace'
109+
]
110+
],
111+
['msqrt', ['mathbackground', 'mathcolor']],
112+
[
113+
'mstyle',
114+
[
115+
'scriptlevel',
116+
'displaystyle',
117+
'scriptsizemultiplier',
118+
'scriptminsize',
119+
'infixlinebreakstyle',
120+
'decimalpoint',
121+
'mathvariant',
122+
'mathsize',
123+
'mathbackground',
124+
'mathcolor',
125+
'dir'
126+
]
127+
],
128+
['msub', ['subscriptshift']],
129+
['msubsup', ['subscriptshift', 'superscriptshift']],
130+
['msup', ['superscriptshift']],
131+
[
132+
'mtable',
133+
[
134+
'align',
135+
'rowalign',
136+
'columnalign',
137+
'groupalign',
138+
'alignmentscope',
139+
'columnwidth',
140+
'width',
141+
'rowspacing',
142+
'columnspacing',
143+
'rowlines',
144+
'columnlines',
145+
'frame',
146+
'framespacing',
147+
'equalrows',
148+
'equalcolumns',
149+
'displaystyle',
150+
'side',
151+
'minlabelspacing'
152+
]
153+
],
154+
['mtd', ['rowspan', 'columnspan', 'rowalign', 'columnalign', 'groupalign']],
155+
['mtext', ['mathvariant', 'mathsize', 'mathbackground', 'mathcolor']],
156+
['mtr', ['rowalign', 'columnalign', 'groupalign']],
157+
['munder', ['accentunder', 'align']],
158+
['munderover', ['accent', 'accentunder', 'align']],
159+
['semantics', ['definitionURL', 'encoding']]
83160
] satisfies [string, string[]][]
84161
).map(
85162
([tag, attributes]) =>

0 commit comments

Comments
 (0)