svelte-preprocess-markdown icon indicating copy to clipboard operation
svelte-preprocess-markdown copied to clipboard

Nested if in ordered list

Open heri16 opened this issue 5 years ago • 5 comments

I've been trying in markdown, but could not achieve the below in markdown.

See: https://svelte.dev/repl/39a28b6d8ad54f409c75106a1871f357?version=3.31.0

<script>
  let test = true;
</script>

<ol>
  <li>
     My First Item
    <ol>
      <li>My Nested First Item</li>
      <li>
        My Nested Second Item
        <ol>
          {#if test}
          <li>Nested Deep</li>
          <li>Nested Deep</li>
          {/if}
          <li>Nested Deep - Bookmarked</li>
        </ol>
      </li>
      <li>My Nested Third Item</li>
      <li>My Nested 4th Item</li>
    </ol>
  </li>
  <li>My Second Item</li>
  <li>My Third Item</li>
  <li>My 4th Item</li>
</ol>

heri16 avatar Dec 10 '20 08:12 heri16

The below loses numbering due to the if block.

1. First item
1. Second item
1. Third item
{#if test }
  1. Indented item
  1. Indented item
{/if}
  1. Third item
  1. Fourth item
1. Fourth item

The below can't even compile:

1. First item
1. Second item
1. Third item
{#if test }
  1. Indented {#if test }item{/if}
  1. Indented item
{/if}
  1. Third item
  1. Fourth item
1. Fourth item

heri16 avatar Dec 10 '20 08:12 heri16

The part about loose lists here applies?

https://github.github.com/gfm/#lists

heri16 avatar Dec 10 '20 09:12 heri16

Currently it is unsupported feature. I'll research is it possible to realize it.

AlexxNB avatar Dec 11 '20 09:12 AlexxNB

What would it take to realize this? Maybe another preprocessor to remove <p> nodes around if tags?

heri16 avatar Dec 31 '20 02:12 heri16

It is hard to implement all edgecases in markdown preprocessor. List inside if is separate list. I don't know how to fix it and not to break behavior in common cases. Somebody helps maybe.

AlexxNB avatar Dec 31 '20 10:12 AlexxNB