@@ -310,9 +310,13 @@ class _KatexParser {
310
310
311
311
final inlineStyles = _parseInlineStyles (innerSpan);
312
312
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 ();
313
317
final styles = KatexSpanStyles (
314
- marginLeftEm: _takeStyleEm (inlineStyles, 'margin-left' ) ,
315
- marginRightEm: _takeStyleEm (inlineStyles, 'margin-right' ) ,
318
+ marginLeftEm: marginLeftIsNegative ? null : marginLeftEm ,
319
+ marginRightEm: marginRightEm ,
316
320
);
317
321
final topEm = _takeStyleEm (inlineStyles, 'top' );
318
322
if (inlineStyles.isNotEmpty) throw _KatexHtmlParseError ();
@@ -325,19 +329,14 @@ class _KatexParser {
325
329
326
330
final KatexSpanNode innerSpanNode;
327
331
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) {
334
333
innerSpanNode = KatexSpanNode (
335
334
styles: KatexSpanStyles (),
336
335
text: null ,
337
336
nodes: [KatexNegativeMarginNode (
338
- leftOffsetEm: marginLeftEm,
337
+ leftOffsetEm: marginLeftEm! ,
339
338
nodes: [KatexSpanNode (
340
- styles: styles. filter (marginLeftEm : false ) ,
339
+ styles: styles,
341
340
text: null ,
342
341
nodes: _parseChildSpans (otherSpans))])]);
343
342
} else {
0 commit comments