2018-04-24 21:06:59 +00:00
|
|
|
!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../tw-meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],t):t(CodeMirror)}(function(t){"use strict";t.defineMode("markdown",function(e,i){var n=t.getMode(e,"text/html"),r="null"==n.name;void 0===i.highlightFormatting&&(i.highlightFormatting=!1),void 0===i.maxBlockquoteDepth&&(i.maxBlockquoteDepth=0),void 0===i.taskLists&&(i.taskLists=!1),void 0===i.strikethrough&&(i.strikethrough=!1),void 0===i.emoji&&(i.emoji=!1),void 0===i.fencedCodeBlockHighlighting&&(i.fencedCodeBlockHighlighting=!0),void 0===i.xml&&(i.xml=!0),void 0===i.tokenTypeOverrides&&(i.tokenTypeOverrides={});var a={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 l in a)a.hasOwnProperty(l)&&i.tokenTypeOverrides[l]&&(a[l]=i.tokenTypeOverrides[l]);var o=/^([*\-_])(?:\s*\1){2,}\s*$/,h=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,g=/^\[(x| )\](?=\s)/i,s=i.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,m=/^ *(?:\={1,}|-{1,})\s*$/,u=/^[^#!\[\]*_\\<>` "'(~:]+/,f=/^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/,c=/^\s*\[[^\]]+?\]:.*$/,d=/[!\"#$%&\'()*+,\-\.\/:;<=>?@\[\\\]^_`{|}~—]/;function k(t,e,i){return e.f=e.inline=i,i(t,e)}function p(t,e,i){return e.f=e.block=i,i(t,e)}function x(t){return t.linkTitle=!1,t.linkHref=!1,t.linkText=!1,t.em=!1,t.strong=!1,t.strikethrough=!1,t.quote=0,t.indentedCode=!1,t.f==S&&(t.f=M,t.block=v),t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.prevLine=t.thisLine,t.thisLine={stream:null},null}function v(n,r){var l,u=n.column()===r.indentation,d=!(l=r.prevLine.stream)||!/\S/.test(l.string),p=r.indentedCode,x=r.prevLine.hr,v=!1!==r.list,S=(r.listStack[r.listStack.length-1]||0)+3;r.indentedCode=!1;var q=r.indentation;if(null===r.indentationDiff&&(r.indentationDiff=r.indentation,v)){for(r.em=!1,r.strong=!1,r.code=!1,r.strikethrough=!1,r.list=null;q<r.listStack[r.listStack.length-1];)r.listStack.pop(),r.listStack.length?r.indentation=r.listStack[r.listStack.length-1]:r.list=!1;!1!==r.list&&(r.indentationDiff=q-r.listStack[r.listStack.length-1])}var M=!(d||x||r.prevLine.header||v&&p||r.prevLine.fencedCodeEnd),F=(!1===r.list||x||d)&&r.indentation<=S&&n.match(o),b=null;if(r.indentationDiff>=4&&(p||r.prevLine.fencedCodeEnd||r.prevLine.header||d))return n.skipToEnd(),r.indentedCode=!0,a.code;if(n.eatSpace())return null;if(u&&r.indentation<=S&&(b=n.match(s))&&b[1].length<=6)return r.quote=0,r.header=b[1].length,r.thisLine.header=!0,i.highlightFormatting&&(r.formatting="header"),r.f=r.inline,T(r);if(r.indentation<=S&&n.eat(">"))return r.quote=u?1:r.quote+1,i.highlightFormatting&&(r.formatting="quote"),n.eatSpace(),T(r);if(!F&&!r.setext&&u&&r.indentation<=S&&(b=n.match(h))){var E=b[1]?"ol":"ul";return r.indentation=q+n.current().length,r.list=!0,r.quote=0,r.listStack.push(r.indentation),i.taskLists&&n.match(g,!1)&&(r.taskList=!0),r.f=r.inline,i.highlightFormatting&&(r.formatting=["list","list-"+E]),T(r)}return u&&r.indentation<=S&&(b=n.match(f,!0))?(r.quote=0,r.fencedEndRE=new RegExp(b[1]+"+ *$"),r.localMode=i.fencedCodeBlockHighlighting&&function(i){if(t.findModeByName){var n=t.findModeByName(i);n&&(i=n.mime||n.mimes[0])}var r=t.getMode(e,i);return"null"==r.name?null:r}(b[2]),r.localMode&&(r.localState=t.startState(r.localMode)),r.f=r.block=L,i.highlightFormatting&&(r.formatting="code-block"),r.code=-1,T(r)):r.setext||!(M&&v||r.quote||!1!==r.list||r.code||F||c.test(n.string))&&(b=n.lookAhead(1))&&(b=b.match(m))?(r.setext?(r.header=r.setext,r.setext=0,n.skipToEnd(),i.highlightFormatting&&(r.formatting="header")):(r.header="="==b[0].charAt(0)?1:2,r.setext=r.header),r.thisLine.header=!0,r.f=r.inline,T(r)):F?(n.skipToEnd(),r.hr=!0,r.thisLine.hr=!0,a.hr):"["===n.peek()?k(n,r,w):k(n,r,r.inline)}function
|