From 03bf339b594db40592d3a4848ec1e5402a371df2 Mon Sep 17 00:00:00 2001 From: Waylan Limberg Date: Tue, 6 Jul 2010 15:43:11 -0400 Subject: Removed Global variable HTML_PLACEHOLDER. Use HtmlStash.get_placeholder(key) if you need it. --- markdown/postprocessors.py | 4 ++-- markdown/util.py | 6 +++--- tests/test_apis.py | 6 ++---- 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("

%s

" % - (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)]) -- cgit v1.2.3