From 888c1b86f00cd50a32f5603abb532695052304b4 Mon Sep 17 00:00:00 2001 From: "Lucas.Xu" Date: Tue, 8 Nov 2022 21:34:27 +0800 Subject: [PATCH] test: markdown decoder test --- .../plugins/markdown/encoder/parser/text_node_parser.dart | 7 +++++++ .../markdown/encoder/document_markdown_encoder_test.dart | 3 +-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/encoder/parser/text_node_parser.dart b/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/encoder/parser/text_node_parser.dart index fe60db7c7e..8857310876 100644 --- a/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/encoder/parser/text_node_parser.dart +++ b/frontend/app_flowy/packages/appflowy_editor/lib/src/plugins/markdown/encoder/parser/text_node_parser.dart @@ -20,6 +20,9 @@ class TextNodeParser extends NodeParser { if (attributes.isNotEmpty && attributes.containsKey(BuiltInAttributeKey.subtype)) { final subtype = attributes[BuiltInAttributeKey.subtype]; + if (node.next == null) { + suffix = ''; + } if (subtype == 'heading') { final heading = attributes[BuiltInAttributeKey.heading]; if (heading == 'h1') { @@ -51,6 +54,10 @@ class TextNodeParser extends NodeParser { result = '- [ ] $markdown'; } } + } else { + if (node.next == null) { + suffix = ''; + } } return '$result$suffix'; } diff --git a/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/document_markdown_encoder_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/document_markdown_encoder_test.dart index a81ff10a62..0c3fdb0254 100644 --- a/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/document_markdown_encoder_test.dart +++ b/frontend/app_flowy/packages/appflowy_editor/test/plugins/markdown/encoder/document_markdown_encoder_test.dart @@ -130,8 +130,7 @@ You can also use ***AppFlowy Editor*** as a component to build your own app. * Use / to insert blocks * Select text to trigger to the toolbar to format your notes. -If you have questions or feedback, please submit an issue on Github or join the community along with 1000+ builders! -'''); +If you have questions or feedback, please submit an issue on Github or join the community along with 1000+ builders!'''); }); }); }