fix a bug in parseMarkdown, add tests

This commit is contained in:
rolux 2012-06-23 13:30:33 +02:00
parent 9503eb7c5a
commit 4b0a07387f

View file

@ -372,6 +372,10 @@
Ox.parseMarkdown <f> Parses (a tiny subset of) Markdown.
> Ox.parseMarkdown('*foo* **bar** `baz` ``back`tick``')
'<em>foo</em> <strong>bar</strong> <code>baz</code> <code>back`tick</code>'
> Ox.parseMarkdown('foo\n\nbar\n\nbaz')
'foo<br><br>bar<br><br>baz'
> Ox.parseMarkdown('\n```foo\n\nbar\n\nbaz\n```')
'<pre><code class="foo">bar<br><br>baz</code></pre>'
> Ox.parseMarkdown('<http://example.com>')
'<a href="http://example.com">http://example.com</a>'
> 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, '<br><br>')
.replace(
/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
'<strong>$2</strong>'
@ -431,7 +434,8 @@
function(match, mail) {
return Ox.encodeEmailAddress(mail);
}
);
)
.replace(/\n\n/g, '<br><br>');
};
/*@