saminsohag

added useDollerSignForLatex

  1 +## 1.0.18
  2 +
  3 +* dollarSignForLatex is added and by default it is false.
  4 +
1 ## 1.0.17 5 ## 1.0.17
2 6
3 * Bloc components rendering inside table. 7 * Bloc components rendering inside table.
@@ -317,6 +317,7 @@ This document was created to test the robustness of Markdown parsers and to ensu @@ -317,6 +317,7 @@ This document was created to test the robustness of Markdown parsers and to ensu
317 317
318 bool writingMod = true; 318 bool writingMod = true;
319 bool selectable = false; 319 bool selectable = false;
  320 + bool useDollarSignsForLatex = false;
320 321
321 @override 322 @override
322 Widget build(BuildContext context) { 323 Widget build(BuildContext context) {
@@ -331,6 +332,22 @@ This document was created to test the robustness of Markdown parsers and to ensu @@ -331,6 +332,22 @@ This document was created to test the robustness of Markdown parsers and to ensu
331 IconButton( 332 IconButton(
332 onPressed: () { 333 onPressed: () {
333 setState(() { 334 setState(() {
  335 + useDollarSignsForLatex = !useDollarSignsForLatex;
  336 + });
  337 + },
  338 + icon: Icon(
  339 + Icons.monetization_on_outlined,
  340 + color: useDollarSignsForLatex
  341 + ? Theme.of(context).colorScheme.onSurfaceVariant
  342 + : Theme.of(context)
  343 + .colorScheme
  344 + .onSurface
  345 + .withValues(alpha: 0.38),
  346 + ),
  347 + ),
  348 + IconButton(
  349 + onPressed: () {
  350 + setState(() {
334 selectable = !selectable; 351 selectable = !selectable;
335 }); 352 });
336 }, 353 },
@@ -421,6 +438,8 @@ This document was created to test the robustness of Markdown parsers and to ensu @@ -421,6 +438,8 @@ This document was created to test the robustness of Markdown parsers and to ensu
421 debugPrint(url); 438 debugPrint(url);
422 debugPrint(title); 439 debugPrint(title);
423 }, 440 },
  441 + useDollarSignsForLatex:
  442 + useDollarSignsForLatex,
424 textAlign: TextAlign.justify, 443 textAlign: TextAlign.justify,
425 textScaler: const TextScaler.linear(1), 444 textScaler: const TextScaler.linear(1),
426 style: const TextStyle( 445 style: const TextStyle(
@@ -42,6 +42,7 @@ class GptMarkdown extends StatelessWidget { @@ -42,6 +42,7 @@ class GptMarkdown extends StatelessWidget {
42 this.unOrderedListBuilder, 42 this.unOrderedListBuilder,
43 this.components, 43 this.components,
44 this.inlineComponents, 44 this.inlineComponents,
  45 + this.useDollarSignsForLatex = false,
45 }); 46 });
46 47
47 /// The direction of the text. 48 /// The direction of the text.
@@ -96,6 +97,9 @@ class GptMarkdown extends StatelessWidget { @@ -96,6 +97,9 @@ class GptMarkdown extends StatelessWidget {
96 /// The unordered list builder. 97 /// The unordered list builder.
97 final UnOrderedListBuilder? unOrderedListBuilder; 98 final UnOrderedListBuilder? unOrderedListBuilder;
98 99
  100 + /// Whether to use dollar signs for LaTeX.
  101 + final bool useDollarSignsForLatex;
  102 +
99 /// The list of components. 103 /// The list of components.
100 /// ```dart 104 /// ```dart
101 /// List<MarkdownComponent> components = [ 105 /// List<MarkdownComponent> components = [
@@ -154,6 +158,7 @@ class GptMarkdown extends StatelessWidget { @@ -154,6 +158,7 @@ class GptMarkdown extends StatelessWidget {
154 @override 158 @override
155 Widget build(BuildContext context) { 159 Widget build(BuildContext context) {
156 String tex = data.trim(); 160 String tex = data.trim();
  161 + if (useDollarSignsForLatex) {
157 tex = tex.replaceAllMapped( 162 tex = tex.replaceAllMapped(
158 RegExp(r"(?<!\\)\$\$(.*?)(?<!\\)\$\$", dotAll: true), 163 RegExp(r"(?<!\\)\$\$(.*?)(?<!\\)\$\$", dotAll: true),
159 (match) => "\\[${match[1] ?? ""}\\]", 164 (match) => "\\[${match[1] ?? ""}\\]",
@@ -170,6 +175,7 @@ class GptMarkdown extends StatelessWidget { @@ -170,6 +175,7 @@ class GptMarkdown extends StatelessWidget {
170 }, 175 },
171 ); 176 );
172 } 177 }
  178 + }
173 // tex = _removeExtraLinesInsideBlockLatex(tex); 179 // tex = _removeExtraLinesInsideBlockLatex(tex);
174 return ClipRRect( 180 return ClipRRect(
175 child: MdWidget( 181 child: MdWidget(
1 name: gpt_markdown 1 name: gpt_markdown
2 description: "Powerful Markdown & LaTeX Renderer for Flutter: Rich Text, Math, Tables, Links, and Text Selection. Ideal for ChatGPT, Gemini, and more." 2 description: "Powerful Markdown & LaTeX Renderer for Flutter: Rich Text, Math, Tables, Links, and Text Selection. Ideal for ChatGPT, Gemini, and more."
3 -version: 1.0.17 3 +version: 1.0.18
4 homepage: https://github.com/Infinitix-LLC/gpt_markdown 4 homepage: https://github.com/Infinitix-LLC/gpt_markdown
5 5
6 environment: 6 environment: