redcarpet icon indicating copy to clipboard operation
redcarpet copied to clipboard

Weird behavior with mix of tight and loose unordered lists

Open bkeepers opened this issue 13 years ago • 5 comments

This is a strange edge case, but the generated markup is strange when mixing tight and loose lists:

>> puts Redcarpet.new(<<EOF).to_html
- uno
- dos

- tres
- quatro
EOF
<ul>
<li>uno</li>
<li><p>dos</p></li>
<li><p>tres</p></li>
<li><p>quatro</p></li>
</ul>

The first list item is not wrapped in a paragraph, but all the others are.

The behavior seems fine if there are consistent spacing:

>> puts Redcarpet.new(<<EOF).to_html
- uno
- dos
- tres
- quatro
EOF
<ul>
<li>uno</li>
<li>dos</li>
<li>tres</li>
<li>quatro</li>
</ul>
=> nil
>> puts Redcarpet.new(<<EOF).to_html
- uno

- dos

- tres

- quatro
EOF
<ul>
<li><p>uno</p></li>
<li><p>dos</p></li>
<li><p>tres</p></li>
<li><p>quatro</p></li>
</ul>
=> nil

This happens on both 1.x and 2.x.

bkeepers avatar Jul 11 '12 00:07 bkeepers

On master, with the following markdown

- uno
- dos

- tres
- quatro

Redcarpet generates

<ul>
<li>uno</li>
<li>dos</li>
<li>tres</li>
<li>quatro</li>
</ul>

which is at least consistent now. I'll close this one out for now. If Redcarpet should be doing something different instead, please feel free to reopen this issue. Thanks!

mattr- avatar Apr 16 '13 04:04 mattr-

no. i lied. pry ate my newlines when I tried this out the first time. :disappointed:

mattr- avatar Apr 16 '13 04:04 mattr-

I assume this still hasn't been fixed because if I type:

1.  Item 1
2.  Item 2

I get:

<ol>
<li> Item 1</li>
<li> Item 2</li>
</ol>

which is fine.

But if I type:

*   A list item
*   Another item

+   A list item
+   Another item

-   A list item
-   Another item

*   Abacus
    * answer
*   Bubbles
    1.  bunk
    2.  bupkis
        * BELITTLER
    3. burper
*   Cunning

I get:

<ul>
  <li>  A list item</li>
  <li><p>Another item</p></li>
  <li><p>A list item</p></li>
  <li><p>Another item</p></li>
  <li><p>A list item</p></li>
  <li><p>Another item</p></li>
  <li><p>Abacus</p>
    <ul>
      <li>answer</li>
    </ul></li>
  <li><p>Bubbles</p>
    <ol>
      <li> bunk</li>
      <li> bupkis
        <ul>
          <li>BELITTLER</li>
        </ul></li>
      <li>burper</li>
    </ol></li>
  <li><p>Cunning</p></li>
</ul>

It looks like it is possibly ok with respect to ol but list items in ul (except for the first item) seem to be wrapped in p tags.

amnesia7 avatar Aug 26 '14 21:08 amnesia7

Having the same issue. Typing:

1. Do xyz.
2. Do zyx.

    NOTE: Do zyx only if abc.
3. Do lmno.
4. Do qrs.

Gets me:

<ol>
<li>Do xyz.</li>
<li><p>Do zyx.</p>
<p>NOTE: Do zyx only if abc.</p></li>
<li><p>Do lmno.</p></li>
<li><p>Do qrs.</p></li>
</ol>

But if I alter my Markdown to:

1. Do xyz.
2. Do zyx.<p>NOTE: Do zyx only if abc.</p>
3. Do lmno.
4. Do qrs.

I get what I would expect from the unaltered Markdown:

<ol>
    <li>Do xyz.</li>
    <li>Do zyx.
        <p>NOTE: Do zyx only if abc.</p>
    </li>
    <li>Do lmno.</li>
    <li>Do qrs.</li>
</ol>

mecrouch avatar Nov 25 '14 20:11 mecrouch

ping

crazymaster avatar Jun 10 '15 18:06 crazymaster