Fix edge-case crash in codehilite by oprypin · Pull Request #1405 · Python-Markdown/markdown (original) (raw)
If there is an empty <pre><code></code></pre>
inserted by another extension, there can be an exception. The added test case was crashing before this change:
File "markdown/core.py", line 361, in convert
newRoot = treeprocessor.run(root)
^^^^^^^^^^^^^^^^^^^^^^^
File "markdown/extensions/codehilite.py", line 274, in run
self.code_unescape(block[0].text),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "markdown/extensions/codehilite.py", line 260, in code_unescape
text = text.replace("<", "<")
^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'