From 064958071b1f1f66e7427001ea205d59c2b9d53e Mon Sep 17 00:00:00 2001 From: Matthias Hadlich Date: Tue, 29 Oct 2024 10:22:31 +0100 Subject: [PATCH] Add newline before each p element apart from the first --- lib/src/markdown_to_delta.dart | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/src/markdown_to_delta.dart b/lib/src/markdown_to_delta.dart index bb02179..c65de62 100644 --- a/lib/src/markdown_to_delta.dart +++ b/lib/src/markdown_to_delta.dart @@ -264,6 +264,12 @@ class MarkdownToDelta extends Converter } void _insertNewLineBeforeElementIfNeeded(md.Element element) { + // make sure this is not the first element + // in all other cases add a new line before p + if (_lastTag != null && element.tag == 'p') { + _delta.insert('\n'); + } + if (!_isInBlockQuote && _lastTag == 'blockquote' && element.tag == 'blockquote') {