showdown/dist/showdown.min.js

4 lines
14 KiB
JavaScript
Raw Normal View History

/*! showdown 26-05-2015 */
(function(){function a(a){"use strict";if(!f.hasOwnProperty(a))throw Error("Extension named "+a+" is not registered!");return f[a]}function b(a,b){"use strict";if("object"!=typeof b)throw Error("A Showdown Extension must be an object, "+typeof b+" given");if(!d.helper.isString(b.type))throw Error('When registering a showdown extension, "type" must be a string, '+typeof b.type+" given");b.type=b.type.toLowerCase(),f[a]=b}function c(a,b){"use strict";var c=b.charCodeAt(0);return"~E"+c+"E"}var d={},e={},f={},g={omitExtraWLInCodeBlocks:!1,prefixHeaderId:!1};d.helper={},d.extensions={},d.setOption=function(a,b){"use strict";return g[a]=b,this},d.getOption=function(a){"use strict";return g[a]},d.getOptions=function(){"use strict";return g},d.subParser=function(a,b){"use strict";if(d.helper.isString(a)){if("undefined"==typeof b){if(e.hasOwnProperty(a))return e[a];throw Error("SubParser named "+a+" not registered!")}e[a]=b}},d.extension=function(c,e){"use strict";if(!d.helper.isString(c))throw Error("Extension 'name' must be a string");return c=d.helper.stdExtName(c),d.helper.isUndefined(e)?a():b()},d.Converter=function(a){"use strict";function b(a){if(!a)return a;var b={gHtmlBlocks:[],gUrls:{},gTitles:{},gListLevel:0,hashLinkCounts:{},langExtensions:h,outputModifiers:i};a=a.replace(/~/g,"~T"),a=a.replace(/\$/g,"~D"),a=a.replace(/\r\n/g,"\n"),a=a.replace(/\r/g,"\n"),a="\n\n"+a+"\n\n",a=e.detab(a,c,b),a=e.stripBlankLines(a,c,b),a=e.languageExtensions(a,c,b);for(var f=0;f<j.length;++f){var g=j[f];a=e[g](a,c,b)}return a=a.replace(/~D/g,"$$"),a=a.replace(/~T/g,"~"),d.helper.forEach(b.outputModifiers,function(b){a=d.subParser("runExtension")(b,a)}),a=e.outputModifiers(a,c,b)}a=a||{};var c={},h=[],i=[],j=["githubCodeBlocks","hashHTMLBlocks","stripLinkDefinitions","blockGamut","unescapeSpecialChars"];for(var k in g)g.hasOwnProperty(k)&&(c[k]=g[k]);if("object"==typeof a)for(var l in a)a.hasOwnProperty(l)&&(c[l]=a[l]);var m=this;return m.makeHtml=b,c.extensions&&d.helper.forEach(c.extensions,function(a){var b=a;if("string"==typeof a){var c=d.helper.stdExtName(a);!d.helper.isUndefined(d.extensions[c])&&d.extensions[c]?a=d.extensions[c]:d.helper.isUndefined(f[c])||(a=f[c])}if("function"!=typeof a){var e="An extension could not be loaded. It was either not found or is not a valid extension.";throw"string"==typeof b&&(e='Extension "'+b+'" could not be loaded. It was either not found or is not a valid extension.'),e}d.helper.forEach(a(m),function(a){a.type?"language"===a.type||"lang"===a.type?h.push(a):("output"===a.type||"html"===a.type)&&i.push(a):i.push(a)})}),{makeHtml:b}},d.hasOwnProperty("helper")||(d.helper={}),d.helper.isString=function(a){"use strict";return"string"==typeof a||a instanceof String},d.helper.forEach=function(a,b){"use strict";if("function"==typeof a.forEach)a.forEach(b);else for(var c=0;c<a.length;c++)b(a[c],c,a)},d.helper.isArray=function(a){"use strict";return a.constructor===Array},d.helper.isUndefined=function(a){"use strict";return"undefined"==typeof a},d.helper.stdExtName=function(a){"use strict";return a.replace(/[_-]||\s/g,"").toLowerCase()},d.helper.escapeCharactersCallback=c,d.helper.escapeCharacters=function(a,b,d){"use strict";var e="(["+b.replace(/([\[\]\\])/g,"\\$1")+"])";d&&(e="\\\\"+e);var f=new RegExp(e,"g");return a=a.replace(f,c)},d.subParser("anchors",function(a,b,c){"use strict";var e=function(a,b,e,f,g,h,i,j){d.helper.isUndefined(j)&&(j=""),a=b;var k=e,l=f.toLowerCase(),m=g,n=j;if(!m)if(l||(l=k.toLowerCase().replace(/ ?\n/g," ")),m="#"+l,d.helper.isUndefined(c.gUrls[l])){if(!(a.search(/\(\s*\)$/m)>-1))return a;m=""}else m=c.gUrls[l],d.helper.isUndefined(c.gTitles[l])||(n=c.gTitles[l]);m=d.helper.escapeCharacters(m,"*_",!1);var o='<a href="'+m+'"';return""!==n&&null!==n&&(n=n.replace(/"/g,"&quot;"),n=d.helper.escapeCharacters(n,"*_",!1),o+=' title="'+n+'"'),o+=">"+k+"</a>"};return a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,e),a=a.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,e),a=a.replace(/(\[([^\[\]
//# sourceMappingURL=showdown.min.js.map