mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
Merge branch 'develop'
This commit is contained in:
commit
eeccee7038
|
@ -89,7 +89,7 @@ module.exports = function (grunt) {
|
|||
options: {
|
||||
globals: ['should'],
|
||||
timeout: 3000,
|
||||
ignoreLeaks: false,
|
||||
ignoreLeaks: true,
|
||||
reporter: 'spec'
|
||||
}
|
||||
},
|
||||
|
|
BIN
dist/showdown.js
vendored
BIN
dist/showdown.js
vendored
Binary file not shown.
BIN
dist/showdown.js.map
vendored
BIN
dist/showdown.js.map
vendored
Binary file not shown.
BIN
dist/showdown.min.js
vendored
BIN
dist/showdown.min.js
vendored
Binary file not shown.
BIN
dist/showdown.min.js.map
vendored
BIN
dist/showdown.min.js.map
vendored
Binary file not shown.
|
@ -26,6 +26,14 @@
|
|||
showdown.subParser('codeSpans', function (text) {
|
||||
'use strict';
|
||||
|
||||
//special case -> literal html code tag
|
||||
text = text.replace(/(<code[^><]*?>)([^]*?)<\/code>/g, function (wholeMatch, tag, c) {
|
||||
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
|
||||
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
|
||||
c = showdown.subParser('encodeCode')(c);
|
||||
return tag + c + '</code>';
|
||||
});
|
||||
|
||||
/*
|
||||
text = text.replace(/
|
||||
(^|[^\\]) // Character before opening ` can't be a backslash
|
||||
|
@ -38,15 +46,15 @@ showdown.subParser('codeSpans', function (text) {
|
|||
(?!`)
|
||||
/gm, function(){...});
|
||||
*/
|
||||
|
||||
text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm, function (wholeMatch, m1, m2, m3) {
|
||||
var c = m3;
|
||||
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
|
||||
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
|
||||
c = showdown.subParser('encodeCode')(c);
|
||||
return m1 + '<code>' + c + '</code>';
|
||||
});
|
||||
text = text.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,
|
||||
function (wholeMatch, m1, m2, m3) {
|
||||
var c = m3;
|
||||
c = c.replace(/^([ \t]*)/g, ''); // leading whitespace
|
||||
c = c.replace(/[ \t]*$/g, ''); // trailing whitespace
|
||||
c = showdown.subParser('encodeCode')(c);
|
||||
return m1 + '<code>' + c + '</code>';
|
||||
}
|
||||
);
|
||||
|
||||
return text;
|
||||
|
||||
});
|
||||
|
|
|
@ -41,6 +41,7 @@ showdown.subParser('images', function (text, options, globals) {
|
|||
}
|
||||
|
||||
altText = altText.replace(/"/g, '"');
|
||||
altText = showdown.helper.escapeCharacters(altText, '*_', false);
|
||||
url = showdown.helper.escapeCharacters(url, '*_', false);
|
||||
var result = '<img src="' + url + '" alt="' + altText + '"';
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ showdown.subParser('italicsAndBold', function (text, options) {
|
|||
if (options.literalMidWordUnderscores) {
|
||||
//underscores
|
||||
// Since we are consuming a \s character, we need to add it
|
||||
text = text.replace(/(^|\s)__(?=\S)([^]+?)__(?=\s|$)/gm, '$1<strong>$2</strong>');
|
||||
text = text.replace(/(^|\s)_(?=\S)([^]+?)_(?=\s|$)/gm, '$1<em>$2</em>');
|
||||
text = text.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm, '$1<strong>$2</strong>');
|
||||
text = text.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm, '$1<em>$2</em>');
|
||||
//asterisks
|
||||
text = text.replace(/\*\*(?=\S)([^]+?)\*\*/g, '<strong>$1</strong>');
|
||||
text = text.replace(/\*(?=\S)([^]+?)\*/g, '<em>$1</em>');
|
||||
|
|
4
test/bootstrap.js
vendored
4
test/bootstrap.js
vendored
|
@ -82,8 +82,8 @@
|
|||
testCase.actual = beautify(testCase.actual, beauOptions);
|
||||
|
||||
// Normalize line returns
|
||||
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, os.EOL);
|
||||
testCase.actual = testCase.actual.replace(/(\r\n)|\n|\r/g, os.EOL);
|
||||
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
|
||||
testCase.actual = testCase.actual.replace(/(\r\n)|\n|\r/g, '\n');
|
||||
|
||||
return testCase;
|
||||
}
|
||||
|
|
1
test/features/autolink_and_disallow_underscores.html
Normal file
1
test/features/autolink_and_disallow_underscores.html
Normal file
|
@ -0,0 +1 @@
|
|||
<p><a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">http://en.wikipedia.org/wiki/Tourism_in_Germany</a></p>
|
1
test/features/autolink_and_disallow_underscores.md
Normal file
1
test/features/autolink_and_disallow_underscores.md
Normal file
|
@ -0,0 +1 @@
|
|||
http://en.wikipedia.org/wiki/Tourism_in_Germany
|
40
test/ghost/markdown-magic.html
Normal file
40
test/ghost/markdown-magic.html
Normal file
|
@ -0,0 +1,40 @@
|
|||
<h3 id="automaticlinks">Automatic Links</h3>
|
||||
|
||||
<pre><code>https://ghost.org
|
||||
</code></pre>
|
||||
|
||||
<p><a href="https://ghost.org">https://ghost.org</a></p>
|
||||
|
||||
<h3 id="markdownfootnotes">Markdown Footnotes</h3>
|
||||
|
||||
<pre><code>The quick brown fox[^1] jumped over the lazy dog[^2].
|
||||
|
||||
[^1]: Foxes are red
|
||||
[^2]: Dogs are usually not red
|
||||
</code></pre>
|
||||
|
||||
<p>The quick brown fox[^1] jumped over the lazy dog[^2].</p>
|
||||
|
||||
<h3 id="syntaxhighlighting">Syntax Highlighting</h3>
|
||||
|
||||
<pre><code>```language-javascript
|
||||
[...]
|
||||
```
|
||||
</code></pre>
|
||||
|
||||
<p>Combined with <a href="http://prismjs.com/">Prism.js</a> in the Ghost theme:</p>
|
||||
|
||||
<pre><code class="language-javascript language-language-javascript">// # Notifications API
|
||||
// RESTful API for creating notifications
|
||||
var Promise = require('bluebird'),
|
||||
_ = require('lodash'),
|
||||
canThis = require('../permissions').canThis,
|
||||
errors = require('../errors'),
|
||||
utils = require('./utils'),
|
||||
|
||||
// Holds the persistent notifications
|
||||
notificationsStore = [],
|
||||
// Holds the last used id
|
||||
notificationCounter = 0,
|
||||
notifications;
|
||||
</code></pre>
|
43
test/ghost/markdown-magic.md
Normal file
43
test/ghost/markdown-magic.md
Normal file
|
@ -0,0 +1,43 @@
|
|||
### Automatic Links
|
||||
|
||||
```
|
||||
https://ghost.org
|
||||
```
|
||||
|
||||
https://ghost.org
|
||||
|
||||
### Markdown Footnotes
|
||||
|
||||
```
|
||||
The quick brown fox[^1] jumped over the lazy dog[^2].
|
||||
|
||||
[^1]: Foxes are red
|
||||
[^2]: Dogs are usually not red
|
||||
```
|
||||
|
||||
The quick brown fox[^1] jumped over the lazy dog[^2].
|
||||
|
||||
|
||||
### Syntax Highlighting
|
||||
|
||||
```language-javascript
|
||||
[...]
|
||||
```
|
||||
|
||||
Combined with [Prism.js](http://prismjs.com/) in the Ghost theme:
|
||||
|
||||
```language-javascript
|
||||
// # Notifications API
|
||||
// RESTful API for creating notifications
|
||||
var Promise = require('bluebird'),
|
||||
_ = require('lodash'),
|
||||
canThis = require('../permissions').canThis,
|
||||
errors = require('../errors'),
|
||||
utils = require('./utils'),
|
||||
|
||||
// Holds the persistent notifications
|
||||
notificationsStore = [],
|
||||
// Holds the last used id
|
||||
notificationCounter = 0,
|
||||
notifications;
|
||||
```
|
78
test/ghost/underscore.html
Normal file
78
test/ghost/underscore.html
Normal file
|
@ -0,0 +1,78 @@
|
|||
<p>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</p>
|
||||
|
||||
<p><em>baz_bar_foo</em></p>
|
||||
|
||||
<p><strong>baz_bar_foo</strong></p>
|
||||
|
||||
<p><strong><em>baz_bar_foo</em></strong></p>
|
||||
|
||||
<p>baz bar foo <em>baz_bar_foo foo bar baz</em> and foo</p>
|
||||
|
||||
<p>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</p>
|
||||
|
||||
<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>
|
||||
|
||||
<pre><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
</code></pre>
|
||||
|
||||
<pre><code class="html language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
</code></pre>
|
||||
|
||||
<pre>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</pre>
|
||||
|
||||
<pre><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>
|
||||
|
||||
<pre class="lang-html"><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>
|
||||
|
||||
<script>
|
||||
var strike = "foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo";
|
||||
var foo_bar_baz_bar_foo = "foo_bar_";
|
||||
</script>
|
||||
|
||||
<p><a href="http://myurl.com/foo_bar_baz_bar_foo">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</a></p>
|
||||
|
||||
<p><a href="http://myurl.com/foo_bar_baz_bar_foo" title="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</a></p>
|
||||
|
||||
<p><img src="http://myurl.com/foo_bar_baz_bar_foo" alt="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo"></p>
|
||||
|
||||
<h2 id="foo_bar_bazfoo_bar_baz_bar_foo_foo_barbaz_bar_baz_foo">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</h2>
|
||||
|
||||
<h3 id="foo_bar_bazfoo_bar_baz_bar_foo_foo_barbaz_bar_baz_foo-1">foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</h3>
|
||||
|
||||
<ol>
|
||||
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
|
||||
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
|
||||
</ol>
|
||||
|
||||
<blockquote>
|
||||
<p>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</p>
|
||||
</blockquote>
|
||||
|
||||
<ul>
|
||||
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
|
||||
<li>foo_bar_baz foo_bar_baz_bar_foo <em>foo_bar baz_bar</em> baz_foo</li>
|
||||
</ul>
|
||||
|
||||
<hr />
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">http://en.wikipedia.org/wiki/Tourism_in_Germany</a></p>
|
||||
|
||||
<p><a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">an example</a></p>
|
||||
|
||||
<p>Another <a href="http://en.wikipedia.org/wiki/Tourism_in_Germany">example</a> of a link</p>
|
||||
|
||||
<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>
|
||||
|
||||
<!-- These two cases still have bad <ems> because showdown handles them incorrectly -->
|
||||
|
||||
<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>
|
||||
|
||||
<p><img src="http://myurl.com/foo_bar_baz_bar_foo" alt="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo"/></p>
|
||||
|
||||
<p><a href="http://myurl.com/foo_bar_baz_bar_foo">http://myurl.com/foo_bar_baz_bar_foo</a></p>
|
||||
|
||||
<p><a href="http://myurl.com/foo_bar_baz_bar_foo">http://myurl.com/foo_bar_baz_bar_foo</a></p>
|
||||
|
||||
<p><em>italics</em>.</p>
|
||||
|
||||
<p><em>italics</em> .</p>
|
76
test/ghost/underscore.md
Normal file
76
test/ghost/underscore.md
Normal file
|
@ -0,0 +1,76 @@
|
|||
foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
|
||||
_baz_bar_foo_
|
||||
|
||||
__baz_bar_foo__
|
||||
|
||||
___baz_bar_foo___
|
||||
|
||||
baz bar foo _baz_bar_foo foo bar baz_ and foo
|
||||
|
||||
foo\_bar\_baz foo\_bar\_baz\_bar\_foo \_foo\_bar baz\_bar\_ baz\_foo
|
||||
|
||||
`foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo`
|
||||
|
||||
|
||||
foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
|
||||
|
||||
```html
|
||||
foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
```
|
||||
|
||||
<pre>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</pre>
|
||||
|
||||
<pre><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>
|
||||
|
||||
<pre class="lang-html"><code class="language-html">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></pre>
|
||||
|
||||
<script>
|
||||
var strike = "foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo";
|
||||
var foo_bar_baz_bar_foo = "foo_bar_";
|
||||
</script>
|
||||
|
||||
[foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo](http://myurl.com/foo_bar_baz_bar_foo)
|
||||
|
||||
<a href="http://myurl.com/foo_bar_baz_bar_foo" title="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo">foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</a>
|
||||
|
||||
<img src="http://myurl.com/foo_bar_baz_bar_foo" alt="foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo">
|
||||
|
||||
foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
-----
|
||||
|
||||
### foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
|
||||
1. foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
2. foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
|
||||
> foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
|
||||
* foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
* foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo
|
||||
|
||||
-------
|
||||
|
||||
http://en.wikipedia.org/wiki/Tourism_in_Germany
|
||||
|
||||
[an example] [wiki]
|
||||
|
||||
Another [example][wiki] of a link
|
||||
|
||||
[wiki]: http://en.wikipedia.org/wiki/Tourism_in_Germany
|
||||
|
||||
<p><code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code></p>
|
||||
|
||||
<!-- These two cases still have bad <ems> because showdown handles them incorrectly -->
|
||||
<code>foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo</code>
|
||||
|
||||
![foo_bar_baz foo_bar_baz_bar_foo _foo_bar baz_bar_ baz_foo](http://myurl.com/foo_bar_baz_bar_foo)
|
||||
|
||||
http://myurl.com/foo_bar_baz_bar_foo
|
||||
|
||||
<http://myurl.com/foo_bar_baz_bar_foo>
|
||||
|
||||
_italics_.
|
||||
|
||||
_italics_ .
|
|
@ -25,6 +25,8 @@ describe('makeHtml() features testsuite', function () {
|
|||
converter = new showdown.Converter({ghCodeBlocks: false});
|
||||
} else if (testsuite[i].name === '#164.4.tasklists') {
|
||||
converter = new showdown.Converter({tasklists: true});
|
||||
} else if (testsuite[i].name === 'autolink_and_disallow_underscores') {
|
||||
converter = new showdown.Converter({literalMidWordUnderscores: true, simplifiedAutoLink: true});
|
||||
} else {
|
||||
converter = new showdown.Converter();
|
||||
}
|
||||
|
|
22
test/node/testsuite.ghost.js
Normal file
22
test/node/testsuite.ghost.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
/**
|
||||
* Created by Estevao on 14-07-2015.
|
||||
*/
|
||||
var bootstrap = require('../bootstrap.js'),
|
||||
converter = new bootstrap.showdown.Converter({
|
||||
strikethrough: true,
|
||||
literalMidWordUnderscores: true,
|
||||
simplifiedAutoLink: true,
|
||||
tables: true,
|
||||
parseImgDimensions: true, //extra
|
||||
tasklists: true //extra
|
||||
}),
|
||||
assertion = bootstrap.assertion,
|
||||
testsuite = bootstrap.getTestSuite('test/ghost/');
|
||||
|
||||
//MD-Testsuite (borrowed from karlcow/markdown-testsuite)
|
||||
describe('makeHtml() ghost testsuite', function () {
|
||||
'use strict';
|
||||
for (var i = 0; i < testsuite.length; ++i) {
|
||||
it(testsuite[i].name, assertion(testsuite[i], converter));
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user