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