saminsohag

fixed block syntax and 24064..24064 syntax works by default

... ... @@ -61,19 +61,29 @@ class GptMarkdown extends StatelessWidget {
final Widget Function(
BuildContext context, String text, String url, TextStyle style)?
linkBuilder;
String _removeExtraLinesInsideBlockLatex(String text) {
return text.replaceAllMapped(
RegExp(
r"\\\[(.*?)\\\]",
multiLine: true,
dotAll: true,
), (match) {
String content = match[0] ?? "";
return content.replaceAllMapped(RegExp(r"\n[\n\ ]+"), (match) => "\n");
});
}
@override
Widget build(BuildContext context) {
String tex = data.trim();
if (!tex.contains(r"\(")) {
tex = tex
.replaceAllMapped(
tex = tex.replaceAllMapped(
RegExp(
r"(?<!\\)\$\$(.*?)(?<!\\)\$\$",
dotAll: true,
),
(match) => "\\[${match[1] ?? ""}\\]")
.replaceAllMapped(
(match) => "\\[${match[1] ?? ""}\\]");
if (!tex.contains(r"\(")) {
tex = tex.replaceAllMapped(
RegExp(
r"(?<!\\)\$(.*?)(?<!\\)\$",
),
... ... @@ -85,6 +95,7 @@ class GptMarkdown extends StatelessWidget {
},
);
}
tex = _removeExtraLinesInsideBlockLatex(tex);
return ClipRRect(
child: MdWidget(
tex,
... ...