yavsc/Yavsc/wwwroot/js/showdown.min.js

1 line
23 KiB
JavaScript

(function(){function e(e){"use strict";var r={omitExtraWLInCodeBlocks:{"default":!1,describe:"Omit the default extra whiteline added to code blocks",type:"boolean"},noHeaderId:{"default":!1,describe:"Turn on/off generated header id",type:"boolean"},prefixHeaderId:{"default":!1,describe:"Specify a prefix to generated header ids",type:"string"},headerLevelStart:{"default":!1,describe:"The header blocks level start",type:"integer"},parseImgDimensions:{"default":!1,describe:"Turn on/off image dimension parsing",type:"boolean"},simplifiedAutoLink:{"default":!1,describe:"Turn on/off GFM autolink style",type:"boolean"},literalMidWordUnderscores:{"default":!1,describe:"Parse midword underscores as literal underscores",type:"boolean"},strikethrough:{"default":!1,describe:"Turn on/off strikethrough support",type:"boolean"},tables:{"default":!1,describe:"Turn on/off tables support",type:"boolean"},tablesHeaderId:{"default":!1,describe:"Add an id to table headers",type:"boolean"},ghCodeBlocks:{"default":!0,describe:"Turn on/off GFM fenced code blocks support",type:"boolean"},tasklists:{"default":!1,describe:"Turn on/off GFM tasklist support",type:"boolean"},smoothLivePreview:{"default":!1,describe:"Prevents weird effects in live previews due to incomplete input",type:"boolean"}};if(e===!1)return JSON.parse(JSON.stringify(r));var t={};for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n]["default"]);return t}function r(e,r){"use strict";var t=r?"Error in "+r+" extension->":"Error in unnamed extension",s={valid:!0,error:""};n.helper.isArray(e)||(e=[e]);for(var a=0;a<e.length;++a){var i=t+" sub-extension "+a+": ",o=e[a];if("object"!=typeof o)return s.valid=!1,s.error=i+"must be an object, but "+typeof o+" given",s;if(!n.helper.isString(o.type))return s.valid=!1,s.error=i+'property "type" must be a string, but '+typeof o.type+" given",s;var u=o.type=o.type.toLowerCase();if("language"===u&&(u=o.type="lang"),"html"===u&&(u=o.type="output"),"lang"!==u&&"output"!==u)return s.valid=!1,s.error=i+"type "+u+' is not recognized. Valid values: "lang" or "output"',s;if(o.filter){if("function"!=typeof o.filter)return s.valid=!1,s.error=i+'"filter" must be a function, but '+typeof o.filter+" given",s}else{if(!o.regex)return s.valid=!1,s.error=i+'extensions must define either a "regex" property or a "filter" method',s;if(n.helper.isString(o.regex)&&(o.regex=new RegExp(o.regex,"g")),!o.regex instanceof RegExp)return s.valid=!1,s.error=i+'"regex" property must either be a string or a RegExp object, but '+typeof o.regex+" given",s;if(n.helper.isUndefined(o.replace))return s.valid=!1,s.error=i+'"regex" extensions must implement a replace string or function',s}if(n.helper.isUndefined(o.filter)&&n.helper.isUndefined(o.regex))return s.valid=!1,s.error=i+"output extensions must define a filter property",s}return s}function t(e,r){"use strict";var t=r.charCodeAt(0);return"~E"+t+"E"}var n={},s={},a={},i=e(!0),o={github:{omitExtraWLInCodeBlocks:!0,prefixHeaderId:"user-content-",simplifiedAutoLink:!0,literalMidWordUnderscores:!0,strikethrough:!0,tables:!0,tablesHeaderId:!0,ghCodeBlocks:!0,tasklists:!0},vanilla:e(!0)};n.helper={},n.extensions={},n.setOption=function(e,r){"use strict";return i[e]=r,this},n.getOption=function(e){"use strict";return i[e]},n.getOptions=function(){"use strict";return i},n.resetOptions=function(){"use strict";i=e(!0)},n.setFlavor=function(e){"use strict";if(o.hasOwnProperty(e)){var r=o[e];for(var t in r)r.hasOwnProperty(t)&&(i[t]=r[t])}},n.getDefaultOptions=function(r){"use strict";return e(r)},n.subParser=function(e,r){"use strict";if(n.helper.isString(e)){if("undefined"==typeof r){if(s.hasOwnProperty(e))return s[e];throw Error("SubParser named "+e+" not registered!")}s[e]=r}},n.extension=function(e,t){"use strict";if(!n.helper.isString(e))throw Error("Extension 'name' must be a string");if(e=n.helper.stdExtName(e),n.helper.isUndefined(t)){if(!a.hasOwnProperty(e))throw Error("Extension named "+e+" is not registered!");return a[e]}"function"==typeof t&&(t=t()),n.helper.isArray(t)||(t=[t]);var s=r(t,e);if(!s.valid)throw Error(s.error);a[e]=t},n.getAllExtensions=function(){"use strict";return a},n.removeExtension=function(e){"use strict";delete a[e]},n.resetExtensions=function(){"use strict";a={}},n.validateExtension=function(e){"use strict";var t=r(e,null);return t.valid?!0:(console.warn(t.error),!1)},n.hasOwnProperty("helper")||(n.helper={}),n.helper.isString=function(e){"use strict";return"string"==typeof e||e instanceof String},n.helper.forEach=function(e,r){"use strict";if("function"==typeof e.forEach)e.forEach(r);else for(var t=0;t<e.length;t++)r(e[t],t,e)},n.helper.isArray=function(e){"use strict";return e.constructor===Array},n.helper.isUndefined=function(e){"use strict";return"undefined"==typeof e},n.helper.stdExtName=function(e){"use strict";return e.replace(/[_-]||\s/g,"").toLowerCase()},n.helper.escapeCharactersCallback=t,n.helper.escapeCharacters=function(e,r,n){"use strict";var s="(["+r.replace(/([\[\]\\])/g,"\\$1")+"])";n&&(s="\\\\"+s);var a=new RegExp(s,"g");return e=e.replace(a,t)},n.helper.isUndefined(console)&&(console={warn:function(e){"use strict";alert(e)},log:function(e){"use strict";alert(e)}}),n.Converter=function(e){"use strict";function t(){e=e||{};for(var r in i)i.hasOwnProperty(r)&&(c[r]=i[r]);if("object"!=typeof e)throw Error("Converter expects the passed parameter to be an object, but "+typeof e+" was passed instead.");for(var t in e)e.hasOwnProperty(t)&&(c[t]=e[t]);c.extensions&&n.helper.forEach(c.extensions,u)}function u(e,t){if(t=t||null,n.helper.isString(e)){if(e=n.helper.stdExtName(e),t=e,n.extensions[e])return console.warn("DEPRECATION WARNING: "+e+" is an old extension that uses a deprecated loading method.Please inform the developer that the extension should be updated!"),void l(n.extensions[e],e);if(n.helper.isUndefined(a[e]))throw Error('Extension "'+e+'" could not be loaded. It was either not found or is not a valid extension.');e=a[e]}"function"==typeof e&&(e=e()),n.helper.isArray(e)||(e=[e]);var s=r(e,t);if(!s.valid)throw Error(s.error);for(var i=0;i<e.length;++i)switch(e[i].type){case"lang":p.push(e[i]);break;case"output":h.push(e[i]);break;default:throw Error("Extension loader error: Type unrecognized!!!")}}function l(e,t){"function"==typeof e&&(e=e(new n.Converter)),n.helper.isArray(e)||(e=[e]);var s=r(e,t);if(!s.valid)throw Error(s.error);for(var a=0;a<e.length;++a)switch(e[a].type){case"lang":p.push(e[a]);break;case"output":h.push(e[a]);break;default:throw Error("Extension loader error: Type unrecognized!!!")}}var c={},p=[],h=[],d=["githubCodeBlocks","hashHTMLBlocks","stripLinkDefinitions","blockGamut","unescapeSpecialChars"];t(),this.makeHtml=function(e){if(!e)return e;var r={gHtmlBlocks:[],gUrls:{},gTitles:{},gDimensions:{},gListLevel:0,hashLinkCounts:{},langExtensions:p,outputModifiers:h,converter:this};e=e.replace(/~/g,"~T"),e=e.replace(/\$/g,"~D"),e=e.replace(/\r\n/g,"\n"),e=e.replace(/\r/g,"\n"),e="\n\n"+e+"\n\n",e=n.subParser("detab")(e,c,r),e=n.subParser("stripBlankLines")(e,c,r),n.helper.forEach(p,function(t){e=n.subParser("runExtension")(t,e,c,r)});for(var t=0;t<d.length;++t){var a=d[t];e=s[a](e,c,r)}return e=e.replace(/~D/g,"$$"),e=e.replace(/~T/g,"~"),n.helper.forEach(h,function(t){e=n.subParser("runExtension")(t,e,c,r)}),e},this.setOption=function(e,r){c[e]=r},this.getOption=function(e){return c[e]},this.getOptions=function(){return c},this.addExtension=function(e,r){r=r||null,u(e,r)},this.useExtension=function(e){u(e)},this.setFlavor=function(e){if(o.hasOwnProperty(e)){var r=o[e];for(var t in r)r.hasOwnProperty(t)&&(c[t]=r[t])}},this.removeExtension=function(e){n.helper.isArray(e)||(e=[e]);for(var r=0;r<e.length;++r){for(var t=e[r],s=0;s<p.length;++s)p[s]===t&&p[s].splice(s,1);for(var a=0;a<h.length;++s)h[a]===t&&h[a].splice(s,1)}},this.getAllExtensions=function(){return{language:p,output:h}}},n.subParser("anchors",function(e,r,t){"use strict";var s=function(e,r,s,a,i,o,u,l){n.helper.isUndefined(l)&&(l=""),e=r;var c=s,p=a.toLowerCase(),h=i,d=l;if(!h)if(p||(p=c.toLowerCase().replace(/ ?\n/g," ")),h="#"+p,n.helper.isUndefined(t.gUrls[p])){if(!(e.search(/\(\s*\)$/m)>-1))return e;h=""}else h=t.gUrls[p],n.helper.isUndefined(t.gTitles[p])||(d=t.gTitles[p]);h=n.helper.escapeCharacters(h,"*_",!1);var f='<a href="'+h+'"';return""!==d&&null!==d&&(d=d.replace(/"/g,"&quot;"),d=n.helper.escapeCharacters(d,"*_",!1),f+=' title="'+d+'"'),f+=">"+c+"</a>"};return e=e.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\][ ]?(?:\n[ ]*)?\[(.*?)\])()()()()/g,s),e=e.replace(/(\[((?:\[[^\]]*\]|[^\[\]])*)\]\([ \t]*()<?(.*?(?:\(.*?\).*?)?)>?[ \t]*((['"])(.*?)\6[ \t]*)?\))/g,s),e=e.replace(/(\[([^\[\]]+)\])()()()()()/g,s)}),n.subParser("autoLinks",function(e,r){"use strict";function t(e,r){var t=n.subParser("unescapeSpecialChars")(r);return n.subParser("encodeEmailAddress")(t)}var s=/\b(((https?|ftp|dict):\/\/|www\.)[^'">\s]+\.[^'">\s]+)(?=\s|$)(?!["<>])/gi,a=/<(((https?|ftp|dict):\/\/|www\.)[^'">\s]+)>/gi,i=/\b(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)\b/gi,o=/<(?:mailto:)?([-.\w]+@[-a-z0-9]+(\.[-a-z0-9]+)*\.[a-z]+)>/gi;return e=e.replace(a,'<a href="$1">$1</a>'),e=e.replace(o,t),r.simplifiedAutoLink&&(e=e.replace(s,'<a href="$1">$1</a>'),e=e.replace(i,t)),e}),n.subParser("blockGamut",function(e,r,t){"use strict";e=n.subParser("blockQuotes")(e,r,t),e=n.subParser("headers")(e,r,t);var s=n.subParser("hashBlock")("<hr />",r,t);return e=e.replace(/^[ ]{0,2}([ ]?\*[ ]?){3,}[ \t]*$/gm,s),e=e.replace(/^[ ]{0,2}([ ]?\-[ ]?){3,}[ \t]*$/gm,s),e=e.replace(/^[ ]{0,2}([ ]?_[ ]?){3,}[ \t]*$/gm,s),e=n.subParser("lists")(e,r,t),e=n.subParser("codeBlocks")(e,r,t),e=n.subParser("tables")(e,r,t),e=n.subParser("hashHTMLBlocks")(e,r,t),e=n.subParser("paragraphs")(e,r,t)}),n.subParser("blockQuotes",function(e,r,t){"use strict";return e=e.replace(/((^[ \t]{0,3}>[ \t]?.+\n(.+\n)*\n*)+)/gm,function(e,s){var a=s;return a=a.replace(/^[ \t]*>[ \t]?/gm,"~0"),a=a.replace(/~0/g,""),a=a.replace(/^[ \t]+$/gm,""),a=n.subParser("githubCodeBlocks")(a,r,t),a=n.subParser("blockGamut")(a,r,t),a=a.replace(/(^|\n)/g,"$1 "),a=a.replace(/(\s*<pre>[^\r]+?<\/pre>)/gm,function(e,r){var t=r;return t=t.replace(/^ /gm,"~0"),t=t.replace(/~0/g,"")}),n.subParser("hashBlock")("<blockquote>\n"+a+"\n</blockquote>",r,t)})}),n.subParser("codeBlocks",function(e,r,t){"use strict";e+="~0";var s=/(?:\n\n|^)((?:(?:[ ]{4}|\t).*\n+)+)(\n*[ ]{0,3}[^ \t\n]|(?=~0))/g;return e=e.replace(s,function(e,s,a){var i=s,o=a,u="\n";return i=n.subParser("outdent")(i),i=n.subParser("encodeCode")(i),i=n.subParser("detab")(i),i=i.replace(/^\n+/g,""),i=i.replace(/\n+$/g,""),r.omitExtraWLInCodeBlocks&&(u=""),i="<pre><code>"+i+u+"</code></pre>",n.subParser("hashBlock")(i,r,t)+o}),e=e.replace(/~0/,"")}),n.subParser("codeSpans",function(e){"use strict";return e=e.replace(/(<code[^><]*?>)([^]*?)<\/code>/g,function(e,r,t){return t=t.replace(/^([ \t]*)/g,""),t=t.replace(/[ \t]*$/g,""),t=n.subParser("encodeCode")(t),r+t+"</code>"}),e=e.replace(/(^|[^\\])(`+)([^\r]*?[^`])\2(?!`)/gm,function(e,r,t,s){var a=s;return a=a.replace(/^([ \t]*)/g,""),a=a.replace(/[ \t]*$/g,""),a=n.subParser("encodeCode")(a),r+"<code>"+a+"</code>"})}),n.subParser("detab",function(e){"use strict";return e=e.replace(/\t(?=\t)/g," "),e=e.replace(/\t/g,"~A~B"),e=e.replace(/~B(.+?)~A/g,function(e,r){for(var t=r,n=4-t.length%4,s=0;n>s;s++)t+=" ";return t}),e=e.replace(/~A/g," "),e=e.replace(/~B/g,"")}),n.subParser("encodeAmpsAndAngles",function(e){"use strict";return e=e.replace(/&(?!#?[xX]?(?:[0-9a-fA-F]+|\w+);)/g,"&amp;"),e=e.replace(/<(?![a-z\/?\$!])/gi,"&lt;")}),n.subParser("encodeBackslashEscapes",function(e){"use strict";return e=e.replace(/\\(\\)/g,n.helper.escapeCharactersCallback),e=e.replace(/\\([`*_{}\[\]()>#+-.!])/g,n.helper.escapeCharactersCallback)}),n.subParser("encodeCode",function(e){"use strict";return e=e.replace(/&/g,"&amp;"),e=e.replace(/</g,"&lt;"),e=e.replace(/>/g,"&gt;"),e=n.helper.escapeCharacters(e,"*_{}[]\\",!1)}),n.subParser("encodeEmailAddress",function(e){"use strict";var r=[function(e){return"&#"+e.charCodeAt(0)+";"},function(e){return"&#x"+e.charCodeAt(0).toString(16)+";"},function(e){return e}];return e="mailto:"+e,e=e.replace(/./g,function(e){if("@"===e)e=r[Math.floor(2*Math.random())](e);else if(":"!==e){var t=Math.random();e=t>.9?r[2](e):t>.45?r[1](e):r[0](e)}return e}),e='<a href="'+e+'">'+e+"</a>",e=e.replace(/">.+:/g,'">')}),n.subParser("escapeSpecialCharsWithinTagAttributes",function(e){"use strict";var r=/(<[a-z\/!$]("[^"]*"|'[^']*'|[^'">])*>|<!(--.*?--\s*)+>)/gi;return e=e.replace(r,function(e){var r=e.replace(/(.)<\/?code>(?=.)/g,"$1`");return r=n.helper.escapeCharacters(r,"\\`*_",!1)})}),n.subParser("githubCodeBlocks",function(e,r,t){"use strict";return r.ghCodeBlocks?(e+="~0",e=e.replace(/(?:^|\n)```(.*)\n([\s\S]*?)\n```/g,function(e,s,a){var i=r.omitExtraWLInCodeBlocks?"":"\n";return a=n.subParser("encodeCode")(a),a=n.subParser("detab")(a),a=a.replace(/^\n+/g,""),a=a.replace(/\n+$/g,""),a="<pre><code"+(s?' class="'+s+" language-"+s+'"':"")+">"+a+i+"</code></pre>",n.subParser("hashBlock")(a,r,t)}),e=e.replace(/~0/,"")):e}),n.subParser("hashBlock",function(e,r,t){"use strict";return e=e.replace(/(^\n+|\n+$)/g,""),"\n\n~K"+(t.gHtmlBlocks.push(e)-1)+"K\n\n"}),n.subParser("hashElement",function(e,r,t){"use strict";return function(e,r){var n=r;return n=n.replace(/\n\n/g,"\n"),n=n.replace(/^\n/,""),n=n.replace(/\n+$/g,""),n="\n\n~K"+(t.gHtmlBlocks.push(n)-1)+"K\n\n"}}),n.subParser("hashHTMLBlocks",function(e,r,t){"use strict";return e=e.replace(/\n/g,"\n\n"),e=e.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|ins|del)\b[^\r]*?\n<\/\2>[ \t]*(?=\n+))/gm,n.subParser("hashElement")(e,r,t)),e=e.replace(/^(<(p|div|h[1-6]|blockquote|pre|table|dl|ol|ul|script|noscript|form|fieldset|iframe|math|style|section|header|footer|nav|article|aside|address|audio|canvas|figure|hgroup|output|video)\b[^\r]*?<\/\2>[ \t]*(?=\n+)\n)/gm,n.subParser("hashElement")(e,r,t)),e=e.replace(/(\n[ ]{0,3}(<(hr)\b([^<>])*?\/?>)[ \t]*(?=\n{2,}))/g,n.subParser("hashElement")(e,r,t)),e=e.replace(/(\n\n[ ]{0,3}<!(--[^\r]*?--\s*)+>[ \t]*(?=\n{2,}))/g,n.subParser("hashElement")(e,r,t)),e=e.replace(/(?:\n\n)([ ]{0,3}(?:<([?%])[^\r]*?\2>)[ \t]*(?=\n{2,}))/g,n.subParser("hashElement")(e,r,t)),e=e.replace(/\n\n/g,"\n")}),n.subParser("headers",function(e,r,t){"use strict";function s(e){var r,s=e.replace(/[^\w]/g,"").toLowerCase();return t.hashLinkCounts[s]?r=s+"-"+t.hashLinkCounts[s]++:(r=s,t.hashLinkCounts[s]=1),a===!0&&(a="section"),n.helper.isString(a)?a+r:r}var a=r.prefixHeaderId,i=isNaN(parseInt(r.headerLevelStart))?1:parseInt(r.headerLevelStart),o=r.smoothLivePreview?/^(.+)[ \t]*\n={2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n=+[ \t]*\n+/gm,u=r.smoothLivePreview?/^(.+)[ \t]*\n-{2,}[ \t]*\n+/gm:/^(.+)[ \t]*\n-+[ \t]*\n+/gm;return e=e.replace(o,function(e,a){var o=n.subParser("spanGamut")(a,r,t),u=r.noHeaderId?"":' id="'+s(a)+'"',l=i,c="<h"+l+u+">"+o+"</h"+l+">";return n.subParser("hashBlock")(c,r,t)}),e=e.replace(u,function(e,a){var o=n.subParser("spanGamut")(a,r,t),u=r.noHeaderId?"":' id="'+s(a)+'"',l=i+1,c="<h"+l+u+">"+o+"</h"+l+">";return n.subParser("hashBlock")(c,r,t)}),e=e.replace(/^(#{1,6})[ \t]*(.+?)[ \t]*#*\n+/gm,function(e,a,o){var u=n.subParser("spanGamut")(o,r,t),l=r.noHeaderId?"":' id="'+s(o)+'"',c=i-1+a.length,p="<h"+c+l+">"+u+"</h"+c+">";return n.subParser("hashBlock")(p,r,t)})}),n.subParser("images",function(e,r,t){"use strict";function s(e,r,s,a,i,o,u,l){var c=t.gUrls,p=t.gTitles,h=t.gDimensions;if(s=s.toLowerCase(),l||(l=""),""===a||null===a){if((""===s||null===s)&&(s=r.toLowerCase().replace(/ ?\n/g," ")),a="#"+s,n.helper.isUndefined(c[s]))return e;a=c[s],n.helper.isUndefined(p[s])||(l=p[s]),n.helper.isUndefined(h[s])||(i=h[s].width,o=h[s].height)}var d="img";if(r.match(/^video:/)?(r=r.substring(6),d="video"):r.match(/^audio:/)?(r=r.substring(6),d="audio"):r.match(/^image:/)&&(r=r.substring(6)),r=r.replace(/"/g,"&quot;"),r=n.helper.escapeCharacters(r,"*_",!1),a=n.helper.escapeCharacters(a,"*_",!1),"img"===d){var f='<img src="'+a+'" alt="'+r+'"';return l&&(l=l.replace(/"/g,"&quot;"),l=n.helper.escapeCharacters(l,"*_",!1),f+=' title="'+l+'"'),i&&o&&(i="*"===i?"auto":i,o="*"===o?"auto":o,f+=' width="'+i+'"',f+=' height="'+o+'"'),f+=" />"}var g="<"+d+' alt="'+r+'"';return l&&(l=l.replace(/"/g,"&quot;"),l=n.helper.escapeCharacters(l,"*_",!1),g+=' title="'+l+'"'),i&&o&&(i="*"===i?"auto":i,o="*"===o?"auto":o,g+=' width="'+i+'"',g+=' height="'+o+'"'),g+=" controls>",g+='<source src="'+a+'">',g+="</"+d+">"}var a=/!\[(.*?)]\s?\([ \t]*()<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*(?:(['"])(.*?)\6[ \t]*)?\)/g,i=/!\[(.*?)][ ]?(?:\n[ ]*)?\[(.*?)]()()()()()/g;return e=e.replace(i,s),e=e.replace(a,s)}),n.subParser("italicsAndBold",function(e,r){"use strict";return r.literalMidWordUnderscores?(e=e.replace(/(^|\s|>|\b)__(?=\S)([^]+?)__(?=\b|<|\s|$)/gm,"$1<strong>$2</strong>"),e=e.replace(/(^|\s|>|\b)_(?=\S)([^]+?)_(?=\b|<|\s|$)/gm,"$1<em>$2</em>"),e=e.replace(/\*\*(?=\S)([^]+?)\*\*/g,"<strong>$1</strong>"),e=e.replace(/\*(?=\S)([^]+?)\*/g,"<em>$1</em>")):(e=e.replace(/(\*\*|__)(?=\S)([^\r]*?\S[*_]*)\1/g,"<strong>$2</strong>"),e=e.replace(/(\*|_)(?=\S)([^\r]*?\S)\1/g,"<em>$2</em>")),e}),n.subParser("lists",function(e,r,t){"use strict";function s(e,s){t.gListLevel++,e=e.replace(/\n{2,}$/,"\n"),e+="~0";var a=/(\n)?(^[ \t]*)([*+-]|\d+[.])[ \t]+((\[(x| )?])?[ \t]*[^\r]+?(\n{1,2}))(?=\n*(~0|\2([*+-]|\d+[.])[ \t]+))/gm,i=/\n[ \t]*\n(?!~0)/.test(e);return e=e.replace(a,function(e,s,a,o,u,l,c){c=c&&""!==c.trim();var p=n.subParser("outdent")(u,r,t),h="";return l&&r.tasklists&&(h=' class="task-list-item" style="list-style-type: none;"',p=p.replace(/^[ \t]*\[(x| )?]/m,function(){var e='<input type="checkbox" disabled style="margin: 0px 0.35em 0.25em -1.6em; vertical-align: middle;"';return c&&(e+=" checked"),e+=">"})),s||p.search(/\n{2,}/)>-1?(p=n.subParser("githubCodeBlocks")(p,r,t),p=n.subParser("blockGamut")(p,r,t)):(p=n.subParser("lists")(p,r,t),p=p.replace(/\n$/,""),p=i?n.subParser("paragraphs")(p,r,t):n.subParser("spanGamut")(p,r,t)),p="\n<li"+h+">"+p+"</li>\n"}),e=e.replace(/~0/g,""),t.gListLevel--,s&&(e=e.replace(/\s+$/,"")),e}function a(e,r,t){var n="ul"===r?/^ {0,2}\d+\.[ \t]/gm:/^ {0,2}[*+-][ \t]/gm,a=[],i="";if(-1!==e.search(n)){!function u(e){var a=e.search(n);-1!==a?(i+="\n\n<"+r+">"+s(e.slice(0,a),!!t)+"</"+r+">\n\n",r="ul"===r?"ol":"ul",n="ul"===r?/^ {0,2}\d+\.[ \t]/gm:/^ {0,2}[*+-][ \t]/gm,u(e.slice(a))):i+="\n\n<"+r+">"+s(e,!!t)+"</"+r+">\n\n"}(e);for(var o=0;o<a.length;++o);}else i="\n\n<"+r+">"+s(e,!!t)+"</"+r+">\n\n";return i}e+="~0";var i=/^(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm;return t.gListLevel?e=e.replace(i,function(e,r,t){var n=t.search(/[*+-]/g)>-1?"ul":"ol";return a(r,n,!0)}):(i=/(\n\n|^\n?)(([ ]{0,3}([*+-]|\d+[.])[ \t]+)[^\r]+?(~0|\n{2,}(?=\S)(?![ \t]*(?:[*+-]|\d+[.])[ \t]+)))/gm,e=e.replace(i,function(e,r,t,n){var s=n.search(/[*+-]/g)>-1?"ul":"ol";return a(t,s)})),e=e.replace(/~0/,"")}),n.subParser("outdent",function(e){"use strict";return e=e.replace(/^(\t|[ ]{1,4})/gm,"~0"),e=e.replace(/~0/g,"")}),n.subParser("paragraphs",function(e,r,t){"use strict";e=e.replace(/^\n+/g,""),e=e.replace(/\n+$/g,"");for(var s=e.split(/\n{2,}/g),a=[],i=s.length,o=0;i>o;o++){var u=s[o];u.search(/~K(\d+)K/g)>=0?a.push(u):u.search(/\S/)>=0&&(u=n.subParser("spanGamut")(u,r,t),u=u.replace(/^([ \t]*)/g,"<p>"),u+="</p>",a.push(u))}for(i=a.length,o=0;i>o;o++)for(;a[o].search(/~K(\d+)K/)>=0;){var l=t.gHtmlBlocks[RegExp.$1];l=l.replace(/\$/g,"$$$$"),a[o]=a[o].replace(/~K\d+K/,l)}return a.join("\n\n")}),n.subParser("runExtension",function(e,r,t,n){"use strict";if(e.filter)r=e.filter(r,n.converter,t);else if(e.regex){var s=e.regex;!s instanceof RegExp&&(s=new RegExp(s,"g")),r=r.replace(s,e.replace)}return r}),n.subParser("spanGamut",function(e,r,t){"use strict";return e=n.subParser("codeSpans")(e,r,t),e=n.subParser("escapeSpecialCharsWithinTagAttributes")(e,r,t),e=n.subParser("encodeBackslashEscapes")(e,r,t),e=n.subParser("images")(e,r,t),e=n.subParser("anchors")(e,r,t),e=n.subParser("autoLinks")(e,r,t),e=n.subParser("encodeAmpsAndAngles")(e,r,t),e=n.subParser("italicsAndBold")(e,r,t),e=n.subParser("strikethrough")(e,r,t),e=e.replace(/ +\n/g," <br />\n")}),n.subParser("strikethrough",function(e,r){"use strict";return r.strikethrough&&(e=e.replace(/(?:~T){2}([^~]+)(?:~T){2}/g,"<del>$1</del>")),e}),n.subParser("stripBlankLines",function(e){"use strict";return e.replace(/^[ \t]+$/gm,"")}),n.subParser("stripLinkDefinitions",function(e,r,t){"use strict";var s=/^ {0,3}\[(.+)]:[ \t]*\n?[ \t]*<?(\S+?)>?(?: =([*\d]+[A-Za-z%]{0,4})x([*\d]+[A-Za-z%]{0,4}))?[ \t]*\n?[ \t]*(?:(\n*)["|'(](.+?)["|')][ \t]*)?(?:\n+|(?=~0))/gm;return e+="~0",e=e.replace(s,function(e,s,a,i,o,u,l){return s=s.toLowerCase(),t.gUrls[s]=n.subParser("encodeAmpsAndAngles")(a),u?u+l:(l&&(t.gTitles[s]=l.replace(/"|'/g,"&quot;")),r.parseImgDimensions&&i&&o&&(t.gDimensions[s]={width:i,height:o}),"")}),e=e.replace(/~0/,"")}),n.subParser("tables",function(e,r,t){"use strict";var s=function(){var e,s={};return s.th=function(e,s){var a="";return e=e.trim(),""===e?"":(r.tableHeaderId&&(a=' id="'+e.replace(/ /g,"_").toLowerCase()+'"'),e=n.subParser("spanGamut")(e,r,t),s=s&&""!==s.trim()?' style="'+s+'"':"","<th"+a+s+">"+e+"</th>")},s.td=function(e,s){var a=n.subParser("spanGamut")(e.trim(),r,t);return s=s&&""!==s.trim()?' style="'+s+'"':"","<td"+s+">"+a+"</td>"},s.ths=function(){var e="",r=0,t=[].slice.apply(arguments[0]),n=[].slice.apply(arguments[1]);for(r;r<t.length;r+=1)e+=s.th(t[r],n[r])+"\n";return e},s.tds=function(){var e="",r=0,t=[].slice.apply(arguments[0]),n=[].slice.apply(arguments[1]);for(r;r<t.length;r+=1)e+=s.td(t[r],n[r])+"\n";return e},s.thead=function(){var e,r=[].slice.apply(arguments[0]),t=[].slice.apply(arguments[1]);return e="<thead>\n",e+="<tr>\n",e+=s.ths.apply(this,[r,t]),e+="</tr>\n",e+="</thead>\n"},s.tr=function(){var e,r=[].slice.apply(arguments[0]),t=[].slice.apply(arguments[1]);return e="<tr>\n",e+=s.tds.apply(this,[r,t]),e+="</tr>\n"},e=function(e){var r,t,n=0,a=e.split("\n"),i=[];for(n;n<a.length;n+=1){if(r=a[n],r.trim().match(/^[|].*[|]$/)){r=r.trim();var o=[],u=a[n+1].trim(),l=[],c=0;if(u.match(/^[|][-=|: ]+[|]$/))for(l=u.substring(1,u.length-1).split("|"),c=0;c<l.length;++c)l[c]=l[c].trim(),l[c]=l[c].match(/^[:][-=| ]+[:]$/)?"text-align:center;":l[c].match(/^[-=| ]+[:]$/)?"text-align:right;":l[c].match(/^[:][-=| ]+$/)?"text-align:left;":"";if(o.push("<table>"),t=r.substring(1,r.length-1).split("|"),0===l.length)for(c=0;c<t.length;++c)l.push("text-align:left");if(o.push(s.thead.apply(this,[t,l])),r=a[++n],r.trim().match(/^[|][-=|: ]+[|]$/)){for(r=a[++n],o.push("<tbody>");r.trim().match(/^[|].*[|]$/);)r=r.trim(),o.push(s.tr.apply(this,[r.substring(1,r.length-1).split("|"),l])),r=a[++n];o.push("</tbody>"),o.push("</table>"),i.push(o.join("\n"));continue}r=a[--n]}i.push(r)}return i.join("\n")},{parse:e}};if(r.tables){var a=s();return a.parse(e)}return e}),n.subParser("unescapeSpecialChars",function(e){"use strict";return e=e.replace(/~E(\d+)E/g,function(e,r){var t=parseInt(r);return String.fromCharCode(t)})});var u=this;"undefined"!=typeof module&&module.exports?module.exports=n:"function"==typeof define&&define.amd?define("showdown",function(){"use strict";return n}):u.showdown=n}).call(this);