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-06-24 18:07:44 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
82c4aba33bbca0dd167cb6b0af495e4387086d35
82c4aba3
1 parent
0b5ae854
change onLinkTab to onLinkTap
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
58 deletions
CHANGELOG.md
example/lib/main.dart
lib/custom_widgets/markdown_config.dart
lib/gpt_markdown.dart
lib/markdown_component.dart
pubspec.yaml
CHANGELOG.md
View file @
82c4aba
## 1.1.0
*
Changed
`onLinkTab` to `onLinkTap`
fixed issues of newLine issues.
## 1.0.20
*
Fix: support balanced parentheses in image and link URLs.
[
#68
](
https://github.com/Infinitix-LLC/gpt_markdown/pull/68
)
...
...
example/lib/main.dart
View file @
82c4aba
...
...
@@ -76,6 +76,10 @@ class _MyHomePageState extends State<MyHomePage> {
TextDirection
_direction
=
TextDirection
.
ltr
;
final
TextEditingController
_controller
=
TextEditingController
(
text:
r''
'
decsiob (*) is on the set PQ = {91, 905} jjjzjsx * jjdbhsjsjmamajmsghdhhi msnnsjnskaksjjshahsh
(*)
This is a sample markdown document.
* **bold**
...
...
@@ -444,7 +448,7 @@ This document was created to test the robustness of Markdown parsers and to ensu
Widget
child
=
GptMarkdown
(
_controller
.
text
,
textDirection:
_direction
,
onLinkTa
b
:
(
url
,
title
)
{
onLinkTa
p
:
(
url
,
title
)
{
debugPrint
(
url
);
debugPrint
(
title
);
},
...
...
@@ -615,40 +619,40 @@ This document was created to test the robustness of Markdown parsers and to ensu
),
);
},
components: [
CodeBlockMd(),
NewLines(),
BlockQuote(),
ImageMd(),
ATagMd(),
TableMd(),
HTag(),
UnOrderedList(),
OrderedList(),
RadioButtonMd(),
CheckBoxMd(),
HrLine(),
StrikeMd(),
BoldMd(),
ItalicMd(),
LatexMath(),
LatexMathMultiLine(),
HighlightedText(),
SourceTag(),
IndentMd(),
],
inlineComponents: [
ImageMd(),
ATagMd(),
TableMd(),
StrikeMd(),
BoldMd(),
ItalicMd(),
LatexMath(),
LatexMathMultiLine(),
HighlightedText(),
SourceTag(),
],
// components: [
// CodeBlockMd(),
// NewLines(),
// BlockQuote(),
// ImageMd(),
// ATagMd(),
// TableMd(),
// HTag(),
// UnOrderedList(),
// OrderedList(),
// RadioButtonMd(),
// CheckBoxMd(),
// HrLine(),
// StrikeMd(),
// BoldMd(),
// ItalicMd(),
// LatexMath(),
// LatexMathMultiLine(),
// HighlightedText(),
// SourceTag(),
// IndentMd(),
// ],
// inlineComponents: [
// ImageMd(),
// ATagMd(),
// TableMd(),
// StrikeMd(),
// BoldMd(),
// ItalicMd(),
// LatexMath(),
// LatexMathMultiLine(),
// HighlightedText(),
// SourceTag(),
// ],
// codeBuilder: (context, name, code, closed) {
// return Padding(
// padding: const EdgeInsets.symmetric(
...
...
lib/custom_widgets/markdown_config.dart
View file @
82c4aba
...
...
@@ -61,12 +61,12 @@ typedef ImageBuilder = Widget Function(BuildContext context, String imageUrl);
/// The [GptMarkdownConfig] class is used to configure the GPT Markdown component.
/// It takes a [style] parameter to set the style of the text,
/// a [textDirection] parameter to set the direction of the text,
/// and an optional [onLinkTa
b
] parameter to handle link clicks.
/// and an optional [onLinkTa
p
] parameter to handle link clicks.
class
GptMarkdownConfig
{
const
GptMarkdownConfig
({
this
.
style
,
this
.
textDirection
=
TextDirection
.
ltr
,
this
.
onLinkTa
b
,
this
.
onLinkTa
p
,
this
.
textAlign
,
this
.
textScaler
,
this
.
latexWorkaround
,
...
...
@@ -98,7 +98,7 @@ class GptMarkdownConfig {
final
TextScaler
?
textScaler
;
/// The callback function to handle link clicks.
final
void
Function
(
String
url
,
String
title
)?
onLinkTa
b
;
final
void
Function
(
String
url
,
String
title
)?
onLinkTa
p
;
/// The LaTeX workaround.
final
String
Function
(
String
tex
)?
latexWorkaround
;
...
...
@@ -146,7 +146,7 @@ class GptMarkdownConfig {
GptMarkdownConfig
copyWith
({
TextStyle
?
style
,
TextDirection
?
textDirection
,
final
void
Function
(
String
url
,
String
title
)?
onLinkTa
b
,
final
void
Function
(
String
url
,
String
title
)?
onLinkTa
p
,
final
TextAlign
?
textAlign
,
final
TextScaler
?
textScaler
,
final
String
Function
(
String
tex
)?
latexWorkaround
,
...
...
@@ -167,7 +167,7 @@ class GptMarkdownConfig {
return
GptMarkdownConfig
(
style:
style
??
this
.
style
,
textDirection:
textDirection
??
this
.
textDirection
,
onLinkTa
b:
onLinkTab
??
this
.
onLinkTab
,
onLinkTa
p:
onLinkTap
??
this
.
onLinkTap
,
textAlign:
textAlign
??
this
.
textAlign
,
textScaler:
textScaler
??
this
.
textScaler
,
latexWorkaround:
latexWorkaround
??
this
.
latexWorkaround
,
...
...
@@ -218,7 +218,7 @@ class GptMarkdownConfig {
// linkBuilder == other.linkBuilder &&
// imageBuilder == other.imageBuilder &&
// highlightBuilder == other.highlightBuilder &&
// onLinkTa
b == other.onLinkTab
&&
// onLinkTa
p == other.onLinkTap
&&
textDirection
==
other
.
textDirection
;
}
}
...
...
lib/gpt_markdown.dart
View file @
82c4aba
...
...
@@ -30,7 +30,7 @@ class GptMarkdown extends StatelessWidget {
this
.
textAlign
,
this
.
imageBuilder
,
this
.
textScaler
,
this
.
onLinkTa
b
,
this
.
onLinkTa
p
,
this
.
latexBuilder
,
this
.
codeBuilder
,
this
.
sourceTagBuilder
,
...
...
@@ -61,7 +61,7 @@ class GptMarkdown extends StatelessWidget {
final
TextScaler
?
textScaler
;
/// The callback function to handle link clicks.
final
void
Function
(
String
url
,
String
title
)?
onLinkTa
b
;
final
void
Function
(
String
url
,
String
title
)?
onLinkTa
p
;
/// The LaTeX workaround.
final
String
Function
(
String
tex
)?
latexWorkaround
;
...
...
@@ -185,7 +185,7 @@ class GptMarkdown extends StatelessWidget {
config:
GptMarkdownConfig
(
textDirection:
textDirection
,
style:
style
,
onLinkTa
b:
onLinkTab
,
onLinkTa
p:
onLinkTap
,
textAlign:
textAlign
,
textScaler:
textScaler
,
followLinkColor:
followLinkColor
,
...
...
lib/markdown_component.dart
View file @
82c4aba
...
...
@@ -2,12 +2,11 @@ part of 'gpt_markdown.dart';
/// Markdown components
abstract
class
MarkdownComponent
{
static
final
List
<
MarkdownComponent
>
components
=
[
static
List
<
MarkdownComponent
>
get
globalComponents
=>
[
CodeBlockMd
(),
LatexMathMultiLine
(),
NewLines
(),
BlockQuote
(),
ImageMd
(),
ATagMd
(),
TableMd
(),
HTag
(),
UnOrderedList
(),
...
...
@@ -15,13 +14,6 @@ abstract class MarkdownComponent {
RadioButtonMd
(),
CheckBoxMd
(),
HrLine
(),
StrikeMd
(),
BoldMd
(),
ItalicMd
(),
LatexMath
(),
LatexMathMultiLine
(),
HighlightedText
(),
SourceTag
(),
IndentMd
(),
];
...
...
@@ -47,7 +39,7 @@ abstract class MarkdownComponent {
)
{
var
components
=
includeGlobalComponents
?
config
.
components
??
MarkdownComponent
.
c
omponents
?
config
.
components
??
MarkdownComponent
.
globalC
omponents
:
config
.
inlineComponents
??
MarkdownComponent
.
inlineComponents
;
List
<
InlineSpan
>
spans
=
[];
Iterable
<
String
>
regexes
=
components
.
map
<
String
>((
e
)
=>
e
.
exp
.
pattern
);
...
...
@@ -75,6 +67,14 @@ abstract class MarkdownComponent {
return
""
;
},
onNonMatch:
(
p0
)
{
if
(
p0
.
isEmpty
)
{
return
""
;
}
if
(
includeGlobalComponents
)
{
var
newSpans
=
generate
(
context
,
p0
,
config
.
copyWith
(),
false
);
spans
.
addAll
(
newSpans
);
return
""
;
}
spans
.
add
(
TextSpan
(
text:
p0
,
style:
config
.
style
));
return
""
;
},
...
...
@@ -830,7 +830,7 @@ class ATagMd extends InlineMd {
if
(
builder
!=
null
)
{
return
WidgetSpan
(
child:
GestureDetector
(
onTap:
()
=>
config
.
onLinkTa
b
?.
call
(
url
,
linkText
),
onTap:
()
=>
config
.
onLinkTa
p
?.
call
(
url
,
linkText
),
child:
builder
(
context
,
linkText
,
...
...
@@ -848,7 +848,7 @@ class ATagMd extends InlineMd {
hoverColor:
theme
.
linkHoverColor
,
color:
theme
.
linkColor
,
onPressed:
()
{
config
.
onLinkTa
b
?.
call
(
url
,
linkText
);
config
.
onLinkTa
p
?.
call
(
url
,
linkText
);
},
text:
linkText
,
config:
config
,
...
...
pubspec.yaml
View file @
82c4aba
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.2
0
version
:
1.
1.
0
homepage
:
https://github.com/Infinitix-LLC/gpt_markdown
environment
:
...
...
Please
register
or
login
to post a comment