Permalink
Browse files

'fix' issue21: bare '>' escaping

  • Loading branch information...
1 parent 6ba39c4 commit a1347fd2a497080c69d75e4d825a9cdc1265a319 @trentm committed Oct 11, 2008
View
@@ -2,6 +2,12 @@
## python-markdown2 v1.0.1.12 (not final yet)
+- [Issue 21] Escape naked '>' characters, as is already done for '&' and '<'
+ characters. Note that other markdown implementations (both Perl and PHP) do
+ *not* do this. This results differing output with two 3rd-party tests:
+ "php-markdown-cases/Backslash escapes.text" and "markdowntest-cases/Amps
+ and angle encoding.tags".
+
## python-markdown2 v1.0.1.11
- Fix syntax_color test for the latest Pygments.
View
@@ -1410,6 +1410,7 @@ def _add_footnotes(self, text):
# http://bumppo.net/projects/amputator/
_ampersand_re = re.compile(r'&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)')
_naked_lt_re = re.compile(r'<(?![a-z/?\$!])', re.I)
+ _naked_gt_re = re.compile(r'''(?<![a-z?!/'"-])>''', re.I)
def _encode_amps_and_angles(self, text):
# Smart processing for ampersands and angle brackets that need
@@ -1418,6 +1419,11 @@ def _encode_amps_and_angles(self, text):
# Encode naked <'s
text = self._naked_lt_re.sub('&lt;', text)
+
+ # Encode naked >'s
+ # Note: Other markdown implementations (e.g. Markdown.pl, PHP
+ # Markdown) don't do this.
+ text = self._naked_gt_re.sub('&gt;', text)
return text
def _encode_backslash_escapes(self, text):
@@ -0,0 +1,2 @@
+# This fails only because python-markdown2 now escapes the naked '>'.
+knownfailure issue21
@@ -0,0 +1,2 @@
+# This fails only because python-markdown2 now escapes the naked '>'.
+knownfailure issue21
@@ -4,4 +4,4 @@
<p>&lt;&gt;</p>
-<p><b></p>
+<p>&lt;b&gt;</p>
@@ -0,0 +1 @@
+{"safe_mode": "escape"}
@@ -0,0 +1 @@
+issue21 escape
@@ -1 +0,0 @@
-knownfailure issue31 escape

0 comments on commit a1347fd

Please sign in to comment.