saminsohag

blockQuote fixed

... ... @@ -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
... ...
... ... @@ -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 | ✅ |
| ✂️ Striked Text | ✅ |
| ✂️ Strike Text | ✅ |
| 🔵 Bold Text | ✅ |
| 📜 Italic Text | ✅ |
| 🔗 Links | ✅ |
| 📱 Selectable | ✅ |
| 🧩 Custom components | ✅ | |
| 📎 Underline | | 🔜 |
| 🧩 Custom components | | 🔜 |
## ✨ Key Features
... ...
... ... @@ -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(
... ...
... ... @@ -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,
... ...
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,
);
}
... ...
... ... @@ -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,
),
),
);
... ...
... ... @@ -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(
... ...