mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
chore(): code fix to pass jscs linter
This commit is contained in:
parent
a79f581094
commit
0da9626408
9
src/angular.js
vendored
9
src/angular.js
vendored
|
@ -1,8 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Tivie on 04-11-2014.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
//Check if AngularJs and Showdown is defined and only load ng-Showdown if both are present
|
//Check if AngularJs and Showdown is defined and only load ng-Showdown if both are present
|
||||||
if (typeof angular !== 'undefined' && typeof showdown !== 'undefined') {
|
if (typeof angular !== 'undefined' && typeof showdown !== 'undefined') {
|
||||||
|
|
||||||
|
@ -11,7 +6,7 @@ if (typeof angular !== 'undefined' && typeof showdown !== 'undefined') {
|
||||||
|
|
||||||
module
|
module
|
||||||
.provider('$showdown', provider)
|
.provider('$showdown', provider)
|
||||||
.directive('sdModelToHtml',['$showdown', markdownToHtmlDirective])
|
.directive('sdModelToHtml', ['$showdown', markdownToHtmlDirective])
|
||||||
.filter('sdStripHtml', stripHtmlFilter);
|
.filter('sdStripHtml', stripHtmlFilter);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +99,7 @@ if (typeof angular !== 'undefined' && typeof showdown !== 'undefined') {
|
||||||
* Usage example:
|
* Usage example:
|
||||||
* <div sd-md-to-html-model="markdownText" ></div>
|
* <div sd-md-to-html-model="markdownText" ></div>
|
||||||
*
|
*
|
||||||
* @param $showdown
|
* @param {showdown.Converter} $showdown
|
||||||
* @returns {*}
|
* @returns {*}
|
||||||
*/
|
*/
|
||||||
function markdownToHtmlDirective($showdown) {
|
function markdownToHtmlDirective($showdown) {
|
||||||
|
|
116
src/helpers.js
116
src/helpers.js
|
@ -1,13 +1,27 @@
|
||||||
/**
|
/**
|
||||||
* Created by Estevao on 11-01-2015.
|
* showdownjs helper functions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function isString(a) {
|
if (!showdown.hasOwnProperty('helper')) {
|
||||||
'use strict';
|
showdown.helper = {};
|
||||||
return (typeof a === 'string' || a instanceof String);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function forEach(obj, callback) {
|
/**
|
||||||
|
* Check if var is string
|
||||||
|
* @param {string} a
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
showdown.helper.isString = function isString(a) {
|
||||||
|
'use strict';
|
||||||
|
return (typeof a === 'string' || a instanceof String);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ForEach helper function
|
||||||
|
* @param {*} obj
|
||||||
|
* @param {function} callback
|
||||||
|
*/
|
||||||
|
showdown.helper.forEach = function forEach(obj, callback) {
|
||||||
'use strict';
|
'use strict';
|
||||||
if (typeof obj.forEach === 'function') {
|
if (typeof obj.forEach === 'function') {
|
||||||
obj.forEach(callback);
|
obj.forEach(callback);
|
||||||
|
@ -17,25 +31,51 @@ function forEach(obj, callback) {
|
||||||
callback(obj[i], i, obj);
|
callback(obj[i], i, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
function isArray(a) {
|
/**
|
||||||
|
* isArray helper function
|
||||||
|
* @param {*} a
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
|
showdown.helper.isArray = function isArray(a) {
|
||||||
'use strict';
|
'use strict';
|
||||||
return a.constructor === Array;
|
return a.constructor === Array;
|
||||||
}
|
};
|
||||||
|
|
||||||
function isUndefined(value) {
|
/**
|
||||||
|
* Check if value is undefined
|
||||||
|
*
|
||||||
|
* @static
|
||||||
|
* @param {*} value The value to check.
|
||||||
|
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
|
||||||
|
*/
|
||||||
|
showdown.helper.isUndefined = function isUndefined(value) {
|
||||||
'use strict';
|
'use strict';
|
||||||
return typeof value === 'undefined';
|
return typeof value === 'undefined';
|
||||||
}
|
};
|
||||||
|
|
||||||
var escapeCharactersCallback = function (wholeMatch, m1) {
|
/**
|
||||||
|
* Callback used to escape characters when passing through String.replace
|
||||||
|
* @param {string} wholeMatch
|
||||||
|
* @param {string} m1
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
|
showdown.helper.escapeCharactersCallback = function escapeCharactersCallback(wholeMatch, m1) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var charCodeToEscape = m1.charCodeAt(0);
|
var charCodeToEscape = m1.charCodeAt(0);
|
||||||
return '~E' + charCodeToEscape + 'E';
|
return '~E' + charCodeToEscape + 'E';
|
||||||
};
|
};
|
||||||
|
|
||||||
var escapeCharacters = function (text, charsToEscape, afterBackslash) {
|
/**
|
||||||
|
* Escape characters in a string
|
||||||
|
*
|
||||||
|
* @param {string} text
|
||||||
|
* @param {string} charsToEscape
|
||||||
|
* @param {boolean} afterBackslash
|
||||||
|
* @returns {XML|string|void|*}
|
||||||
|
*/
|
||||||
|
showdown.helper.escapeCharacters = function escapeCharacters(text, charsToEscape, afterBackslash) {
|
||||||
'use strict';
|
'use strict';
|
||||||
// First we have to escape the escape characters so that
|
// First we have to escape the escape characters so that
|
||||||
// we can build a character class out of them
|
// we can build a character class out of them
|
||||||
|
@ -50,55 +90,3 @@ var escapeCharacters = function (text, charsToEscape, afterBackslash) {
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!showdown.hasOwnProperty('helper')) {
|
|
||||||
showdown.helper = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* isString helper function
|
|
||||||
* @param a
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
showdown.helper.isString = isString;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ForEach helper function
|
|
||||||
* @param {*} obj
|
|
||||||
* @param callback
|
|
||||||
*/
|
|
||||||
showdown.helper.forEach = forEach;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* isArray helper function
|
|
||||||
* @param {*} a
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
showdown.helper.isArray = isArray;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if value is undefined
|
|
||||||
*
|
|
||||||
* @static
|
|
||||||
* @param {*} value The value to check.
|
|
||||||
* @returns {boolean} Returns `true` if `value` is `undefined`, else `false`.
|
|
||||||
*/
|
|
||||||
showdown.helper.isUndefined = isUndefined;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback used to escape characters when passing through String.replace
|
|
||||||
* @param {string} wholeMatch
|
|
||||||
* @param {string} m1
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
showdown.helper.escapeCharactersCallback = escapeCharactersCallback;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Escape characters in a string
|
|
||||||
*
|
|
||||||
* @param {string} text
|
|
||||||
* @param {string} charsToEscape
|
|
||||||
* @param {boolean} afterBackslash
|
|
||||||
* @returns {XML|string|void|*}
|
|
||||||
*/
|
|
||||||
showdown.helper.escapeCharacters = escapeCharacters;
|
|
||||||
|
|
|
@ -1,21 +1,17 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 15-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
var root = this;
|
var root = this;
|
||||||
|
|
||||||
// CommonJS/nodeJS Loader
|
// CommonJS/nodeJS Loader
|
||||||
if (typeof module !== 'undefined' && module.exports) {
|
if (typeof module !== 'undefined' && module.exports) {
|
||||||
module.exports = showdown;
|
module.exports = showdown;
|
||||||
}
|
|
||||||
// AMD Loader
|
// AMD Loader
|
||||||
else if (typeof define === 'function' && define.amd) {
|
} else if (typeof define === 'function' && define.amd) {
|
||||||
define('showdown', function () {
|
define('showdown', function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
return showdown;
|
return showdown;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
// Regular Browser loader
|
// Regular Browser loader
|
||||||
else {
|
} else {
|
||||||
root.showdown = showdown;
|
root.showdown = showdown;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn Markdown link shortcuts into XHTML <a> tags.
|
* Turn Markdown link shortcuts into XHTML <a> tags.
|
||||||
*/
|
*/
|
||||||
|
@ -40,12 +36,12 @@ showdown.subParser('anchors', function (text, config, globals) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
url = showdown.helper.escapeCharacters(url, '*_');
|
url = showdown.helper.escapeCharacters(url, '*_', false);
|
||||||
var result = '<a href="' + url + '"';
|
var result = '<a href="' + url + '"';
|
||||||
|
|
||||||
if (title !== '' && title !== null) {
|
if (title !== '' && title !== null) {
|
||||||
title = title.replace(/"/g, '"');
|
title = title.replace(/"/g, '"');
|
||||||
title = showdown.helper.escapeCharacters(title, '*_');
|
title = showdown.helper.escapeCharacters(title, '*_', false);
|
||||||
result += ' title="' + title + '"';
|
result += ' title="' + title + '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,11 +117,11 @@ showdown.subParser('anchors', function (text, config, globals) {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
text = text.replace(/
|
text = text.replace(/
|
||||||
( // wrap whole match in $1
|
( // wrap whole match in $1
|
||||||
\[
|
\[
|
||||||
([^\[\]]+) // link text = $2; can't contain '[' or ']'
|
([^\[\]]+) // link text = $2; can't contain '[' or ']'
|
||||||
\]
|
\]
|
||||||
)()()()()() // pad rest of backreferences
|
)()()()()() // pad rest of backreferences
|
||||||
/g, writeAnchorTag);
|
/g, writeAnchorTag);
|
||||||
*/
|
*/
|
||||||
text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
|
text = text.replace(/(\[([^\[\]]+)\])()()()()()/g, writeAnchorTag);
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
showdown.subParser('autoLinks', function (text) {
|
showdown.subParser('autoLinks', function (text) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are all the transformations that form block-level
|
* These are all the transformations that form block-level
|
||||||
* tags like paragraphs, headers, and list items.
|
* tags like paragraphs, headers, and list items.
|
||||||
|
@ -29,5 +25,5 @@ showdown.subParser('blockGamut', function (text, options, globals) {
|
||||||
text = showdown.subParser('paragraphs')(text, options, globals);
|
text = showdown.subParser('paragraphs')(text, options, globals);
|
||||||
|
|
||||||
return text;
|
return text;
|
||||||
});
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
showdown.subParser('blockQuotes', function (text, options, globals) {
|
showdown.subParser('blockQuotes', function (text, options, globals) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process Markdown `<pre><code>` blocks.
|
* Process Markdown `<pre><code>` blocks.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* * Backtick quotes are used for <code></code> spans.
|
* * Backtick quotes are used for <code></code> spans.
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert all tabs to spaces
|
* Convert all tabs to spaces
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smart processing for ampersands and angle brackets that need to be encoded.
|
* Smart processing for ampersands and angle brackets that need to be encoded.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the string, with after processing the following backslash escape sequences.
|
* Returns the string, with after processing the following backslash escape sequences.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode/escape certain characters inside Markdown code runs.
|
* Encode/escape certain characters inside Markdown code runs.
|
||||||
* The point is that in code, these characters are literals,
|
* The point is that in code, these characters are literals,
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Input: an email address, e.g. "foo@example.com"
|
* Input: an email address, e.g. "foo@example.com"
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Within tags -- meaning between < and > -- encode [\ ` * _] so they
|
* Within tags -- meaning between < and > -- encode [\ ` * _] so they
|
||||||
* don't conflict with their use in Markdown for code, italics and strong.
|
* don't conflict with their use in Markdown for code, italics and strong.
|
||||||
|
@ -15,7 +11,7 @@ showdown.subParser('escapeSpecialCharsWithinTagAttributes', function (text) {
|
||||||
|
|
||||||
text = text.replace(regex, function (wholeMatch) {
|
text = text.replace(regex, function (wholeMatch) {
|
||||||
var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, '$1`');
|
var tag = wholeMatch.replace(/(.)<\/?code>(?=.)/g, '$1`');
|
||||||
tag = showdown.helper.escapeCharacters(tag, '\\`*_');
|
tag = showdown.helper.escapeCharacters(tag, '\\`*_', false);
|
||||||
return tag;
|
return tag;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle github codeblocks prior to running HashHTML so that
|
* Handle github codeblocks prior to running HashHTML so that
|
||||||
* HTML contained within the codeblock gets escaped properly
|
* HTML contained within the codeblock gets escaped properly
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
showdown.subParser('hashBlock', function (text, options, globals) {
|
showdown.subParser('hashBlock', function (text, options, globals) {
|
||||||
'use strict';
|
'use strict';
|
||||||
text = text.replace(/(^\n+|\n+$)/g, '');
|
text = text.replace(/(^\n+|\n+$)/g, '');
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
showdown.subParser('hashElement', function (text, options, globals) {
|
showdown.subParser('hashElement', function (text, options, globals) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
|
showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
showdown.subParser('headers', function (text, options, globals) {
|
showdown.subParser('headers', function (text, options, globals) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turn Markdown image shortcuts into <img> tags.
|
* Turn Markdown image shortcuts into <img> tags.
|
||||||
*/
|
*/
|
||||||
|
@ -40,7 +36,7 @@ showdown.subParser('images', function (text, options, globals) {
|
||||||
}
|
}
|
||||||
|
|
||||||
altText = altText.replace(/"/g, '"');
|
altText = altText.replace(/"/g, '"');
|
||||||
url = showdown.helper.escapeCharacters(url, '*_');
|
url = showdown.helper.escapeCharacters(url, '*_', false);
|
||||||
var result = '<img src="' + url + '" alt="' + altText + '"';
|
var result = '<img src="' + url + '" alt="' + altText + '"';
|
||||||
|
|
||||||
// attacklab: Markdown.pl adds empty title attributes to images.
|
// attacklab: Markdown.pl adds empty title attributes to images.
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
showdown.subParser('italicsAndBold', function (text) {
|
showdown.subParser('italicsAndBold', function (text) {
|
||||||
'use strict';
|
'use strict';
|
||||||
// <strong> must go first:
|
// <strong> must go first:
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form HTML ordered (numbered) and unordered (bulleted) lists.
|
* Form HTML ordered (numbered) and unordered (bulleted) lists.
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +7,7 @@ showdown.subParser('lists', function (text, options, globals) {
|
||||||
/**
|
/**
|
||||||
* Process the contents of a single ordered or unordered list, splitting it
|
* Process the contents of a single ordered or unordered list, splitting it
|
||||||
* into individual list items.
|
* into individual list items.
|
||||||
* @param listStr
|
* @param {string} listStr
|
||||||
* @returns {string|*}
|
* @returns {string|*}
|
||||||
*/
|
*/
|
||||||
var processListItems = function (listStr) {
|
var processListItems = function (listStr) {
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove one level of line-leading tabs or spaces
|
* Remove one level of line-leading tabs or spaces
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -12,10 +8,10 @@ showdown.subParser('paragraphs', function (text, options, globals) {
|
||||||
text = text.replace(/^\n+/g, '');
|
text = text.replace(/^\n+/g, '');
|
||||||
text = text.replace(/\n+$/g, '');
|
text = text.replace(/\n+$/g, '');
|
||||||
|
|
||||||
var grafs = text.split(/\n{2,}/g), grafsOut = [];
|
var grafs = text.split(/\n{2,}/g),
|
||||||
|
grafsOut = [],
|
||||||
|
end = grafs.length; // Wrap <p> tags
|
||||||
|
|
||||||
/** Wrap <p> tags. */
|
|
||||||
var end = grafs.length;
|
|
||||||
for (var i = 0; i < end; i++) {
|
for (var i = 0; i < end; i++) {
|
||||||
var str = grafs[i];
|
var str = grafs[i];
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These are all the transformations that occur *within* block-level
|
* These are all the transformations that occur *within* block-level
|
||||||
* tags like paragraphs, headers, and list items.
|
* tags like paragraphs, headers, and list items.
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strip any lines consisting only of spaces and tabs.
|
* Strip any lines consisting only of spaces and tabs.
|
||||||
* This makes subsequent regexs easier to write, because we can
|
* This makes subsequent regexs easier to write, because we can
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 11-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Strips link definitions from text, stores the URLs and titles in
|
* Strips link definitions from text, stores the URLs and titles in
|
||||||
* hash references.
|
* hash references.
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
/**
|
|
||||||
* Created by Estevao on 12-01-2015.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Swap back in all the special characters we've hidden.
|
* Swap back in all the special characters we've hidden.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -8,7 +8,15 @@
|
||||||
require('source-map-support').install();
|
require('source-map-support').install();
|
||||||
require('chai').should();
|
require('chai').should();
|
||||||
|
|
||||||
var fs = require('fs'), showdown = require('../../../dist/showdown.js'), converter = new showdown.Converter(), cases = fs.readdirSync('test/cases/').filter(filter()).map(map('test/cases/')), issues = fs.readdirSync('test/issues/').filter(filter()).map(map('test/issues/'));
|
var fs = require('fs'),
|
||||||
|
showdown = require('../../../dist/showdown.js'),
|
||||||
|
converter = new showdown.Converter(),
|
||||||
|
cases = fs.readdirSync('test/cases/')
|
||||||
|
.filter(filter())
|
||||||
|
.map(map('test/cases/')),
|
||||||
|
issues = fs.readdirSync('test/issues/')
|
||||||
|
.filter(filter())
|
||||||
|
.map(map('test/issues/'));
|
||||||
|
|
||||||
//Tests
|
//Tests
|
||||||
describe('Converter.makeHtml() simple testcases', function () {
|
describe('Converter.makeHtml() simple testcases', function () {
|
||||||
|
@ -23,7 +31,6 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
function filter() {
|
function filter() {
|
||||||
return function (file) {
|
return function (file) {
|
||||||
var ext = file.slice(-3);
|
var ext = file.slice(-3);
|
||||||
|
@ -33,9 +40,11 @@
|
||||||
|
|
||||||
function map(dir) {
|
function map(dir) {
|
||||||
return function (file) {
|
return function (file) {
|
||||||
var name = file.replace('.md', ''), htmlPath = dir + name + '.html', html = fs.readFileSync(htmlPath,
|
var name = file.replace('.md', ''),
|
||||||
'utf8'), mdPath = dir + name + '.md', md = fs.readFileSync(mdPath,
|
htmlPath = dir + name + '.html',
|
||||||
'utf8');
|
html = fs.readFileSync(htmlPath, 'utf8'),
|
||||||
|
mdPath = dir + name + '.md',
|
||||||
|
md = fs.readFileSync(mdPath, 'utf8');
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: name,
|
name: name,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user