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
2024-02-16 10:13:57 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
397e76430714c78d782fc9319bb0138bf459648b
397e7643
1 parent
39102613
Table heading color added
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
4 deletions
gpt_markdown/example/lib/main.dart
gpt_markdown/lib/md_widget.dart
gpt_markdown/example/lib/main.dart
View file @
397e764
...
...
@@ -122,8 +122,7 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
Column(
children: [
Expanded(
child: SingleChildScrollView(
child: Column(
child: ListView(
children: [
AnimatedBuilder(
animation: _controller,
...
...
@@ -172,6 +171,18 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
tex.replaceAllMapped(RegExp(r"align
\
*"),
(match) => "aligned"),
latexBuilder: (contex, tex) {
if (tex.contains(r"
\
begin{tabular}")) {
// return table.
String tableString = "|
${(RegExp(
r"^\\begin\{tabular\}
\
{.*?
\
}(.*?)
\\
end
\
{tabular
\
}
$
",
multiLine: true,
dotAll: true,
).firstMatch(tex)?[1] ?? "").trim()}|";
tableString = tableString
.replaceAll(r"
\\
", "|
\n
|")
.replaceAll("&", "|");
return TexMarkdown(tableString);
}
var controller = ScrollController();
return Column(
children: [
...
...
@@ -201,7 +212,6 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
],
),
),
),
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 200),
child: Padding(
...
...
gpt_markdown/lib/md_widget.dart
View file @
397e764
...
...
@@ -58,6 +58,8 @@ class MdWidget extends StatelessWidget {
.
asMap
(),
)
.
toList
();
bool
heading
=
RegExp
(
r"^\|.*?\|\n\|-[-\\ |]*?-\|\n"
).
hasMatch
(
eachLn
.
trim
());
int
maxCol
=
0
;
for
(
final
each
in
value
)
{
if
(
maxCol
<
each
.
keys
.
length
)
{
...
...
@@ -80,11 +82,23 @@ class MdWidget extends StatelessWidget {
color:
Theme
.
of
(
context
).
colorScheme
.
onSurface
,
),
children:
value
.
asMap
()
.
entries
.
map
<
TableRow
>(
(
e
)
=>
TableRow
(
(
entry
)
=>
TableRow
(
decoration:
(
heading
)
?
BoxDecoration
(
color:
(
entry
.
key
==
0
)
?
Theme
.
of
(
context
)
.
colorScheme
.
surfaceVariant
:
null
,
)
:
null
,
children:
List
.
generate
(
maxCol
,
(
index
)
{
var
e
=
entry
.
value
;
String
data
=
e
[
index
]
??
""
;
if
(
RegExp
(
r"^---+$"
).
hasMatch
(
data
.
trim
()))
{
return
const
SizedBox
();
...
...
Please
register
or
login
to post a comment