saminsohag

source config added

## 0.1.9
* source config added.
## 0.1.8
* unordered list bullet color fixed.
... ...
... ... @@ -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"),
... ...
... ... @@ -190,7 +190,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.8"
version: "0.1.9"
http:
dependency: transitive
description:
... ...
... ... @@ -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,
);
... ...
... ... @@ -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,
),
));
}
... ...
... ... @@ -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,
),
),
),
),
),
),
),
);
}
... ...
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:
... ...