@@ -424,6 +424,8 @@ class _KatexParser {
424
424
if (stylesheet.topLevels case [css_visitor.RuleSet () && final rule]) {
425
425
double ? heightEm;
426
426
double ? verticalAlignEm;
427
+ double ? marginRightEm;
428
+ double ? marginLeftEm;
427
429
428
430
for (final declaration in rule.declarationGroup.declarations) {
429
431
if (declaration case css_visitor.Declaration (
@@ -439,6 +441,20 @@ class _KatexParser {
439
441
case 'vertical-align' :
440
442
verticalAlignEm = _getEm (expression);
441
443
if (verticalAlignEm != null ) continue ;
444
+
445
+ case 'margin-right' :
446
+ marginRightEm = _getEm (expression);
447
+ if (marginRightEm != null ) {
448
+ if (marginRightEm < 0 ) throw KatexHtmlParseError ();
449
+ continue ;
450
+ }
451
+
452
+ case 'margin-left' :
453
+ marginLeftEm = _getEm (expression);
454
+ if (marginLeftEm != null ) {
455
+ if (marginLeftEm < 0 ) throw KatexHtmlParseError ();
456
+ continue ;
457
+ }
442
458
}
443
459
444
460
// TODO handle more CSS properties
@@ -453,6 +469,8 @@ class _KatexParser {
453
469
return KatexSpanStyles (
454
470
heightEm: heightEm,
455
471
verticalAlignEm: verticalAlignEm,
472
+ marginRightEm: marginRightEm,
473
+ marginLeftEm: marginLeftEm,
456
474
);
457
475
} else {
458
476
throw KatexHtmlParseError ();
@@ -491,6 +509,9 @@ class KatexSpanStyles {
491
509
final double ? heightEm;
492
510
final double ? verticalAlignEm;
493
511
512
+ final double ? marginRightEm;
513
+ final double ? marginLeftEm;
514
+
494
515
final String ? fontFamily;
495
516
final double ? fontSizeEm;
496
517
final KatexSpanFontWeight ? fontWeight;
@@ -500,6 +521,8 @@ class KatexSpanStyles {
500
521
const KatexSpanStyles ({
501
522
this .heightEm,
502
523
this .verticalAlignEm,
524
+ this .marginRightEm,
525
+ this .marginLeftEm,
503
526
this .fontFamily,
504
527
this .fontSizeEm,
505
528
this .fontWeight,
@@ -512,6 +535,8 @@ class KatexSpanStyles {
512
535
'KatexSpanStyles' ,
513
536
heightEm,
514
537
verticalAlignEm,
538
+ marginRightEm,
539
+ marginLeftEm,
515
540
fontFamily,
516
541
fontSizeEm,
517
542
fontWeight,
@@ -524,6 +549,8 @@ class KatexSpanStyles {
524
549
return other is KatexSpanStyles &&
525
550
other.heightEm == heightEm &&
526
551
other.verticalAlignEm == verticalAlignEm &&
552
+ other.marginRightEm == marginRightEm &&
553
+ other.marginLeftEm == marginLeftEm &&
527
554
other.fontFamily == fontFamily &&
528
555
other.fontSizeEm == fontSizeEm &&
529
556
other.fontWeight == fontWeight &&
@@ -536,6 +563,8 @@ class KatexSpanStyles {
536
563
final args = < String > [];
537
564
if (heightEm != null ) args.add ('heightEm: $heightEm ' );
538
565
if (verticalAlignEm != null ) args.add ('verticalAlignEm: $verticalAlignEm ' );
566
+ if (marginRightEm != null ) args.add ('marginRightEm: $marginRightEm ' );
567
+ if (marginLeftEm != null ) args.add ('marginLeftEm: $marginLeftEm ' );
539
568
if (fontFamily != null ) args.add ('fontFamily: $fontFamily ' );
540
569
if (fontSizeEm != null ) args.add ('fontSizeEm: $fontSizeEm ' );
541
570
if (fontWeight != null ) args.add ('fontWeight: $fontWeight ' );
@@ -548,6 +577,8 @@ class KatexSpanStyles {
548
577
return KatexSpanStyles (
549
578
heightEm: other.heightEm ?? heightEm,
550
579
verticalAlignEm: other.verticalAlignEm ?? verticalAlignEm,
580
+ marginRightEm: other.marginRightEm ?? marginRightEm,
581
+ marginLeftEm: other.marginLeftEm ?? marginLeftEm,
551
582
fontFamily: other.fontFamily ?? fontFamily,
552
583
fontSizeEm: other.fontSizeEm ?? fontSizeEm,
553
584
fontStyle: other.fontStyle ?? fontStyle,
@@ -559,6 +590,8 @@ class KatexSpanStyles {
559
590
KatexSpanStyles filter ({
560
591
bool heightEm = true ,
561
592
bool verticalAlignEm = true ,
593
+ bool marginRightEm = true ,
594
+ bool marginLeftEm = true ,
562
595
bool fontFamily = true ,
563
596
bool fontSizeEm = true ,
564
597
bool fontWeight = true ,
@@ -568,6 +601,8 @@ class KatexSpanStyles {
568
601
return KatexSpanStyles (
569
602
heightEm: heightEm ? this .heightEm : null ,
570
603
verticalAlignEm: verticalAlignEm ? this .verticalAlignEm : null ,
604
+ marginRightEm: marginRightEm ? this .marginRightEm : null ,
605
+ marginLeftEm: marginLeftEm ? this .marginLeftEm : null ,
571
606
fontFamily: fontFamily ? this .fontFamily : null ,
572
607
fontSizeEm: fontSizeEm ? this .fontSizeEm : null ,
573
608
fontWeight: fontWeight ? this .fontWeight : null ,
0 commit comments