aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/postprocessors.py4
-rw-r--r--markdown/util.py6
-rw-r--r--tests/test_apis.py6
3 files changed, 7 insertions, 9 deletions
diff --git a/markdown/postprocessors.py b/markdown/postprocessors.py
index b4b36de..2093289 100644
--- a/markdown/postprocessors.py
+++ b/markdown/postprocessors.py
@@ -48,9 +48,9 @@ class RawHtmlPostprocessor(Postprocessor):
html = util.HTML_REMOVED_TEXT
if safe or not self.markdown.safeMode:
text = text.replace("<p>%s</p>" %
- (util.HTML_PLACEHOLDER % i),
+ (self.markdown.htmlStash.get_placeholder(i)),
html + "\n")
- text = text.replace(util.HTML_PLACEHOLDER % i,
+ text = text.replace(self.markdown.htmlStash.get_placeholder(i),
html)
return text
diff --git a/markdown/util.py b/markdown/util.py
index d1485db..9d1531a 100644
--- a/markdown/util.py
+++ b/markdown/util.py
@@ -33,8 +33,6 @@ ETX = u'\u0003' # Use ETX ("End of text") for end-of-placeholder
INLINE_PLACEHOLDER_PREFIX = STX+"klzzwxh:"
INLINE_PLACEHOLDER = INLINE_PLACEHOLDER_PREFIX + "%s" + ETX
AMP_SUBSTITUTE = STX+"amp"+ETX
-HTML_PLACEHOLDER_PREFIX = STX+"wzxhzdk:"
-HTML_PLACEHOLDER = HTML_PLACEHOLDER_PREFIX + "%d" + ETX
"""
Constants you probably do not need to change
@@ -105,7 +103,7 @@ class HtmlStash:
"""
self.rawHtmlBlocks.append((html, safe))
- placeholder = HTML_PLACEHOLDER % self.html_counter
+ placeholder = self.get_placeholder(self.html_counter)
self.html_counter += 1
return placeholder
@@ -113,4 +111,6 @@ class HtmlStash:
self.html_counter = 0
self.rawHtmlBlocks = []
+ def get_placeholder(self, key):
+ return "%swzxhzdk:%d%s" % (STX, key, ETX)
diff --git a/tests/test_apis.py b/tests/test_apis.py
index 760afa8..0c81585 100644
--- a/tests/test_apis.py
+++ b/tests/test_apis.py
@@ -101,16 +101,14 @@ class TestHtmlStash(unittest.TestCase):
def testSimpleStore(self):
""" Test HtmlStash.store. """
- self.assertEqual(self.placeholder,
- markdown.util.HTML_PLACEHOLDER % 0)
+ self.assertEqual(self.placeholder, self.stash.get_placeholder(0))
self.assertEqual(self.stash.html_counter, 1)
self.assertEqual(self.stash.rawHtmlBlocks, [('foo', False)])
def testStoreMore(self):
""" Test HtmlStash.store with additional blocks. """
placeholder = self.stash.store('bar')
- self.assertEqual(placeholder,
- markdown.util.HTML_PLACEHOLDER % 1)
+ self.assertEqual(placeholder, self.stash.get_placeholder(1))
self.assertEqual(self.stash.html_counter, 2)
self.assertEqual(self.stash.rawHtmlBlocks,
[('foo', False), ('bar', False)])