Skip to content

Commit 114968f

Browse files
committed
fix: markdown decoder and encoder test error
1 parent 29952bc commit 114968f

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ class DocumentMarkdownDecoder extends Converter<String, Document> {
8080
BuiltInAttributeKey.subtype: BuiltInAttributeKey.quote,
8181
},
8282
);
83-
} else if (RegExp(r'^-*').stringMatch(text) == text) {
83+
} else if (text.isNotEmpty && RegExp(r'^-*').stringMatch(text) == text) {
8484
return Node(type: 'divider');
8585
}
8686

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import 'package:appflowy_editor/appflowy_editor.dart';
2+
import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/divider_node_parser.dart';
3+
import 'package:flutter_test/flutter_test.dart';
4+
5+
void main() async {
6+
group('divider_node_parser.dart', () {
7+
test('parser divider node', () {
8+
final node = Node(
9+
type: 'divider',
10+
);
11+
final result = const DividerNodeParser().transform(node);
12+
expect(result, '---\n');
13+
});
14+
});
15+
}

frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/text_node_parser_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void main() async {
8686
final node = TextNode(
8787
delta: Delta(operations: [TextInsert(text)]),
8888
attributes: {
89-
BuiltInAttributeKey.subtype: 'code-block',
89+
BuiltInAttributeKey.subtype: 'code_block',
9090
},
9191
);
9292
expect(const TextNodeParser().transform(node), '```\n$text\n```');

0 commit comments

Comments
 (0)