mirror of
https://github.com/showdownjs/showdown.git
synced 2024-03-22 13:30:55 +08:00
Update dependencies to enable Greenkeeper 🌴 (#335)
adapt code to updated dependencies
This commit is contained in:
parent
1832b7f721
commit
b5e46fdb8d
27
.eslintrc.json
Normal file
27
.eslintrc.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"rules": {
|
||||||
|
"indent": [2, 2, {"SwitchCase": 1, "VariableDeclarator": 2}],
|
||||||
|
"curly": [2, "all"],
|
||||||
|
"operator-linebreak": [2, "after"],
|
||||||
|
"camelcase": [2, {"properties": "never"}],
|
||||||
|
"quotes": [2, "single"],
|
||||||
|
"no-multi-str": 2,
|
||||||
|
"no-mixed-spaces-and-tabs": 2,
|
||||||
|
"no-trailing-spaces": 2,
|
||||||
|
"space-unary-ops": [2,
|
||||||
|
{
|
||||||
|
"nonwords": false,
|
||||||
|
"overrides": {}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"brace-style": [2, "1tbs", {"allowSingleLine": true}],
|
||||||
|
"keyword-spacing": [2, {}],
|
||||||
|
"space-infix-ops": 2,
|
||||||
|
"space-before-blocks": [2, "always"],
|
||||||
|
"eol-last": 2,
|
||||||
|
"space-before-function-paren": [2, "always"],
|
||||||
|
"array-bracket-spacing": [2, "never", {"singleValue": false}],
|
||||||
|
"space-in-parens": [2, "never"],
|
||||||
|
"no-multiple-empty-lines": 2
|
||||||
|
}
|
||||||
|
}
|
3
.gitattributes
vendored
3
.gitattributes
vendored
@ -3,12 +3,13 @@
|
|||||||
.editorconfig export-ignore
|
.editorconfig export-ignore
|
||||||
.gitattributes export-ignore
|
.gitattributes export-ignore
|
||||||
.gitignore export-ignore
|
.gitignore export-ignore
|
||||||
.jscs.json export-ignore
|
.eslintrc.json export-ignore
|
||||||
.jshintignore export-ignore
|
.jshintignore export-ignore
|
||||||
.jshintrc
|
.jshintrc
|
||||||
.travis.yml export-ignore
|
.travis.yml export-ignore
|
||||||
bower.json
|
bower.json
|
||||||
Gruntfile.js export-ignore
|
Gruntfile.js export-ignore
|
||||||
|
performance.*
|
||||||
|
|
||||||
# Line endings control
|
# Line endings control
|
||||||
CHANGELOG.md text
|
CHANGELOG.md text
|
||||||
|
89
.jscs.json
89
.jscs.json
@ -1,89 +0,0 @@
|
|||||||
{
|
|
||||||
"validateIndentation": 2,
|
|
||||||
"requireCurlyBraces": [
|
|
||||||
"if",
|
|
||||||
"else",
|
|
||||||
"for",
|
|
||||||
"while",
|
|
||||||
"do",
|
|
||||||
"try",
|
|
||||||
"catch"
|
|
||||||
],
|
|
||||||
"requireOperatorBeforeLineBreak": true,
|
|
||||||
"requireCamelCaseOrUpperCaseIdentifiers": true,
|
|
||||||
"validateQuoteMarks": "'",
|
|
||||||
"disallowMultipleLineStrings": true,
|
|
||||||
"disallowMixedSpacesAndTabs": true,
|
|
||||||
"disallowTrailingWhitespace": true,
|
|
||||||
"disallowSpaceAfterPrefixUnaryOperators": true,
|
|
||||||
"requireMultipleVarDecl": true,
|
|
||||||
"disallowKeywordsOnNewLine": ["else"],
|
|
||||||
"requireSpaceAfterKeywords": [
|
|
||||||
"if",
|
|
||||||
"else",
|
|
||||||
"for",
|
|
||||||
"while",
|
|
||||||
"do",
|
|
||||||
"switch",
|
|
||||||
"return",
|
|
||||||
"try",
|
|
||||||
"catch"
|
|
||||||
],
|
|
||||||
"requireSpaceBeforeBinaryOperators": [
|
|
||||||
"=",
|
|
||||||
"+=",
|
|
||||||
"-=",
|
|
||||||
"*=",
|
|
||||||
"/=",
|
|
||||||
"%=",
|
|
||||||
"<<=",
|
|
||||||
">>=",
|
|
||||||
">>>=",
|
|
||||||
"&=",
|
|
||||||
"|=",
|
|
||||||
"^=",
|
|
||||||
"+=",
|
|
||||||
"+",
|
|
||||||
"-",
|
|
||||||
"*",
|
|
||||||
"/",
|
|
||||||
"%",
|
|
||||||
"<<",
|
|
||||||
">>",
|
|
||||||
">>>",
|
|
||||||
"&",
|
|
||||||
"|",
|
|
||||||
"^",
|
|
||||||
"&&",
|
|
||||||
"||",
|
|
||||||
"===",
|
|
||||||
"==",
|
|
||||||
">=",
|
|
||||||
"<=",
|
|
||||||
"<",
|
|
||||||
">",
|
|
||||||
"!=",
|
|
||||||
"!=="
|
|
||||||
],
|
|
||||||
"requireSpaceAfterBinaryOperators": true,
|
|
||||||
"requireSpacesInConditionalExpression": true,
|
|
||||||
"requireSpaceBeforeBlockStatements": true,
|
|
||||||
"requireSpacesInForStatement": true,
|
|
||||||
"requireLineFeedAtFileEnd": true,
|
|
||||||
"requireSpacesInFunctionExpression": {
|
|
||||||
"beforeOpeningCurlyBrace": true
|
|
||||||
},
|
|
||||||
"requireSpacesInAnonymousFunctionExpression": {
|
|
||||||
"beforeOpeningRoundBrace": true,
|
|
||||||
"beforeOpeningCurlyBrace": true
|
|
||||||
},
|
|
||||||
"disallowSpacesInsideObjectBrackets": "all",
|
|
||||||
"disallowSpacesInsideArrayBrackets": "all",
|
|
||||||
"disallowSpacesInsideParentheses": true,
|
|
||||||
"validateJSDoc": {
|
|
||||||
"checkParamNames": true,
|
|
||||||
"requireParamTypes": true
|
|
||||||
},
|
|
||||||
"disallowMultipleLineBreaks": true,
|
|
||||||
"disallowNewlineBeforeBlockStatements": true
|
|
||||||
}
|
|
@ -13,6 +13,10 @@ cache:
|
|||||||
directories:
|
directories:
|
||||||
- node_modules
|
- node_modules
|
||||||
|
|
||||||
|
# scripts
|
||||||
|
script:
|
||||||
|
- 'if [ "$TRAVIS_NODE_VERSION" == "0.12" ]; then echo "Bypassing EsLint" && grunt test-old; else echo "Running normal tests" && grunt test; fi'
|
||||||
|
|
||||||
# hooks
|
# hooks
|
||||||
notifications:
|
notifications:
|
||||||
webhooks:
|
webhooks:
|
||||||
|
25
Gruntfile.js
25
Gruntfile.js
@ -73,17 +73,15 @@ module.exports = function (grunt) {
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
jscs: {
|
eslint: {
|
||||||
options: {
|
options: {
|
||||||
config: '.jscs.json'
|
config: '.eslintrc.json'
|
||||||
},
|
},
|
||||||
files: {
|
target: [
|
||||||
src: [
|
|
||||||
'Gruntfile.js',
|
'Gruntfile.js',
|
||||||
'src/**/*.js',
|
'src/**/*.js',
|
||||||
'test/**/*.js'
|
'test/**/*.js'
|
||||||
]
|
]
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
conventionalChangelog: {
|
conventionalChangelog: {
|
||||||
@ -171,7 +169,14 @@ module.exports = function (grunt) {
|
|||||||
|
|
||||||
grunt.initConfig(config);
|
grunt.initConfig(config);
|
||||||
|
|
||||||
require('load-grunt-tasks')(grunt);
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-uglify');
|
||||||
|
grunt.loadNpmTasks('grunt-conventional-changelog');
|
||||||
|
grunt.loadNpmTasks('grunt-conventional-github-releaser');
|
||||||
|
grunt.loadNpmTasks('grunt-endline');
|
||||||
|
grunt.loadNpmTasks('grunt-simple-mocha');
|
||||||
|
grunt.loadNpmTasks('grunt-contrib-jshint');
|
||||||
|
|
||||||
grunt.registerTask('single-test', function (grep) {
|
grunt.registerTask('single-test', function (grep) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -195,8 +200,14 @@ module.exports = function (grunt) {
|
|||||||
perf.generateLogs();
|
perf.generateLogs();
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('lint', ['jshint', 'jscs']);
|
grunt.registerTask('lint', function () {
|
||||||
|
'use strict';
|
||||||
|
grunt.loadNpmTasks('grunt-eslint');
|
||||||
|
grunt.task.run('jshint', 'eslint');
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
|
grunt.registerTask('test', ['clean', 'lint', 'concat:test', 'simplemocha:node', 'clean']);
|
||||||
|
grunt.registerTask('test-old', ['concat:test', 'simplemocha:node', 'clean']);
|
||||||
grunt.registerTask('performance', ['concat:test', 'performancejs', 'clean']);
|
grunt.registerTask('performance', ['concat:test', 'performancejs', 'clean']);
|
||||||
grunt.registerTask('build', ['test', 'concat:dist', 'uglify', 'endline']);
|
grunt.registerTask('build', ['test', 'concat:dist', 'uglify', 'endline']);
|
||||||
grunt.registerTask('prep-release', ['build', 'conventionalChangelog']);
|
grunt.registerTask('prep-release', ['build', 'conventionalChangelog']);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
![Showdown][sd-logo]
|
![Showdown][sd-logo]
|
||||||
|
|
||||||
[](https://travis-ci.org/showdownjs/showdown) [](http://badge.fury.io/js/showdown) [](http://badge.fury.io/bo/showdown) [](https://gitter.im/showdownjs/showdown?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
[](https://travis-ci.org/showdownjs/showdown) [](http://badge.fury.io/js/showdown) [](http://badge.fury.io/bo/showdown) [](https://gitter.im/showdownjs/showdown?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [](https://greenkeeper.io/)
|
||||||
|
|
||||||
------
|
------
|
||||||
|
|
||||||
|
40
dist/showdown.js
vendored
40
dist/showdown.js
vendored
@ -4,7 +4,7 @@
|
|||||||
* Created by Tivie on 13-07-2015.
|
* Created by Tivie on 13-07-2015.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getDefaultOpts(simple) {
|
function getDefaultOpts (simple) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
@ -131,7 +131,7 @@ function getDefaultOpts(simple) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allOptionsOn() {
|
function allOptionsOn () {
|
||||||
'use strict';
|
'use strict';
|
||||||
var options = getDefaultOpts(true),
|
var options = getDefaultOpts(true),
|
||||||
ret = {};
|
ret = {};
|
||||||
@ -382,7 +382,7 @@ showdown.resetExtensions = function () {
|
|||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @returns {{valid: boolean, error: string}}
|
* @returns {{valid: boolean, error: string}}
|
||||||
*/
|
*/
|
||||||
function validate(extension, name) {
|
function validate (extension, name) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
|
var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
|
||||||
@ -469,7 +469,7 @@ function validate(extension, name) {
|
|||||||
if (showdown.helper.isString(ext.regex)) {
|
if (showdown.helper.isString(ext.regex)) {
|
||||||
ext.regex = new RegExp(ext.regex, 'g');
|
ext.regex = new RegExp(ext.regex, 'g');
|
||||||
}
|
}
|
||||||
if (!ext.regex instanceof RegExp) {
|
if (!(ext.regex instanceof RegExp)) {
|
||||||
ret.valid = false;
|
ret.valid = false;
|
||||||
ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
|
ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
|
||||||
return ret;
|
return ret;
|
||||||
@ -603,7 +603,7 @@ showdown.helper.stdExtName = function (s) {
|
|||||||
return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
|
return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
|
||||||
};
|
};
|
||||||
|
|
||||||
function escapeCharactersCallback(wholeMatch, m1) {
|
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';
|
||||||
@ -897,7 +897,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* Converter constructor
|
* Converter constructor
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function _constructor() {
|
function _constructor () {
|
||||||
converterOptions = converterOptions || {};
|
converterOptions = converterOptions || {};
|
||||||
|
|
||||||
for (var gOpt in globalOptions) {
|
for (var gOpt in globalOptions) {
|
||||||
@ -929,7 +929,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* @param {string} [name='']
|
* @param {string} [name='']
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function _parseExtension(ext, name) {
|
function _parseExtension (ext, name) {
|
||||||
|
|
||||||
name = name || null;
|
name = name || null;
|
||||||
// If it's a string, the extension was previously loaded
|
// If it's a string, the extension was previously loaded
|
||||||
@ -993,7 +993,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* @param {*} ext
|
* @param {*} ext
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
*/
|
*/
|
||||||
function legacyExtensionLoading(ext, name) {
|
function legacyExtensionLoading (ext, name) {
|
||||||
if (typeof ext === 'function') {
|
if (typeof ext === 'function') {
|
||||||
ext = ext(new showdown.Converter());
|
ext = ext(new showdown.Converter());
|
||||||
}
|
}
|
||||||
@ -1025,7 +1025,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {function} callback
|
* @param {function} callback
|
||||||
*/
|
*/
|
||||||
function listen(name, callback) {
|
function listen (name, callback) {
|
||||||
if (!showdown.helper.isString(name)) {
|
if (!showdown.helper.isString(name)) {
|
||||||
throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
|
throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
|
||||||
}
|
}
|
||||||
@ -1040,7 +1040,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
listeners[name].push(callback);
|
listeners[name].push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rTrimInputText(text) {
|
function rTrimInputText (text) {
|
||||||
var rsp = text.match(/^\s*/)[0].length,
|
var rsp = text.match(/^\s*/)[0].length,
|
||||||
rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
|
rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
|
||||||
return text.replace(rgx, '');
|
return text.replace(rgx, '');
|
||||||
@ -1388,7 +1388,7 @@ showdown.subParser('autoLinks', function (text, options, globals) {
|
|||||||
text = text.replace(simpleMailRegex, replaceMail);
|
text = text.replace(simpleMailRegex, replaceMail);
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceLink(wm, link, m2, m3, trailingPunctuation) {
|
function replaceLink (wm, link, m2, m3, trailingPunctuation) {
|
||||||
var lnkTxt = link,
|
var lnkTxt = link,
|
||||||
append = '';
|
append = '';
|
||||||
if (/^www\./i.test(link)) {
|
if (/^www\./i.test(link)) {
|
||||||
@ -1400,7 +1400,7 @@ showdown.subParser('autoLinks', function (text, options, globals) {
|
|||||||
return '<a href="' + link + '">' + lnkTxt + '</a>' + append;
|
return '<a href="' + link + '">' + lnkTxt + '</a>' + append;
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceMail(wholeMatch, b, mail) {
|
function replaceMail (wholeMatch, b, mail) {
|
||||||
var href = 'mailto:';
|
var href = 'mailto:';
|
||||||
b = b || '';
|
b = b || '';
|
||||||
mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
|
mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
|
||||||
@ -1945,7 +1945,7 @@ showdown.subParser('headers', function (text, options, globals) {
|
|||||||
return showdown.subParser('hashBlock')(header, options, globals);
|
return showdown.subParser('hashBlock')(header, options, globals);
|
||||||
});
|
});
|
||||||
|
|
||||||
function headerId(m) {
|
function headerId (m) {
|
||||||
var title, escapedId;
|
var title, escapedId;
|
||||||
|
|
||||||
if (ghHeaderId) {
|
if (ghHeaderId) {
|
||||||
@ -2261,7 +2261,7 @@ showdown.subParser('lists', function (text, options, globals) {
|
|||||||
* @param {boolean} trimTrailing
|
* @param {boolean} trimTrailing
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function parseConsecutiveLists(list, listType, trimTrailing) {
|
function parseConsecutiveLists (list, listType, trimTrailing) {
|
||||||
// check if we caught 2 or more consecutive lists by mistake
|
// check if we caught 2 or more consecutive lists by mistake
|
||||||
// we use the counterRgx, meaning if listType is UL we look for OL and vice versa
|
// we use the counterRgx, meaning if listType is UL we look for OL and vice versa
|
||||||
var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
|
var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
|
||||||
@ -2270,7 +2270,7 @@ showdown.subParser('lists', function (text, options, globals) {
|
|||||||
result = '';
|
result = '';
|
||||||
|
|
||||||
if (list.search(counterRxg) !== -1) {
|
if (list.search(counterRxg) !== -1) {
|
||||||
(function parseCL(txt) {
|
(function parseCL (txt) {
|
||||||
var pos = txt.search(counterRxg);
|
var pos = txt.search(counterRxg);
|
||||||
if (pos !== -1) {
|
if (pos !== -1) {
|
||||||
// slice
|
// slice
|
||||||
@ -2419,7 +2419,7 @@ showdown.subParser('runExtension', function (ext, text, options, globals) {
|
|||||||
} else if (ext.regex) {
|
} else if (ext.regex) {
|
||||||
// TODO remove this when old extension loading mechanism is deprecated
|
// TODO remove this when old extension loading mechanism is deprecated
|
||||||
var re = ext.regex;
|
var re = ext.regex;
|
||||||
if (!re instanceof RegExp) {
|
if (!(re instanceof RegExp)) {
|
||||||
re = new RegExp(re, 'g');
|
re = new RegExp(re, 'g');
|
||||||
}
|
}
|
||||||
text = text.replace(re, ext.replace);
|
text = text.replace(re, ext.replace);
|
||||||
@ -2530,7 +2530,7 @@ showdown.subParser('tables', function (text, options, globals) {
|
|||||||
|
|
||||||
var tableRgx = /^ {0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|¨0)/gm;
|
var tableRgx = /^ {0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|¨0)/gm;
|
||||||
|
|
||||||
function parseStyles(sLine) {
|
function parseStyles (sLine) {
|
||||||
if (/^:[ \t]*--*$/.test(sLine)) {
|
if (/^:[ \t]*--*$/.test(sLine)) {
|
||||||
return ' style="text-align:left;"';
|
return ' style="text-align:left;"';
|
||||||
} else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
|
} else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
|
||||||
@ -2542,7 +2542,7 @@ showdown.subParser('tables', function (text, options, globals) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseHeaders(header, style) {
|
function parseHeaders (header, style) {
|
||||||
var id = '';
|
var id = '';
|
||||||
header = header.trim();
|
header = header.trim();
|
||||||
if (options.tableHeaderId) {
|
if (options.tableHeaderId) {
|
||||||
@ -2553,12 +2553,12 @@ showdown.subParser('tables', function (text, options, globals) {
|
|||||||
return '<th' + id + style + '>' + header + '</th>\n';
|
return '<th' + id + style + '>' + header + '</th>\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCells(cell, style) {
|
function parseCells (cell, style) {
|
||||||
var subText = showdown.subParser('spanGamut')(cell, options, globals);
|
var subText = showdown.subParser('spanGamut')(cell, options, globals);
|
||||||
return '<td' + style + '>' + subText + '</td>\n';
|
return '<td' + style + '>' + subText + '</td>\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTable(headers, cells) {
|
function buildTable (headers, cells) {
|
||||||
var tb = '<table>\n<thead>\n<tr>\n',
|
var tb = '<table>\n<thead>\n<tr>\n',
|
||||||
tblLgn = headers.length;
|
tblLgn = headers.length;
|
||||||
|
|
||||||
|
2
dist/showdown.js.map
vendored
2
dist/showdown.js.map
vendored
File diff suppressed because one or more lines are too long
4
dist/showdown.min.js
vendored
4
dist/showdown.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/showdown.min.js.map
vendored
2
dist/showdown.min.js.map
vendored
File diff suppressed because one or more lines are too long
22
package.json
22
package.json
@ -40,24 +40,24 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^3.5.0",
|
"chai": "^3.5.0",
|
||||||
"grunt": "^0.4.5",
|
"grunt": "^1.0.1",
|
||||||
"grunt-contrib-clean": "^0.6.0",
|
"grunt-contrib-clean": "^1.0.0",
|
||||||
"grunt-contrib-concat": "^0.5.0",
|
"grunt-contrib-concat": "^1.0.1",
|
||||||
"grunt-contrib-jshint": "^0.10.0",
|
"grunt-contrib-jshint": "^1.1.0",
|
||||||
"grunt-contrib-uglify": "^0.6.0",
|
"grunt-contrib-uglify": "^2.0.0",
|
||||||
"grunt-conventional-changelog": "^4.0.0",
|
"grunt-conventional-changelog": "^6.1.0",
|
||||||
"grunt-conventional-github-releaser": "^0.3.0",
|
"grunt-conventional-github-releaser": "^1.0.0",
|
||||||
"grunt-endline": "^0.4.0",
|
"grunt-endline": "^0.6.1",
|
||||||
"grunt-jscs": "^1.2.0",
|
"grunt-eslint": "^19.0.0",
|
||||||
"grunt-simple-mocha": "^0.4.0",
|
"grunt-simple-mocha": "^0.4.0",
|
||||||
"js-beautify": "^1.5.6",
|
"js-beautify": "^1.5.6",
|
||||||
"load-grunt-tasks": "^3.2.0",
|
"load-grunt-tasks": "^3.2.0",
|
||||||
"performance-now": "^0.2.0",
|
"performance-now": "^2.0.0",
|
||||||
"quiet-grunt": "^0.2.3",
|
"quiet-grunt": "^0.2.3",
|
||||||
"semver": "^5.0.0",
|
"semver": "^5.0.0",
|
||||||
"semver-sort": "0.0.4",
|
"semver-sort": "0.0.4",
|
||||||
"sinon": "^1.14.1",
|
"sinon": "^1.14.1",
|
||||||
"source-map-support": "^0.2.9"
|
"source-map-support": "^0.4.11"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"yargs": "^6.6.0"
|
"yargs": "^6.6.0"
|
||||||
|
File diff suppressed because one or more lines are too long
@ -6,40 +6,40 @@
|
|||||||
### Test Suite: Basic (50 cycles)
|
### Test Suite: Basic (50 cycles)
|
||||||
| test | avgTime | max | min |
|
| test | avgTime | max | min |
|
||||||
|:-----|--------:|----:|----:|
|
|:-----|--------:|----:|----:|
|
||||||
|Simple "Hello World"|0.366|6.060|0.165|
|
|Simple "Hello World"|0.388|6.064|0.174|
|
||||||
|performance.testfile.md|26.820|47.685|24.495|
|
|performance.testfile.md|26.899|49.063|24.845|
|
||||||
|
|
||||||
### Test Suite: subParsers (20 cycles)
|
### Test Suite: subParsers (20 cycles)
|
||||||
| test | avgTime | max | min |
|
| test | avgTime | max | min |
|
||||||
|:-----|--------:|----:|----:|
|
|:-----|--------:|----:|----:|
|
||||||
|hashHTMLBlocks|2.660|9.402|1.874|
|
|hashHTMLBlocks|2.616|8.181|1.899|
|
||||||
|anchors|0.502|3.829|0.256|
|
|anchors|0.515|4.691|0.264|
|
||||||
|autoLinks|0.097|0.244|0.073|
|
|autoLinks|0.093|0.188|0.073|
|
||||||
|blockQuotes|3.239|6.987|2.821|
|
|blockQuotes|4.518|8.953|3.036|
|
||||||
|codeBlocks|0.195|0.382|0.174|
|
|codeBlocks|0.223|0.348|0.188|
|
||||||
|codeSpans|0.267|0.814|0.157|
|
|codeSpans|0.318|1.095|0.177|
|
||||||
|detab|0.102|0.176|0.087|
|
|detab|0.092|0.137|0.087|
|
||||||
|encodeAmpsAndAngles|0.042|0.070|0.038|
|
|encodeAmpsAndAngles|0.044|0.089|0.038|
|
||||||
|encodeBackslashEscapes|0.076|0.125|0.068|
|
|encodeBackslashEscapes|0.108|0.265|0.078|
|
||||||
|encodeCode|0.919|1.457|0.823|
|
|encodeCode|1.535|9.896|0.865|
|
||||||
|escapeSpecialCharsWithinTagAttributes|0.276|0.638|0.242|
|
|escapeSpecialCharsWithinTagAttributes|0.294|0.523|0.253|
|
||||||
|githubCodeBlocks|0.189|0.821|0.137|
|
|githubCodeBlocks|0.208|0.790|0.142|
|
||||||
|hashBlock|0.119|1.526|0.036|
|
|hashBlock|0.042|0.123|0.036|
|
||||||
|hashElement|0.002|0.032|0.000|
|
|hashElement|0.002|0.029|0.000|
|
||||||
|hashHTMLSpans|0.341|1.617|0.238|
|
|hashHTMLSpans|0.410|1.598|0.240|
|
||||||
|hashPreCodeTags|0.139|0.299|0.109|
|
|hashPreCodeTags|0.132|0.395|0.110|
|
||||||
|headers|0.955|2.204|0.803|
|
|headers|1.015|1.502|0.806|
|
||||||
|horizontalRule|0.216|0.331|0.194|
|
|horizontalRule|0.220|0.357|0.195|
|
||||||
|images|0.081|0.165|0.073|
|
|images|0.158|0.978|0.077|
|
||||||
|italicsAndBold|0.254|0.438|0.210|
|
|italicsAndBold|0.288|0.639|0.241|
|
||||||
|lists|5.076|5.787|4.679|
|
|lists|5.151|6.331|4.629|
|
||||||
|outdent|0.157|0.255|0.142|
|
|outdent|0.180|0.363|0.143|
|
||||||
|paragraphs|4.067|5.360|3.584|
|
|paragraphs|4.548|6.309|4.002|
|
||||||
|spanGamut|1.524|2.136|1.321|
|
|spanGamut|1.519|1.864|1.372|
|
||||||
|strikethrough|0.005|0.093|0.000|
|
|strikethrough|0.003|0.065|0.000|
|
||||||
|stripLinkDefinitions|0.160|0.229|0.143|
|
|stripLinkDefinitions|0.179|0.313|0.144|
|
||||||
|tables|0.002|0.038|0.000|
|
|tables|0.004|0.063|0.000|
|
||||||
|unescapeSpecialChars|0.009|0.050|0.006|
|
|unescapeSpecialChars|0.011|0.049|0.007|
|
||||||
|
|
||||||
|
|
||||||
## [version 1.6.2](https://github.com/showdownjs/showdown/tree/1.6.2)
|
## [version 1.6.2](https://github.com/showdownjs/showdown/tree/1.6.2)
|
||||||
|
@ -32,6 +32,7 @@ yargs
|
|||||||
|
|
||||||
var argv = yargs.argv,
|
var argv = yargs.argv,
|
||||||
command = argv._[0];
|
command = argv._[0];
|
||||||
|
|
||||||
if (command === 'makehtml') {
|
if (command === 'makehtml') {
|
||||||
require('./makehtml.cmd.js').run();
|
require('./makehtml.cmd.js').run();
|
||||||
} else {
|
} else {
|
||||||
|
@ -72,7 +72,7 @@ for (var opt in showdownOptions) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function run() {
|
function run () {
|
||||||
'use strict';
|
'use strict';
|
||||||
var argv = yargs.argv,
|
var argv = yargs.argv,
|
||||||
readMode = (!argv.i || argv.i === '') ? 'stdin' : 'file',
|
readMode = (!argv.i || argv.i === '') ? 'stdin' : 'file',
|
||||||
@ -120,7 +120,7 @@ function run() {
|
|||||||
write(html, append);
|
write(html, append);
|
||||||
messenger.okExit();
|
messenger.okExit();
|
||||||
|
|
||||||
function parseOptions(flavor) {
|
function parseOptions (flavor) {
|
||||||
var options = {},
|
var options = {},
|
||||||
flavorOpts = showdown.getFlavorOptions(flavor) || {};
|
flavorOpts = showdown.getFlavorOptions(flavor) || {};
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ function run() {
|
|||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function readFromStdIn() {
|
function readFromStdIn () {
|
||||||
try {
|
try {
|
||||||
var size = fs.fstatSync(process.stdin.fd).size;
|
var size = fs.fstatSync(process.stdin.fd).size;
|
||||||
return size > 0 ? fs.readSync(process.stdin.fd, size)[0] : '';
|
return size > 0 ? fs.readSync(process.stdin.fd, size)[0] : '';
|
||||||
@ -166,7 +166,7 @@ function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readFromFile(encoding) {
|
function readFromFile (encoding) {
|
||||||
try {
|
try {
|
||||||
return fs.readFileSync(argv.i, encoding);
|
return fs.readFileSync(argv.i, encoding);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -174,11 +174,11 @@ function run() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeToStdOut(html) {
|
function writeToStdOut (html) {
|
||||||
return process.stdout.write(html);
|
return process.stdout.write(html);
|
||||||
}
|
}
|
||||||
|
|
||||||
function writeToFile(html, append) {
|
function writeToFile (html, append) {
|
||||||
// If a flag is passed, it means we should append instead of overwriting.
|
// If a flag is passed, it means we should append instead of overwriting.
|
||||||
// Only works with files, obviously
|
// Only works with files, obviously
|
||||||
var write = (append) ? fs.appendFileSync : fs.writeFileSync;
|
var write = (append) ? fs.appendFileSync : fs.writeFileSync;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
function Messenger(writeMode, supress, mute) {
|
function Messenger (writeMode, supress, mute) {
|
||||||
'use strict';
|
'use strict';
|
||||||
writeMode = writeMode || 'stderr';
|
writeMode = writeMode || 'stderr';
|
||||||
supress = (!!supress || !!mute);
|
supress = (!!supress || !!mute);
|
||||||
|
@ -51,7 +51,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* Converter constructor
|
* Converter constructor
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function _constructor() {
|
function _constructor () {
|
||||||
converterOptions = converterOptions || {};
|
converterOptions = converterOptions || {};
|
||||||
|
|
||||||
for (var gOpt in globalOptions) {
|
for (var gOpt in globalOptions) {
|
||||||
@ -83,7 +83,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* @param {string} [name='']
|
* @param {string} [name='']
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
function _parseExtension(ext, name) {
|
function _parseExtension (ext, name) {
|
||||||
|
|
||||||
name = name || null;
|
name = name || null;
|
||||||
// If it's a string, the extension was previously loaded
|
// If it's a string, the extension was previously loaded
|
||||||
@ -147,7 +147,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* @param {*} ext
|
* @param {*} ext
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
*/
|
*/
|
||||||
function legacyExtensionLoading(ext, name) {
|
function legacyExtensionLoading (ext, name) {
|
||||||
if (typeof ext === 'function') {
|
if (typeof ext === 'function') {
|
||||||
ext = ext(new showdown.Converter());
|
ext = ext(new showdown.Converter());
|
||||||
}
|
}
|
||||||
@ -179,7 +179,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @param {function} callback
|
* @param {function} callback
|
||||||
*/
|
*/
|
||||||
function listen(name, callback) {
|
function listen (name, callback) {
|
||||||
if (!showdown.helper.isString(name)) {
|
if (!showdown.helper.isString(name)) {
|
||||||
throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
|
throw Error('Invalid argument in converter.listen() method: name must be a string, but ' + typeof name + ' given');
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ showdown.Converter = function (converterOptions) {
|
|||||||
listeners[name].push(callback);
|
listeners[name].push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rTrimInputText(text) {
|
function rTrimInputText (text) {
|
||||||
var rsp = text.match(/^\s*/)[0].length,
|
var rsp = text.match(/^\s*/)[0].length,
|
||||||
rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
|
rgx = new RegExp('^\\s{0,' + rsp + '}', 'gm');
|
||||||
return text.replace(rgx, '');
|
return text.replace(rgx, '');
|
||||||
|
@ -101,7 +101,7 @@ showdown.helper.stdExtName = function (s) {
|
|||||||
return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
|
return s.replace(/[_?*+\/\\.^-]/g, '').replace(/\s/g, '').toLowerCase();
|
||||||
};
|
};
|
||||||
|
|
||||||
function escapeCharactersCallback(wholeMatch, m1) {
|
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';
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Created by Tivie on 13-07-2015.
|
* Created by Tivie on 13-07-2015.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getDefaultOpts(simple) {
|
function getDefaultOpts (simple) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
@ -129,7 +129,7 @@ function getDefaultOpts(simple) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function allOptionsOn() {
|
function allOptionsOn () {
|
||||||
'use strict';
|
'use strict';
|
||||||
var options = getDefaultOpts(true),
|
var options = getDefaultOpts(true),
|
||||||
ret = {};
|
ret = {};
|
||||||
|
@ -237,7 +237,7 @@ showdown.resetExtensions = function () {
|
|||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @returns {{valid: boolean, error: string}}
|
* @returns {{valid: boolean, error: string}}
|
||||||
*/
|
*/
|
||||||
function validate(extension, name) {
|
function validate (extension, name) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
|
var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
|
||||||
@ -324,7 +324,7 @@ function validate(extension, name) {
|
|||||||
if (showdown.helper.isString(ext.regex)) {
|
if (showdown.helper.isString(ext.regex)) {
|
||||||
ext.regex = new RegExp(ext.regex, 'g');
|
ext.regex = new RegExp(ext.regex, 'g');
|
||||||
}
|
}
|
||||||
if (!ext.regex instanceof RegExp) {
|
if (!(ext.regex instanceof RegExp)) {
|
||||||
ret.valid = false;
|
ret.valid = false;
|
||||||
ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
|
ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -23,7 +23,7 @@ showdown.subParser('autoLinks', function (text, options, globals) {
|
|||||||
text = text.replace(simpleMailRegex, replaceMail);
|
text = text.replace(simpleMailRegex, replaceMail);
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceLink(wm, link, m2, m3, trailingPunctuation) {
|
function replaceLink (wm, link, m2, m3, trailingPunctuation) {
|
||||||
var lnkTxt = link,
|
var lnkTxt = link,
|
||||||
append = '';
|
append = '';
|
||||||
if (/^www\./i.test(link)) {
|
if (/^www\./i.test(link)) {
|
||||||
@ -35,7 +35,7 @@ showdown.subParser('autoLinks', function (text, options, globals) {
|
|||||||
return '<a href="' + link + '">' + lnkTxt + '</a>' + append;
|
return '<a href="' + link + '">' + lnkTxt + '</a>' + append;
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceMail(wholeMatch, b, mail) {
|
function replaceMail (wholeMatch, b, mail) {
|
||||||
var href = 'mailto:';
|
var href = 'mailto:';
|
||||||
b = b || '';
|
b = b || '';
|
||||||
mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
|
mail = showdown.subParser('unescapeSpecialChars')(mail, options, globals);
|
||||||
|
@ -52,7 +52,7 @@ showdown.subParser('headers', function (text, options, globals) {
|
|||||||
return showdown.subParser('hashBlock')(header, options, globals);
|
return showdown.subParser('hashBlock')(header, options, globals);
|
||||||
});
|
});
|
||||||
|
|
||||||
function headerId(m) {
|
function headerId (m) {
|
||||||
var title, escapedId;
|
var title, escapedId;
|
||||||
|
|
||||||
if (ghHeaderId) {
|
if (ghHeaderId) {
|
||||||
|
@ -132,7 +132,7 @@ showdown.subParser('lists', function (text, options, globals) {
|
|||||||
* @param {boolean} trimTrailing
|
* @param {boolean} trimTrailing
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function parseConsecutiveLists(list, listType, trimTrailing) {
|
function parseConsecutiveLists (list, listType, trimTrailing) {
|
||||||
// check if we caught 2 or more consecutive lists by mistake
|
// check if we caught 2 or more consecutive lists by mistake
|
||||||
// we use the counterRgx, meaning if listType is UL we look for OL and vice versa
|
// we use the counterRgx, meaning if listType is UL we look for OL and vice versa
|
||||||
var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
|
var olRgx = (options.disableForced4SpacesIndentedSublists) ? /^ ?\d+\.[ \t]/gm : /^ {0,3}\d+\.[ \t]/gm,
|
||||||
@ -141,7 +141,7 @@ showdown.subParser('lists', function (text, options, globals) {
|
|||||||
result = '';
|
result = '';
|
||||||
|
|
||||||
if (list.search(counterRxg) !== -1) {
|
if (list.search(counterRxg) !== -1) {
|
||||||
(function parseCL(txt) {
|
(function parseCL (txt) {
|
||||||
var pos = txt.search(counterRxg);
|
var pos = txt.search(counterRxg);
|
||||||
if (pos !== -1) {
|
if (pos !== -1) {
|
||||||
// slice
|
// slice
|
||||||
|
@ -10,7 +10,7 @@ showdown.subParser('runExtension', function (ext, text, options, globals) {
|
|||||||
} else if (ext.regex) {
|
} else if (ext.regex) {
|
||||||
// TODO remove this when old extension loading mechanism is deprecated
|
// TODO remove this when old extension loading mechanism is deprecated
|
||||||
var re = ext.regex;
|
var re = ext.regex;
|
||||||
if (!re instanceof RegExp) {
|
if (!(re instanceof RegExp)) {
|
||||||
re = new RegExp(re, 'g');
|
re = new RegExp(re, 'g');
|
||||||
}
|
}
|
||||||
text = text.replace(re, ext.replace);
|
text = text.replace(re, ext.replace);
|
||||||
|
@ -7,7 +7,7 @@ showdown.subParser('tables', function (text, options, globals) {
|
|||||||
|
|
||||||
var tableRgx = /^ {0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|¨0)/gm;
|
var tableRgx = /^ {0,3}\|?.+\|.+\n[ \t]{0,3}\|?[ \t]*:?[ \t]*(?:-|=){2,}[ \t]*:?[ \t]*\|[ \t]*:?[ \t]*(?:-|=){2,}[\s\S]+?(?:\n\n|¨0)/gm;
|
||||||
|
|
||||||
function parseStyles(sLine) {
|
function parseStyles (sLine) {
|
||||||
if (/^:[ \t]*--*$/.test(sLine)) {
|
if (/^:[ \t]*--*$/.test(sLine)) {
|
||||||
return ' style="text-align:left;"';
|
return ' style="text-align:left;"';
|
||||||
} else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
|
} else if (/^--*[ \t]*:[ \t]*$/.test(sLine)) {
|
||||||
@ -19,7 +19,7 @@ showdown.subParser('tables', function (text, options, globals) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseHeaders(header, style) {
|
function parseHeaders (header, style) {
|
||||||
var id = '';
|
var id = '';
|
||||||
header = header.trim();
|
header = header.trim();
|
||||||
if (options.tableHeaderId) {
|
if (options.tableHeaderId) {
|
||||||
@ -30,12 +30,12 @@ showdown.subParser('tables', function (text, options, globals) {
|
|||||||
return '<th' + id + style + '>' + header + '</th>\n';
|
return '<th' + id + style + '>' + header + '</th>\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseCells(cell, style) {
|
function parseCells (cell, style) {
|
||||||
var subText = showdown.subParser('spanGamut')(cell, options, globals);
|
var subText = showdown.subParser('spanGamut')(cell, options, globals);
|
||||||
return '<td' + style + '>' + subText + '</td>\n';
|
return '<td' + style + '>' + subText + '</td>\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildTable(headers, cells) {
|
function buildTable (headers, cells) {
|
||||||
var tb = '<table>\n<thead>\n<tr>\n',
|
var tb = '<table>\n<thead>\n<tr>\n',
|
||||||
tblLgn = headers.length;
|
tblLgn = headers.length;
|
||||||
|
|
||||||
|
10
test/bootstrap.js
vendored
10
test/bootstrap.js
vendored
@ -19,20 +19,20 @@
|
|||||||
};
|
};
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function getTestSuite(dir) {
|
function getTestSuite (dir) {
|
||||||
return fs.readdirSync(dir)
|
return fs.readdirSync(dir)
|
||||||
.filter(filter())
|
.filter(filter())
|
||||||
.map(map(dir));
|
.map(map(dir));
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter() {
|
function filter () {
|
||||||
return function (file) {
|
return function (file) {
|
||||||
var ext = file.slice(-3);
|
var ext = file.slice(-3);
|
||||||
return (ext === '.md');
|
return (ext === '.md');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function map(dir) {
|
function map (dir) {
|
||||||
return function (file) {
|
return function (file) {
|
||||||
var name = file.replace('.md', ''),
|
var name = file.replace('.md', ''),
|
||||||
htmlPath = dir + name + '.html',
|
htmlPath = dir + name + '.html',
|
||||||
@ -48,7 +48,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function assertion(testCase, converter) {
|
function assertion (testCase, converter) {
|
||||||
return function () {
|
return function () {
|
||||||
testCase.actual = converter.makeHtml(testCase.input);
|
testCase.actual = converter.makeHtml(testCase.input);
|
||||||
testCase = normalize(testCase);
|
testCase = normalize(testCase);
|
||||||
@ -59,7 +59,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Normalize input/output
|
//Normalize input/output
|
||||||
function normalize(testCase) {
|
function normalize (testCase) {
|
||||||
|
|
||||||
// Normalize line returns
|
// Normalize line returns
|
||||||
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
|
testCase.expected = testCase.expected.replace(/(\r\n)|\n|\r/g, '\n');
|
||||||
|
@ -25,10 +25,10 @@ var globals = {
|
|||||||
outputModifiers: [],
|
outputModifiers: [],
|
||||||
converter: converter,
|
converter: converter,
|
||||||
ghCodeBlocks: []
|
ghCodeBlocks: []
|
||||||
},
|
},
|
||||||
options = showdown.getOptions();
|
options = showdown.getOptions();
|
||||||
|
|
||||||
function runTests() {
|
function runTests () {
|
||||||
var testMDFile = fs.readFileSync('test/performance.testfile.md', 'utf8');
|
var testMDFile = fs.readFileSync('test/performance.testfile.md', 'utf8');
|
||||||
new performance.Suite('Basic')
|
new performance.Suite('Basic')
|
||||||
.setOption('cycles', 50)
|
.setOption('cycles', 50)
|
||||||
|
@ -43,7 +43,7 @@ describe('showdown.Converter', function () {
|
|||||||
check(opt, ghOpts[opt]);
|
check(opt, ghOpts[opt]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function check(key, val) {
|
function check (key, val) {
|
||||||
it('should set ' + opt + ' to ' + val, function () {
|
it('should set ' + opt + ' to ' + val, function () {
|
||||||
converter.getOption(key).should.equal(val);
|
converter.getOption(key).should.equal(val);
|
||||||
});
|
});
|
||||||
|
@ -11,6 +11,7 @@ describe('showdown.Converter', function () {
|
|||||||
var showdown = require('../bootstrap').showdown;
|
var showdown = require('../bootstrap').showdown;
|
||||||
|
|
||||||
describe('Converter.options extensions', function () {
|
describe('Converter.options extensions', function () {
|
||||||
|
var runCount;
|
||||||
showdown.extensions.testext = function () {
|
showdown.extensions.testext = function () {
|
||||||
return [{
|
return [{
|
||||||
type: 'output',
|
type: 'output',
|
||||||
@ -20,8 +21,8 @@ describe('showdown.Converter', function () {
|
|||||||
}
|
}
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
var runCount,
|
|
||||||
converter = new showdown.Converter({extensions: ['testext']});
|
var converter = new showdown.Converter({extensions: ['testext']});
|
||||||
|
|
||||||
it('output extensions should run once', function () {
|
it('output extensions should run once', function () {
|
||||||
runCount = 0;
|
runCount = 0;
|
||||||
|
@ -39,8 +39,7 @@ performance.generateLog = function (filename, MDFilename, asTable) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
jsonParsed = JSON.parse(json);
|
jsonParsed = JSON.parse(json);
|
||||||
}
|
} catch (err) {
|
||||||
catch (err) {
|
|
||||||
jsonParsed = {};
|
jsonParsed = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -99,7 +98,7 @@ performance.generateLog = function (filename, MDFilename, asTable) {
|
|||||||
generateMD(MDFilename, finalJsonObj, asTable);
|
generateMD(MDFilename, finalJsonObj, asTable);
|
||||||
};
|
};
|
||||||
|
|
||||||
function generateMD(filename, obj, asTable) {
|
function generateMD (filename, obj, asTable) {
|
||||||
fs.closeSync(fs.openSync(filename, 'w'));
|
fs.closeSync(fs.openSync(filename, 'w'));
|
||||||
asTable = !!asTable;
|
asTable = !!asTable;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user