-
Notifications
You must be signed in to change notification settings - Fork 70
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
preserveNewlines off by one newline #111
Comments
Thanks! Tests would be really awesome too... The newline preservation behaviour is a bit of a tricky one, lots of edge cases, I also have this issue: Question for you: Draft by default does a "hard" newline when you press return, so a brand new paragraph, although you can optionally insert a soft newline. I'm wondering if the behaviour you're describing is expected given draft's default hard vs soft newline behaviour, but I'm not 100% sure as I haven't dug in to your solution or the issue too deeply yet, just read your note 😳 |
I think I'll write new tests to help confirm if my issue is real. Hopefully I don't have to modify soft vs hard new lines. I worry that I don't understand the subtleties around changing that. Hard newlines are |
I ran my new tests on master without my changes, and they failed in the same way I described in my first post. I think this means it's not just me–that my issue is legitimate. Take a look at my new committed tests af777bd. What do you think? Here's what it looks like when my new tests fail:
Thanks a lot for the help, |
Hi Rosey! I hope you and your family are well!! No rush (family is more important) but we are waiting to hear if you have feedback or want to merge this PR (#112). All the best! |
I'm sorry :) we've all been down with the flu this past week and are still on the recovery! Tomorrow is doctors appointments but I'll try to find some time later this week when the toddler is in daycare to sit down and look at this 🙂 |
Get well soon! 😊 |
Ugh I'm actually back at the hospital again so depending on how things go it may be a longer wait :( |
Sorry things have been very busy around here. I'm just taking a quick look at the PR now but I'll probably have to finish looking a bit later. I think it looks good and thanks for writing tests! I just want to check your branch out locally and confirm that it still works correctly in cases where there's a blockquote followed by a paragraph, just because the comment in the code about "styled followed by unstyled" makes me wonder if in some cases an extra newline was necessary to avoid things like block quotes persisting, eg:
renders as
and so if we were converting we'd want it to be
To ensure blockquote is escaped. Anyway I'll confirm when I have a chance and write a test for this case if one doesn't exist! |
I totally agree about the block quotes. Great point! Test my branch if you
get a chance :-). Thank you.
I hope you are well!
…On Fri, Jan 24, 2020 at 12:31 PM Rose ***@***.***> wrote:
Sorry things have been very busy around here. I'm just taking a quick look
at the PR now but I'll probably have to finish looking a bit later. I think
it looks good and thanks for writing tests! I just want to check your
branch out locally and confirm that it still works correctly in cases where
there's a blockquote followed by a paragraph, just because the comment in
the code about "styled followed by unstyled" makes me wonder if in some
cases an extra newline was necessary to avoid things like block quotes
persisting, eg:
> Test
Hello
renders as
Test
Hello
and so if we were converting we'd want it to be
> Test
Hello
To ensure blockquote is escaped.
Anyway I'll confirm when I have a chance and write a test for this case if
one doesn't exist!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#111?email_source=notifications&email_token=AANIGWFKEPCZYDYOO45WGG3Q7MQW5A5CNFSM4KGJ5TC2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ3QLKY#issuecomment-578225579>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AANIGWFBXY5ZRE7A3G4D5ATQ7MQW5ANCNFSM4KGJ5TCQ>
.
|
Closing as the related PR has been merged 🙂 |
@danielsnider I released your fix under 2.2.0 🙂 👏 🎉 |
Thank you! 🎉🎉 |
@Rosey It was a pleasure to help. Thanks again for this great project. |
Hi @Rosey,
I am really happy for the preserveNewlines feature. It got me closer to 1-to-1 exact matching looks when converting, but I found newline handling was still a little bit off. I was able to fix it without breaking any unit tests. My draft-js editor is pretty much this, the standard Rich Text Editor Draft.js example.
Here is my example:
Input:
When converted by
draft-to-markdown.js
it added a newline after each character, output:And here's the same example but converted by
markdown-to-draft.js
, input:When converted by
markdown-to-draft.js
it removed one newline after each character (except "a"), output:Does this make sense?
Should I write unit tests to test these things?
I wrote a fix PR (#112)
Can this be included in your package and put into NPM to help us develop: rareconnect.org?
The text was updated successfully, but these errors were encountered: