From 33d3f28f8a01cbd0ec13bb55ec8ce3755deaa29a Mon Sep 17 00:00:00 2001 From: Artem Yunusov Date: Thu, 3 Jul 2008 21:53:03 +0500 Subject: Code blocks escaping bug fixed. Some test suite modifications. --- markdown.py | 6 ++-- test-markdown.py | 2 +- tests/markdown-test/auto-links.html | 5 ++- tests/markdown-test/markdown-syntax.html | 59 +++++++++++--------------------- tests/misc/arabic.html | 5 ++- tests/misc/bidi.html | 5 ++- tests/misc/image-2.html | 2 +- tests/misc/stronintags.html | 2 +- tests/safe_mode/unsafe_urls.html | 5 +-- 9 files changed, 35 insertions(+), 56 deletions(-) diff --git a/markdown.py b/markdown.py index 56b4285..7a1e9d2 100644 --- a/markdown.py +++ b/markdown.py @@ -1315,7 +1315,7 @@ class InlineStash: def _genPlaceholder(self, type): """ Generates placeholder """ id = "%04d" % len(self._nodes) - hash = "%s%s:%s%s" % (self.prefix, type[0:3], id, + hash = "%s%s:%s%s" % (self.prefix, type, id, self.suffix) return hash, id @@ -1910,7 +1910,6 @@ class Markdown: result = [] prefix = self.inlineStash.prefix strartIndex = 0 - while data: index = data.find(prefix, strartIndex) @@ -1938,6 +1937,7 @@ class Markdown: child.value) pos = node.childNodes.index(child) node.removeChild(child) + childResult.reverse() for newChild in childResult: node.insertChild(pos, newChild) @@ -1986,7 +1986,7 @@ class Markdown: if not node: return data, False - if isinstance(node, Element): + if isinstance(node, Element) and not node.nodeName in ["code", "pre"]: for child in node.childNodes: if isinstance(child, TextNode): child.value = self._handleInline(child.value, patternIndex) diff --git a/test-markdown.py b/test-markdown.py index 3007d72..68a10e6 100644 --- a/test-markdown.py +++ b/test-markdown.py @@ -244,9 +244,9 @@ def testDirectory(dir, measure_time=False, safe_mode=False) : t = time.clock() for x in repeat: actual_output = md.convert(input) - conversion_time = time.clock() - t conversion_mem = memory(mem) + md.reset() expected_lines = [x.encode("utf8") for x in smart_split(expected_output)] actual_lines = [x.encode("utf8") for x in smart_split(actual_output)] diff --git a/tests/markdown-test/auto-links.html b/tests/markdown-test/auto-links.html index 229ebb4..976d22b 100644 --- a/tests/markdown-test/auto-links.html +++ b/tests/markdown-test/auto-links.html @@ -11,8 +11,7 @@ In a list? -
  • - http://example.com/ +
  • http://example.com/
  • @@ -24,4 +23,4 @@

    Auto-links should not occur here: <http://example.com/>

    or here: <http://example.com/>
    -
    \ No newline at end of file + diff --git a/tests/markdown-test/markdown-syntax.html b/tests/markdown-test/markdown-syntax.html index c789d95..40f9547 100644 --- a/tests/markdown-test/markdown-syntax.html +++ b/tests/markdown-test/markdown-syntax.html @@ -8,81 +8,62 @@