We get the same out...">

PI () is escaped in error with md_in_html · Issue #1070 · Python-Markdown/markdown (original) (raw)

In any of the following source documents:

<div markdown=1>

<?php print("foo"); >

</div>
<div markdown=1>
<?php print("foo"); >
</div>
<div markdown=1><?php print("foo"); ></div>

We get the same output:

<?php print("foo"); >

Which is correct except for the fact the the opening and closing brackets of the processing instruction (PI) are escaped. We should be getting:

The problem is related to the fact that the extension builds an etree object of raw HTML when markdown=1. However, the PI (<?php print("foo"); >) is simply passed to the etree object as text data (to treebuilder.data). Upon serialization, it is escaped. The obvious fix would be to pass the content of the PI to treebuilder.pi, except that xml.etree.ElementTree.TreeBuilder.pi was only added in PY3.8. What do we do for PY3.6 and PY3.7?