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-10-13 18:36:55 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
2390380a6bce7265c1ba8a3c5844db571f34de17
2390380a
1 parent
8a38e02a
source config added
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
55 additions
and
18 deletions
gpt_markdown/CHANGELOG.md
gpt_markdown/example/lib/main.dart
gpt_markdown/example/pubspec.lock
gpt_markdown/lib/custom_widgets/markdow_config.dart
gpt_markdown/lib/gpt_markdown.dart
gpt_markdown/lib/markdown_component.dart
gpt_markdown/pubspec.yaml
gpt_markdown/CHANGELOG.md
View file @
2390380
## 0.1.9
*
source config added.
## 0.1.8
*
unordered list bullet color fixed.
...
...
gpt_markdown/example/lib/main.dart
View file @
2390380
...
...
@@ -326,6 +326,24 @@ Markdown and LaTeX can be powerful tools for formatting text and mathematical ex
);
return child;
},
sourceTagBuilder:
(buildContext, string, textStyle) {
var value = int.tryParse(string);
value ??= -1;
value += 1;
return SizedBox(
height: 20,
width: 20,
child: Container(
decoration: BoxDecoration(
color: Colors.red,
borderRadius:
BorderRadius.circular(10),
),
child: Center(child: Text("
$value
")),
),
);
},
),
),
// child: const Text("Hello"),
...
...
gpt_markdown/example/pubspec.lock
View file @
2390380
...
...
@@ -190,7 +190,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.
8
"
version: "0.1.
9
"
http:
dependency: transitive
description:
...
...
gpt_markdown/lib/custom_widgets/markdow_config.dart
View file @
2390380
...
...
@@ -11,6 +11,7 @@ class GptMarkdownConfig {
this
.
latexBuilder
,
this
.
followLinkColor
=
false
,
this
.
codeBuilder
,
this
.
sourceTagBuilder
,
this
.
maxLines
,
this
.
overflow
,
});
...
...
@@ -23,11 +24,15 @@ class GptMarkdownConfig {
final
Widget
Function
(
BuildContext
context
,
String
tex
,
TextStyle
textStyle
,
bool
inline
)?
latexBuilder
;
final
Widget
Function
(
BuildContext
context
,
String
content
,
TextStyle
textStyle
)?
sourceTagBuilder
;
final
bool
followLinkColor
;
final
Widget
Function
(
BuildContext
context
,
String
name
,
String
code
)?
codeBuilder
;
final
int
?
maxLines
;
final
TextOverflow
?
overflow
;
GptMarkdownConfig
copyWith
({
TextStyle
?
style
,
TextDirection
?
textDirection
,
...
...
@@ -38,6 +43,9 @@ class GptMarkdownConfig {
final
Widget
Function
(
BuildContext
context
,
String
tex
,
TextStyle
textStyle
,
bool
inline
)?
latexBuilder
,
final
Widget
Function
(
BuildContext
context
,
String
content
,
TextStyle
textStyle
)?
sourceTagBuilder
,
bool
?
followLinkColor
,
final
Widget
Function
(
BuildContext
context
,
String
name
,
String
code
)?
codeBuilder
,
...
...
@@ -54,6 +62,7 @@ class GptMarkdownConfig {
latexBuilder:
latexBuilder
??
this
.
latexBuilder
,
followLinkColor:
followLinkColor
??
this
.
followLinkColor
,
codeBuilder:
codeBuilder
??
this
.
codeBuilder
,
sourceTagBuilder:
sourceTagBuilder
??
this
.
sourceTagBuilder
,
maxLines:
maxLines
??
this
.
maxLines
,
overflow:
overflow
??
this
.
overflow
,
);
...
...
gpt_markdown/lib/gpt_markdown.dart
View file @
2390380
...
...
@@ -19,6 +19,7 @@ class TexMarkdown extends StatelessWidget {
this
.
onLinkTab
,
this
.
latexBuilder
,
this
.
codeBuilder
,
this
.
sourceTagBuilder
,
this
.
maxLines
,
this
.
overflow
,
});
...
...
@@ -37,6 +38,7 @@ class TexMarkdown extends StatelessWidget {
final
bool
followLinkColor
;
final
Widget
Function
(
BuildContext
context
,
String
name
,
String
code
)?
codeBuilder
;
final
Widget
Function
(
BuildContext
,
String
,
TextStyle
)?
sourceTagBuilder
;
@override
Widget
build
(
BuildContext
context
)
{
...
...
@@ -76,6 +78,7 @@ class TexMarkdown extends StatelessWidget {
codeBuilder:
codeBuilder
,
maxLines:
maxLines
,
overflow:
overflow
,
sourceTagBuilder:
sourceTagBuilder
,
),
));
}
...
...
gpt_markdown/lib/markdown_component.dart
View file @
2390380
...
...
@@ -618,7 +618,7 @@ class ItalicMd extends InlineMd {
/// source text component
class
SourceTag
extends
InlineMd
{
@override
RegExp
get
exp
=>
RegExp
(
r"\[(\d+?)\]"
);
RegExp
get
exp
=>
RegExp
(
r"
(?:【.*?)?
\[(\d+?)\]"
);
@override
InlineSpan
span
(
...
...
@@ -627,7 +627,8 @@ class SourceTag extends InlineMd {
final
GptMarkdownConfig
config
,
)
{
var
match
=
exp
.
firstMatch
(
text
.
trim
());
if
(
match
?[
1
]
==
null
)
{
var
content
=
match
?[
1
];
if
(
content
==
null
)
{
return
const
TextSpan
();
}
return
WidgetSpan
(
...
...
@@ -635,22 +636,24 @@ class SourceTag extends InlineMd {
// baseline: TextBaseline.alphabetic,
child:
Padding
(
padding:
const
EdgeInsets
.
all
(
2
),
child:
SizedBox
(
width:
20
,
height:
20
,
child:
Material
(
color:
Theme
.
of
(
context
).
colorScheme
.
onInverseSurface
,
shape:
const
OvalBorder
(),
child:
FittedBox
(
fit:
BoxFit
.
scaleDown
,
child:
Text
(
"
${match?[1]}
"
,
// style: (style ?? const TextStyle()).copyWith(),
textDirection:
config
.
textDirection
,
child:
config
.
sourceTagBuilder
?.
call
(
context
,
content
,
const
TextStyle
())
??
SizedBox
(
width:
20
,
height:
20
,
child:
Material
(
color:
Theme
.
of
(
context
).
colorScheme
.
onInverseSurface
,
shape:
const
OvalBorder
(),
child:
FittedBox
(
fit:
BoxFit
.
scaleDown
,
child:
Text
(
content
,
// style: (style ?? const TextStyle()).copyWith(),
textDirection:
config
.
textDirection
,
),
),
),
),
),
),
),
);
}
...
...
gpt_markdown/pubspec.yaml
View file @
2390380
name
:
gpt_markdown
description
:
"
The
purpose
of
this
package
is
to
render
the
response
of
ChatGPT
into
a
Flutter
app."
version
:
0.1.
8
version
:
0.1.
9
homepage
:
https://github.com/saminsohag/flutter_packages/tree/main/gpt_markdown
environment
:
...
...
Please
register
or
login
to post a comment