mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
chore(): code style fix and tests fix due to code style changes
This commit is contained in:
parent
29c108d5a5
commit
79829dbbf1
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.
7
src/angular.js
vendored
7
src/angular.js
vendored
|
@ -9,9 +9,10 @@ if (typeof angular !== 'undefined' && typeof showdown !== 'undefined') {
|
|||
(function (module, showdown) {
|
||||
'use strict';
|
||||
|
||||
module.provider('$showdown', provider).directive('sdModelToHtml',
|
||||
['$showdown', markdownToHtmlDirective]).filter('sdStripHtml',
|
||||
stripHtmlFilter);
|
||||
module
|
||||
.provider('$showdown', provider)
|
||||
.directive('sdModelToHtml',['$showdown', markdownToHtmlDirective])
|
||||
.filter('sdStripHtml', stripHtmlFilter);
|
||||
|
||||
/**
|
||||
* Angular Provider
|
||||
|
|
|
@ -11,6 +11,7 @@ if (typeof module !== 'undefined' && module.exports) {
|
|||
// AMD Loader
|
||||
else if (typeof define === 'function' && define.amd) {
|
||||
define('showdown', function () {
|
||||
'use strict';
|
||||
return showdown;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
showdown.subParser('autoLinks', function (text) {
|
||||
'use strict';
|
||||
|
||||
text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi, "<a href=\"$1\">$1</a>");
|
||||
text = text.replace(/<((https?|ftp|dict):[^'">\s]+)>/gi, '<a href=\"$1\">$1</a>');
|
||||
|
||||
// Email addresses: <address@domain.foo>
|
||||
|
||||
|
@ -19,9 +19,10 @@ showdown.subParser('autoLinks', function (text) {
|
|||
[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+
|
||||
)
|
||||
>
|
||||
/gi, _DoAutoLinks_callback());
|
||||
/gi);
|
||||
*/
|
||||
text = text.replace(/<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi, function (wholeMatch, m1) {
|
||||
var pattern = /<(?:mailto:)?([-.\w]+\@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;
|
||||
text = text.replace(pattern, function (wholeMatch, m1) {
|
||||
var unescapedStr = showdown.subParser('unescapeSpecialChars')(m1);
|
||||
return showdown.subParser('encodeEmailAddress')(unescapedStr);
|
||||
});
|
||||
|
|
|
@ -24,20 +24,20 @@ showdown.subParser('codeBlocks', function (text, options, globals) {
|
|||
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
|
||||
text += '~0';
|
||||
|
||||
text = text.replace(/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g,
|
||||
function (wholeMatch, m1, m2) {
|
||||
var codeblock = m1, nextChar = m2;
|
||||
var pattern = /(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;
|
||||
text = text.replace(pattern, function (wholeMatch, m1, m2) {
|
||||
var codeblock = m1, nextChar = m2;
|
||||
|
||||
codeblock = showdown.subParser('outdent')(codeblock);
|
||||
codeblock = showdown.subParser('encodeCode')(codeblock);
|
||||
codeblock = showdown.subParser('detab')(codeblock);
|
||||
codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
|
||||
codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
|
||||
codeblock = showdown.subParser('outdent')(codeblock);
|
||||
codeblock = showdown.subParser('encodeCode')(codeblock);
|
||||
codeblock = showdown.subParser('detab')(codeblock);
|
||||
codeblock = codeblock.replace(/^\n+/g, ''); // trim leading newlines
|
||||
codeblock = codeblock.replace(/\n+$/g, ''); // trim trailing whitespace
|
||||
|
||||
codeblock = '<pre><code>' + codeblock + '\n</code></pre>';
|
||||
codeblock = '<pre><code>' + codeblock + '\n</code></pre>';
|
||||
|
||||
return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
|
||||
});
|
||||
return showdown.subParser('hashBlock')(codeblock, options, globals) + nextChar;
|
||||
});
|
||||
|
||||
// attacklab: strip sentinel
|
||||
text = text.replace(/~0/, '');
|
||||
|
|
|
@ -16,7 +16,8 @@ showdown.subParser('detab', function (text) {
|
|||
|
||||
// use the sentinel to anchor our regex so it doesn't explode
|
||||
text = text.replace(/~B(.+?)~A/g, function (wholeMatch, m1) {
|
||||
var leadingText = m1, numSpaces = 4 - leadingText.length % 4; // g_tab_width
|
||||
var leadingText = m1,
|
||||
numSpaces = 4 - leadingText.length % 4; // g_tab_width
|
||||
|
||||
// there *must* be a better way to do this:
|
||||
for (var i = 0; i < numSpaces; i++) {
|
||||
|
|
|
@ -29,5 +29,4 @@ showdown.subParser('encodeCode', function (text) {
|
|||
// ---
|
||||
|
||||
return text;
|
||||
|
||||
});
|
||||
|
|
|
@ -23,9 +23,11 @@ showdown.subParser('encodeEmailAddress', function (addr) {
|
|||
var encode = [
|
||||
function (ch) {
|
||||
return '&#' + ch.charCodeAt(0) + ';';
|
||||
}, function (ch) {
|
||||
},
|
||||
function (ch) {
|
||||
return '&#x' + ch.charCodeAt(0).toString(16) + ';';
|
||||
}, function (ch) {
|
||||
},
|
||||
function (ch) {
|
||||
return ch;
|
||||
}
|
||||
];
|
||||
|
@ -51,5 +53,4 @@ showdown.subParser('encodeEmailAddress', function (addr) {
|
|||
addr = addr.replace(/">.+:/g, '">'); // strip the mailto: from the visible part
|
||||
|
||||
return addr;
|
||||
|
||||
});
|
||||
|
|
|
@ -18,7 +18,9 @@ showdown.subParser('githubCodeBlocks', function (text, options, globals) {
|
|||
text += '~0';
|
||||
|
||||
text = text.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g, function (wholeMatch, m1, m2) {
|
||||
var language = m1, codeblock = m2, end = '\n';
|
||||
var language = m1,
|
||||
codeblock = m2,
|
||||
end = '\n';
|
||||
|
||||
if (options.omitExtraWLInCodeBlocks) {
|
||||
end = '';
|
||||
|
|
|
@ -15,17 +15,15 @@ showdown.subParser('headers', function (text, options, globals) {
|
|||
// --------
|
||||
//
|
||||
text = text.replace(/^(.+)[ \t]*\n=+[ \t]*\n+/gm, function (wholeMatch, m1) {
|
||||
return showdown.subParser('hashBlock')('<h1 id="' + headerId(m1) + '">' + showdown.subParser('spanGamut')(m1,
|
||||
options,
|
||||
globals) + '</h1>',
|
||||
options, globals);
|
||||
var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
|
||||
hashBlock = '<h1 id="' + headerId(m1) + '">' + spanGamut + '</h1>';
|
||||
return showdown.subParser('hashBlock')(hashBlock, options, globals);
|
||||
});
|
||||
|
||||
text = text.replace(/^(.+)[ \t]*\n-+[ \t]*\n+/gm, function (matchFound, m1) {
|
||||
return showdown.subParser('hashBlock')('<h2 id="' + headerId(m1) + '">' + showdown.subParser('spanGamut')(m1,
|
||||
options,
|
||||
globals) + '</h2>',
|
||||
options, globals);
|
||||
var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
|
||||
hashBlock = '<h2 id="' + headerId(m1) + '">' + spanGamut + '</h2>';
|
||||
return showdown.subParser('hashBlock')(hashBlock, options, globals);
|
||||
});
|
||||
|
||||
// atx-style headers:
|
||||
|
@ -48,8 +46,8 @@ showdown.subParser('headers', function (text, options, globals) {
|
|||
*/
|
||||
|
||||
text = text.replace(/^(\#{1,6})[ \t]*(.+?)[ \t]*\#*\n+/gm, function (wholeMatch, m1, m2) {
|
||||
var span = showdown.subParser('spanGamut')(m2, options,
|
||||
globals), header = '<h' + m1.length + ' id="' + headerId(m2) + '">' + span + '</h' + m1.length + '>';
|
||||
var span = showdown.subParser('spanGamut')(m2, options, globals),
|
||||
header = '<h' + m1.length + ' id="' + headerId(m2) + '">' + span + '</h' + m1.length + '>';
|
||||
|
||||
return showdown.subParser('hashBlock')(header, options, globals);
|
||||
});
|
||||
|
|
|
@ -11,7 +11,12 @@ showdown.subParser('images', function (text, options, globals) {
|
|||
var writeImageTag = function (wholeMatch, m1, m2, m3, m4, m5, m6, m7) {
|
||||
|
||||
wholeMatch = m1;
|
||||
var altText = m2, linkId = m3.toLowerCase(), url = m4, title = m7, gUrls = globals.gUrls, gTitles = globals.gTitles;
|
||||
var altText = m2,
|
||||
linkId = m3.toLowerCase(),
|
||||
url = m4,
|
||||
title = m7,
|
||||
gUrls = globals.gUrls,
|
||||
gTitles = globals.gTitles;
|
||||
|
||||
if (!title) {
|
||||
title = '';
|
||||
|
|
|
@ -109,7 +109,8 @@ showdown.subParser('lists', function (text, options, globals) {
|
|||
|
||||
if (globals.gListLevel) {
|
||||
text = text.replace(wholeList, function (wholeMatch, m1, m2) {
|
||||
var list = m1, listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
|
||||
var list = m1,
|
||||
listType = (m2.search(/[*+-]/g) > -1) ? 'ul' : 'ol';
|
||||
|
||||
// Turn double returns into triple returns, so that we can make a
|
||||
// paragraph for the last item in a list, if necessary:
|
||||
|
@ -132,8 +133,9 @@ showdown.subParser('lists', function (text, options, globals) {
|
|||
|
||||
// Turn double returns into triple returns, so that we can make a
|
||||
// paragraph for the last item in a list, if necessary:
|
||||
var list = m2.replace(/\n{2,}/g,
|
||||
'\n\n\n'), listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol', result = processListItems(list);
|
||||
var list = m2.replace(/\n{2,}/g, '\n\n\n'),
|
||||
listType = (m3.search(/[*+-]/g) > -1) ? 'ul' : 'ol',
|
||||
result = processListItems(list);
|
||||
|
||||
return m1 + '<' + listType + '>\n' + result + '</' + listType + '>\n';
|
||||
});
|
||||
|
|
|
@ -30,25 +30,26 @@
|
|||
showdown.subParser('stripLinkDefinitions', function (text, options, globals) {
|
||||
'use strict';
|
||||
|
||||
var regex = /^[ ]{0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm;
|
||||
|
||||
// attacklab: sentinel workarounds for lack of \A and \Z, safari\khtml bug
|
||||
text += '~0';
|
||||
|
||||
text = text.replace(/^[ ]{0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|(?=~0))/gm,
|
||||
function (wholeMatch, m1, m2, m3, m4) {
|
||||
m1 = m1.toLowerCase();
|
||||
globals.gUrls[m1] = showdown.subParser('encodeAmpsAndAngles')(m2); // Link IDs are
|
||||
// case-insensitive
|
||||
if (m3) {
|
||||
// Oops, found blank lines, so it's not a title.
|
||||
// Put back the parenthetical statement we stole.
|
||||
return m3 + m4;
|
||||
} else if (m4) {
|
||||
globals.gTitles[m1] = m4.replace(/"/g, '"');
|
||||
}
|
||||
text = text.replace(regex, function (wholeMatch, m1, m2, m3, m4) {
|
||||
m1 = m1.toLowerCase();
|
||||
globals.gUrls[m1] = showdown.subParser('encodeAmpsAndAngles')(m2); // Link IDs are case-insensitive
|
||||
if (m3) {
|
||||
// Oops, found blank lines, so it's not a title.
|
||||
// Put back the parenthetical statement we stole.
|
||||
return m3 + m4;
|
||||
|
||||
// Completely remove the definition from the text
|
||||
return '';
|
||||
});
|
||||
} else if (m4) {
|
||||
globals.gTitles[m1] = m4.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
// Completely remove the definition from the text
|
||||
return '';
|
||||
});
|
||||
|
||||
// attacklab: strip sentinel
|
||||
text = text.replace(/~0/, '');
|
||||
|
|
|
@ -1 +1 @@
|
|||
It happened in 1986\. What a great season.
|
||||
It happened in 1986\. What a great season.
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<hr/>
|
||||
<hr />
|
||||
|
||||
<hr/>
|
||||
<hr />
|
||||
|
||||
<hr/>
|
||||
<hr />
|
||||
|
||||
<hr/>
|
||||
<hr />
|
||||
|
||||
<hr/>
|
||||
<hr />
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
<aside>ignore me</aside>
|
||||
|
||||
<article>read
|
||||
me
|
||||
</article>
|
||||
me</article>
|
||||
|
||||
<aside>
|
||||
ignore me
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<p><img src="/path/to/img.jpg" alt="Alt text" title=""/></p>
|
||||
<p><img src="/path/to/img.jpg" alt="Alt text" title="" /></p>
|
||||
|
||||
<p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title"/></p>
|
||||
<p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title" /></p>
|
||||
|
||||
<p><img src="url/to/image" alt="Alt text" title="Optional title attribute"/></p>
|
||||
<p><img src="url/to/image" alt="Alt text" title="Optional title attribute" /></p>
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
<p>Search the web at <a href="http://google.com/">Google</a> or <a href="http://daringfireball.net/">Daring Fireball</a>.
|
||||
</p>
|
||||
<p>Search the web at <a href="http://google.com/">Google</a> or <a href="http://daringfireball.net/">Daring Fireball</a>.</p>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<style>
|
||||
p {
|
||||
line-height: 20px;
|
||||
}
|
||||
p { line-height: 20px; }
|
||||
</style>
|
||||
|
||||
<p>An exciting sentence.</p>
|
||||
|
|
|
@ -4,6 +4,5 @@
|
|||
<blockquote>
|
||||
<p>This is a blockquote
|
||||
inside a list item.</p>
|
||||
</blockquote>
|
||||
</li>
|
||||
</blockquote></li>
|
||||
</ul>
|
||||
|
|
|
@ -2,6 +2,5 @@
|
|||
<li><p>A list item with code:</p>
|
||||
|
||||
<pre><code>alert('Hello world!');
|
||||
</code></pre>
|
||||
</li>
|
||||
</code></pre></li>
|
||||
</ul>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<ul>
|
||||
<li>This line spans
|
||||
more than one line and is lazy
|
||||
</li>
|
||||
more than one line and is lazy</li>
|
||||
<li>Similar to this line</li>
|
||||
</ul>
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
<p>There's an <a href="http://en.memory-alpha.org/wiki/Darmok_(episode)">episode</a> of Star Trek: The Next Generation
|
||||
</p>
|
||||
<p>There's an <a href="http://en.memory-alpha.org/wiki/Darmok_(episode)">episode</a> of Star Trek: The Next Generation</p>
|
||||
|
|
|
@ -1,2 +1 @@
|
|||
|
||||
There's an [episode](http://en.memory-alpha.org/wiki/Darmok_(episode)) of Star Trek: The Next Generation
|
Loading…
Reference in New Issue
Block a user