Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deeply nested lists rendering incorrectly #108

Open
schalk-b opened this issue May 30, 2024 · 0 comments
Open

Deeply nested lists rendering incorrectly #108

schalk-b opened this issue May 30, 2024 · 0 comments

Comments

@schalk-b
Copy link

schalk-b commented May 30, 2024

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"
   }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant