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

Inconsistent List Formatting With Linebreaks #551

Closed
JoeJHoward opened this issue Jan 18, 2018 · 2 comments
Closed

Inconsistent List Formatting With Linebreaks #551

JoeJHoward opened this issue Jan 18, 2018 · 2 comments

Comments

@JoeJHoward
Copy link

I'm getting inconsistent list formatting on the last list item of both ordered and unordered lists when there is are line-breaks in the list item body text.

For example the following markdown:

1. One
   First body copy

2. Two
   Last body copy

The expected output should be:

<ol>
  <li>
    <p>One
    First body copy</p>
  </li>
  <li>
    <p>Two
    Last body copy</p>
  </li>
</ol>

But the parser strips the <p> tags on the last item and outputs:

<ol>
  <li>
    <p>One
    First body copy</p>
  </li>
  <li>Two
    Last body copy
  </li>
</ol>
@johnnymatthews
Copy link

johnnymatthews commented Jan 29, 2018

I'm getting a similar issue. It looks like removing the returns between each list item in markdown removes the <p> tags from the HTML completely.

Original Markdown Input

- [List item one](#link-one)

- [List item two](#link-two)

- [List item three](#link-three)

- [List item four](#link-four)

Broken HTML Output

<ul>
    <li>
        <a href="#link-one">
            <p>List item one</p>
        </a>
    </li>
    <li>
        <a href="#link-two">
            <p>List item two</p>
        </a>
    </li>
    <li>
        <a href="#link-three">
            <p>List item three</p>
        </a>
    </li>
    <li>
        <a href="#link-four">
            List item four        <--- Missing <p> tags
        </a>
    </li>
</ul>

Modified Markdown Input

- [List item one](#link-one)
- [List item two](#link-two)
- [List item three](#link-three)
- [List item four](#link-four)

Working HTML Output

<ul>
    <li>
        <a href="#link-one">
            List item one
        </a>
    </li>
    <li>
        <a href="#link-two">
            List item two
        </a>
    </li>
    <li>
        <a href="#link-three">
            List item three
        </a>
    </li>
    <li>
        <a href="#link-four">
            List item four
        </a>
    </li>
</ul>

Edit

Here's a workaround if you really, really need your formatting to be perfect:

- [List item one](#link-one)

- [List item two](#link-two)

- [List item three](#link-three)

- [<p>List item four</p>](#link-four)        <--- Hardcoded <p> tags

@aidantwoods
Copy link
Collaborator

aidantwoods commented Jan 29, 2018

I just added this as a test-case in my PR #475 and it looks to be resolved there.
@erusev any chance at merging #475? It is a pretty minor change that's completely additive (I should mention that it does change test-case expectations though: they are changed to match the output of the commonmark reference parser for the respective inputs).

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

3 participants