saminsohag

underlined md added

@@ -451,9 +451,9 @@ This document was created to test the robustness of Markdown parsers and to ensu @@ -451,9 +451,9 @@ This document was created to test the robustness of Markdown parsers and to ensu
451 textAlign: TextAlign.justify, 451 textAlign: TextAlign.justify,
452 textScaler: const TextScaler.linear(1), 452 textScaler: const TextScaler.linear(1),
453 style: const TextStyle( 453 style: const TextStyle(
454 - fontFamily: 'monospace',  
455 - fontWeight: FontWeight.bold,  
456 - ), 454 + // fontFamily: 'monospace',
  455 + // fontWeight: FontWeight.bold,
  456 + ),
457 highlightBuilder: (context, text, style) { 457 highlightBuilder: (context, text, style) {
458 return Container( 458 return Container(
459 padding: const EdgeInsets.symmetric( 459 padding: const EdgeInsets.symmetric(
@@ -24,6 +24,7 @@ abstract class MarkdownComponent { @@ -24,6 +24,7 @@ abstract class MarkdownComponent {
24 StrikeMd(), 24 StrikeMd(),
25 BoldMd(), 25 BoldMd(),
26 ItalicMd(), 26 ItalicMd(),
  27 + UnderLineMd(),
27 LatexMath(), 28 LatexMath(),
28 LatexMathMultiLine(), 29 LatexMathMultiLine(),
29 HighlightedText(), 30 HighlightedText(),
@@ -1164,3 +1165,33 @@ class CodeBlockMd extends BlockMd { @@ -1164,3 +1165,33 @@ class CodeBlockMd extends BlockMd {
1164 CodeField(name: name, codes: codes); 1165 CodeField(name: name, codes: codes);
1165 } 1166 }
1166 } 1167 }
  1168 +
  1169 +class UnderLineMd extends InlineMd {
  1170 + @override
  1171 + RegExp get exp =>
  1172 + RegExp(r"<u>(.*?)(?:</u>|$)", multiLine: true, dotAll: true);
  1173 +
  1174 + @override
  1175 + InlineSpan span(
  1176 + BuildContext context,
  1177 + String text,
  1178 + final GptMarkdownConfig config,
  1179 + ) {
  1180 + var match = exp.firstMatch(text.trim());
  1181 + var conf = config.copyWith(
  1182 + style: (config.style ?? const TextStyle()).copyWith(
  1183 + decoration: TextDecoration.underline,
  1184 + decorationColor: config.style?.color,
  1185 + ),
  1186 + );
  1187 + return TextSpan(
  1188 + children: MarkdownComponent.generate(
  1189 + context,
  1190 + "${match?[1]}",
  1191 + conf,
  1192 + false,
  1193 + ),
  1194 + style: conf.style,
  1195 + );
  1196 + }
  1197 +}