Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.
Dart blogconfluence-alternativecontent-managementcontent-servicesdocumentationflutternote-takingnotion-alternativeproject-managementtask-managementteam-collaborationwiki
fix: markdown decoder and encoder test error
Lucas.Xu114968f2eeb2
diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/decoder/document_markdown_decoder.dartindex 05b8c4a1ff..fa12159106 100644--- a/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart+++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/decoder/document_markdown_decoder.dart@@ -80,7 +80,7 @@ class DocumentMarkdownDecoder extends Converter<String, Document> {BuiltInAttributeKey.subtype: BuiltInAttributeKey.quote,},);- } else if (RegExp(r'^-*').stringMatch(text) == text) {+ } else if (text.isNotEmpty && RegExp(r'^-*').stringMatch(text) == text) {return Node(type: 'divider');}diff --git a/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/divider_node_parser_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/divider_node_parser_test.dartnew file mode 100644index 0000000000..f4cb580684--- /dev/null+++ b/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/divider_node_parser_test.dart@@ -0,0 +1,15 @@+import 'package:appflowy_editor/appflowy_editor.dart';+import 'package:appflowy_editor/src/plugins/markdown/encoder/parser/divider_node_parser.dart';+import 'package:flutter_test/flutter_test.dart';++void main() async {+ group('divider_node_parser.dart', () {+ test('parser divider node', () {+ final node = Node(+ type: 'divider',+ );+ final result = const DividerNodeParser().transform(node);+ expect(result, '---\n');+ });+ });+}diff --git a/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/text_node_parser_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/text_node_parser_test.dartindex 0d7c540a2b..4932dbde6f 100644--- a/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/text_node_parser_test.dart+++ b/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/parser/text_node_parser_test.dart@@ -86,7 +86,7 @@ void main() async {final node = TextNode(delta: Delta(operations: [TextInsert(text)]),attributes: {- BuiltInAttributeKey.subtype: 'code-block',+ BuiltInAttributeKey.subtype: 'code_block',},);expect(const TextNodeParser().transform(node), '```\n$text\n```');