fabianmichael / kirby-markdown-field

Super-sophisticated markdown editor for Kirby 3, community built.
Other
160 stars 14 forks source link

Nested lists #171

Closed timotheegoguely closed 1 year ago

timotheegoguely commented 1 year ago

The following markdown is rendered is 2 consecutive lists instead of a proper nested list:

1. Item
2. Item
3. Item
    - Item
    - Item
    - Item
- Item
- Item
- Item
    1. Item
    2. Item
    3. Item

Actual output:

<ol>
  <li>Item</li>
  <li>Item</li>
  <li>Item</li>
</ol>
<ul>
  <li>Item</li>
  <li>Item</li>
  <li>Item</li>
</ul>
<ul>
  <li>Item</li>
  <li>Item</li>
  <li>Item</li>
</ul>
<ol>
  <li>Item</li>
  <li>Item</li>
  <li>Item</li>
</ol>

Expected output:

<ol>
  <li>Item</li>
  <li>Item</li>
  <li>
    <ul>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
    </ul>
  </li>
</ol>
<ul>
  <li>Item</li>
  <li>Item</li>
  <li>
    <ol>
      <li>Item</li>
      <li>Item</li>
      <li>Item</li>
    </ol>
  </li>
</ul>
fabianmichael commented 1 year ago

@timotheegoguely The markdown is actually rendered by Kirby itself and not my plugin and Kirby currently uses a library called Parsedown for that. It would be a great help, if you could find out what formatting is acutally needed in order to procude the expected markup. If you provide me that, I would be happy to update the field’s behavior. Thanks :-)

timotheegoguely commented 1 year ago

Thank you for your answer. The examples I provided aren't enough? I'm not sure to understand well how can I be more precise to help you. 🤔

I guess the missing part of the parser is to detect the number of spaces (2 or 4) at the beginning of a list item (ordered 1. or unordered * - ) and to convert it into the appropriate nested html structure.

GitHub implement it very well by the way.

fabianmichael commented 1 year ago

@timotheegoguely Since my plugin only provides the markdown field and has nothing to do with Kirby’s markdown parser, there is always a little chance for the PHP parser to behave a bit differently from the JS syntax highlighter used by the field. If you got a few minutes, please provide me an example of a nested list that is interpreted correctly by Kirby. That would make it easier for me, since my resources are quite limited at the moment.

fabianmichael commented 1 year ago

Closing this, as there has not been any activity and not scope of the plugin.