diff options
author | Waylan Limberg <waylan@gmail.com> | 2007-10-07 03:03:51 +0000 |
---|---|---|
committer | Waylan Limberg <waylan@gmail.com> | 2007-10-07 03:03:51 +0000 |
commit | c80490a261431c7dae1a3c1d4ad02f77db98d05e (patch) | |
tree | eca1587fa5a61b1307ebc129a9726fd30d84a02e /markdown.py | |
parent | b918b4e17442990d548a8124c49ecb2451a46129 (diff) | |
download | markdown-c80490a261431c7dae1a3c1d4ad02f77db98d05e.tar.gz markdown-c80490a261431c7dae1a3c1d4ad02f77db98d05e.tar.bz2 markdown-c80490a261431c7dae1a3c1d4ad02f77db98d05e.zip |
Limit recursion in inlinePatterns to patterns not yet run
Diffstat (limited to 'markdown.py')
-rw-r--r-- | markdown.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/markdown.py b/markdown.py index 9b2d8e7..3263252 100644 --- a/markdown.py +++ b/markdown.py @@ -1477,11 +1477,11 @@ class Markdown: - def _handleInlineWrapper (self, line) : + def _handleInlineWrapper (self, line, patternIndex=0) : parts = [line] - for pattern in self.inlinePatterns : + while patternIndex < len(self.inlinePatterns) : i = 0 @@ -1490,7 +1490,9 @@ class Markdown: x = parts[i] if isinstance(x, (str, unicode)) : - result = self._applyPattern(x, pattern) + result = self._applyPattern(x, \ + self.inlinePatterns[patternIndex], \ + patternIndex ) if result : i -= 1 @@ -1499,6 +1501,7 @@ class Markdown: parts.insert(i+1,y) i += 1 + patternIndex += 1 for i in range(len(parts)) : x = parts[i] @@ -1527,7 +1530,7 @@ class Markdown: return [self.doc.createTextNode(line)] - def _applyPattern(self, line, pattern) : + def _applyPattern(self, line, pattern, patternIndex) : """ Given a pattern name, this function checks if the line fits the pattern, creates the necessary elements, and returns @@ -1561,7 +1564,7 @@ class Markdown: for child in node.childNodes : if isinstance(child, TextNode): - result = self._handleInlineWrapper(child.value) + result = self._handleInlineWrapper(child.value, patternIndex+1) if result: |