You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

76 lines
971 B

/**
* @author Titus Wormer
* @copyright 2016 Titus Wormer
* @license MIT
* @module markdown-escapes
* @fileoverview List of escapable characters in markdown.
*/
'use strict';
/* eslint-env commonjs */
/* Expose. */
module.exports = escapes;
/* Characters. */
var defaults = [
'\\',
'`',
'*',
'{',
'}',
'[',
']',
'(',
')',
'#',
'+',
'-',
'.',
'!',
'_',
'>'
];
var gfm = defaults.concat(['~', '|']);
var commonmark = gfm.concat([
'\n',
'"',
'$',
'%',
'&',
'\'',
',',
'/',
':',
';',
'<',
'=',
'?',
'@',
'^'
]);
/* Expose characters. */
escapes.default = defaults;
escapes.gfm = gfm;
escapes.commonmark = commonmark;
/**
* Get markdown escapes.
*
* @param {Object?} [options] - Configuration.
* @return {Array.<string>} - Escapes.
*/
function escapes(options) {
var settings = options || {};
if (settings.commonmark) {
return commonmark;
}
return settings.gfm ? gfm : defaults;
}