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-02-09 14:46:25 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8c6aa7ac70bcef499d7768558d866442f7a7b5ab
8c6aa7ac
1 parent
70b6fdf9
fixed block syntax and 24064..24064 syntax works by default
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
12 deletions
lib/gpt_markdown.dart
lib/gpt_markdown.dart
View file @
8c6aa7a
...
...
@@ -61,23 +61,33 @@ class GptMarkdown extends StatelessWidget {
final
Widget
Function
(
BuildContext
context
,
String
text
,
String
url
,
TextStyle
style
)?
linkBuilder
;
String
_removeExtraLinesInsideBlockLatex
(
String
text
)
{
return
text
.
replaceAllMapped
(
RegExp
(
r"\\\[(.*?)\\\]"
,
multiLine:
true
,
dotAll:
true
,
),
(
match
)
{
String
content
=
match
[
0
]
??
""
;
return
content
.
replaceAllMapped
(
RegExp
(
r"\n[\n\ ]+"
),
(
match
)
=>
"
\n
"
);
});
}
@override
Widget
build
(
BuildContext
context
)
{
String
tex
=
data
.
trim
();
tex
=
tex
.
replaceAllMapped
(
RegExp
(
r"(?<!\\)\$\$(.*?)(?<!\\)\$\$"
,
dotAll:
true
,
),
(
match
)
=>
"
\\
[
${match[1] ?? ""}
\\
]"
);
if
(!
tex
.
contains
(
r"\("
))
{
tex
=
tex
.
replaceAllMapped
(
RegExp
(
r"(?<!\\)\$\$(.*?)(?<!\\)\$\$"
,
dotAll:
true
,
),
(
match
)
=>
"
\\
[
${match[1] ?? ""}
\\
]"
)
.
replaceAllMapped
(
RegExp
(
r"(?<!\\)\$(.*?)(?<!\\)\$"
,
),
(
match
)
=>
"
\\
(
${match[1] ?? ""}
\\
)"
);
tex
=
tex
.
replaceAllMapped
(
RegExp
(
r"(?<!\\)\$(.*?)(?<!\\)\$"
,
),
(
match
)
=>
"
\\
(
${match[1] ?? ""}
\\
)"
);
tex
=
tex
.
splitMapJoin
(
RegExp
(
r"\[.*?\]|\(.*?\)"
),
onNonMatch:
(
p0
)
{
...
...
@@ -85,6 +95,7 @@ class GptMarkdown extends StatelessWidget {
},
);
}
tex
=
_removeExtraLinesInsideBlockLatex
(
tex
);
return
ClipRRect
(
child:
MdWidget
(
tex
,
...
...
Please
register
or
login
to post a comment