md/libs/scripts/markdown.min.js
yanglbme de630f9cb2 feat: add local files for library
添加本地文件,并进行相对引用
2019-11-06 19:21:01 +08:00

1 line
14 KiB
JavaScript

!function(t){"object"==typeof exports&&"object"==typeof module?t(require("../../lib/codemirror"),require("../xml/xml"),require("../meta")):"function"==typeof define&&define.amd?define(["../../lib/codemirror","../xml/xml","../meta"],t):t(CodeMirror)}(function(y){"use strict";y.defineMode("markdown",function(f,x){var A=y.getMode(f,"text/html"),u="null"==A.name;void 0===x.highlightFormatting&&(x.highlightFormatting=!1),void 0===x.maxBlockquoteDepth&&(x.maxBlockquoteDepth=0),void 0===x.taskLists&&(x.taskLists=!1),void 0===x.strikethrough&&(x.strikethrough=!1),void 0===x.emoji&&(x.emoji=!1),void 0===x.fencedCodeBlockHighlighting&&(x.fencedCodeBlockHighlighting=!0),void 0===x.xml&&(x.xml=!0),void 0===x.tokenTypeOverrides&&(x.tokenTypeOverrides={});var S={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 t in S)S.hasOwnProperty(t)&&x.tokenTypeOverrides[t]&&(S[t]=x.tokenTypeOverrides[t]);var c=/^([*\-_])(?:\s*\1){2,}\s*$/,d=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,C=/^\[(x| )\](?=\s)/i,k=x.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,F=/^ *(?:\={1,}|-{1,})\s*$/,i=/^[^#!\[\]*_\\<>` "'(~:]+/,D=/^(~~~+|```+)[ \t]*([\w+#-]*)[^\n`]*$/,p=/^\s*\[[^\]]+?\]:.*$/,v=/[!"#$%&'()*+,\-.\/:;<=>?@\[\\\]^_`{|}~\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]/;function E(t,e,i){return e.f=e.inline=i,i(t,e)}function B(t,e,i){return e.f=e.block=i,i(t,e)}function n(t){if(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==L){var e=u;if(!e){var i=y.innerMode(A,t.htmlState);e="xml"==i.mode.name&&null===i.state.tagStart&&!i.state.context&&i.state.tokenize.isInText}e&&(t.f=M,t.block=a,t.htmlState=null)}return t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.prevLine=t.thisLine,t.thisLine={stream:null},null}function a(t,e){var i=t.column()===e.indentation,n=function(t){return!t||!/\S/.test(t.string)}(e.prevLine.stream),u=e.indentedCode,r=e.prevLine.hr,a=!1!==e.list,l=(e.listStack[e.listStack.length-1]||0)+3;e.indentedCode=!1;var o=e.indentation;if(null===e.indentationDiff&&(e.indentationDiff=e.indentation,a)){for(e.em=!1,e.strong=!1,e.code=!1,e.strikethrough=!1,e.list=null;o<e.listStack[e.listStack.length-1];)e.listStack.pop(),e.listStack.length?e.indentation=e.listStack[e.listStack.length-1]:e.list=!1;!1!==e.list&&(e.indentationDiff=o-e.listStack[e.listStack.length-1])}var h=!(n||r||e.prevLine.header||a&&u||e.prevLine.fencedCodeEnd),s=(!1===e.list||r||n)&&e.indentation<=l&&t.match(c),g=null;if(4<=e.indentationDiff&&(u||e.prevLine.fencedCodeEnd||e.prevLine.header||n))return t.skipToEnd(),e.indentedCode=!0,S.code;if(t.eatSpace())return null;if(i&&e.indentation<=l&&(g=t.match(k))&&g[1].length<=6)return e.quote=0,e.header=g[1].length,e.thisLine.header=!0,x.highlightFormatting&&(e.formatting="header"),e.f=e.inline,q(e);if(e.indentation<=l&&t.eat(">"))return e.quote=i?1:e.quote+1,x.highlightFormatting&&(e.formatting="quote"),t.eatSpace(),q(e);if(!s&&!e.setext&&i&&e.indentation<=l&&(g=t.match(d))){var m=g[1]?"ol":"ul";return e.indentation=o+t.current().length,e.list=!0,e.quote=0,e.listStack.push(e.indentation),x.taskLists&&t.match(C,!1)&&(e.taskList=!0),e.f=e.inline,x.highlightFormatting&&(e.formatting=["list","list-"+m]),q(e)}return i&&e.indentation<=l&&(g=t.match(D,!0))?(e.quote=0,e.fencedEndRE=new RegExp(g[1]+"+ *$"),e.localMode=x.fencedCodeBlockHighlighting&&function(t){if(y.findModeByName){var e=y.findModeByName(t);e&&(t=e.mime||e.mimes[0])}var i=y.getMode(f,t);return"null"==i.name?null:i}(g[2]),e.localMode&&(e.localState=y.startState(e.localMode)),e.f=e.block=T,x.highlightFormatting&&(e.formatting="code-block"),e.code=-1,q(e)):e.setext||!(h&&a||e.quote||!1!==e.list||e.code||s||p.test(t.string))&&(g=t.lookAhead(1))&&(g=g.match(F))?(e.setext?(e.header=e.setext,e.setext=0,t.skipToEnd(),x.highlightFormatting&&(e.formatting="header")):(e.header="="==g[0].charAt(0)?1:2,e.setext=e.header),e.thisLine.header=!0,e.f=e.inline,q(e)):s?(t.skipToEnd(),e.hr=!0,e.thisLine.hr=!0,S.hr):"["===t.peek()?E(t,e,j):E(t,e,e.inline)}function L(t,e){var i=A.token(t,e.htmlState);if(!u){var n=y.innerMode(A,e.htmlState);("xml"==n.mode.name&&null===n.state.tagStart&&!n.state.context&&n.state.tokenize.isInText||e.md_inside&&-1<t.current().indexOf(">"))&&(e.f=M,e.block=a,e.htmlState=null)}return i}function T(t,e){var i,n=e.listStack[e.listStack.length-1]||0,u=e.indentation<n,r=n+3;return e.fencedEndRE&&e.indentation<=r&&(u||t.match(e.fencedEndRE))?(x.highlightFormatting&&(e.formatting="code-block"),u||(i=q(e)),e.localMode=e.localState=null,e.block=a,e.f=M,e.fencedEndRE=null,e.code=0,e.thisLine.fencedCodeEnd=!0,u?B(t,e,e.block):i):e.localMode?e.localMode.token(t,e.localState):(t.skipToEnd(),S.code)}function q(t){var e=[];if(t.formatting){e.push(S.formatting),"string"==typeof t.formatting&&(t.formatting=[t.formatting]);for(var i=0;i<t.formatting.length;i++)e.push(S.formatting+"-"+t.formatting[i]),"header"===t.formatting[i]&&e.push(S.formatting+"-"+t.formatting[i]+"-"+t.header),"quote"===t.formatting[i]&&(!x.maxBlockquoteDepth||x.maxBlockquoteDepth>=t.quote?e.push(S.formatting+"-"+t.formatting[i]+"-"+t.quote):e.push("error"))}if(t.taskOpen)return e.push("meta"),e.length?e.join(" "):null;if(t.taskClosed)return e.push("property"),e.length?e.join(" "):null;if(t.linkHref?e.push(S.linkHref,"url"):(t.strong&&e.push(S.strong),t.em&&e.push(S.em),t.strikethrough&&e.push(S.strikethrough),t.emoji&&e.push(S.emoji),t.linkText&&e.push(S.linkText),t.code&&e.push(S.code),t.image&&e.push(S.image),t.imageAltText&&e.push(S.imageAltText,"link"),t.imageMarker&&e.push(S.imageMarker)),t.header&&e.push(S.header,S.header+"-"+t.header),t.quote&&(e.push(S.quote),!x.maxBlockquoteDepth||x.maxBlockquoteDepth>=t.quote?e.push(S.quote+"-"+t.quote):e.push(S.quote+"-"+x.maxBlockquoteDepth)),!1!==t.list){var n=(t.listStack.length-1)%3;n?1==n?e.push(S.list2):e.push(S.list3):e.push(S.list1)}return t.trailingSpaceNewLine?e.push("trailing-space-new-line"):t.trailingSpace&&e.push("trailing-space-"+(t.trailingSpace%2?"a":"b")),e.length?e.join(" "):null}function e(t,e){if(t.match(i,!0))return q(e)}function M(t,e){var i=e.text(t,e);if(void 0!==i)return i;if(e.list)return e.list=null,q(e);if(e.taskList)return" "===t.match(C,!0)[1]?e.taskOpen=!0:e.taskClosed=!0,x.highlightFormatting&&(e.formatting="task"),e.taskList=!1,q(e);if(e.taskOpen=!1,e.taskClosed=!1,e.header&&t.match(/^#+$/,!0))return x.highlightFormatting&&(e.formatting="header"),q(e);var n=t.next();if(e.linkTitle){e.linkTitle=!1;var u=n;"("===n&&(u=")");var r="^\\s*(?:[^"+(u=(u+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1"))+"\\\\]+|\\\\\\\\|\\\\.)"+u;if(t.match(new RegExp(r),!0))return S.linkHref}if("`"===n){var a=e.formatting;x.highlightFormatting&&(e.formatting="code"),t.eatWhile("`");var l=t.current().length;if(0!=e.code||e.quote&&1!=l){if(l!=e.code)return e.formatting=a,q(e);var o=q(e);return e.code=0,o}return e.code=l,q(e)}if(e.code)return q(e);if("\\"===n&&(t.next(),x.highlightFormatting)){var h=q(e),s=S.formatting+"-escape";return h?h+" "+s:s}if("!"===n&&t.match(/\[[^\]]*\] ?(?:\(|\[)/,!1))return e.imageMarker=!0,e.image=!0,x.highlightFormatting&&(e.formatting="image"),q(e);if("["===n&&e.imageMarker&&t.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/,!1))return e.imageMarker=!1,e.imageAltText=!0,x.highlightFormatting&&(e.formatting="image"),q(e);if("]"===n&&e.imageAltText){x.highlightFormatting&&(e.formatting="image");var h=q(e);return e.imageAltText=!1,e.image=!1,e.inline=e.f=w,h}if("["===n&&!e.image)return e.linkText&&t.match(/^.*?\]/)||(e.linkText=!0,x.highlightFormatting&&(e.formatting="link")),q(e);if("]"===n&&e.linkText){x.highlightFormatting&&(e.formatting="link");var h=q(e);return e.linkText=!1,e.inline=e.f=t.match(/\(.*?\)| ?\[.*?\]/,!1)?w:M,h}if("<"===n&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1))return e.f=e.inline=b,x.highlightFormatting&&(e.formatting="link"),(h=q(e))?h+=" ":h="",h+S.linkInline;if("<"===n&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1))return e.f=e.inline=b,x.highlightFormatting&&(e.formatting="link"),(h=q(e))?h+=" ":h="",h+S.linkEmail;if(x.xml&&"<"===n&&t.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var g=t.string.indexOf(">",t.pos);if(-1!=g){var m=t.string.substring(t.start,g);/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(m)&&(e.md_inside=!0)}return t.backUp(1),e.htmlState=y.startState(A),B(t,e,L)}if(x.xml&&"<"===n&&t.match(/^\/\w*?>/))return e.md_inside=!1,"tag";if("*"===n||"_"===n){for(var f=1,c=1==t.pos?" ":t.string.charAt(t.pos-2);f<3&&t.eat(n);)f++;var d=t.peek()||" ",k=!/\s/.test(d)&&(!v.test(d)||/\s/.test(c)||v.test(c)),F=!/\s/.test(c)&&(!v.test(c)||/\s/.test(d)||v.test(d)),D=null,p=null;if(f%2&&(e.em||!k||"*"!==n&&F&&!v.test(c)?e.em!=n||!F||"*"!==n&&k&&!v.test(d)||(D=!1):D=!0),1<f&&(e.strong||!k||"*"!==n&&F&&!v.test(c)?e.strong!=n||!F||"*"!==n&&k&&!v.test(d)||(p=!1):p=!0),null!=p||null!=D){x.highlightFormatting&&(e.formatting=null==D?"strong":null==p?"em":"strong em"),!0===D&&(e.em=n),!0===p&&(e.strong=n);o=q(e);return!1===D&&(e.em=!1),!1===p&&(e.strong=!1),o}}else if(" "===n&&(t.eat("*")||t.eat("_"))){if(" "===t.peek())return q(e);t.backUp(1)}if(x.strikethrough)if("~"===n&&t.eatWhile(n)){if(e.strikethrough){x.highlightFormatting&&(e.formatting="strikethrough");o=q(e);return e.strikethrough=!1,o}if(t.match(/^[^\s]/,!1))return e.strikethrough=!0,x.highlightFormatting&&(e.formatting="strikethrough"),q(e)}else if(" "===n&&t.match(/^~~/,!0)){if(" "===t.peek())return q(e);t.backUp(2)}if(x.emoji&&":"===n&&t.match(/^(?:[a-z_\d+][a-z_\d+-]*|\-[a-z_\d+][a-z_\d+-]*):/)){e.emoji=!0,x.highlightFormatting&&(e.formatting="emoji");var E=q(e);return e.emoji=!1,E}return" "===n&&(t.match(/^ +$/,!1)?e.trailingSpace++:e.trailingSpace&&(e.trailingSpaceNewLine=!0)),q(e)}function b(t,e){if(">"!==t.next())return t.match(/^[^>]+/,!0),S.linkInline;e.f=e.inline=M,x.highlightFormatting&&(e.formatting="link");var i=q(e);return i?i+=" ":i="",i+S.linkInline}function w(t,e){if(t.eatSpace())return null;var i=t.next();return"("===i||"["===i?(e.f=e.inline=function(n){return function(t,e){if(t.next()!==n)return t.match(r[n]),e.linkHref=!0,q(e);e.f=e.inline=M,x.highlightFormatting&&(e.formatting="link-string");var i=q(e);return e.linkHref=!1,i}}("("===i?")":"]"),x.highlightFormatting&&(e.formatting="link-string"),e.linkHref=!0,q(e)):"error"}var r={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function j(t,e){return t.match(/^([^\]\\]|\\.)*\]:/,!1)?(e.f=l,t.next(),x.highlightFormatting&&(e.formatting="link"),e.linkText=!0,q(e)):E(t,e,M)}function l(t,e){if(t.match(/^\]:/,!0)){e.f=e.inline=o,x.highlightFormatting&&(e.formatting="link");var i=q(e);return e.linkText=!1,i}return t.match(/^([^\]\\]|\\.)+/,!0),S.linkText}function o(t,e){return t.eatSpace()?null:(t.match(/^[^\s]+/,!0),void 0===t.peek()?e.linkTitle=!0:t.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/,!0),e.f=e.inline=M,S.linkHref+" url")}var h={startState:function(){return{f:a,prevLine:{stream:null},thisLine:{stream:null},block:a,htmlState:null,indentation:0,inline:M,text:e,formatting:!1,linkText:!1,linkHref:!1,linkTitle:!1,code:0,em:!1,strong:!1,header:0,setext:0,hr:!1,taskList:!1,list:!1,listStack:[],quote:0,trailingSpace:0,trailingSpaceNewLine:!1,strikethrough:!1,emoji:!1,fencedEndRE:null}},copyState:function(t){return{f:t.f,prevLine:t.prevLine,thisLine:t.thisLine,block:t.block,htmlState:t.htmlState&&y.copyState(A,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?y.copyState(t.localMode,t.localState):null,inline:t.inline,text:t.text,formatting:!1,linkText:t.linkText,linkTitle:t.linkTitle,linkHref:t.linkHref,code:t.code,em:t.em,strong:t.strong,strikethrough:t.strikethrough,emoji:t.emoji,header:t.header,setext:t.setext,hr:t.hr,taskList:t.taskList,list:t.list,listStack:t.listStack.slice(0),quote:t.quote,indentedCode:t.indentedCode,trailingSpace:t.trailingSpace,trailingSpaceNewLine:t.trailingSpaceNewLine,md_inside:t.md_inside,fencedEndRE:t.fencedEndRE}},token:function(t,e){if(e.formatting=!1,t!=e.thisLine.stream){if(e.header=0,e.hr=!1,t.match(/^\s*$/,!0))return n(e),null;if(e.prevLine=e.thisLine,e.thisLine={stream:t},e.taskList=!1,e.trailingSpace=0,e.trailingSpaceNewLine=!1,!e.localState&&(e.f=e.block,e.f!=L)){var i=t.match(/^\s*/,!0)[0].replace(/\t/g," ").length;if(e.indentation=i,e.indentationDiff=null,0<i)return null}}return e.f(t,e)},innerMode:function(t){return t.block==L?{state:t.htmlState,mode:A}:t.localState?{state:t.localState,mode:t.localMode}:{state:t,mode:h}},indent:function(t,e,i){return t.block==L&&A.indent?A.indent(t.htmlState,e,i):t.localState&&t.localMode.indent?t.localMode.indent(t.localState,e,i):y.Pass},blankLine:n,getType:q,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return h},"xml"),y.defineMIME("text/markdown","markdown"),y.defineMIME("text/x-markdown","markdown")});