diff options
-rw-r--r-- | markdown_extensions/codehilite.py | 7 | ||||
-rw-r--r-- | tests/extensions-x-codehilite/code.html | 11 |
2 files changed, 7 insertions, 11 deletions
diff --git a/markdown_extensions/codehilite.py b/markdown_extensions/codehilite.py index 890a66b..edfcedb 100644 --- a/markdown_extensions/codehilite.py +++ b/markdown_extensions/codehilite.py @@ -204,10 +204,9 @@ class CodeHiliteExtention(markdown.Extension): text = "\n".join(detabbed).rstrip()+"\n" code = CodeHilite(text, linenos=self.config['force_linenos'][0]) placeholder = md.htmlStash.store(code.hilite(), safe=True) - if parent_elem.text: - parent_elem.text += placeholder - else: - parent_elem.text = placeholder + # This wrapping p element will be removed when inserting raw html + p = markdown.etree.SubElement(parent_elem, 'p') + p.text = placeholder md._processSection(parent_elem, theRest, inList) md._processCodeBlock = _hiliteCodeBlock diff --git a/tests/extensions-x-codehilite/code.html b/tests/extensions-x-codehilite/code.html index 43b09ea..6a8ee91 100644 --- a/tests/extensions-x-codehilite/code.html +++ b/tests/extensions-x-codehilite/code.html @@ -1,7 +1,5 @@ - -<p>Some text -</p> -<table><tr><td class="linenos"><pre>1 +<p>Some text</p> +<table class="codehilitetable"><tr><td class="linenos"><pre>1 2 3 4 @@ -13,7 +11,6 @@ <span class="k">def</span> <span class="nf">getCompiledRegExp</span> <span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="p">:</span> <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">compiled_re</span> </pre></div> -</td></tr></table><p>More text -</p> - +</td></tr></table> +<p>More text</p>
\ No newline at end of file |