From a4c80246770b87ca3d2cce5b5184901fd2495a7d Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 26 Aug 2008 13:01:17 -0400 Subject: Fixed ticket 12. Insert code placeholder into a wrapping ET element rather than parent_elem.text as text will alway be at beginning of doc. The wrapping element is a

tag as, later, when the rawhtml is inserted, markdown will first check for the placeholder inside a

tag, and if the placeholder is the *only* content of the

tag, replace the entire

tag - not just the placeholder. Perhaps a little hacky, but this is how markdown works internally anyway. --- markdown_extensions/codehilite.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'markdown_extensions') 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 -- cgit v1.2.3