rdiscount
rdiscount copied to clipboard
Allow stricter handling of consecutive bullet lists with MKD_EXPLICITLIST flag
Code:
require 'rdiscount'
markdown = <<EOF
- Bullet
- Bullet
1. Numbered
2. Numbered
EOF
puts RDiscount.new(markdown).to_html
Output:
<ul>
<li>Bullet</li>
<li><p>Bullet</p></li>
<li><p>Numbered</p></li>
<li>Numbered</li>
</ul>
Expected Output:
<ul>
<li>Bullet</li>
<li>Bullet</li>
</ul>
<ol>
<li>Numbered</li>
<li>Numbered</li>
</ol>
If anything is inserted between the lists (like ----
), the result is fine.
Confirmed with underlying Discount 2.2.0.
Reported upstream at: https://github.com/Orc/discount/issues/150
The upstream is closed with comment https://github.com/Orc/discount/issues/150#issuecomment-225477646
Sadly, this is not a defect; it's the way markdown processes lists :-(
I'm working on yet another effing option flag to process lists in the expected nonsurprising manner, but it has to be an option because the reference implementation merges adjacent lists no matter what type they are.
Should this also be closed?
It seems now that it is possible to get the expected output mentioned above via the new MKD_EXPLICITLIST flag that Discount just added for v2.2.3b6 . However RDiscount doesn't support this flag yet. I'll plan to wait until Discount 2.2.3(final) is released before supporting that option.
Discount 2.2.3 final has been released, so this issue is now unblocked.
This is an old issue, and I have since moved on - but I am not sure why is this considered "not a defect" as mentioned in the linked comment. This is purely a bug. It does not need flags to be "stricter", it needs to be fixed... nobody needs the broken behavior. A new line in markdown marks the end of a block, as is the case in all other markdown implementations I have seen.
FWIW, I'm classifying it as a feature because it is something that will need to be requested explicitly via flag.
it needs to be fixed... nobody needs the broken behavior.
I am certain there are folks depending on the old behavior. I'm not planning on breaking the world without a good reason.