Skip to content

Commit ebce0a4

Browse files
committed
katex [nfc]: Dedupe logic for vlist child between margin/no-margin cases
1 parent f54d168 commit ebce0a4

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

lib/model/katex.dart

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,29 +327,24 @@ class _KatexParser {
327327
if (pstrutHeightEm == null) throw _KatexHtmlParseError();
328328
if (pstrutStyles.isNotEmpty) throw _KatexHtmlParseError();
329329

330-
final KatexSpanNode innerSpanNode;
330+
KatexSpanNode child = KatexSpanNode(
331+
styles: styles,
332+
text: null,
333+
nodes: _parseChildSpans(otherSpans));
331334

332335
if (marginLeftIsNegative) {
333-
innerSpanNode = KatexSpanNode(
336+
child = KatexSpanNode(
334337
styles: KatexSpanStyles(),
335338
text: null,
336339
nodes: [KatexNegativeMarginNode(
337340
leftOffsetEm: marginLeftEm!,
338-
nodes: [KatexSpanNode(
339-
styles: styles,
340-
text: null,
341-
nodes: _parseChildSpans(otherSpans))])]);
342-
} else {
343-
innerSpanNode = KatexSpanNode(
344-
styles: styles,
345-
text: null,
346-
nodes: _parseChildSpans(otherSpans));
341+
nodes: [child])]);
347342
}
348343

349344
rows.add(KatexVlistRowNode(
350345
verticalOffsetEm: (topEm ?? 0) + pstrutHeightEm,
351346
debugHtmlNode: kDebugMode ? innerSpan : null,
352-
node: innerSpanNode));
347+
node: child));
353348
} else {
354349
throw _KatexHtmlParseError();
355350
}

0 commit comments

Comments
 (0)