diff options
author | Waylan Limberg <waylan@gmail.com> | 2010-07-14 15:21:30 -0400 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2010-07-14 15:21:30 -0400 |
commit | de949d2af47b9a094ace82ed64f810aaff7d3ac7 (patch) | |
tree | 04727d20c616d0b0ac50443697a35bc6fe73ed9d | |
parent | d955e45663c656b7db6e77abac86092d34e5fcb0 (diff) | |
download | markdown-de949d2af47b9a094ace82ed64f810aaff7d3ac7.tar.gz markdown-de949d2af47b9a094ace82ed64f810aaff7d3ac7.tar.bz2 markdown-de949d2af47b9a094ace82ed64f810aaff7d3ac7.zip |
Fixed Ticket 65. Lines with only a lessthan sign (<) no longer crash the raw html parser. Fixed a related but I found while debugging this as well. Also added tests for both.
-rw-r--r-- | markdown/preprocessors.py | 4 | ||||
-rw-r--r-- | tests/misc/html.html | 6 | ||||
-rw-r--r-- | tests/misc/html.txt | 9 |
3 files changed, 16 insertions, 3 deletions
diff --git a/markdown/preprocessors.py b/markdown/preprocessors.py index a83a78a..ab44f96 100644 --- a/markdown/preprocessors.py +++ b/markdown/preprocessors.py @@ -79,7 +79,7 @@ class HtmlBlockPreprocessor(Preprocessor): return tag, len(m.group(0)), attrs else: tag = block[1:].replace(">", " ", 1).split()[0].lower() - return tag, len(tag+2), {} + return tag, len(tag)+2, {} def _get_right_tag(self, left_tag, left_index, block): for p in self.right_tag_patterns: @@ -124,7 +124,7 @@ class HtmlBlockPreprocessor(Preprocessor): block = block[1:] if not in_tag: - if block.startswith("<"): + if block.startswith("<") and len(block.strip()) > 1: left_tag, left_index, attrs = self._get_left_tag(block) right_tag, data_index = self._get_right_tag(left_tag, left_index, diff --git a/tests/misc/html.html b/tests/misc/html.html index c4bad4f..dd4e4e8 100644 --- a/tests/misc/html.html +++ b/tests/misc/html.html @@ -11,4 +11,8 @@ Html with various attributes. <p>And of course <script>blah</script>.</p> <p><a href="script>stuff</script">this <script>link</a></p> -<p>Some funky <x\]> inline stuff with markdown escaping syntax.</p>
\ No newline at end of file +<p>Some funky <x\]> inline stuff with markdown escaping syntax.</p> +<p>And now a line with only an opening bracket:</p> +<p><</p> +<p>And one with other stuff but no closing bracket:</p> +<p>< foo</p>
\ No newline at end of file diff --git a/tests/misc/html.txt b/tests/misc/html.txt index b04b740..b51d30b 100644 --- a/tests/misc/html.txt +++ b/tests/misc/html.txt @@ -16,3 +16,12 @@ And of course <script>blah</script>. [this <script>link](<script>stuff</script>) Some funky <x\]> inline stuff with markdown escaping syntax. + +And now a line with only an opening bracket: + +< + +And one with other stuff but no closing bracket: + +< foo + |