顾海波

【修复】markdown渲染问题

... ... @@ -108,10 +108,16 @@ class GptMarkdown extends StatelessWidget {
@override
Widget build(BuildContext context) {
String tex = data.trim();
// print("texBefore:\n:$tex");
//去除 $$前面的空格 会导致渲染出错
tex = tex.replaceAllMapped(
RegExp(r"(?<!\\)\$\$(.*?)(?<!\\)\$\$", dotAll: true),
(match) => "\\[${match[1] ?? ""}\\]",
RegExp(r"(?<!\\)\s*\$\$(.*?)(?<!\\)\$\$", dotAll: true),
(match) => "\n\\[${match[1] ?? ""}\\]",
);
// print("texAfter:\n:$tex");
if (!tex.contains(r"\(")) {
tex = tex.replaceAllMapped(
RegExp(r"(?<!\\)\$(.*?)(?<!\\)\$"),
... ...