From 34c680a61d0bd83d6b21596e9a086e7db73706e1 Mon Sep 17 00:00:00 2001 From: David Wolever Date: Fri, 29 Feb 2008 22:22:39 +0000 Subject: Fixed bugs involving greedy/non-greedy regexes --- markdown.py | 12 ++++---- tests/markdown-test/benchmark.dat.tmp | 20 ------------- tests/misc/benchmark.dat.tmp | 53 --------------------------------- tests/misc/strong-with-underscores.html | 2 ++ tests/misc/strong-with-underscores.txt | 1 + 5 files changed, 9 insertions(+), 79 deletions(-) delete mode 100644 tests/markdown-test/benchmark.dat.tmp delete mode 100644 tests/misc/benchmark.dat.tmp create mode 100644 tests/misc/strong-with-underscores.html create mode 100644 tests/misc/strong-with-underscores.txt 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'(?\)' # [text]() @@ -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 @@ +

this_is_strong +

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__ -- cgit v1.2.3