jgm / cheapskate

Experimental markdown processor in Haskell
BSD 3-Clause "New" or "Revised" License
107 stars 18 forks source link

Lines between a link reference and the next blank line are lost #20

Open avh4 opened 7 years ago

avh4 commented 7 years ago

In the following markdown, non-reference lines following a reference cause cheapskate to completely ignore the block

Text [a].

[a]: #a
other text

is incorrectly parsed by cheapskate-0.1.0.5 as

<p>Text [a].</p>

For comparison, commonmark parses the input as:

<p>Text <a href="#a">a</a>.</p>
<p>other text</p>
jgm commented 7 years ago

It's not clear that this is a bug, because there's no real specification for reference links. (Now there is commonmark, but this didn't exist when cheapskate was written, and cheapskate does not conform to commonmark.)

In any case, I'm not actively maintaining cheapskate any more; I recommend using cmark-hs.

avh4 commented 7 years ago

Thanks for the info. I'm using a fork of cheapskate in elm-format because I wanted to avoid adding a c dependency (and also because I needed to match some of the non-commonmark behavior of marked.js!)

I'm probably going to fix this in elm-format (but probably won't make a PR here because my fork has already diverged a bit from cheapskate/master).

avh4 commented 7 years ago

It turns out this happens any time non-reference lines follow a reference line without a blank line in between.

For reference, here's the fix I used in the forked version of cheapskate that's used in elm-format: https://github.com/avh4/elm-format/commit/f8f8b8d02d7f349f300843d18b13804efdacc92a