Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
gpt_markdown
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
saminsohag
2025-04-27 15:28:22 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
45fd08d61556656f90c02c630fcb04700749aaca
45fd08d6
1 parent
6109fe2f
added useDollerSignForLatex
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
14 deletions
CHANGELOG.md
example/lib/main.dart
lib/gpt_markdown.dart
pubspec.yaml
CHANGELOG.md
View file @
45fd08d
## 1.0.18
*
dollarSignForLatex is added and by default it is false.
## 1.0.17
*
Bloc components rendering inside table.
...
...
example/lib/main.dart
View file @
45fd08d
...
...
@@ -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
(
...
...
lib/gpt_markdown.dart
View file @
45fd08d
...
...
@@ -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
(
...
...
pubspec.yaml
View file @
45fd08d
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.1
7
version
:
1.0.1
8
homepage
:
https://github.com/Infinitix-LLC/gpt_markdown
environment
:
...
...
Please
register
or
login
to post a comment