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-11-15 20:08:11 +0600
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8812ed66081ff07b3b6a867df53ea0667af5ccf0
8812ed66
1 parent
2390380a
some fixes for italic and bold text
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
gpt_markdown/lib/markdown_component.dart
gpt_markdown/lib/markdown_component.dart
View file @
8812ed6
...
...
@@ -11,7 +11,7 @@ import 'md_widget.dart';
/// Markdown components
abstract
class
MarkdownComponent
{
static
final
List
<
MarkdownComponent
>
components
=
[
static
List
<
MarkdownComponent
>
get
components
=>
[
CodeBlockMd
(),
NewLines
(),
TableMd
(),
...
...
@@ -25,9 +25,9 @@ abstract class MarkdownComponent {
ImageMd
(),
HighlightedText
(),
BoldMd
(),
ItalicMd
(),
LatexMathMultyLine
(),
LatexMath
(),
ItalicMd
(),
ATagMd
(),
SourceTag
(),
];
...
...
@@ -435,7 +435,7 @@ class HighlightedText extends InlineMd {
/// Bold text component
class
BoldMd
extends
InlineMd
{
@override
RegExp
get
exp
=>
RegExp
(
r"
\*\*(([\S^\*].*?)?[\S^\*?])\*\*
"
);
RegExp
get
exp
=>
RegExp
(
r"
(?<!\*)\*\*(?<!\s)(.+?)(?<!\s)\*\*(?!\*)
"
);
@override
InlineSpan
span
(
...
...
@@ -458,6 +458,32 @@ class BoldMd extends InlineMd {
}
}
/// Italic text component
class
ItalicMd
extends
InlineMd
{
@override
RegExp
get
exp
=>
RegExp
(
r"(?<!\*)\*(?<!\s)(.+?)(?<!\s)\*(?!\*)"
,
dotAll:
true
);
@override
InlineSpan
span
(
BuildContext
context
,
String
text
,
final
GptMarkdownConfig
config
,
)
{
var
match
=
exp
.
firstMatch
(
text
.
trim
());
var
conf
=
config
.
copyWith
(
style:
(
config
.
style
??
const
TextStyle
())
.
copyWith
(
fontStyle:
FontStyle
.
italic
));
return
TextSpan
(
children:
MarkdownComponent
.
generate
(
context
,
"
${match?[1]}
"
,
conf
,
),
style:
conf
.
style
,
);
}
}
class
LatexMathMultyLine
extends
BlockMd
{
@override
RegExp
get
exp
=>
RegExp
(
...
...
@@ -589,32 +615,6 @@ class LatexMath extends InlineMd {
}
}
/// Italic text component
class
ItalicMd
extends
InlineMd
{
@override
RegExp
get
exp
=>
RegExp
(
r"\*(\S(.*?\S)?)\*"
,
dotAll:
true
);
@override
InlineSpan
span
(
BuildContext
context
,
String
text
,
final
GptMarkdownConfig
config
,
)
{
var
match
=
exp
.
firstMatch
(
text
.
trim
());
var
conf
=
config
.
copyWith
(
style:
(
config
.
style
??
const
TextStyle
())
.
copyWith
(
fontStyle:
FontStyle
.
italic
));
return
TextSpan
(
children:
MarkdownComponent
.
generate
(
context
,
"
${match?[1]}
"
,
conf
,
),
style:
conf
.
style
,
);
}
}
/// source text component
class
SourceTag
extends
InlineMd
{
@override
...
...
Please
register
or
login
to post a comment