fix a bug in parseMarkdown, add tests
This commit is contained in:
parent
9503eb7c5a
commit
4b0a07387f
1 changed files with 6 additions and 2 deletions
|
@ -372,6 +372,10 @@
|
||||||
Ox.parseMarkdown <f> Parses (a tiny subset of) Markdown.
|
Ox.parseMarkdown <f> Parses (a tiny subset of) Markdown.
|
||||||
> Ox.parseMarkdown('*foo* **bar** `baz` ``back`tick``')
|
> Ox.parseMarkdown('*foo* **bar** `baz` ``back`tick``')
|
||||||
'<em>foo</em> <strong>bar</strong> <code>baz</code> <code>back`tick</code>'
|
'<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>')
|
> Ox.parseMarkdown('<http://example.com>')
|
||||||
'<a href="http://example.com">http://example.com</a>'
|
'<a href="http://example.com">http://example.com</a>'
|
||||||
> Ox.parseMarkdown('[example](http://example.com "example.com")')
|
> Ox.parseMarkdown('[example](http://example.com "example.com")')
|
||||||
|
@ -390,7 +394,6 @@
|
||||||
Ox.parseMarkdown = function(string) {
|
Ox.parseMarkdown = function(string) {
|
||||||
// see https://github.com/coreyti/showdown/blob/master/src/showdown.js
|
// see https://github.com/coreyti/showdown/blob/master/src/showdown.js
|
||||||
return string.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
|
return string.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
|
||||||
.replace(/\n\n/g, '<br><br>')
|
|
||||||
.replace(
|
.replace(
|
||||||
/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
|
/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,
|
||||||
'<strong>$2</strong>'
|
'<strong>$2</strong>'
|
||||||
|
@ -431,7 +434,8 @@
|
||||||
function(match, mail) {
|
function(match, mail) {
|
||||||
return Ox.encodeEmailAddress(mail);
|
return Ox.encodeEmailAddress(mail);
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
|
.replace(/\n\n/g, '<br><br>');
|
||||||
};
|
};
|
||||||
|
|
||||||
/*@
|
/*@
|
||||||
|
|
Loading…
Reference in a new issue