Update dependencies to enable Greenkeeper 🌴 (#335)

adapt code to updated dependencies
This commit is contained in:
greenkeeper[bot] 2017-01-31 05:46:25 +00:00 committed by Estevão Soares dos Santos
parent 1832b7f721
commit b5e46fdb8d
34 changed files with 258 additions and 303 deletions

27
.eslintrc.json Normal file
View 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
View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,6 @@
![Showdown][sd-logo] ![Showdown][sd-logo]
[![Build Status](https://travis-ci.org/showdownjs/showdown.svg?branch=master)](https://travis-ci.org/showdownjs/showdown) [![npm version](https://badge.fury.io/js/showdown.svg)](http://badge.fury.io/js/showdown) [![Bower version](https://badge.fury.io/bo/showdown.svg)](http://badge.fury.io/bo/showdown) [![Join the chat at https://gitter.im/showdownjs/showdown](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/showdownjs/showdown?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Build Status](https://travis-ci.org/showdownjs/showdown.svg?branch=master)](https://travis-ci.org/showdownjs/showdown) [![npm version](https://badge.fury.io/js/showdown.svg)](http://badge.fury.io/js/showdown) [![Bower version](https://badge.fury.io/bo/showdown.svg)](http://badge.fury.io/bo/showdown) [![Join the chat at https://gitter.im/showdownjs/showdown](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/showdownjs/showdown?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Greenkeeper badge](https://badges.greenkeeper.io/showdownjs/showdown.svg)](https://greenkeeper.io/)
------ ------

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.

View File

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

View File

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

View File

@ -31,7 +31,8 @@ yargs
.wrap(yargs.terminalWidth()); .wrap(yargs.terminalWidth());
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 {

View File

@ -1,8 +1,8 @@
var yargs = require('yargs'), var yargs = require('yargs'),
fs = require('fs'), fs = require('fs'),
Messenger = require('./messenger.js'), Messenger = require('./messenger.js'),
showdown = require('../../dist/showdown'), showdown = require('../../dist/showdown'),
showdownOptions = showdown.getDefaultOptions(false); showdownOptions = showdown.getDefaultOptions(false);
yargs.reset() yargs.reset()
.usage('Usage: showdown makehtml [options]') .usage('Usage: showdown makehtml [options]')
@ -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,9 +120,9 @@ 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) || {};
// if flavor is not undefined, let's tell the user we're loading that preset // if flavor is not undefined, let's tell the user we're loading that preset
if (flavor) { if (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;

View File

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

View File

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

View File

@ -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';
@ -143,11 +143,11 @@ showdown.helper.escapeCharacters = function (text, charsToEscape, afterBackslash
var rgxFindMatchPos = function (str, left, right, flags) { var rgxFindMatchPos = function (str, left, right, flags) {
'use strict'; 'use strict';
var f = flags || '', var f = flags || '',
g = f.indexOf('g') > -1, g = f.indexOf('g') > -1,
x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')), x = new RegExp(left + '|' + right, 'g' + f.replace(/g/g, '')),
l = new RegExp(left, f.replace(/g/g, '')), l = new RegExp(left, f.replace(/g/g, '')),
pos = [], pos = [],
t, s, m, start, end; t, s, m, start, end;
do { do {
t = 0; t = 0;
@ -211,7 +211,7 @@ showdown.helper.matchRecursiveRegExp = function (str, left, right, flags) {
'use strict'; 'use strict';
var matchPos = rgxFindMatchPos (str, left, right, flags), var matchPos = rgxFindMatchPos (str, left, right, flags),
results = []; results = [];
for (var i = 0; i < matchPos.length; ++i) { for (var i = 0; i < matchPos.length; ++i) {
results.push([ results.push([

View File

@ -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 = {};

View File

@ -237,14 +237,14 @@ 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',
ret = { ret = {
valid: true, valid: true,
error: '' error: ''
}; };
if (!showdown.helper.isArray(extension)) { if (!showdown.helper.isArray(extension)) {
extension = [extension]; extension = [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;

View File

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

View File

@ -3,50 +3,50 @@ showdown.subParser('hashHTMLBlocks', function (text, options, globals) {
text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals); text = globals.converter._dispatch('hashHTMLBlocks.before', text, options, globals);
var blockTags = [ var blockTags = [
'pre', 'pre',
'div', 'div',
'h1', 'h1',
'h2', 'h2',
'h3', 'h3',
'h4', 'h4',
'h5', 'h5',
'h6', 'h6',
'blockquote', 'blockquote',
'table', 'table',
'dl', 'dl',
'ol', 'ol',
'ul', 'ul',
'script', 'script',
'noscript', 'noscript',
'form', 'form',
'fieldset', 'fieldset',
'iframe', 'iframe',
'math', 'math',
'style', 'style',
'section', 'section',
'header', 'header',
'footer', 'footer',
'nav', 'nav',
'article', 'article',
'aside', 'aside',
'address', 'address',
'audio', 'audio',
'canvas', 'canvas',
'figure', 'figure',
'hgroup', 'hgroup',
'output', 'output',
'video', 'video',
'p' 'p'
], ],
repFunc = function (wholeMatch, match, left, right) { repFunc = function (wholeMatch, match, left, right) {
var txt = wholeMatch; var txt = wholeMatch;
// check if this html element is marked as markdown // check if this html element is marked as markdown
// if so, it's contents should be parsed as markdown // if so, it's contents should be parsed as markdown
if (left.search(/\bmarkdown\b/) !== -1) { if (left.search(/\bmarkdown\b/) !== -1) {
txt = left + globals.converter.makeHtml(match) + right; txt = left + globals.converter.makeHtml(match) + right;
} }
return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n'; return '\n\n¨K' + (globals.gHtmlBlocks.push(txt) - 1) + 'K\n\n';
}; };
for (var i = 0; i < blockTags.length; ++i) { for (var i = 0; i < blockTags.length; ++i) {
text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<' + blockTags[i] + '\\b[^>]*>', '</' + blockTags[i] + '>', 'gim'); text = showdown.helper.replaceRecursiveRegExp(text, repFunc, '^ {0,3}<' + blockTags[i] + '\\b[^>]*>', '</' + blockTags[i] + '>', 'gim');

View File

@ -30,7 +30,7 @@ showdown.subParser('headers', function (text, options, globals) {
var spanGamut = showdown.subParser('spanGamut')(m1, options, globals), var spanGamut = showdown.subParser('spanGamut')(m1, options, globals),
hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"', hID = (options.noHeaderId) ? '' : ' id="' + headerId(m1) + '"',
hLevel = headerLevelStart + 1, hLevel = headerLevelStart + 1,
hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>'; hashBlock = '<h' + hLevel + hID + '>' + spanGamut + '</h' + hLevel + '>';
return showdown.subParser('hashBlock')(hashBlock, options, globals); return showdown.subParser('hashBlock')(hashBlock, 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) {

View File

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

View File

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

View File

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

18
test/bootstrap.js vendored
View File

@ -19,26 +19,26 @@
}; };
*/ */
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',
html = fs.readFileSync(htmlPath, 'utf8'), html = fs.readFileSync(htmlPath, 'utf8'),
mdPath = dir + name + '.md', mdPath = dir + name + '.md',
md = fs.readFileSync(mdPath, 'utf8'); md = fs.readFileSync(mdPath, 'utf8');
return { return {
name: name, name: name,
@ -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');

View File

@ -13,22 +13,22 @@ performance.setVersion(pkg.version);
performance.setGithubLink('https://github.com/showdownjs/showdown/tree/'); performance.setGithubLink('https://github.com/showdownjs/showdown/tree/');
var globals = { var globals = {
gHtmlBlocks: [], gHtmlBlocks: [],
gHtmlMdBlocks: [], gHtmlMdBlocks: [],
gHtmlSpans: [], gHtmlSpans: [],
gUrls: {}, gUrls: {},
gTitles: {}, gTitles: {},
gDimensions: {}, gDimensions: {},
gListLevel: 0, gListLevel: 0,
hashLinkCounts: {}, hashLinkCounts: {},
langExtensions: [], langExtensions: [],
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)

View File

@ -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);
}); });
@ -112,22 +112,22 @@ describe('showdown.Converter', function () {
describe('events', function () { describe('events', function () {
var events = [ var events = [
'anchors', 'anchors',
'autoLinks', 'autoLinks',
'blockGamut', 'blockGamut',
'blockQuotes', 'blockQuotes',
'codeBlocks', 'codeBlocks',
'codeSpans', 'codeSpans',
'githubCodeBlocks', 'githubCodeBlocks',
'headers', 'headers',
'images', 'images',
'italicsAndBold', 'italicsAndBold',
'lists', 'lists',
'paragraph', 'paragraph',
'spanGamut' 'spanGamut'
//'strikeThrough', //'strikeThrough',
//'tables' //'tables'
]; ];
for (var i = 0; i < events.length; ++i) { for (var i = 0; i < events.length; ++i) {
runListener(events[i] + '.before'); runListener(events[i] + '.before');

View File

@ -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;
@ -32,8 +33,8 @@ describe('showdown.Converter', function () {
describe('makeHtml() with option omitExtraWLInCodeBlocks', function () { describe('makeHtml() with option omitExtraWLInCodeBlocks', function () {
var converter = new showdown.Converter({omitExtraWLInCodeBlocks: true}), var converter = new showdown.Converter({omitExtraWLInCodeBlocks: true}),
text = 'var foo = bar;', text = 'var foo = bar;',
html = converter.makeHtml(' ' + text); html = converter.makeHtml(' ' + text);
it('should omit extra line after code tag', function () { it('should omit extra line after code tag', function () {
var expectedHtml = '<pre><code>' + text + '</code></pre>'; var expectedHtml = '<pre><code>' + text + '</code></pre>';
html.should.equal(expectedHtml); html.should.equal(expectedHtml);
@ -42,19 +43,19 @@ describe('showdown.Converter', function () {
describe('makeHtml() with option prefixHeaderId', function () { describe('makeHtml() with option prefixHeaderId', function () {
var converter = new showdown.Converter(), var converter = new showdown.Converter(),
text = 'foo header'; text = 'foo header';
it('should prefix header id with "section"', function () { it('should prefix header id with "section"', function () {
converter.setOption('prefixHeaderId', true); converter.setOption('prefixHeaderId', true);
var html = converter.makeHtml('# ' + text), var html = converter.makeHtml('# ' + text),
expectedHtml = '<h1 id="sectionfooheader">' + text + '</h1>'; expectedHtml = '<h1 id="sectionfooheader">' + text + '</h1>';
html.should.equal(expectedHtml); html.should.equal(expectedHtml);
}); });
it('should prefix header id with custom string', function () { it('should prefix header id with custom string', function () {
converter.setOption('prefixHeaderId', 'blabla'); converter.setOption('prefixHeaderId', 'blabla');
var html = converter.makeHtml('# ' + text), var html = converter.makeHtml('# ' + text),
expectedHtml = '<h1 id="blablafooheader">' + text + '</h1>'; expectedHtml = '<h1 id="blablafooheader">' + text + '</h1>';
html.should.equal(expectedHtml); html.should.equal(expectedHtml);
}); });
}); });

View File

@ -6,7 +6,7 @@
/*jshint -W010 */ /*jshint -W010 */
/*jshint -W009 */ /*jshint -W009 */
var bootstrap = require('../bootstrap.js'), var bootstrap = require('../bootstrap.js'),
showdown = bootstrap.showdown; showdown = bootstrap.showdown;
describe('encodeEmailAddress()', function () { describe('encodeEmailAddress()', function () {
'use strict'; 'use strict';

View File

@ -100,9 +100,9 @@ describe('showdown.extension()', function () {
describe('showdown.getAllExtensions()', function () { describe('showdown.getAllExtensions()', function () {
'use strict'; 'use strict';
var extObjMock = { var extObjMock = {
type: 'lang', type: 'lang',
filter: function () {} filter: function () {}
}; };
it('should return all extensions', function () { it('should return all extensions', function () {
showdown.extension('bar', extObjMock); showdown.extension('bar', extObjMock);

View File

@ -2,16 +2,16 @@
* Created by Estevao on 14-07-2015. * Created by Estevao on 14-07-2015.
*/ */
var bootstrap = require('../bootstrap.js'), var bootstrap = require('../bootstrap.js'),
converter = new bootstrap.showdown.Converter({ converter = new bootstrap.showdown.Converter({
strikethrough: true, strikethrough: true,
literalMidWordUnderscores: true, literalMidWordUnderscores: true,
simplifiedAutoLink: true, simplifiedAutoLink: true,
tables: true, tables: true,
parseImgDimensions: true, //extra parseImgDimensions: true, //extra
tasklists: true //extra tasklists: true //extra
}), }),
assertion = bootstrap.assertion, assertion = bootstrap.assertion,
testsuite = bootstrap.getTestSuite('test/ghost/'); testsuite = bootstrap.getTestSuite('test/ghost/');
//MD-Testsuite (borrowed from karlcow/markdown-testsuite) //MD-Testsuite (borrowed from karlcow/markdown-testsuite)
describe('makeHtml() ghost testsuite', function () { describe('makeHtml() ghost testsuite', function () {

View File

@ -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;
@ -137,11 +136,11 @@ function generateMD(filename, obj, asTable) {
performance.Suite = function (name) { performance.Suite = function (name) {
var suiteName = name || '', var suiteName = name || '',
tests = [], tests = [],
hasRunFlag = false, hasRunFlag = false,
options = { options = {
cycles: 20 cycles: 20
}; };
this.setOption = function (key, val) { this.setOption = function (key, val) {
options[key] = val; options[key] = val;
@ -200,7 +199,7 @@ performance.Suite = function (name) {
console.log('running tests: ' + nn + ' cycles each.'); console.log('running tests: ' + nn + ' cycles each.');
for (var i = 0; i < tests.length; ++i) { for (var i = 0; i < tests.length; ++i) {
var times = [], var times = [],
passVar = tests[i].obj.prepare(); passVar = tests[i].obj.prepare();
for (var ii = 0; ii < nn; ++ii) { for (var ii = 0; ii < nn; ++ii) {
var before = now(); var before = now();
tests[i].obj.test(passVar); tests[i].obj.test(passVar);