diff options
author | David Wolever <wolever@cs.toronto.edu> | 2008-02-29 22:22:39 +0000 |
---|---|---|
committer | David Wolever <wolever@cs.toronto.edu> | 2008-02-29 22:22:39 +0000 |
commit | 34c680a61d0bd83d6b21596e9a086e7db73706e1 (patch) | |
tree | 8f265a5db12144eb70912c18716bf1523f085906 /markdown.py | |
parent | c33803ad2e84cdce6e4ebf2c66d450216aefbe7f (diff) | |
download | markdown-34c680a61d0bd83d6b21596e9a086e7db73706e1.tar.gz markdown-34c680a61d0bd83d6b21596e9a086e7db73706e1.tar.bz2 markdown-34c680a61d0bd83d6b21596e9a086e7db73706e1.zip |
Fixed bugs involving greedy/non-greedy regexes
Diffstat (limited to 'markdown.py')
-rw-r--r-- | markdown.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/markdown.py b/markdown.py index 1681a98..97038ba 100644 --- a/markdown.py +++ b/markdown.py @@ -686,19 +686,19 @@ BRK = ( r'\[(' NOIMG = r'(?<!\!)' BACKTICK_RE = r'\`([^\`]*)\`' # `e= m*c^2` -DOUBLE_BACKTICK_RE = r'\`\`(.*)\`\`' # ``e=f("`")`` +DOUBLE_BACKTICK_RE = r'\`\`(.*?)\`\`' # ``e=f("`")`` ESCAPE_RE = r'\\(.)' # \< EMPHASIS_RE = r'\*([^\*]*)\*' # *emphasis* -STRONG_RE = r'\*\*(.*)\*\*' # **strong** -STRONG_EM_RE = r'\*\*\*([^_]*)\*\*\*' # ***strong*** +STRONG_RE = r'\*\*(.*?)\*\*' # **strong** +STRONG_EM_RE = r'\*\*\*(.*?)\*\*\*' # ***strong*** if SMART_EMPHASIS: EMPHASIS_2_RE = r'(?<!\S)_(\S[^_]*)_' # _emphasis_ else: EMPHASIS_2_RE = r'_([^_]*)_' # _emphasis_ -STRONG_2_RE = r'__([^_]*)__' # __strong__ -STRONG_EM_2_RE = r'___([^_]*)___' # ___strong___ +STRONG_2_RE = r'__(.*?)__' # __strong__ +STRONG_EM_2_RE = r'___(.*?)___' # ___strong___ LINK_RE = NOIMG + BRK + r'\s*\(([^\)]*)\)' # [text](url) LINK_ANGLED_RE = NOIMG + BRK + r'\s*\(<([^\)]*)>\)' # [text](<url>) @@ -718,7 +718,7 @@ class Pattern: def __init__ (self, pattern): self.pattern = pattern - self.compiled_re = re.compile("^(.*)%s(.*)$" % pattern, re.DOTALL) + self.compiled_re = re.compile("^(.*?)%s(.*?)$" % pattern, re.DOTALL) def getCompiledRegExp (self): return self.compiled_re |