MacDownApp / macdown

Open source Markdown editor for macOS.
https://macdown.uranusjr.com/
9.43k stars 1.09k forks source link

multiple lists render incorrectly #640

Open konobi opened 8 years ago

konobi commented 8 years ago

I have rendering issues with the following:

# Carp 
<sub><sup>[#article](https://www.linux.com/news/carp-your-way-high-availability)</sup></sub>

* `net.inet.carp.allow`
* `net.inet.carp.arpbalance`
* `net.inet.carp.log`
* `net.inet.carp.preempt`

* `advbase`
* `advskew`
 * `rachael# ifconfig carp0 create`
 * `rachael# ifconfig carp0 vhid 1 pass tyrell 192.168.0.7`

* `/etc/hostname.carp0`
 * `up vhid 1 pass tyrell 192.168.0.7`

* `/etc/sysctl.conf`
 * `rachael# sysctl -w net.inet.carp.preempt=1`
 * `pris# ifconfig carp0 advskew 100`

The spacing between the list items in the lists after the first list is way too wide. Should be able to see it for yourself, if not, let me know and I'll add a screenshot. Reporting version: Macdown: Version 0.6 (749)

Jmuccigr commented 8 years ago

Here's a simpler case:

* one
* two
* three
* four

* new

Insert a comment (which isn't displayed) after the first list and the problem will disappear.

Note how github renders it, with the same problem:


Here's a screenshot:

screenshot 2016-08-14 09 30 12

FranklinYu commented 8 years ago

@Jmuccigr Are you trying to create a new list with three blank line? According to CommonMark, this shouldn't interrupt the original list. This works:

* one
* two
* three

Below is a new list.

* one again
* two again
* three again
Jmuccigr commented 8 years ago

I think the point is that the spacing is too large between three and four when four is itself followed by a blank line or two. Switch to numbered lists and you can see that the list is intact, but the spacing is odd:

1. one
1. two
1. three
1. four  

1. new

becomes

  1. one
  2. two
  3. three
  4. four
  5. new

where, to be clear, thereʻs extra space between three and four.

Looking at the markdown syntax though, I think this is the expected behavior and itʻs from this bit:

If list items are separated by blank lines, Markdown will wrap the items in <p> tags in the HTML output.

So four gets wrapped in <p>, even though itʻs followed and not preceded by a blank line. pandoc does this too.

FranklinYu commented 8 years ago

The original Markdown syntax missed a lot of corner cases like this; that's why I suggested to refer to CommonMark.

Jmuccigr commented 8 years ago

Yes, in the pandoc output from common mark, all the items get wrapped with <p> when there's a single blank line in the list, instead of just some of them. It seems that the observed behavior is considered correct for non-Commonmark though.

FranklinYu commented 8 years ago

Well, for non-CommonMark, there are a lot of "correct" behavior. Authors of every editor/renderer just implemented what they consider the correct behavior. I am considering to open another issue to discuss whether we should move our syntax to (a super set of) CommonMark, so that we actually have something to refer to. @Jmuccigr @konobi any ideas?

FranklinYu commented 7 years ago

@Jmuccigr Sorry, I misinterpreted what you meant until I reviewed your comments today. Now I fully agree with you: given

1. one
1. two
1. three
1. four  

1. new

MacDown should have rendered

<ol>
  <li>
    <p>one</p>
  </li>
  <li>
    <p>two</p>
  </li>
  <li>
    <p>three</p>
  </li>
  <li>
    <p>four</p>
  </li>
  <li>
    <p>new</p>
  </li>
</ol>

but now it rendered

<ol>
  <li>one</li>
  <li>two</li>
  <li>three</li>
  <li>
    <p>four  </p>
  </li>
  <li>
    <p>new</p>
  </li>
</ol>

instead. This behavior is reproducible with Hoedown.

"Expected behavior" concluded from CommonMark:

A list is loose if any of its constituent list items are separated by blank lines, or if any of its constituent list items directly contain two block-level elements with a blank line between them.

so "being loose" is not a property of a list item, but the entire list.