@@ -411,6 +411,7 @@ class _KatexParser {
411411 KatexSpanFontWeight ? fontWeight;
412412 KatexSpanFontStyle ? fontStyle;
413413 KatexSpanTextAlign ? textAlign;
414+ KatexBorderStyle ? borderStyle;
414415 var index = 0 ;
415416 while (index < spanClasses.length) {
416417 final spanClass = spanClasses[index++ ];
@@ -626,6 +627,32 @@ class _KatexParser {
626627 case 'nobreak' :
627628 case 'allowbreak' :
628629 case 'mathdefault' :
630+ case 'tag' :
631+ case 'eqn-num' :
632+ case 'mtable' :
633+ case 'col-align-l' :
634+ case 'col-align-c' :
635+ case 'col-align-r' :
636+ case 'delimcenter' :
637+ case 'accent' :
638+ case 'accent-body' :
639+ case 'vlist' :
640+ case 'vlist-r' :
641+ case 'vlist-s' :
642+ case 'svg-align' :
643+ case 'hide-tail' :
644+ case 'halfarrow-left' :
645+ case 'halfarrow-right' :
646+ case 'brace-left' :
647+ case 'brace-center' :
648+ case 'brace-right' :
649+ case 'root' :
650+ case 'sqrt' :
651+ case 'pstrut' :
652+ case 'arraycolsep' :
653+ case 'vertical-separator' :
654+ case 'frac-line' :
655+ case 'mfrac' :
629656 // Ignore these classes because they don't have a CSS definition
630657 // in katex.scss, but we encounter them in the generated HTML.
631658 // (Why are they there if they're not used? The story seems to be:
@@ -636,6 +663,24 @@ class _KatexParser {
636663 // )
637664 break ;
638665
666+ case 'overline' :
667+ case 'underline' :
668+ break ;
669+
670+ case 'overline-line' :
671+ borderStyle = KatexBorderStyle (
672+ position: KatexBorderPosition .bottom,
673+ widthEm: 0.04 ,
674+ );
675+ break ;
676+
677+ case 'underline-line' :
678+ borderStyle = KatexBorderStyle (
679+ position: KatexBorderPosition .bottom,
680+ widthEm: 0.04 ,
681+ );
682+ break ;
683+
639684 default :
640685 assert (debugLog ('KaTeX: Unsupported CSS class: $spanClass ' ));
641686 unsupportedCssClasses.add (spanClass);
@@ -644,6 +689,18 @@ class _KatexParser {
644689 }
645690
646691 final inlineStyles = _parseInlineStyles (element);
692+ // Extract border width if borderStyle was set
693+ if (borderStyle != null ) {
694+ if (inlineStyles != null ) {
695+ final borderWidthEm = _takeStyleEm (inlineStyles, 'border-bottom-width' );
696+ if (borderWidthEm != null ) {
697+ borderStyle = KatexBorderStyle (
698+ position: borderStyle.position,
699+ widthEm: borderWidthEm,
700+ color: borderStyle.color,
701+ );
702+ }}
703+ }
647704 final styles = KatexSpanStyles (
648705 widthEm: widthEm,
649706 fontFamily: fontFamily,
@@ -657,17 +714,19 @@ class _KatexParser {
657714 marginRightEm: _takeStyleEm (inlineStyles, 'margin-right' ),
658715 color: _takeStyleColor (inlineStyles, 'color' ),
659716 position: _takeStylePosition (inlineStyles, 'position' ),
717+ borderStyle: borderStyle,
660718 // TODO handle more CSS properties
661719 );
662720 if (inlineStyles != null && inlineStyles.isNotEmpty) {
663721 for (final property in inlineStyles.keys) {
722+ // Ignore known properties that don't need special handling
723+ if (property == 'width' || property == 'min-width' || property == 'border-bottom-width' ) {continue ;}
664724 assert (debugLog ('KaTeX: Unexpected inline CSS property: $property ' ));
665725 unsupportedInlineCssProperties.add (property);
666726 _hasError = true ;
667727 }
668728 }
669729 if (styles.topEm != null && styles.position != KatexSpanPosition .relative) {
670- // The meaning of `top` would be different without `position: relative`.
671730 throw _KatexHtmlParseError (
672731 'unsupported inline CSS property "top" given "position: ${styles .position }"' );
673732 }
@@ -840,6 +899,39 @@ enum KatexSpanPosition {
840899 relative,
841900}
842901
902+ enum KatexBorderPosition {
903+ top,
904+ bottom,
905+ }
906+
907+ class KatexBorderStyle {
908+ const KatexBorderStyle ({
909+ required this .position,
910+ required this .widthEm,
911+ this .color,
912+ });
913+
914+ final KatexBorderPosition position;
915+ final double widthEm;
916+ final KatexSpanColor ? color;
917+
918+ @override
919+ bool operator == (Object other) {
920+ return other is KatexBorderStyle &&
921+ other.position == position &&
922+ other.widthEm == widthEm &&
923+ other.color == color;
924+ }
925+
926+ @override
927+ int get hashCode => Object .hash ('KatexBorderStyle' , position, widthEm, color);
928+
929+ @override
930+ String toString () {
931+ return '${objectRuntimeType (this , 'KatexBorderStyle' )}($position , $widthEm , $color )' ;
932+ }
933+ }
934+
843935class KatexSpanColor {
844936 const KatexSpanColor (this .r, this .g, this .b, this .a);
845937
@@ -893,6 +985,7 @@ class KatexSpanStyles {
893985
894986 final KatexSpanColor ? color;
895987 final KatexSpanPosition ? position;
988+ final KatexBorderStyle ? borderStyle;
896989
897990 const KatexSpanStyles ({
898991 this .widthEm,
@@ -907,6 +1000,7 @@ class KatexSpanStyles {
9071000 this .textAlign,
9081001 this .color,
9091002 this .position,
1003+ this .borderStyle,
9101004 });
9111005
9121006 @override
@@ -924,6 +1018,7 @@ class KatexSpanStyles {
9241018 textAlign,
9251019 color,
9261020 position,
1021+ borderStyle,
9271022 );
9281023
9291024 @override
@@ -940,7 +1035,8 @@ class KatexSpanStyles {
9401035 other.fontStyle == fontStyle &&
9411036 other.textAlign == textAlign &&
9421037 other.color == color &&
943- other.position == position;
1038+ other.position == position &&
1039+ other.borderStyle == borderStyle;
9441040 }
9451041
9461042 @override
@@ -958,6 +1054,7 @@ class KatexSpanStyles {
9581054 if (textAlign != null ) args.add ('textAlign: $textAlign ' );
9591055 if (color != null ) args.add ('color: $color ' );
9601056 if (position != null ) args.add ('position: $position ' );
1057+ if (borderStyle != null ) args.add ('borderStyle: $borderStyle ' );
9611058 return '${objectRuntimeType (this , 'KatexSpanStyles' )}(${args .join (', ' )})' ;
9621059 }
9631060
@@ -975,6 +1072,7 @@ class KatexSpanStyles {
9751072 bool textAlign = true ,
9761073 bool color = true ,
9771074 bool position = true ,
1075+ bool borderStyle = true ,
9781076 }) {
9791077 return KatexSpanStyles (
9801078 widthEm: widthEm ? this .widthEm : null ,
@@ -989,6 +1087,7 @@ class KatexSpanStyles {
9891087 textAlign: textAlign ? this .textAlign : null ,
9901088 color: color ? this .color : null ,
9911089 position: position ? this .position : null ,
1090+ borderStyle: borderStyle ? this .borderStyle : null ,
9921091 );
9931092 }
9941093}
0 commit comments