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

Unwanted new line characters within lists with paragraphs #92

Open
diogoosorio opened this issue Oct 8, 2020 · 1 comment
Open

Unwanted new line characters within lists with paragraphs #92

diogoosorio opened this issue Oct 8, 2020 · 1 comment

Comments

@diogoosorio
Copy link
Contributor

The library is adding what I believe to be unintended newline characters, when parsing a document with li > p structure with newlines in between the 2 nodes:

[6] pry(main)> ReverseMarkdown.convert("<ul> <li><p>a</p></li></ul>")
=> "- a\n\n"
[7] pry(main)> ReverseMarkdown.convert("<ul><li><p>a</p></li></ul>")
=> "- a\n\n"
[8] pry(main)> ReverseMarkdown.convert("<ul><li> <p>a</p></li></ul>")
=> "-  \n\na\n\n"
[9] pry(main)> ReverseMarkdown.convert("<ul><li>\n<p>a</p>\n</li></ul>")
=> "- \n\na\n\n"

The 2 first examples work as intended, but if you add a space or newline character between the <li> and the <p> the library changes its behaviour and introduces the problem.

Funnily enough this scenario was accounted for in the list specs here, but the corresponding assertion is being skipped here - and it has been this way since 2012 (cd24cc3).

Anyway I'll open a PR shortly with a fix proposal. 👍

@diogoosorio
Copy link
Contributor Author

Oh and I forgot, this is where we "caught" the problem: forem/forem#10664

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

1 participant