aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Wolever <wolever@cs.toronto.edu>2008-02-29 22:22:39 +0000
committerDavid Wolever <wolever@cs.toronto.edu>2008-02-29 22:22:39 +0000
commit34c680a61d0bd83d6b21596e9a086e7db73706e1 (patch)
tree8f265a5db12144eb70912c18716bf1523f085906
parentc33803ad2e84cdce6e4ebf2c66d450216aefbe7f (diff)
downloadmarkdown-34c680a61d0bd83d6b21596e9a086e7db73706e1.tar.gz
markdown-34c680a61d0bd83d6b21596e9a086e7db73706e1.tar.bz2
markdown-34c680a61d0bd83d6b21596e9a086e7db73706e1.zip
Fixed bugs involving greedy/non-greedy regexes
-rw-r--r--markdown.py12
-rw-r--r--tests/markdown-test/benchmark.dat.tmp20
-rw-r--r--tests/misc/benchmark.dat.tmp53
-rw-r--r--tests/misc/strong-with-underscores.html2
-rw-r--r--tests/misc/strong-with-underscores.txt1
5 files changed, 9 insertions, 79 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
diff --git a/tests/markdown-test/benchmark.dat.tmp b/tests/markdown-test/benchmark.dat.tmp
deleted file mode 100644
index 4a43ce5..0000000
--- a/tests/markdown-test/benchmark.dat.tmp
+++ /dev/null
@@ -1,20 +0,0 @@
-construction:0.000000:0.000000
-amps-and-angle-encoding:0.060000:397312.000000
-auto-links:0.070000:0.000000
-backlash-escapes:0.230000:131072.000000
-blockquotes-with-dode-blocks:0.020000:0.000000
-hard-wrapped:0.030000:0.000000
-horizontal-rules:0.160000:0.000000
-inline-html-advanced:0.060000:0.000000
-inline-html-comments:0.070000:0.000000
-inline-html-simple:0.190000:0.000000
-links-inline:0.110000:0.000000
-links-reference:0.120000:0.000000
-literal-quotes:0.080000:0.000000
-markdown-documentation-basics:0.620000:1482752.000000
-markdown-syntax:4.120000:2621440.000000
-nested-blockquotes:0.110000:0.000000
-ordered-and-unordered-list:0.390000:0.000000
-strong-and-em-together:0.130000:0.000000
-tabs:0.140000:0.000000
-tidyness:0.110000:0.000000
diff --git a/tests/misc/benchmark.dat.tmp b/tests/misc/benchmark.dat.tmp
deleted file mode 100644
index a712c3a..0000000
--- a/tests/misc/benchmark.dat.tmp
+++ /dev/null
@@ -1,53 +0,0 @@
-construction:0.000000:0.000000
-adjacent-headers:0.020000:0.000000
-amp-in-url:0.020000:0.000000
-ampersand:0.010000:0.000000
-arabic:0.130000:0.000000
-attributes2:0.030000:0.000000
-bidi:0.280000:0.000000
-blank:0.000000:0.000000
-blank-block-quote:0.010000:0.000000
-blockquote-hr:0.050000:0.000000
-br:0.040000:0.000000
-bracket_re:6.310000:0.000000
-code-first-line:0.010000:0.000000
-comments:0.040000:0.000000
-div:0.040000:0.000000
-email:0.040000:0.000000
-funky-list:0.050000:0.000000
-h1:0.020000:0.000000
-hash:0.040000:0.000000
-headers:0.040000:0.000000
-hline:0.030000:0.000000
-html:0.130000:0.000000
-image:0.070000:0.000000
-image-2:0.090000:0.000000
-image_in_links:0.050000:0.000000
-inside_html:0.050000:0.000000
-japanese:0.120000:0.000000
-lazy-block-quote:0.050000:0.000000
-lists:0.100000:0.000000
-lists2:0.040000:0.000000
-lists3:0.040000:0.000000
-lists4:0.050000:0.000000
-lists5:0.060000:0.000000
-markup-inside-p:0.060000:0.000000
-mismatched-tags:0.040000:0.000000
-more_comments:0.040000:0.000000
-multi-line-tags:0.050000:0.000000
-multi-paragraph-block-quote:0.080000:0.000000
-multi-test:0.140000:0.000000
-multiline-comments:0.070000:0.000000
-normalize:0.060000:0.000000
-numeric-entity:0.070000:0.000000
-php:0.080000:0.000000
-pre:0.070000:0.000000
-russian:0.170000:0.000000
-some-test:0.170000:0.000000
-span:0.100000:0.000000
-stronintags:0.110000:0.000000
-tabs-in-lists:0.140000:0.000000
-two-spaces:0.110000:0.000000
-uche:0.130000:0.000000
-underscores:0.110000:0.000000
-url_spaces:0.090000:0.000000
diff --git a/tests/misc/strong-with-underscores.html b/tests/misc/strong-with-underscores.html
new file mode 100644
index 0000000..0074174
--- /dev/null
+++ b/tests/misc/strong-with-underscores.html
@@ -0,0 +1,2 @@
+<p><strong>this_is_strong</strong>
+</p>
diff --git a/tests/misc/strong-with-underscores.txt b/tests/misc/strong-with-underscores.txt
new file mode 100644
index 0000000..1a3544f
--- /dev/null
+++ b/tests/misc/strong-with-underscores.txt
@@ -0,0 +1 @@
+__this_is_strong__