Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Deeply nested lists rendering incorrectly #108

@schalk-b

Description

@schalk-b

I'm working on a rust portable text library. I'm checking against @portabletext/to-html for correctness. Deeply nested, orphaned lists are rendering incorrectly.

Editor:
image

To HTML:
image

<ul>
  <li>first</li>
</ul>
<ul>
  <li>second <ul>
      <li>third</li>
    </ul>
  </li>
</ul>
<ul>
  <li>forth <ol>
      <li>what</li>
    </ol>
  </li>
</ul>
<ol>
  <li>is this</li>
</ol>

Expected:
image

<ul>
  <li>
    <ul>
      <li>
        <ul>
          <li>first</li>
        </ul>
      </li>
    </ul>
  </li>
  <li>second <ul>
      <li>
        <ul>
          <li>
            <ul>
              <li>
                <ul>
                  <li>third</li>
                </ul>
              </li>
            </ul>
          </li>
        </ul>
      </li>
      <li>forth</li>
    </ul>
  </li>
</ul>
<ol>
  <li>
    <ol>
      <li>
        <ol>
          <li>
            <ol>
              <li>
                <ol>
                  <li>what</li>
                </ol>
              </li>
            </ol>
          </li>
        </ol>
      </li>
    </ol>
  </li>
  <li>is this</li>
</ol>

Data:

[
   {
      "style":"normal",
      "_key":"9333573cb3b3",
      "listItem":"bullet",
      "markDefs":[
         
      ],
      "children":[
         {
            "marks":[
               
            ],
            "text":"first",
            "_key":"cc69677971e7",
            "_type":"span"
         }
      ],
      "level":3,
      "_type":"block"
   },
   {
      "children":[
         {
            "_type":"span",
            "marks":[
               
            ],
            "text":"second",
            "_key":"5709fa2ce7e2"
         }
      ],
      "level":1,
      "_type":"block",
      "style":"normal",
      "_key":"8f4b1692d9df",
      "listItem":"bullet",
      "markDefs":[
         
      ]
   },
   {
      "listItem":"bullet",
      "markDefs":[
         
      ],
      "children":[
         {
            "marks":[
               
            ],
            "text":"third",
            "_key":"77523a19752e",
            "_type":"span"
         }
      ],
      "level":5,
      "_type":"block",
      "style":"normal",
      "_key":"6a4d1e1cb26a"
   },
   {
      "level":2,
      "_type":"block",
      "style":"normal",
      "_key":"ca4cb79ff48d",
      "listItem":"bullet",
      "markDefs":[
         
      ],
      "children":[
         {
            "_type":"span",
            "marks":[
               
            ],
            "text":"forth",
            "_key":"9a539b337911"
         }
      ]
   },
   {
      "level":5,
      "_type":"block",
      "style":"normal",
      "_key":"bb240543afcb",
      "listItem":"number",
      "markDefs":[
         
      ],
      "children":[
         {
            "_type":"span",
            "marks":[
               
            ],
            "text":"what",
            "_key":"2c73cd215c87"
         }
      ]
   },
   {
      "_key":"aecde7e5ac87",
      "listItem":"number",
      "markDefs":[
         
      ],
      "children":[
         {
            "_type":"span",
            "marks":[
               
            ],
            "text":"is this",
            "_key":"3463474af021"
         }
      ],
      "level":1,
      "_type":"block",
      "style":"normal"
   }
]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions