Skip to content

Commit f54d168

Browse files
committed
katex [nfc]: Construct vlist child's styles directly, without filter
1 parent 0f634c9 commit f54d168

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

lib/model/katex.dart

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,13 @@ class _KatexParser {
310310

311311
final inlineStyles = _parseInlineStyles(innerSpan);
312312
if (inlineStyles == null) throw _KatexHtmlParseError();
313+
final marginLeftEm = _takeStyleEm(inlineStyles, 'margin-left');
314+
final marginLeftIsNegative = marginLeftEm?.isNegative ?? false;
315+
final marginRightEm = _takeStyleEm(inlineStyles, 'margin-right');
316+
if (marginRightEm?.isNegative ?? false) throw _KatexHtmlParseError();
313317
final styles = KatexSpanStyles(
314-
marginLeftEm: _takeStyleEm(inlineStyles, 'margin-left'),
315-
marginRightEm: _takeStyleEm(inlineStyles, 'margin-right'),
318+
marginLeftEm: marginLeftIsNegative ? null : marginLeftEm,
319+
marginRightEm: marginRightEm,
316320
);
317321
final topEm = _takeStyleEm(inlineStyles, 'top');
318322
if (inlineStyles.isNotEmpty) throw _KatexHtmlParseError();
@@ -325,19 +329,14 @@ class _KatexParser {
325329

326330
final KatexSpanNode innerSpanNode;
327331

328-
final marginRightEm = styles.marginRightEm;
329-
final marginLeftEm = styles.marginLeftEm;
330-
if (marginRightEm != null && marginRightEm.isNegative) {
331-
throw _KatexHtmlParseError();
332-
}
333-
if (marginLeftEm != null && marginLeftEm.isNegative) {
332+
if (marginLeftIsNegative) {
334333
innerSpanNode = KatexSpanNode(
335334
styles: KatexSpanStyles(),
336335
text: null,
337336
nodes: [KatexNegativeMarginNode(
338-
leftOffsetEm: marginLeftEm,
337+
leftOffsetEm: marginLeftEm!,
339338
nodes: [KatexSpanNode(
340-
styles: styles.filter(marginLeftEm: false),
339+
styles: styles,
341340
text: null,
342341
nodes: _parseChildSpans(otherSpans))])]);
343342
} else {

0 commit comments

Comments
 (0)