chore(): code style fix and tests fix due to code style changes

This commit is contained in:
Estevão Soares dos Santos 2015-01-19 12:04:22 +00:00
parent 29c108d5a5
commit 79829dbbf1
27 changed files with 81 additions and 78 deletions

BIN
dist/showdown.js vendored

Binary file not shown.

BIN
dist/showdown.js.map vendored

Binary file not shown.

BIN
dist/showdown.min.js vendored

Binary file not shown.

Binary file not shown.

7
src/angular.js vendored
View File

@ -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

View File

@ -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;
});
}

View File

@ -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);
});

View File

@ -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/, '');

View File

@ -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++) {

View File

@ -29,5 +29,4 @@ showdown.subParser('encodeCode', function (text) {
// ---
return text;
});

View File

@ -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;
});

View File

@ -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 = '';

View File

@ -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);
});

View File

@ -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 = '';

View File

@ -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';
});

View File

@ -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, '&quot;');
}
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, '&quot;');
}
// Completely remove the definition from the text
return '';
});
// attacklab: strip sentinel
text = text.replace(/~0/, '');

View File

@ -1 +1 @@
It happened in 1986\. What a great season.
It happened in 1986\. What a great season.

View File

@ -1,9 +1,9 @@
<hr/>
<hr />
<hr/>
<hr />
<hr/>
<hr />
<hr/>
<hr />
<hr/>
<hr />

View File

@ -13,8 +13,7 @@
<aside>ignore me</aside>
<article>read
me
</article>
me</article>
<aside>
ignore me

View File

@ -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>

View File

@ -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>

View File

@ -1,7 +1,5 @@
<style>
p {
line-height: 20px;
}
p { line-height: 20px; }
</style>
<p>An exciting sentence.</p>

View File

@ -4,6 +4,5 @@
<blockquote>
<p>This is a blockquote
inside a list item.</p>
</blockquote>
</li>
</blockquote></li>
</ul>

View File

@ -2,6 +2,5 @@
<li><p>A list item with code:</p>
<pre><code>alert('Hello world!');
</code></pre>
</li>
</code></pre></li>
</ul>

View File

@ -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>

View File

@ -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>

View File

@ -1,2 +1 @@
There's an [episode](http://en.memory-alpha.org/wiki/Darmok_(episode)) of Star Trek: The Next Generation
There's an [episode](http://en.memory-alpha.org/wiki/Darmok_(episode)) of Star Trek: The Next Generation