?
Path : /home/admin/public_html/old/media/editors/codemirror/mode/markdown/ |
Current File : /home/admin/public_html/old/media/editors/codemirror/mode/markdown/markdown.min.js |
!function(a){"object"==typeof exports&&"object"==typeof module?a(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],a):a(CodeMirror)}(function(a){"use strict";a.defineMode("markdown",function(b,c){function d(c){if(a.findModeByName){var d=a.findModeByName(c);d&&(c=d.mime||d.mimes[0])}var e=a.getMode(b,c);return"null"==e.name?null:e}function e(a,b,c){return b.f=b.inline=c,c(a,b)}function f(a,b,c){return b.f=b.block=c,c(a,b)}function g(a){return a.linkTitle=!1,a.em=!1,a.strong=!1,a.strikethrough=!1,a.quote=0,v||a.f!=i||(a.f=n,a.block=h),a.trailingSpace=0,a.trailingSpaceNewLine=!1,a.thisLineHasContent=!1,null}function h(a,b){var f=a.sol(),g=b.list!==!1;g&&(b.indentationDiff>=0?(b.indentationDiff<4&&(b.indentation-=b.indentationDiff),b.list=null):b.indentation>0?(b.list=null,b.listDepth=Math.floor(b.indentation/4)):(b.list=!1,b.listDepth=0));var h=null;if(b.indentationDiff>=4)return b.indentation-=4,a.skipToEnd(),z;if(a.eatSpace())return null;if(h=a.match(S))return b.header=Math.min(6,-1!==h[0].indexOf(" ")?h[0].length-1:h[0].length),c.highlightFormatting&&(b.formatting="header"),b.f=b.inline,l(b);if(b.prevLineHasContent&&(h=a.match(T)))return b.header="="==h[0].charAt(0)?1:2,c.highlightFormatting&&(b.formatting="header"),b.f=b.inline,l(b);if(a.eat(">"))return b.indentation++,b.quote=f?1:b.quote+1,c.highlightFormatting&&(b.formatting="quote"),a.eatSpace(),l(b);if("["===a.peek())return e(a,b,r);if(a.match(O,!0))return E;if((!b.prevLineHasContent||g)&&(a.match(P,!1)||a.match(Q,!1))){var i=null;return a.match(P,!0)?i="ul":(a.match(Q,!0),i="ol"),b.indentation+=4,b.list=!0,b.listDepth++,c.taskLists&&a.match(R,!1)&&(b.taskList=!0),b.f=b.inline,c.highlightFormatting&&(b.formatting=["list","list-"+i]),l(b)}return c.fencedCodeBlocks&&a.match(/^```[ \t]*([\w+#]*)/,!0)?(b.localMode=d(RegExp.$1),b.localMode&&(b.localState=b.localMode.startState()),b.f=b.block=j,c.highlightFormatting&&(b.formatting="code-block"),b.code=!0,l(b)):e(a,b,b.inline)}function i(a,b){var c=w.token(a,b.htmlState);return(v&&null===b.htmlState.tagStart&&!b.htmlState.context||b.md_inside&&a.current().indexOf(">")>-1)&&(b.f=n,b.block=h,b.htmlState=null),c}function j(a,b){return a.sol()&&a.match("```",!1)?(b.localMode=b.localState=null,b.f=b.block=k,null):b.localMode?b.localMode.token(a,b.localState):(a.skipToEnd(),z)}function k(a,b){a.match("```"),b.block=h,b.f=n,c.highlightFormatting&&(b.formatting="code-block"),b.code=!0;var d=l(b);return b.code=!1,d}function l(a){var b=[];if(a.formatting){b.push(G),"string"==typeof a.formatting&&(a.formatting=[a.formatting]);for(var d=0;d<a.formatting.length;d++)b.push(G+"-"+a.formatting[d]),"header"===a.formatting[d]&&b.push(G+"-"+a.formatting[d]+"-"+a.header),"quote"===a.formatting[d]&&(!c.maxBlockquoteDepth||c.maxBlockquoteDepth>=a.quote?b.push(G+"-"+a.formatting[d]+"-"+a.quote):b.push("error"))}if(a.taskOpen)return b.push("meta"),b.length?b.join(" "):null;if(a.taskClosed)return b.push("property"),b.length?b.join(" "):null;if(a.linkHref)return b.push(K),b.length?b.join(" "):null;if(a.strong&&b.push(M),a.em&&b.push(L),a.strikethrough&&b.push(N),a.linkText&&b.push(J),a.code&&b.push(z),a.header&&(b.push(y),b.push(y+"-"+a.header)),a.quote&&(b.push(A),!c.maxBlockquoteDepth||c.maxBlockquoteDepth>=a.quote?b.push(A+"-"+a.quote):b.push(A+"-"+c.maxBlockquoteDepth)),a.list!==!1){var e=(a.listDepth-1)%3;e?1===e?b.push(C):b.push(D):b.push(B)}return a.trailingSpaceNewLine?b.push("trailing-space-new-line"):a.trailingSpace&&b.push("trailing-space-"+(a.trailingSpace%2?"a":"b")),b.length?b.join(" "):null}function m(a,b){return a.match(U,!0)?l(b):void 0}function n(b,d){var e=d.text(b,d);if("undefined"!=typeof e)return e;if(d.list)return d.list=null,l(d);if(d.taskList){var g="x"!==b.match(R,!0)[1];return g?d.taskOpen=!0:d.taskClosed=!0,c.highlightFormatting&&(d.formatting="task"),d.taskList=!1,l(d)}if(d.taskOpen=!1,d.taskClosed=!1,d.header&&b.match(/^#+$/,!0))return c.highlightFormatting&&(d.formatting="header"),l(d);var h=b.sol(),j=b.next();if("\\"===j&&(b.next(),c.highlightFormatting)){var k=l(d);return k?k+" formatting-escape":"formatting-escape"}if(d.linkTitle){d.linkTitle=!1;var m=j;"("===j&&(m=")"),m=(m+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1");var n="^\\s*(?:[^"+m+"\\\\]+|\\\\\\\\|\\\\.)"+m;if(b.match(new RegExp(n),!0))return K}if("`"===j){var q=d.formatting;c.highlightFormatting&&(d.formatting="code");var r=l(d),s=b.pos;b.eatWhile("`");var t=1+b.pos-s;return d.code?t===x?(d.code=!1,r):(d.formatting=q,l(d)):(x=t,d.code=!0,l(d))}if(d.code)return l(d);if("!"===j&&b.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return b.match(/\[[^\]]*\]/),d.inline=d.f=p,F;if("["===j&&b.match(/.*\](\(.*\)| ?\[.*\])/,!1))return d.linkText=!0,c.highlightFormatting&&(d.formatting="link"),l(d);if("]"===j&&d.linkText&&b.match(/\(.*\)| ?\[.*\]/,!1)){c.highlightFormatting&&(d.formatting="link");var k=l(d);return d.linkText=!1,d.inline=d.f=p,k}if("<"===j&&b.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=o,c.highlightFormatting&&(d.formatting="link");var k=l(d);return k?k+=" ":k="",k+H}if("<"===j&&b.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1)){d.f=d.inline=o,c.highlightFormatting&&(d.formatting="link");var k=l(d);return k?k+=" ":k="",k+I}if("<"===j&&b.match(/^\w/,!1)){if(-1!=b.string.indexOf(">")){var u=b.string.substring(1,b.string.indexOf(">"));/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(u)&&(d.md_inside=!0)}return b.backUp(1),d.htmlState=a.startState(w),f(b,d,i)}if("<"===j&&b.match(/^\/\w*?>/))return d.md_inside=!1,"tag";var v=!1;if(!c.underscoresBreakWords&&"_"===j&&"_"!==b.peek()&&b.match(/(\w)/,!1)){var y=b.pos-2;if(y>=0){var z=b.string.charAt(y);"_"!==z&&z.match(/(\w)/,!1)&&(v=!0)}}if("*"===j||"_"===j&&!v)if(h&&" "===b.peek());else{if(d.strong===j&&b.eat(j)){c.highlightFormatting&&(d.formatting="strong");var r=l(d);return d.strong=!1,r}if(!d.strong&&b.eat(j))return d.strong=j,c.highlightFormatting&&(d.formatting="strong"),l(d);if(d.em===j){c.highlightFormatting&&(d.formatting="em");var r=l(d);return d.em=!1,r}if(!d.em)return d.em=j,c.highlightFormatting&&(d.formatting="em"),l(d)}else if(" "===j&&(b.eat("*")||b.eat("_"))){if(" "===b.peek())return l(d);b.backUp(1)}if(c.strikethrough)if("~"===j&&b.eatWhile(j)){if(d.strikethrough){c.highlightFormatting&&(d.formatting="strikethrough");var r=l(d);return d.strikethrough=!1,r}if(b.match(/^[^\s]/,!1))return d.strikethrough=!0,c.highlightFormatting&&(d.formatting="strikethrough"),l(d)}else if(" "===j&&b.match(/^~~/,!0)){if(" "===b.peek())return l(d);b.backUp(2)}return" "===j&&(b.match(/ +$/,!1)?d.trailingSpace++:d.trailingSpace&&(d.trailingSpaceNewLine=!0)),l(d)}function o(a,b){var d=a.next();if(">"===d){b.f=b.inline=n,c.highlightFormatting&&(b.formatting="link");var e=l(b);return e?e+=" ":e="",e+H}return a.match(/^[^>]+/,!0),H}function p(a,b){if(a.eatSpace())return null;var d=a.next();return"("===d||"["===d?(b.f=b.inline=q("("===d?")":"]"),c.highlightFormatting&&(b.formatting="link-string"),b.linkHref=!0,l(b)):"error"}function q(a){return function(b,d){var e=b.next();if(e===a){d.f=d.inline=n,c.highlightFormatting&&(d.formatting="link-string");var f=l(d);return d.linkHref=!1,f}return b.match(u(a),!0)&&b.backUp(1),d.linkHref=!0,l(d)}}function r(a,b){return a.match(/^[^\]]*\]:/,!1)?(b.f=s,a.next(),c.highlightFormatting&&(b.formatting="link"),b.linkText=!0,l(b)):e(a,b,n)}function s(a,b){if(a.match(/^\]:/,!0)){b.f=b.inline=t,c.highlightFormatting&&(b.formatting="link");var d=l(b);return b.linkText=!1,d}return a.match(/^[^\]]+/,!0),J}function t(a,b){return a.eatSpace()?null:(a.match(/^[^\s]+/,!0),void 0===a.peek()?b.linkTitle=!0:a.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),b.f=b.inline=n,K)}function u(a){return V[a]||(a=(a+"").replace(/([.?*+^$[\]\\(){}|-])/g,"\\$1"),V[a]=new RegExp("^(?:[^\\\\]|\\\\.)*?("+a+")")),V[a]}var v=a.modes.hasOwnProperty("xml"),w=a.getMode(b,v?{name:"xml",htmlMode:!0}:"text/plain");void 0===c.highlightFormatting&&(c.highlightFormatting=!1),void 0===c.maxBlockquoteDepth&&(c.maxBlockquoteDepth=0),void 0===c.underscoresBreakWords&&(c.underscoresBreakWords=!0),void 0===c.fencedCodeBlocks&&(c.fencedCodeBlocks=!1),void 0===c.taskLists&&(c.taskLists=!1),void 0===c.strikethrough&&(c.strikethrough=!1);var x=0,y="header",z="comment",A="quote",B="variable-2",C="variable-3",D="keyword",E="hr",F="tag",G="formatting",H="link",I="link",J="link",K="string",L="em",M="strong",N="strikethrough",O=/^([*\-=_])(?:\s*\1){2,}\s*$/,P=/^[*\-+]\s+/,Q=/^[0-9]+\.\s+/,R=/^\[(x| )\](?=\s)/,S=/^#+ ?/,T=/^(?:\={1,}|-{1,})$/,U=/^[^#!\[\]*_\\<>` "'(~]+/,V=[],W={startState:function(){return{f:h,prevLineHasContent:!1,thisLineHasContent:!1,block:h,htmlState:null,indentation:0,inline:n,text:m,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,em:!1,strong:!1,header:0,taskList:!1,list:!1,listDepth:0,quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1}},copyState:function(b){return{f:b.f,prevLineHasContent:b.prevLineHasContent,thisLineHasContent:b.thisLineHasContent,block:b.block,htmlState:b.htmlState&&a.copyState(w,b.htmlState),indentation:b.indentation,localMode:b.localMode,localState:b.localMode?a.copyState(b.localMode,b.localState):null,inline:b.inline,text:b.text,formatting:!1,linkTitle:b.linkTitle,em:b.em,strong:b.strong,strikethrough:b.strikethrough,header:b.header,taskList:b.taskList,list:b.list,listDepth:b.listDepth,quote:b.quote,trailingSpace:b.trailingSpace,trailingSpaceNewLine:b.trailingSpaceNewLine,md_inside:b.md_inside}},token:function(a,b){if(b.formatting=!1,a.sol()){var c=!!b.header;if(b.header=0,a.match(/^\s*$/,!0)||c)return b.prevLineHasContent=!1,g(b),c?this.token(a,b):null;b.prevLineHasContent=b.thisLineHasContent,b.thisLineHasContent=!0,b.taskList=!1,b.code=!1,b.trailingSpace=0,b.trailingSpaceNewLine=!1,b.f=b.block;var d=a.match(/^\s*/,!0)[0].replace(/\t/g," ").length,e=4*Math.floor((d-b.indentation)/4);e>4&&(e=4);var f=b.indentation+e;if(b.indentationDiff=f-b.indentation,b.indentation=f,d>0)return null}return b.f(a,b)},innerMode:function(a){return a.block==i?{state:a.htmlState,mode:w}:a.localState?{state:a.localState,mode:a.localMode}:{state:a,mode:W}},blankLine:g,getType:l,fold:"markdown"};return W},"xml"),a.defineMIME("text/x-markdown","markdown")});