Mixed-language "mismatch close tag" scenario

Hello
I am wondering with the method of mixed-language parsing as shown in CodeMirror Mixed-Language Parsing Example. Is there a possibility to support a situation like below?

<div>
{% if extra_content1 %}
</div>
{% endif %}
{% if extra_content2 %}
</div>
{% endif %}

If this snippet is pasted in the second last CodeMirror section on the example page, the second </div> is highlighted in red since it’s treated as a mismatch close tag.

The snippet did not use else because it’s not supported in the example.
But if the snippet becomes

<div>
{% if extra_content %}
</div>
{% else %}
</div>
{% endif %}

Then there should be no mismatch close tag.

Any hint if this is achievable, perhaps custom extension needed?

Thank you.

Making the parsing aware of the way the outer blocks affect the order in which the HTML is parsed doesn’t seem realistic. You could just turn off tag matching to sidestep the issue.