From 4b0a07387f13fbc26f14079521b7bb7cda2f69b2 Mon Sep 17 00:00:00 2001 From: rolux Date: Sat, 23 Jun 2012 13:30:33 +0200 Subject: [PATCH] fix a bug in parseMarkdown, add tests --- source/Ox/js/HTML.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/Ox/js/HTML.js b/source/Ox/js/HTML.js index b4b0b530..43c99af2 100644 --- a/source/Ox/js/HTML.js +++ b/source/Ox/js/HTML.js @@ -372,6 +372,10 @@ Ox.parseMarkdown Parses (a tiny subset of) Markdown. > Ox.parseMarkdown('*foo* **bar** `baz` ``back`tick``') 'foo bar baz back`tick' + > Ox.parseMarkdown('foo\n\nbar\n\nbaz') + 'foo

bar

baz' + > Ox.parseMarkdown('\n```foo\n\nbar\n\nbaz\n```') + '
bar

baz
' > Ox.parseMarkdown('') 'http://example.com' > Ox.parseMarkdown('[example](http://example.com "example.com")') @@ -390,7 +394,6 @@ Ox.parseMarkdown = function(string) { // see https://github.com/coreyti/showdown/blob/master/src/showdown.js return string.replace(/\r\n/g, '\n').replace(/\r/g, '\n') - .replace(/\n\n/g, '

') .replace( /(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g, '$2' @@ -431,7 +434,8 @@ function(match, mail) { return Ox.encodeEmailAddress(mail); } - ); + ) + .replace(/\n\n/g, '

'); }; /*@