diff options
-rw-r--r-- | markdown.py | 13 | ||||
-rw-r--r-- | tests/safe_mode/script_tags.html | 4 | ||||
-rw-r--r-- | tests/safe_mode/script_tags.txt | 2 |
3 files changed, 7 insertions, 12 deletions
diff --git a/markdown.py b/markdown.py index dcfe18e..5b4fa5f 100644 --- a/markdown.py +++ b/markdown.py @@ -507,8 +507,7 @@ BRK = ( r'\[(' + NOBRACKET + r')\]' ) NOIMG = r'(?<!\!)' -BACKTICK_RE = r'(?<!\\)(?:`+)(?!`)(.+?)(?<!`)(`+)(?!`)' -DOUBLE_BACKTICK_RE = r'\`\`(.*?)\`\`' # ``e=f("`")`` +BACKTICK_RE = r'(?<!\\)(`+)(.+?)(?<!`)\2(?!`)' # `e=f()` or ``e=f("`")`` ESCAPE_RE = r'\\(.)' # \< EMPHASIS_RE = r'\*([^\*]*)\*' # *emphasis* STRONG_RE = r'\*\*(.*?|[^**]+?)\*\*' # **strong** @@ -791,8 +790,7 @@ class AutomailPattern (Pattern): ESCAPE_PATTERN = SimpleTextPattern(ESCAPE_RE) NOT_STRONG_PATTERN = SimpleTextPattern(NOT_STRONG_RE) -BACKTICK_PATTERN = BacktickPattern(BACKTICK_RE) -DOUBLE_BACKTICK_PATTERN = BacktickPattern(DOUBLE_BACKTICK_RE) +BACKTICK_PATTERN = BacktickPattern(BACKTICK_RE, 3) STRONG_PATTERN = SimpleTagPattern(STRONG_RE, 'strong') STRONG_PATTERN_2 = SimpleTagPattern(STRONG_2_RE, 'strong') EMPHASIS_PATTERN = SimpleTagPattern(EMPHASIS_RE, 'em') @@ -1188,7 +1186,6 @@ class Markdown: self.prePatterns = [] self.inlinePatterns = [ - DOUBLE_BACKTICK_PATTERN, BACKTICK_PATTERN, ESCAPE_PATTERN, REFERENCE_PATTERN, @@ -1674,7 +1671,7 @@ class Markdown: if not match: return data, False - + node = pattern.handleMatch(match) if node is None: @@ -1692,10 +1689,8 @@ class Markdown: patternIndex) pholder = self.inlineStash.add(node, pattern.type()) - left = "".join([match.group(i) for i in xrange(1, - pattern.contentGroup)]) - return "%s%s%s" % (left, pholder, match.groups()[-1]), True + return "%s%s%s" % (match.group(1), pholder, match.groups()[-1]), True def _processElementText(self, node, subnode, isText=True): diff --git a/tests/safe_mode/script_tags.html b/tests/safe_mode/script_tags.html index 4c669dd..940329f 100644 --- a/tests/safe_mode/script_tags.html +++ b/tests/safe_mode/script_tags.html @@ -12,7 +12,7 @@ alert("Hello world!") <p> <code><script <!-- alert("Hello world!") -</script <></code>`</p> +</script <></code> `</p> <p>Try another way.</p> <p><script <!-- alert("Hello world!") @@ -26,4 +26,4 @@ alert("Hello world!") </script <> -</p>
\ No newline at end of file +</p> diff --git a/tests/safe_mode/script_tags.txt b/tests/safe_mode/script_tags.txt index 55c60e9..44041c2 100644 --- a/tests/safe_mode/script_tags.txt +++ b/tests/safe_mode/script_tags.txt @@ -16,7 +16,7 @@ Now with some weirdness ``<script <!-- alert("Hello world!") -</script <>``` +</script <>`` ` Try another way. |