saminsohag

added useDollerSignForLatex

## 1.0.18
* dollarSignForLatex is added and by default it is false.
## 1.0.17
* Bloc components rendering inside table.
... ...
... ... @@ -317,6 +317,7 @@ This document was created to test the robustness of Markdown parsers and to ensu
bool writingMod = true;
bool selectable = false;
bool useDollarSignsForLatex = false;
@override
Widget build(BuildContext context) {
... ... @@ -331,6 +332,22 @@ This document was created to test the robustness of Markdown parsers and to ensu
IconButton(
onPressed: () {
setState(() {
useDollarSignsForLatex = !useDollarSignsForLatex;
});
},
icon: Icon(
Icons.monetization_on_outlined,
color: useDollarSignsForLatex
? Theme.of(context).colorScheme.onSurfaceVariant
: Theme.of(context)
.colorScheme
.onSurface
.withValues(alpha: 0.38),
),
),
IconButton(
onPressed: () {
setState(() {
selectable = !selectable;
});
},
... ... @@ -421,6 +438,8 @@ This document was created to test the robustness of Markdown parsers and to ensu
debugPrint(url);
debugPrint(title);
},
useDollarSignsForLatex:
useDollarSignsForLatex,
textAlign: TextAlign.justify,
textScaler: const TextScaler.linear(1),
style: const TextStyle(
... ...
... ... @@ -42,6 +42,7 @@ class GptMarkdown extends StatelessWidget {
this.unOrderedListBuilder,
this.components,
this.inlineComponents,
this.useDollarSignsForLatex = false,
});
/// The direction of the text.
... ... @@ -96,6 +97,9 @@ class GptMarkdown extends StatelessWidget {
/// The unordered list builder.
final UnOrderedListBuilder? unOrderedListBuilder;
/// Whether to use dollar signs for LaTeX.
final bool useDollarSignsForLatex;
/// The list of components.
/// ```dart
/// List<MarkdownComponent> components = [
... ... @@ -154,21 +158,23 @@ class GptMarkdown extends StatelessWidget {
@override
Widget build(BuildContext context) {
String tex = data.trim();
tex = tex.replaceAllMapped(
RegExp(r"(?<!\\)\$\$(.*?)(?<!\\)\$\$", dotAll: true),
(match) => "\\[${match[1] ?? ""}\\]",
);
if (!tex.contains(r"\(")) {
if (useDollarSignsForLatex) {
tex = tex.replaceAllMapped(
RegExp(r"(?<!\\)\$(.*?)(?<!\\)\$"),
(match) => "\\(${match[1] ?? ""}\\)",
);
tex = tex.splitMapJoin(
RegExp(r"\[.*?\]|\(.*?\)"),
onNonMatch: (p0) {
return p0.replaceAll("\\\$", "\$");
},
RegExp(r"(?<!\\)\$\$(.*?)(?<!\\)\$\$", dotAll: true),
(match) => "\\[${match[1] ?? ""}\\]",
);
if (!tex.contains(r"\(")) {
tex = tex.replaceAllMapped(
RegExp(r"(?<!\\)\$(.*?)(?<!\\)\$"),
(match) => "\\(${match[1] ?? ""}\\)",
);
tex = tex.splitMapJoin(
RegExp(r"\[.*?\]|\(.*?\)"),
onNonMatch: (p0) {
return p0.replaceAll("\\\$", "\$");
},
);
}
}
// tex = _removeExtraLinesInsideBlockLatex(tex);
return ClipRRect(
... ...
name: gpt_markdown
description: "Powerful Markdown & LaTeX Renderer for Flutter: Rich Text, Math, Tables, Links, and Text Selection. Ideal for ChatGPT, Gemini, and more."
version: 1.0.17
version: 1.0.18
homepage: https://github.com/Infinitix-LLC/gpt_markdown
environment:
... ...