Skip to content

Unwanted new line characters within lists with paragraphs #92

Description

@diogoosorio

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. 👍

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions