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-03-18 17:34:43 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7b2cd2432334a682f0a78b5f97101bea881b6a04
7b2cd243
1 parent
63469c82
blockQuote fixed
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
10 deletions
CHANGELOG.md
README.md
example/lib/main.dart
lib/custom_widgets/indent_widget.dart
lib/custom_widgets/markdown_config.dart
lib/gpt_markdown.dart
lib/markdown_component.dart
CHANGELOG.md
View file @
7b2cd24
...
...
@@ -3,6 +3,8 @@
*
`IndentMd` and `BlockQuote`
fixed.
*
Baseline of bloc type component is fixed.
*
block quote support improved.
*
custom components support added.
*
`Table`
syntax improved.
## 1.0.15
...
...
README.md
View file @
7b2cd24
...
...
@@ -21,15 +21,16 @@ A comprehensive Flutter package for rendering rich Markdown and LaTeX content in
| ➖ Horizontal Line | ✅ | |
| 🔢 Latex Math | ✅ | |
| ↩️ Indent | ✅ |
| ↩️ BlockQuote | ✅ |
| 🖼️ Image | ✅ |
| ✨ Highlighted Text | ✅ |
| ✂️ Strike
d
Text | ✅ |
| ✂️ Strike Text | ✅ |
| 🔵 Bold Text | ✅ |
| 📜 Italic Text | ✅ |
| 🔗 Links | ✅ |
| 📱 Selectable | ✅ |
| 🧩 Custom components | ✅ | |
| 📎 Underline | | 🔜 |
| 🧩 Custom components | | 🔜 |
## ✨ Key Features
...
...
example/lib/main.dart
View file @
7b2cd24
...
...
@@ -586,6 +586,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(),
],
// codeBuilder: (context, name, code, closed) {
// return Padding(
// padding: const EdgeInsets.symmetric(
...
...
lib/custom_widgets/indent_widget.dart
View file @
7b2cd24
...
...
@@ -31,7 +31,7 @@ class BlockQuoteWidget extends StatelessWidget {
Widget
build
(
BuildContext
context
)
{
return
Row
(
children:
[
Expanded
(
Flexible
(
child:
CustomPaint
(
foregroundPainter:
BlockQuotePainter
(
color
,
direction
,
width
),
child:
child
,
...
...
lib/custom_widgets/markdown_config.dart
View file @
7b2cd24
import
'package:flutter/material.dart'
;
import
'package:gpt_markdown/gpt_markdown.dart'
;
/// A builder function for the ordered list.
typedef
OrderedListBuilder
=
...
...
@@ -80,6 +81,8 @@ class GptMarkdownConfig {
this
.
imageBuilder
,
this
.
maxLines
,
this
.
overflow
,
this
.
components
,
this
.
inlineComponents
,
});
/// The direction of the text.
...
...
@@ -133,6 +136,12 @@ class GptMarkdownConfig {
/// The image builder.
final
ImageBuilder
?
imageBuilder
;
/// The list of components.
final
List
<
MarkdownComponent
>?
components
;
/// The list of inline components.
final
List
<
MarkdownComponent
>?
inlineComponents
;
/// A copy of the configuration with the specified parameters.
GptMarkdownConfig
copyWith
({
TextStyle
?
style
,
...
...
@@ -152,6 +161,8 @@ class GptMarkdownConfig {
final
ImageBuilder
?
imageBuilder
,
final
OrderedListBuilder
?
orderedListBuilder
,
final
UnOrderedListBuilder
?
unOrderedListBuilder
,
final
List
<
MarkdownComponent
>?
components
,
final
List
<
MarkdownComponent
>?
inlineComponents
,
})
{
return
GptMarkdownConfig
(
style:
style
??
this
.
style
,
...
...
@@ -171,6 +182,8 @@ class GptMarkdownConfig {
imageBuilder:
imageBuilder
??
this
.
imageBuilder
,
orderedListBuilder:
orderedListBuilder
??
this
.
orderedListBuilder
,
unOrderedListBuilder:
unOrderedListBuilder
??
this
.
unOrderedListBuilder
,
components:
components
??
this
.
components
,
inlineComponents:
inlineComponents
??
this
.
inlineComponents
,
);
}
...
...
lib/gpt_markdown.dart
View file @
7b2cd24
...
...
@@ -40,6 +40,8 @@ class GptMarkdown extends StatelessWidget {
this
.
overflow
,
this
.
orderedListBuilder
,
this
.
unOrderedListBuilder
,
this
.
components
,
this
.
inlineComponents
,
});
/// The direction of the text.
...
...
@@ -94,6 +96,50 @@ class GptMarkdown extends StatelessWidget {
/// The unordered list builder.
final
UnOrderedListBuilder
?
unOrderedListBuilder
;
/// The list of components.
/// ```dart
/// List<MarkdownComponent> components = [
/// CodeBlockMd(),
/// NewLines(),
/// BlockQuote(),
/// ImageMd(),
/// ATagMd(),
/// TableMd(),
/// HTag(),
/// UnOrderedList(),
/// OrderedList(),
/// RadioButtonMd(),
/// CheckBoxMd(),
/// HrLine(),
/// StrikeMd(),
/// BoldMd(),
/// ItalicMd(),
/// LatexMath(),
/// LatexMathMultiLine(),
/// HighlightedText(),
/// SourceTag(),
/// IndentMd(),
/// ];
/// ```
final
List
<
MarkdownComponent
>?
components
;
/// The list of inline components.
/// ```dart
/// List<MarkdownComponent> inlineComponents = [
/// ImageMd(),
/// ATagMd(),
/// TableMd(),
/// StrikeMd(),
/// BoldMd(),
/// ItalicMd(),
/// LatexMath(),
/// LatexMathMultiLine(),
/// HighlightedText(),
/// SourceTag(),
/// ];
/// ```
final
List
<
MarkdownComponent
>?
inlineComponents
;
/// A method to remove extra lines inside block LaTeX.
// String _removeExtraLinesInsideBlockLatex(String text) {
// return text.replaceAllMapped(
...
...
@@ -147,6 +193,8 @@ class GptMarkdown extends StatelessWidget {
imageBuilder:
imageBuilder
,
orderedListBuilder:
orderedListBuilder
,
unOrderedListBuilder:
unOrderedListBuilder
,
components:
components
,
inlineComponents:
inlineComponents
,
),
),
);
...
...
lib/markdown_component.dart
View file @
7b2cd24
...
...
@@ -2,7 +2,7 @@ part of 'gpt_markdown.dart';
/// Markdown components
abstract
class
MarkdownComponent
{
static
List
<
MarkdownComponent
>
get
components
=>
[
static
final
List
<
MarkdownComponent
>
components
=
[
CodeBlockMd
(),
NewLines
(),
BlockQuote
(),
...
...
@@ -25,7 +25,7 @@ abstract class MarkdownComponent {
IndentMd
(),
];
static
List
<
MarkdownComponent
>
get
inlineComponents
=>
[
static
final
List
<
MarkdownComponent
>
inlineComponents
=
[
ImageMd
(),
ATagMd
(),
TableMd
(),
...
...
@@ -47,8 +47,8 @@ abstract class MarkdownComponent {
)
{
var
components
=
includeGlobalComponents
?
MarkdownComponent
.
components
:
MarkdownComponent
.
inlineComponents
;
?
config
.
components
??
MarkdownComponent
.
components
:
config
.
inlineComponents
??
MarkdownComponent
.
inlineComponents
;
List
<
InlineSpan
>
spans
=
[];
Iterable
<
String
>
regexes
=
components
.
map
<
String
>((
e
)
=>
e
.
exp
.
pattern
);
final
combinedRegex
=
RegExp
(
...
...
@@ -134,7 +134,7 @@ abstract class BlockMd extends MarkdownComponent {
child:
child
,
);
}
child
=
Row
(
children:
[
Expanded
(
child:
child
)]);
child
=
Row
(
children:
[
Flexible
(
child:
child
)]);
return
WidgetSpan
(
child:
child
,
alignment:
PlaceholderAlignment
.
baseline
,
...
...
@@ -165,7 +165,7 @@ class IndentMd extends BlockMd {
textDirection:
config
.
textDirection
,
child:
Row
(
children:
[
Expanded
(
Flexible
(
child:
config
.
getRich
(
TextSpan
(
children:
MarkdownComponent
.
generate
(
...
...
@@ -322,7 +322,11 @@ class BlockQuote extends InlineMd {
@override
RegExp
get
exp
=>
// RegExp(r"(?<=\n\n)(\ +)(.+?)(?=\n\n)", dotAll: true, multiLine: true);
RegExp
(
r"(?:(?:^|\n)\ *>[^\n]+)+"
,
dotAll:
true
,
multiLine:
true
);
RegExp
(
r"(?:(?:^)\ *>[^\n]+)(?:(?:\n)\ *>[^\n]+)*"
,
dotAll:
true
,
multiLine:
true
,
);
@override
InlineSpan
span
(
...
...
Please
register
or
login
to post a comment