delta_markdown
delta_markdown copied to clipboard
Issues with new lines
Thank you very much for this great tool. I noticed an issue with new lines handling
In markdown new lines must be specified with 2 (or more) consecutive lines. so one \n
in quill should be transformed into two \n
. and 1 \n
in markdown should be ignored and more than that should result in only a single \n
.
deltaToMarkdown
[{"insert":"line 1line 2\\nline 3\\n"}]
expected:
line 1line 2
line3
actual:
line 1line 2
line 3
markdownToDelta
line 1
line 2
line 3
expected:
[{"insert":"line 1line 2\\nline3\\n"}]
actual:
[{"insert":"line 1\\nline 2\\nline 3\\n"}]
@TarekkMA this might help
// Converts single line break from "\n" to " \n"
// Ignores double or more line breaks
final regex = RegExp(r'(?<!\n)\n(?!\n)');
final formattedMarkdown = markdown.replaceAll(regex, ' \n');