Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with new lines #3

Open
TarekkMA opened this issue Nov 18, 2021 · 1 comment
Open

Issues with new lines #3

TarekkMA opened this issue Nov 18, 2021 · 1 comment

Comments

@TarekkMA
Copy link

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"}]
@Juliotati
Copy link

@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');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants