Skip to content

Commit b0b0ff1

Browse files
content: Make sure there aren't any unexpected styles on .vlist span
Also add a comment explaining the reason of ignoring the `height` inline styles value.
1 parent 47b03a3 commit b0b0ff1

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

lib/model/katex.dart

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,18 @@ class _KatexParser {
224224
dom.Element(localName: 'span', className: 'vlist-r', nodes: [
225225
dom.Element(localName: 'span', className: 'vlist', nodes: [
226226
dom.Element(localName: 'span', className: '', nodes: []),
227-
]),
227+
]) && final vlist,
228228
]),
229229
]) {
230-
// Do nothing.
230+
// In the generated HTML the .vlist in second .vlist-r span will have
231+
// a "height" inline style which we ignore, because it doesn't seem
232+
// to have any effect in rendering on the web.
233+
// But also make sure there aren't any other inline styles present.
234+
final vlistStyles = _parseSpanInlineStyles(vlist);
235+
if (vlistStyles != null
236+
&& vlistStyles.filter(heightEm: false) != const KatexSpanStyles()) {
237+
throw _KatexHtmlParseError();
238+
}
231239
} else {
232240
throw _KatexHtmlParseError();
233241
}
@@ -241,6 +249,17 @@ class _KatexParser {
241249
if (vlistR.nodes.first
242250
case dom.Element(localName: 'span', className: 'vlist') &&
243251
final vlist) {
252+
// Same as above for the second .vlist-r span, .vlist span in first
253+
// .vlist-r span will have "height" inline style which we ignore,
254+
// because it doesn't seem to have any effect in rendering on
255+
// the web.
256+
// But also make sure there aren't any other inline styles present.
257+
final vlistStyles = _parseSpanInlineStyles(vlist);
258+
if (vlistStyles != null
259+
&& vlistStyles.filter(heightEm: false) != const KatexSpanStyles()) {
260+
throw _KatexHtmlParseError();
261+
}
262+
244263
final rows = <KatexVlistRowNode>[];
245264

246265
for (final innerSpan in vlist.nodes) {

0 commit comments

Comments
 (0)