(function(a){if(typeof exports=="object"&&typeof module=="object")a(require("../../lib/codemirror"),require("../xml/xml"),require("../meta"));else if(typeof define=="function"&&define.amd)define(["../../lib/codemirror","../xml/xml","../meta"],a);else a(CodeMirror)})(function(a){"use strict";a.defineMode("markdown",function(b,c){var d=a.getMode(b,"text/html");var e=d.name=="null";function f(c){if(a.findModeByName){var d=a.findModeByName(c);if(d)c=d.mime||d.mimes[0]}var e=a.getMode(b,c);return e.name=="null"?null:e}if(c.highlightFormatting===undefined)c.highlightFormatting=false;if(c.maxBlockquoteDepth===undefined)c.maxBlockquoteDepth=0;if(c.taskLists===undefined)c.taskLists=false;if(c.strikethrough===undefined)c.strikethrough=false;if(c.emoji===undefined)c.emoji=false;if(c.fencedCodeBlockHighlighting===undefined)c.fencedCodeBlockHighlighting=true;if(c.fencedCodeBlockDefaultMode===undefined)c.fencedCodeBlockDefaultMode="text/plain";if(c.xml===undefined)c.xml=true;if(c.tokenTypeOverrides===undefined)c.tokenTypeOverrides={};var g={header:"header",code:"comment",quote:"quote",list1:"variable-2",list2:"variable-3",list3:"keyword",hr:"hr",image:"image",imageAltText:"image-alt-text",imageMarker:"image-marker",formatting:"formatting",linkInline:"link",linkEmail:"link",linkText:"link",linkHref:"string",em:"em",strong:"strong",strikethrough:"strikethrough",emoji:"builtin"};for(var h in g){if(g.hasOwnProperty(h)&&c.tokenTypeOverrides[h]){g[h]=c.tokenTypeOverrides[h]}}var i=/^([*\-_])(?:\s*\1){2,}\s*$/,j=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,k=/^\[(x| )\](?=\s)/i,l=c.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,m=/^ {0,3}(?:\={1,}|-{2,})\s*$/,n=/^[^#!\[\]*_\\<>` "'(~:]+/,o=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,p=/^\s*\[[^\]]+?\]:.*$/,q=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E42\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC9\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDF3C-\uDF3E]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]/,r=" ";function s(a,b,c){b.f=b.inline=c;return c(a,b)}function t(a,b,c){b.f=b.block=c;return c(a,b)}function u(a){return!a||!/\S/.test(a.string)}function v(b){b.linkTitle=false;b.linkHref=false;b.linkText=false;b.em=false;b.strong=false;b.strikethrough=false;b.quote=0;b.indentedCode=false;if(b.f==x){var c=e;if(!c){var f=a.innerMode(d,b.htmlState);c=f.mode.name=="xml"&&f.state.tagStart===null&&(!f.state.context&&f.state.tokenize.isInText)}if(c){b.f=B;b.block=w;b.htmlState=null}}b.trailingSpace=0;b.trailingSpaceNewLine=false;b.prevLine=b.thisLine;b.thisLine={stream:null};return null}function w(b,d){var e=b.column()===d.indentation;var h=u(d.prevLine.stream);var n=d.indentedCode;var q=d.prevLine.hr;var r=d.list!==false;var t=(d.listStack[d.listStack.length-1]||0)+3;d.indentedCode=false;var v=d.indentation;if(d.indentationDiff===null){d.indentationDiff=d.indentation;if(r){d.list=null;while(v=4&&(n||d.prevLine.fencedCodeEnd||d.prevLine.header||h)){b.skipToEnd();d.indentedCode=true;return g.code}else if(b.eatSpace()){return null}else if(e&&d.indentation<=t&&(A=b.match(l))&&A[1].length<=6){d.quote=0;d.header=A[1].length;d.thisLine.header=true;if(c.highlightFormatting)d.formatting="header";d.f=d.inline;return z(d)}else if(d.indentation<=t&&b.eat(">")){d.quote=e?1:d.quote+1;if(c.highlightFormatting)d.formatting="quote";b.eatSpace();return z(d)}else if(!x&&!d.setext&&e&&d.indentation<=t&&(A=b.match(j))){var B=A[1]?"ol":"ul";d.indentation=v+b.current().length;d.list=true;d.quote=0;d.listStack.push(d.indentation);d.em=false;d.strong=false;d.code=false;d.strikethrough=false;if(c.taskLists&&b.match(k,false)){d.taskList=true}d.f=d.inline;if(c.highlightFormatting)d.formatting=["list","list-"+B];return z(d)}else if(e&&d.indentation<=t&&(A=b.match(o,true))){d.quote=0;d.fencedEndRE=new RegExp(A[1]+"+ *$");d.localMode=c.fencedCodeBlockHighlighting&&f(A[2]||c.fencedCodeBlockDefaultMode);if(d.localMode)d.localState=a.startState(d.localMode);d.f=d.block=y;if(c.highlightFormatting)d.formatting="code-block";d.code=-1;return z(d)}else if(d.setext||(!w||!r)&&!d.quote&&d.list===false&&!d.code&&!x&&!p.test(b.string)&&(A=b.lookAhead(1))&&(A=A.match(m))){if(!d.setext){d.header=A[0].charAt(0)=="="?1:2;d.setext=d.header}else{d.header=d.setext;d.setext=0;b.skipToEnd();if(c.highlightFormatting)d.formatting="header"}d.thisLine.header=true;d.f=d.inline;return z(d)}else if(x){b.skipToEnd();d.hr=true;d.thisLine.hr=true;return g.hr}else if(b.peek()==="["){return s(b,d,G)}return s(b,d,d.inline)}function x(b,c){var f=d.token(b,c.htmlState);if(!e){var g=a.innerMode(d,c.htmlState);if(g.mode.name=="xml"&&g.state.tagStart===null&&(!g.state.context&&g.state.tokenize.isInText)||c.md_inside&&b.current().indexOf(">")>-1){c.f=B;c.block=w;c.htmlState=null}}return f}function y(a,b){var d=b.listStack[b.listStack.length-1]||0;var e=b.indentation=a.quote){b.push(g.formatting+"-"+a.formatting[d]+"-"+a.quote)}else{b.push("error")}}}}if(a.taskOpen){b.push("meta");return b.length?b.join(" "):null}if(a.taskClosed){b.push("property");return b.length?b.join(" "):null}if(a.linkHref){b.push(g.linkHref,"url")}else{if(a.strong){b.push(g.strong)}if(a.em){b.push(g.em)}if(a.strikethrough){b.push(g.strikethrough)}if(a.emoji){b.push(g.emoji)}if(a.linkText){b.push(g.linkText)}if(a.code){b.push(g.code)}if(a.image){b.push(g.image)}if(a.imageAltText){b.push(g.imageAltText,"link")}if(a.imageMarker){b.push(g.imageMarker)}}if(a.header){b.push(g.header,g.header+"-"+a.header)}if(a.quote){b.push(g.quote);if(!c.maxBlockquoteDepth||c.maxBlockquoteDepth>=a.quote){b.push(g.quote+"-"+a.quote)}else{b.push(g.quote+"-"+c.maxBlockquoteDepth)}}if(a.list!==false){var e=(a.listStack.length-1)%3;if(!e){b.push(g.list1)}else if(e===1){b.push(g.list2)}else{b.push(g.list3)}}if(a.trailingSpaceNewLine){b.push("trailing-space-new-line")}else if(a.trailingSpace){b.push("trailing-space-"+(a.trailingSpace%2?"a":"b"))}return b.length?b.join(" "):null}function A(a,b){if(a.match(n,true)){return z(b)}return undefined}function B(b,e){var f=e.text(b,e);if(typeof f!=="undefined")return f;if(e.list){e.list=null;return z(e)}if(e.taskList){var h=b.match(k,true)[1]===" ";if(h)e.taskOpen=true;else e.taskClosed=true;if(c.highlightFormatting)e.formatting="task";e.taskList=false;return z(e)}e.taskOpen=false;e.taskClosed=false;if(e.header&&b.match(/^#+$/,true)){if(c.highlightFormatting)e.formatting="header";return z(e)}var i=b.next();if(e.linkTitle){e.linkTitle=false;var j=i;if(i==="("){j=")"}j=(j+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1");var l="^\\s*(?:[^"+j+"\\\\]+|\\\\\\\\|\\\\.)"+j;if(b.match(new RegExp(l),true)){return g.linkHref}}if(i==="`"){var m=e.formatting;if(c.highlightFormatting)e.formatting="code";b.eatWhile("`");var n=b.current().length;if(e.code==0&&(!e.quote||n==1)){e.code=n;return z(e)}else if(n==e.code){var o=z(e);e.code=0;return o}else{e.formatting=m;return z(e)}}else if(e.code){return z(e)}if(i==="\\"){b.next();if(c.highlightFormatting){var p=z(e);var r=g.formatting+"-escape";return p?p+" "+r:r}}if(i==="!"&&b.match(/\[[^\]]*\] ?(?:\(|\[)/,false)){e.imageMarker=true;e.image=true;if(c.highlightFormatting)e.formatting="image";return z(e)}if(i==="["&&e.imageMarker&&b.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,false)){e.imageMarker=false;e.imageAltText=true;if(c.highlightFormatting)e.formatting="image";return z(e)}if(i==="]"&&e.imageAltText){if(c.highlightFormatting)e.formatting="image";var p=z(e);e.imageAltText=false;e.image=false;e.inline=e.f=D;return p}if(i==="["&&!e.image){if(e.linkText&&b.match(/^.*?\]/))return z(e);e.linkText=true;if(c.highlightFormatting)e.formatting="link";return z(e)}if(i==="]"&&e.linkText){if(c.highlightFormatting)e.formatting="link";var p=z(e);e.linkText=false;e.inline=e.f=b.match(/\(.*?\)| ?\[.*?\]/,false)?D:B;return p}if(i==="<"&&b.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,false)){e.f=e.inline=C;if(c.highlightFormatting)e.formatting="link";var p=z(e);if(p){p+=" "}else{p=""}return p+g.linkInline}if(i==="<"&&b.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,false)){e.f=e.inline=C;if(c.highlightFormatting)e.formatting="link";var p=z(e);if(p){p+=" "}else{p=""}return p+g.linkEmail}if(c.xml&&i==="<"&&b.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,false)){var s=b.string.indexOf(">",b.pos);if(s!=-1){var u=b.string.substring(b.start,s);if(/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(u))e.md_inside=true}b.backUp(1);e.htmlState=a.startState(d);return t(b,e,x)}if(c.xml&&i==="<"&&b.match(/^\/\w*?>/)){e.md_inside=false;return"tag"}else if(i==="*"||i==="_"){var v=1,w=b.pos==1?" ":b.string.charAt(b.pos-2);while(v<3&&b.eat(i))v++;var y=b.peek()||" ";var A=!/\s/.test(y)&&(!q.test(y)||/\s/.test(w)||q.test(w));var E=!/\s/.test(w)&&(!q.test(w)||/\s/.test(y)||q.test(y));var F=null,G=null;if(v%2){if(!e.em&&A&&(i==="*"||!E||q.test(w)))F=true;else if(e.em==i&&E&&(i==="*"||!A||q.test(y)))F=false}if(v>1){if(!e.strong&&A&&(i==="*"||!E||q.test(w)))G=true;else if(e.strong==i&&E&&(i==="*"||!A||q.test(y)))G=false}if(G!=null||F!=null){if(c.highlightFormatting)e.formatting=F==null?"strong":G==null?"em":"strong em";if(F===true)e.em=i;if(G===true)e.strong=i;var o=z(e);if(F===false)e.em=false;if(G===false)e.strong=false;return o}}else if(i===" "){if(b.eat("*")||b.eat("_")){if(b.peek()===" "){return z(e)}else{b.backUp(1)}}}if(c.strikethrough){if(i==="~"&&b.eatWhile(i)){if(e.strikethrough){if(c.highlightFormatting)e.formatting="strikethrough";var o=z(e);e.strikethrough=false;return o}else if(b.match(/^[^\s]/,false)){e.strikethrough=true;if(c.highlightFormatting)e.formatting="strikethrough";return z(e)}}else if(i===" "){if(b.match(/^~~/,true)){if(b.peek()===" "){return z(e)}else{b.backUp(2)}}}}if(c.emoji&&i===":"&&b.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){e.emoji=true;if(c.highlightFormatting)e.formatting="emoji";var H=z(e);e.emoji=false;return H}if(i===" "){if(b.match(/^ +$/,false)){e.trailingSpace++}else if(e.trailingSpace){e.trailingSpaceNewLine=true}}return z(e)}function C(a,b){var d=a.next();if(d===">"){b.f=b.inline=B;if(c.highlightFormatting)b.formatting="link";var e=z(b);if(e){e+=" "}else{e=""}return e+g.linkInline}a.match(/^[^>]+/,true);return g.linkInline}function D(a,b){if(a.eatSpace()){return null}var d=a.next();if(d==="("||d==="["){b.f=b.inline=F(d==="("?")":"]");if(c.highlightFormatting)b.formatting="link-string";b.linkHref=true;return z(b)}return"error"}var E={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function F(a){return function(b,d){var e=b.next();if(e===a){d.f=d.inline=B;if(c.highlightFormatting)d.formatting="link-string";var f=z(d);d.linkHref=false;return f}b.match(E[a]);d.linkHref=true;return z(d)}}function G(a,b){if(a.match(/^([^\]\\]|\\.)*\]:/,false)){b.f=H;a.next();if(c.highlightFormatting)b.formatting="link";b.linkText=true;return z(b)}return s(a,b,B)}function H(a,b){if(a.match(/^\]:/,true)){b.f=b.inline=I;if(c.highlightFormatting)b.formatting="link";var d=z(b);b.linkText=false;return d}a.match(/^([^\]\\]|\\.)+/,true);return g.linkText}function I(a,b){if(a.eatSpace()){return null}a.match(/^[^\s]+/,true);if(a.peek()===undefined){b.linkTitle=true}else{a.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,true)}b.f=b.inline=B;return g.linkHref+" url"}var J={startState:function(){return{f:w,prevLine:{stream:null},thisLine:{stream:null},block:w,htmlState:null,indentation:0,inline:B,text:A,formatting:false,linkText:false,linkHref:false,linkTitle:false,code:0,em:false,strong:false,header:0,setext:0,hr:false,taskList:false,list:false,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:false,strikethrough:false,emoji:false,fencedEndRE:null}},copyState:function(b){return{f:b.f,prevLine:b.prevLine,thisLine:b.thisLine,block:b.block,htmlState:b.htmlState&&a.copyState(d,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:false,linkText:b.linkText,linkTitle:b.linkTitle,linkHref:b.linkHref,code:b.code,em:b.em,strong:b.strong,strikethrough:b.strikethrough,emoji:b.emoji,header:b.header,setext:b.setext,hr:b.hr,taskList:b.taskList,list:b.list,listStack:b.listStack.slice(0),quote:b.quote,indentedCode:b.indentedCode,trailingSpace:b.trailingSpace,trailingSpaceNewLine:b.trailingSpaceNewLine,md_inside:b.md_inside,fencedEndRE:b.fencedEndRE}},token:function(a,b){b.formatting=false;if(a!=b.thisLine.stream){b.header=0;b.hr=false;if(a.match(/^\s*$/,true)){v(b);return null}b.prevLine=b.thisLine;b.thisLine={stream:a};b.taskList=false;b.trailingSpace=0;b.trailingSpaceNewLine=false;if(!b.localState){b.f=b.block;if(b.f!=x){var c=a.match(/^\s*/,true)[0].replace(/\t/g,r).length;b.indentation=c;b.indentationDiff=null;if(c>0)return null}}}return b.f(a,b)},innerMode:function(a){if(a.block==x)return{state:a.htmlState,mode:d};if(a.localState)return{state:a.localState,mode:a.localMode};return{state:a,mode:J}},indent:function(b,c,e){if(b.block==x&&d.indent)return d.indent(b.htmlState,c,e);if(b.localState&&b.localMode.indent)return b.localMode.indent(b.localState,c,e);return a.Pass},blankLine:v,getType:z,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return J},"xml");a.defineMIME("text/markdown","markdown");a.defineMIME("text/x-markdown","markdown")}); //# sourceMappingURL=markdown.min.js.map