developit / snarkdown

:smirk_cat: A snarky 1kb Markdown parser written in JavaScript
http://jsfiddle.net/developit/828w6t1x/
MIT License
2.29k stars 109 forks source link

Nested lists not working #104

Open MaxTru opened 2 years ago

MaxTru commented 2 years ago

I would like to have nested lists. I cannot get them to work. I tried various "styles" (e.g., 2 spaces, 4 spaces). See example below.

Example

Markdown input

* Fruit
  * Apple
  * Orange
* Milk
  * Cheese

Expected output

<ul>
  <li>Fruit
    <ul>
      <li>Apple</li>
      <li>Orange</li>
    </ul>
  </li>
  <li>Milk
    <ul>
      <li>Cheese</li>
    </ul>
  </li>
</ul>

Actual output

<ul>
  <li>Fruit</li>
</ul>
<em> Apple</em> 
Orange
<ul>
  <li>Milk</li>
</ul>
<em> Cheese</em>

Context

snarkdown 2.0.0

SephReed commented 2 years ago

Also having this issue, but it looks intentional:

https://github.com/developit/snarkdown/blob/7619436b10a3e31e6779bf1209da4762409b86be/src/index.js#L67-L77

I think most people would be willing to have a few extra lines of code for such a feature. I know that elements inside elements aren't part of this code base, but it doesn't necessarily take many lines to add.

SephReed commented 2 years ago

For now, this works:

- hey
- there
- delilah<ul>
- what's
- it 
- like
</ul>
- in <ul>
- new
- york
- city
</ul>

Hard to read, but that will generate nested lists.

samuellawrentz commented 5 months ago

Any timeline to merge this? or get this fixed?