Problem with DOMParser when parsing nested list

I’ve created my own list_item which allow inline content.

When I use DOMParse to parsing html fragmengt like


The normalizeList function in DOMParser will transform my list DOM to image

It makes my list lose nested list items, because my list_item only allows inline content.

Is this expected behavior?

Thanks for your help

HTML officially only allows <ul> nodes to have <li> children (see MDN). Many browsers are okay with directly nested lists, but they tend to mess up parsing of more typical list structure (moving sublists that were supposed to be in the item above them into their own item), hence the normalization.

Therefore, your suggestion is that I modify the content that list_items can contain?

Would there be an option to ignore this handler in the future? Thanks

Does this patch help for you? It tries to detect a schema like yours and disable normalization in that case.

Yes! It works. Thank you very much!

Wonderful. Published as prosemirror-model 1.10.0

1 Like