Skip to content
New issue

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

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

Already on GitHub? # to your account

Blackfriday adds extra blank line in code block within a list #228

Closed
cmbrandenburg opened this issue Dec 22, 2015 · 6 comments
Closed

Blackfriday adds extra blank line in code block within a list #228

cmbrandenburg opened this issue Dec 22, 2015 · 6 comments

Comments

@cmbrandenburg
Copy link

Input:

* Foo

        bar

        qux

Expected output:

<ul>
<li><p>Foo</p>

<pre><code>bar

qux
</code></pre></li>
</ul>

Actual output:

<ul>
<li><p>Foo</p>

<pre><code>bar


qux
</code></pre></li>
</ul>

Notice the extra blank line between “bar” and “qux.”

@dmitshur
Copy link
Collaborator

Are you using blackfriday.MarkdownCommon or something else?

@cmbrandenburg
Copy link
Author

I'm using Hugo, and I get the same result with blackfriday-tool. I can dig in to find out more details if you need them.

For what it's worth, the canonical Gruber Perl markdown program has the same bug.

@dmitshur
Copy link
Collaborator

I can reproduce.

For what it's worth, the canonical Gruber Perl markdown program has the same bug.

That's helpful to know, thanks.

Interestingly, it also happens if using fenced code block:

* Foo

    ```     
    bar

    qux
    ```

@dmitshur
Copy link
Collaborator

Another test case:

* Foo

    ```     
    bar












    qux
    ```

That produces the same output as above, which is incorrect.

@rtfb
Copy link
Collaborator

rtfb commented Dec 26, 2015

I think I have a fix. I'll test it a bit more and post later today.

rtfb added a commit that referenced this issue Dec 26, 2015
Instead of swallowing an empty line and then reintroducing it back again
in certain cases, collect the list item body in an unaltered form and
let the recursive parsing call sort things out.

Fixes issue #228.
@dmitshur
Copy link
Collaborator

Fixed via #229.

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

No branches or pull requests

3 participants