saminsohag

.$ syntex added with a gard condition for \(_\)

... ... @@ -161,7 +161,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
},
textAlign: TextAlign.justify,
// textScaler: const TextScaler.linear(1.3),
textScaleFactor: 1.7,
textScaleFactor: 1,
style: const TextStyle(
// Regular text font size here.
fontSize: 15,
... ...
... ... @@ -30,9 +30,29 @@ class TexMarkdown extends StatelessWidget {
@override
Widget build(BuildContext context) {
String tex = data.trim();
if (!tex.contains(r"\(")) {
tex = tex
.replaceAllMapped(
RegExp(
r"(?<!\\)\$\$(.*?)(?<!\\)\$\$",
),
(match) => "\\[${match[1] ?? ""}\\]")
.replaceAllMapped(
RegExp(
r"(?<!\\)\$(.*?)(?<!\\)\$",
),
(match) => "\\(${match[1] ?? ""}\\)");
tex = tex.splitMapJoin(
RegExp(r"\[.*?\]|\(.*?\)"),
onNonMatch: (p0) {
return p0.replaceAll("\\\$", "\$");
},
);
}
return ClipRRect(
child: MdWidget(
data.trim(),
tex,
textDirection: textDirection,
style: style,
onLinkTab: onLinkTab,
... ...