Skip to content

Commit 002b338

Browse files
content: Handle 'top' property in KaTeX span inline style
1 parent ee9d42c commit 002b338

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

lib/model/katex.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ class _KatexParser {
392392
if (stylesheet.topLevels case [css_visitor.RuleSet() && final rule]) {
393393
double? heightEm;
394394
double? verticalAlignEm;
395+
double? topEm;
395396
double? marginRightEm;
396397
double? marginLeftEm;
397398

@@ -410,6 +411,10 @@ class _KatexParser {
410411
verticalAlignEm = _getEm(expression);
411412
if (verticalAlignEm != null) continue;
412413

414+
case 'top':
415+
topEm = _getEm(expression);
416+
if (topEm != null) continue;
417+
413418
case 'margin-right':
414419
marginRightEm = _getEm(expression);
415420
if (marginRightEm != null) {
@@ -436,6 +441,7 @@ class _KatexParser {
436441

437442
return KatexSpanStyles(
438443
heightEm: heightEm,
444+
topEm: topEm,
439445
verticalAlignEm: verticalAlignEm,
440446
marginRightEm: marginRightEm,
441447
marginLeftEm: marginLeftEm,
@@ -477,6 +483,8 @@ class KatexSpanStyles {
477483
final double? heightEm;
478484
final double? verticalAlignEm;
479485

486+
final double? topEm;
487+
480488
final double? marginRightEm;
481489
final double? marginLeftEm;
482490

@@ -489,6 +497,7 @@ class KatexSpanStyles {
489497
const KatexSpanStyles({
490498
this.heightEm,
491499
this.verticalAlignEm,
500+
this.topEm,
492501
this.marginRightEm,
493502
this.marginLeftEm,
494503
this.fontFamily,
@@ -503,6 +512,7 @@ class KatexSpanStyles {
503512
'KatexSpanStyles',
504513
heightEm,
505514
verticalAlignEm,
515+
topEm,
506516
marginRightEm,
507517
marginLeftEm,
508518
fontFamily,
@@ -517,6 +527,7 @@ class KatexSpanStyles {
517527
return other is KatexSpanStyles &&
518528
other.heightEm == heightEm &&
519529
other.verticalAlignEm == verticalAlignEm &&
530+
other.topEm == topEm &&
520531
other.marginRightEm == marginRightEm &&
521532
other.marginLeftEm == marginLeftEm &&
522533
other.fontFamily == fontFamily &&
@@ -531,6 +542,7 @@ class KatexSpanStyles {
531542
final args = <String>[];
532543
if (heightEm != null) args.add('heightEm: $heightEm');
533544
if (verticalAlignEm != null) args.add('verticalAlignEm: $verticalAlignEm');
545+
if (topEm != null) args.add('topEm: $topEm');
534546
if (marginRightEm != null) args.add('marginRightEm: $marginRightEm');
535547
if (marginLeftEm != null) args.add('marginLeftEm: $marginLeftEm');
536548
if (fontFamily != null) args.add('fontFamily: $fontFamily');
@@ -545,6 +557,7 @@ class KatexSpanStyles {
545557
return KatexSpanStyles(
546558
heightEm: other.heightEm ?? heightEm,
547559
verticalAlignEm: other.verticalAlignEm ?? verticalAlignEm,
560+
topEm: other.topEm ?? topEm,
548561
marginRightEm: other.marginRightEm ?? marginRightEm,
549562
marginLeftEm: other.marginLeftEm ?? marginLeftEm,
550563
fontFamily: other.fontFamily ?? fontFamily,

lib/widgets/content.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -992,6 +992,9 @@ class _KatexSpan extends StatelessWidget {
992992
height: styles.heightEm != null
993993
? styles.heightEm! * em
994994
: null,
995+
transform: styles.topEm != null
996+
? Matrix4.translationValues(0, styles.topEm! * em, 0)
997+
: null,
995998
child: widget,
996999
);
9971000
}

0 commit comments

Comments
 (0)