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-01-08 15:13:06 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
07ae633389e015848fda432661a401583b8a0ecb
07ae6333
1 parent
c83a76b2
Fix latex
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
21 deletions
example/macos/Podfile.lock
lib/custom_widgets/unordered_ordered_list.dart
lib/markdown_component.dart
example/macos/Podfile.lock
View file @
07ae633
...
...
@@ -19,4 +19,4 @@ SPEC CHECKSUMS:
PODFILE CHECKSUM: 236401fc2c932af29a9fcf0e97baeeb2d750d367
COCOAPODS: 1.1
5
.2
COCOAPODS: 1.1
6
.2
...
...
lib/custom_widgets/unordered_ordered_list.dart
View file @
07ae633
...
...
@@ -63,7 +63,7 @@ class OrderedListView extends StatelessWidget {
const
OrderedListView
(
{
super
.
key
,
this
.
spacing
=
6
,
this
.
padding
=
10
,
this
.
padding
=
6
,
TextStyle
?
style
,
required
this
.
child
,
this
.
textDirection
=
TextDirection
.
ltr
,
...
...
lib/markdown_component.dart
View file @
07ae633
...
...
@@ -5,6 +5,8 @@ abstract class MarkdownComponent {
static
final
List
<
MarkdownComponent
>
components
=
[
CodeBlockMd
(),
NewLines
(),
// IndentMd(),
ImageMd
(),
TableMd
(),
HTag
(),
UnOrderedList
(),
...
...
@@ -13,7 +15,6 @@ abstract class MarkdownComponent {
CheckBoxMd
(),
HrLine
(),
LatexMathMultiLine
(),
IndentMd
(),
LatexMath
(),
ImageMd
(),
HighlightedText
(),
...
...
@@ -306,8 +307,11 @@ class RadioButtonMd extends BlockMd {
/// Indent
class
IndentMd
extends
InlineMd
{
@override
bool
get
inline
=>
false
;
@override
RegExp
get
exp
=>
RegExp
(
r"^(\ +)(((?!(\n\n|\n\ )).)+)$"
,
dotAll:
true
,
multiLine:
true
);
// RegExp(r"(?<=\n\n)(\ +)(.+?)(?=\n\n)", dotAll: true, multiLine: true);
RegExp
(
r"(?:\n\n+)^(\ *)(.+?)$(?:\n\n+)"
,
dotAll:
true
,
multiLine:
true
);
@override
InlineSpan
span
(
...
...
@@ -318,7 +322,8 @@ class IndentMd extends InlineMd {
var
match
=
exp
.
firstMatch
(
text
);
int
spaces
=
(
match
?[
1
]
??
""
).
length
;
var
data
=
"
${match?[2]}
"
.
trim
();
data
=
data
.
replaceAll
(
RegExp
(
r'\n\ {'
'
$spaces
'
'}'
),
'
\n
'
).
trim
();
// data = data.replaceAll(RegExp(r'\n\ {' '$spaces' '}'), '\n').trim();
data
=
data
.
trim
();
var
child
=
TextSpan
(
children:
MarkdownComponent
.
generate
(
context
,
...
...
@@ -326,19 +331,24 @@ class IndentMd extends InlineMd {
config
,
),
);
var
leftPadding
=
20.0
;
if
(
spaces
<
4
)
{
return
child
;
leftPadding
=
0
;
}
var
padding
=
config
.
style
?.
fontSize
??
16.0
;
return
TextSpan
(
children:
[
WidgetSpan
(
child:
Row
(
children:
[
const
SizedBox
(
width:
20
,
),
Expanded
(
child:
config
.
getRich
(
child
)),
],
child:
Padding
(
padding:
EdgeInsets
.
symmetric
(
vertical:
padding
),
child:
Row
(
children:
[
SizedBox
(
width:
leftPadding
,
),
Expanded
(
child:
config
.
getRich
(
child
)),
],
),
),
),
],
...
...
@@ -350,7 +360,6 @@ class IndentMd extends InlineMd {
class
UnOrderedList
extends
BlockMd
{
@override
String
get
expString
=>
(
r"(?:\-|\*)\ ([^\n]+)$"
);
get
onLinkTab
=>
null
;
@override
Widget
build
(
...
...
@@ -361,9 +370,10 @@ class UnOrderedList extends BlockMd {
var
match
=
this
.
exp
.
firstMatch
(
text
);
return
UnorderedListView
(
bulletColor:
config
.
style
?.
color
??
DefaultTextStyle
.
of
(
context
).
style
.
color
,
padding:
10.0
,
bulletSize:
0.4
*
(
config
.
style
?.
color
??
DefaultTextStyle
.
of
(
context
).
style
.
color
),
padding:
7
,
spacing:
10
,
bulletSize:
0.3
*
(
config
.
style
?.
fontSize
??
DefaultTextStyle
.
of
(
context
).
style
.
fontSize
??
kDefaultFontSize
),
...
...
@@ -381,8 +391,6 @@ class OrderedList extends BlockMd {
@override
String
get
expString
=>
(
r"([0-9]+\.)\ ([^\n]+)$"
);
get
onLinkTab
=>
null
;
@override
Widget
build
(
BuildContext
context
,
...
...
@@ -701,7 +709,7 @@ class SourceTag extends InlineMd {
/// Link text component
class
ATagMd
extends
InlineMd
{
@override
RegExp
get
exp
=>
RegExp
(
r"\[([^\s\*
][^\n]*?[^\s]?)?\]\(([^\s\*]+?)?
\)"
);
RegExp
get
exp
=>
RegExp
(
r"\[([^\s\*
\[][^\n]*?[^\s]?)?\]\(([^\s\*]*[^\)])
\)"
);
@override
InlineSpan
span
(
...
...
@@ -721,7 +729,7 @@ class ATagMd extends InlineMd {
onPressed:
()
{
config
.
onLinkTab
?.
call
(
"
${match?[2]}
"
,
"
${match?[1]}
"
);
},
text:
"
${match?[1]}
"
,
text:
match
?[
1
]
??
"
"
,
config:
config
,
),
);
...
...
Please
register
or
login
to post a comment