@@ -492,6 +492,8 @@ class _KatexParser {
492
492
if (stylesheet.topLevels case [css_visitor.RuleSet () && final rule]) {
493
493
double ? heightEm;
494
494
double ? verticalAlignEm;
495
+ double ? marginRightEm;
496
+ double ? marginLeftEm;
495
497
496
498
for (final declaration in rule.declarationGroup.declarations) {
497
499
if (declaration case css_visitor.Declaration (
@@ -507,6 +509,20 @@ class _KatexParser {
507
509
case 'vertical-align' :
508
510
verticalAlignEm = _getEm (expression);
509
511
if (verticalAlignEm != null ) continue ;
512
+
513
+ case 'margin-right' :
514
+ marginRightEm = _getEm (expression);
515
+ if (marginRightEm != null ) {
516
+ if (marginRightEm < 0 ) throw _KatexHtmlParseError ();
517
+ continue ;
518
+ }
519
+
520
+ case 'margin-left' :
521
+ marginLeftEm = _getEm (expression);
522
+ if (marginLeftEm != null ) {
523
+ if (marginLeftEm < 0 ) throw _KatexHtmlParseError ();
524
+ continue ;
525
+ }
510
526
}
511
527
512
528
// TODO handle more CSS properties
@@ -522,6 +538,8 @@ class _KatexParser {
522
538
return KatexSpanStyles (
523
539
heightEm: heightEm,
524
540
verticalAlignEm: verticalAlignEm,
541
+ marginRightEm: marginRightEm,
542
+ marginLeftEm: marginLeftEm,
525
543
);
526
544
} else {
527
545
throw _KatexHtmlParseError ();
@@ -560,6 +578,9 @@ class KatexSpanStyles {
560
578
final double ? heightEm;
561
579
final double ? verticalAlignEm;
562
580
581
+ final double ? marginRightEm;
582
+ final double ? marginLeftEm;
583
+
563
584
final String ? fontFamily;
564
585
final double ? fontSizeEm;
565
586
final KatexSpanFontWeight ? fontWeight;
@@ -569,6 +590,8 @@ class KatexSpanStyles {
569
590
const KatexSpanStyles ({
570
591
this .heightEm,
571
592
this .verticalAlignEm,
593
+ this .marginRightEm,
594
+ this .marginLeftEm,
572
595
this .fontFamily,
573
596
this .fontSizeEm,
574
597
this .fontWeight,
@@ -581,6 +604,8 @@ class KatexSpanStyles {
581
604
'KatexSpanStyles' ,
582
605
heightEm,
583
606
verticalAlignEm,
607
+ marginRightEm,
608
+ marginLeftEm,
584
609
fontFamily,
585
610
fontSizeEm,
586
611
fontWeight,
@@ -593,6 +618,8 @@ class KatexSpanStyles {
593
618
return other is KatexSpanStyles &&
594
619
other.heightEm == heightEm &&
595
620
other.verticalAlignEm == verticalAlignEm &&
621
+ other.marginRightEm == marginRightEm &&
622
+ other.marginLeftEm == marginLeftEm &&
596
623
other.fontFamily == fontFamily &&
597
624
other.fontSizeEm == fontSizeEm &&
598
625
other.fontWeight == fontWeight &&
@@ -605,6 +632,8 @@ class KatexSpanStyles {
605
632
final args = < String > [];
606
633
if (heightEm != null ) args.add ('heightEm: $heightEm ' );
607
634
if (verticalAlignEm != null ) args.add ('verticalAlignEm: $verticalAlignEm ' );
635
+ if (marginRightEm != null ) args.add ('marginRightEm: $marginRightEm ' );
636
+ if (marginLeftEm != null ) args.add ('marginLeftEm: $marginLeftEm ' );
608
637
if (fontFamily != null ) args.add ('fontFamily: $fontFamily ' );
609
638
if (fontSizeEm != null ) args.add ('fontSizeEm: $fontSizeEm ' );
610
639
if (fontWeight != null ) args.add ('fontWeight: $fontWeight ' );
@@ -624,6 +653,8 @@ class KatexSpanStyles {
624
653
return KatexSpanStyles (
625
654
heightEm: other.heightEm ?? heightEm,
626
655
verticalAlignEm: other.verticalAlignEm ?? verticalAlignEm,
656
+ marginRightEm: other.marginRightEm ?? marginRightEm,
657
+ marginLeftEm: other.marginLeftEm ?? marginLeftEm,
627
658
fontFamily: other.fontFamily ?? fontFamily,
628
659
fontSizeEm: other.fontSizeEm ?? fontSizeEm,
629
660
fontStyle: other.fontStyle ?? fontStyle,
@@ -635,6 +666,8 @@ class KatexSpanStyles {
635
666
KatexSpanStyles filter ({
636
667
bool heightEm = true ,
637
668
bool verticalAlignEm = true ,
669
+ bool marginRightEm = true ,
670
+ bool marginLeftEm = true ,
638
671
bool fontFamily = true ,
639
672
bool fontSizeEm = true ,
640
673
bool fontWeight = true ,
@@ -644,6 +677,8 @@ class KatexSpanStyles {
644
677
return KatexSpanStyles (
645
678
heightEm: heightEm ? this .heightEm : null ,
646
679
verticalAlignEm: verticalAlignEm ? this .verticalAlignEm : null ,
680
+ marginRightEm: marginRightEm ? this .marginRightEm : null ,
681
+ marginLeftEm: marginLeftEm ? this .marginLeftEm : null ,
647
682
fontFamily: fontFamily ? this .fontFamily : null ,
648
683
fontSizeEm: fontSizeEm ? this .fontSizeEm : null ,
649
684
fontWeight: fontWeight ? this .fontWeight : null ,
0 commit comments