@@ -209,6 +209,89 @@ class _KatexParser {
209
209
debugHtmlNode: debugHtmlNode);
210
210
}
211
211
212
+ if (element.className == 'vlist-t'
213
+ || element.className == 'vlist-t vlist-t2' ) {
214
+ final vlistT = element;
215
+ if (vlistT.nodes.isEmpty) throw _KatexHtmlParseError ();
216
+ if (vlistT.attributes.containsKey ('style' )) throw _KatexHtmlParseError ();
217
+
218
+ final hasTwoVlistR = vlistT.className == 'vlist-t vlist-t2' ;
219
+ if (! hasTwoVlistR && vlistT.nodes.length != 1 ) throw _KatexHtmlParseError ();
220
+
221
+ if (hasTwoVlistR) {
222
+ if (vlistT.nodes case [
223
+ _,
224
+ dom.Element (localName: 'span' , className: 'vlist-r' , nodes: [
225
+ dom.Element (localName: 'span' , className: 'vlist' , nodes: [
226
+ dom.Element (localName: 'span' , className: '' , nodes: []),
227
+ ]),
228
+ ]),
229
+ ]) {
230
+ // Do nothing.
231
+ } else {
232
+ throw _KatexHtmlParseError ();
233
+ }
234
+ }
235
+
236
+ if (vlistT.nodes.first
237
+ case dom.Element (localName: 'span' , className: 'vlist-r' ) &&
238
+ final vlistR) {
239
+ if (vlistR.attributes.containsKey ('style' )) throw _KatexHtmlParseError ();
240
+
241
+ if (vlistR.nodes.first
242
+ case dom.Element (localName: 'span' , className: 'vlist' ) &&
243
+ final vlist) {
244
+ final rows = < KatexVlistRowNode > [];
245
+
246
+ for (final innerSpan in vlist.nodes) {
247
+ if (innerSpan case dom.Element (
248
+ localName: 'span' ,
249
+ className: '' ,
250
+ nodes: [
251
+ dom.Element (localName: 'span' , className: 'pstrut' ) &&
252
+ final pstrutSpan,
253
+ ...final otherSpans,
254
+ ],
255
+ )) {
256
+ var styles = _parseSpanInlineStyles (innerSpan);
257
+ if (styles == null ) throw _KatexHtmlParseError ();
258
+ if (styles.verticalAlignEm != null ) throw _KatexHtmlParseError ();
259
+ final topEm = styles.topEm ?? 0 ;
260
+
261
+ styles = styles.filter (topEm: false );
262
+
263
+ final pstrutStyles = _parseSpanInlineStyles (pstrutSpan);
264
+ if (pstrutStyles == null ) throw _KatexHtmlParseError ();
265
+ if (pstrutStyles.filter (heightEm: false )
266
+ != const KatexSpanStyles ()) {
267
+ throw _KatexHtmlParseError ();
268
+ }
269
+ final pstrutHeight = pstrutStyles.heightEm ?? 0 ;
270
+
271
+ rows.add (KatexVlistRowNode (
272
+ verticalOffsetEm: topEm + pstrutHeight,
273
+ debugHtmlNode: kDebugMode ? innerSpan : null ,
274
+ node: KatexSpanNode (
275
+ styles: styles,
276
+ text: null ,
277
+ nodes: _parseChildSpans (otherSpans))));
278
+ } else {
279
+ throw _KatexHtmlParseError ();
280
+ }
281
+ }
282
+
283
+ return KatexVlistNode (
284
+ rows: rows,
285
+ debugHtmlNode: kDebugMode ? vlistT : null ,
286
+ );
287
+ } else {
288
+ throw _KatexHtmlParseError ();
289
+ }
290
+ } else {
291
+ throw _KatexHtmlParseError ();
292
+ }
293
+ }
294
+
212
295
final inlineStyles = _parseSpanInlineStyles (element);
213
296
if (inlineStyles != null ) {
214
297
// We expect `vertical-align` inline style to be only present on a
@@ -224,7 +307,9 @@ class _KatexParser {
224
307
// https://github.com/KaTeX/KaTeX/blob/2fe1941b/src/styles/katex.scss
225
308
// A copy of class definition (where possible) is accompanied in a comment
226
309
// with each case statement to keep track of updates.
227
- final spanClasses = List <String >.unmodifiable (element.className.split (' ' ));
310
+ final spanClasses = element.className != ''
311
+ ? List <String >.unmodifiable (element.className.split (' ' ))
312
+ : const < String > [];
228
313
String ? fontFamily;
229
314
double ? fontSizeEm;
230
315
KatexSpanFontWeight ? fontWeight;
0 commit comments