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

The number of newlines after a list alters output of to_html #144

Open
martinhath opened this issue Sep 22, 2024 · 1 comment
Open

The number of newlines after a list alters output of to_html #144

martinhath opened this issue Sep 22, 2024 · 1 comment

Comments

@martinhath
Copy link

This markdown:

- one
- two

Next line

should have the same output as this:

- one
- two


Next line

but it doesn't.

The output of the first snippet is (as expected)

<ul>
<li>one</li>
<li>two</li>
</ul>
<p>Next line</p>

but the output of the second snippet is

<ul>
<li>
<p>one</p>
</li>
<li>
<p>two</p>
</li>
</ul>
<p>Next line</p>

which is not expected. The <p> tags should probably not be there.

Here's a failing test

#[test]
fn two_blank_lines_inserts_paragraphs() {
    let out = to_html("- one\n- two\nNext line");
    assert!(!out.contains("<p>one</p>")); // Passes
    let out = to_html("- one\n- two\n\nNext line");
    assert!(!out.contains("<p>one</p>")); // Passes
    let out = to_html("- one\n- two\n\n\nNext line");
    assert!(!out.contains("<p>one</p>")); // Fails 💥
}
@wooorm
Copy link
Owner

wooorm commented Sep 23, 2024

looks like the loose/tight/spread algorithm is taking the line endings after the list/last item into account, where it should only look internally.

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