Confusing link structure

To my knowledge, currently <a> is defined as a mark in basic schema. But when nesting strong tag with it, I got following structure:

<a>foo<strong>bar</strong> baz</a>

Instead of:


But the latter one is what happens when nesting <em> and <strong>, wondering is this expected? Is <a> an inline node under the hood?

This depends on the order in which you define your marks—those with lower precedence (defined earlier) always wrap around those with higher precedence, and mark DOM elements for adjacent inline nodes are combined when possible, so with links, which are typically low-precedence, you tend to get uninterrupted nodes, whereas when you interrupt a high-precedence mark with a lower-precedence one, the DOM element will be split to be able to keep the proper nesting order.

1 Like