mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-15 06:14:53 +00:00
769ffa19b7
* Update codemirror.js to 5.58.2 * Update codemirror.css to 5.58.2 * Update activeline.js to 5.58.2 * Update dialog.js to 5.58.2 * Update jump-to-line.js to 5.58.2 * Update search.js to 5.58.2 * Update searchcursor.js to 5.58.2 * Update xml.js to 5.58.2 * Update show-hint.js to 5.58.2 * Update show-hint.css to 5.58.2 * Update javascript-hint.js to 5.58.2 * Update xml-hint.js to 5.58.2 * Update html-hint.js to 5.58.2 * Update css-hint.js to 5.58.2 * Update anyword-hint.js to 5.58.2 * Update closebrackets.js to 5.58.2 * Update matchbrackets.js to 5.58.2 * Update closetag.js to 5.58.2 * Update xml-fold.js to 5.58.2 * Update fullscreen.js to 5.58.2 * Update emacs.js to 5.58.2 * Update sublime.js to 5.58.2 * Update comment.js to 5.58.2 * Update vim.js to 5.58.2 * Update css.js to 5.58.2 * Update multiplex.js to 5.58.2 * Update htmlembedded.js to 5.58.2 * Update htmlmixed.js to 5.58.2 * Update javascript.js to 5.58.2 * Update markdown.js to 5.58.2 * Update markdown.js * Update readme.tid * Update markdown.js
4 lines
15 KiB
JavaScript
Executable File
4 lines
15 KiB
JavaScript
Executable File
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
|
!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","../tw-meta"],t):t(CodeMirror)}(function(j){"use strict";j.defineMode("markdown",function(c,x){var A=j.getMode(c,"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.fencedCodeBlockDefaultMode&&(x.fencedCodeBlockDefaultMode="text/plain"),void 0===x.xml&&(x.xml=!0),void 0===x.tokenTypeOverrides&&(x.tokenTypeOverrides={});var C={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 C)C.hasOwnProperty(t)&&x.tokenTypeOverrides[t]&&(C[t]=x.tokenTypeOverrides[t]);var f=/^([*\-_])(?:\s*\1){2,}\s*$/,k=/^(?:[*\-+]|^[0-9]+([.)]))\s+/,S=/^\[(x| )\](?=\s)/i,F=x.allowAtxHeaderWithoutSpace?/^(#+)/:/^(#+)(?: |$)/,D=/^ {0,3}(?:\={1,}|-{2,})\s*$/,i=/^[^#!\[\]*_\\<>` "'(~:]+/,p=/^(~~~+|```+)[ \t]*([\w\/+#-]*)[^\n`]*$/,E=/^\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 B(t,e,i){return(e.f=e.inline=i)(t,e)}function L(t,e,i){return(e.f=e.block=i)(t,e)}function n(t){var e,i;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==T&&((i=u)||(i="xml"==(e=j.innerMode(A,t.htmlState)).mode.name&&null===e.state.tagStart&&!e.state.context&&e.state.tokenize.isInText),i&&(t.f=b,t.block=a,t.htmlState=null)),t.trailingSpace=0,t.trailingSpaceNewLine=!1,t.prevLine=t.thisLine,t.thisLine={stream:null},null}function a(t,e){var i,n=t.column()===e.indentation,u=!(i=e.prevLine.stream)||!/\S/.test(i.string),r=e.indentedCode,a=e.prevLine.hr,o=!1!==e.list,l=(e.listStack[e.listStack.length-1]||0)+3;e.indentedCode=!1;var h=e.indentation;if(null===e.indentationDiff&&(e.indentationDiff=e.indentation,o)){for(e.list=null;h<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=h-e.listStack[e.listStack.length-1])}var s=!(u||a||e.prevLine.header||o&&r||e.prevLine.fencedCodeEnd),g=(!1===e.list||a||u)&&e.indentation<=l&&t.match(f),m=null;if(4<=e.indentationDiff&&(r||e.prevLine.fencedCodeEnd||e.prevLine.header||u))return t.skipToEnd(),e.indentedCode=!0,C.code;if(t.eatSpace())return null;if(n&&e.indentation<=l&&(m=t.match(F))&&m[1].length<=6)return e.quote=0,e.header=m[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=n?1:e.quote+1,x.highlightFormatting&&(e.formatting="quote"),t.eatSpace(),q(e);if(!g&&!e.setext&&n&&e.indentation<=l&&(m=t.match(k))){var d=m[1]?"ol":"ul";return e.indentation=h+t.current().length,e.list=!0,e.quote=0,e.listStack.push(e.indentation),e.em=!1,e.strong=!1,e.code=!1,e.strikethrough=!1,x.taskLists&&t.match(S,!1)&&(e.taskList=!0),e.f=e.inline,x.highlightFormatting&&(e.formatting=["list","list-"+d]),q(e)}return n&&e.indentation<=l&&(m=t.match(p,!0))?(e.quote=0,e.fencedEndRE=new RegExp(m[1]+"+ *$"),e.localMode=x.fencedCodeBlockHighlighting&&function(t){var e;!j.findModeByName||(e=j.findModeByName(t))&&(t=e.mime||e.mimes[0]);var i=j.getMode(c,t);return"null"==i.name?null:i}(m[2]||x.fencedCodeBlockDefaultMode),e.localMode&&(e.localState=j.startState(e.localMode)),e.f=e.block=M,x.highlightFormatting&&(e.formatting="code-block"),e.code=-1,q(e)):e.setext||!(s&&o||e.quote||!1!==e.list||e.code||g||E.test(t.string))&&(m=t.lookAhead(1))&&(m=m.match(D))?(e.setext?(e.header=e.setext,e.setext=0,t.skipToEnd(),x.highlightFormatting&&(e.formatting="header")):(e.header="="==m[0].charAt(0)?1:2,e.setext=e.header),e.thisLine.header=!0,e.f=e.inline,q(e)):g?(t.skipToEnd(),e.hr=!0,e.thisLine.hr=!0,C.hr):"["===t.peek()?B(t,e,H):B(t,e,e.inline)}function T(t,e){var i,n=A.token(t,e.htmlState);return u||("xml"==(i=j.innerMode(A,e.htmlState)).mode.name&&null===i.state.tagStart&&!i.state.context&&i.state.tokenize.isInText||e.md_inside&&-1<t.current().indexOf(">"))&&(e.f=b,e.block=a,e.htmlState=null),n}function M(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=b,e.fencedEndRE=null,e.code=0,e.thisLine.fencedCodeEnd=!0,u?L(t,e,e.block):i):e.localMode?e.localMode.token(t,e.localState):(t.skipToEnd(),C.code)}function q(t){var e,i=[];if(t.formatting){i.push(C.formatting),"string"==typeof t.formatting&&(t.formatting=[t.formatting]);for(var n=0;n<t.formatting.length;n++)i.push(C.formatting+"-"+t.formatting[n]),"header"===t.formatting[n]&&i.push(C.formatting+"-"+t.formatting[n]+"-"+t.header),"quote"===t.formatting[n]&&(!x.maxBlockquoteDepth||x.maxBlockquoteDepth>=t.quote?i.push(C.formatting+"-"+t.formatting[n]+"-"+t.quote):i.push("error"))}return t.taskOpen?i.push("meta"):t.taskClosed?i.push("property"):(t.linkHref?i.push(C.linkHref,"url"):(t.strong&&i.push(C.strong),t.em&&i.push(C.em),t.strikethrough&&i.push(C.strikethrough),t.emoji&&i.push(C.emoji),t.linkText&&i.push(C.linkText),t.code&&i.push(C.code),t.image&&i.push(C.image),t.imageAltText&&i.push(C.imageAltText,"link"),t.imageMarker&&i.push(C.imageMarker)),t.header&&i.push(C.header,C.header+"-"+t.header),t.quote&&(i.push(C.quote),!x.maxBlockquoteDepth||x.maxBlockquoteDepth>=t.quote?i.push(C.quote+"-"+t.quote):i.push(C.quote+"-"+x.maxBlockquoteDepth)),!1!==t.list&&((e=(t.listStack.length-1)%3)?1==e?i.push(C.list2):i.push(C.list3):i.push(C.list1)),t.trailingSpaceNewLine?i.push("trailing-space-new-line"):t.trailingSpace&&i.push("trailing-space-"+(t.trailingSpace%2?"a":"b"))),i.length?i.join(" "):null}function e(t,e){if(t.match(i,!0))return q(e)}function b(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(S,!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,r="^\\s*(?:[^"+(u=(u+"").replace(/([.?*+^\[\]\\(){}|-])/g,"\\$1"))+"\\\\]+|\\\\\\\\|\\\\.)"+u;if(t.match(new RegExp(r),!0))return C.linkHref}if("`"===n){var a=e.formatting;x.highlightFormatting&&(e.formatting="code"),t.eatWhile("`");var o=t.current().length;if(0!=e.code||e.quote&&1!=o){if(o!=e.code)return e.formatting=a,q(e);var l=q(e);return e.code=0,l}return e.code=o,q(e)}if(e.code)return q(e);if("\\"===n&&(t.next(),x.highlightFormatting)){var h=q(e),s=C.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=y,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)?y:b,h}if("<"===n&&t.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/,!1))return e.f=e.inline=w,x.highlightFormatting&&(e.formatting="link"),(h=q(e))?h+=" ":h="",h+C.linkInline;if("<"===n&&t.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/,!1))return e.f=e.inline=w,x.highlightFormatting&&(e.formatting="link"),(h=q(e))?h+=" ":h="",h+C.linkEmail;if(x.xml&&"<"===n&&t.match(/^(!--|\?|!\[CDATA\[|[a-z][a-z0-9-]*(?:\s+[a-z_:.\-]+(?:\s*=\s*[^>]+)?)*\s*(?:>|$))/i,!1)){var g,m=t.string.indexOf(">",t.pos);return-1!=m&&(g=t.string.substring(t.start,m),/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(g)&&(e.md_inside=!0)),t.backUp(1),e.htmlState=j.startState(A),L(t,e,T)}if(x.xml&&"<"===n&&t.match(/^\/\w*?>/))return e.md_inside=!1,"tag";if("*"===n||"_"===n){for(var d=1,c=1==t.pos?" ":t.string.charAt(t.pos-2);d<3&&t.eat(n);)d++;var f=t.peek()||" ",k=!/\s/.test(f)&&(!v.test(f)||/\s/.test(c)||v.test(c)),F=!/\s/.test(c)&&(!v.test(c)||/\s/.test(f)||v.test(f)),D=null,p=null;if(d%2&&(e.em||!k||"*"!==n&&F&&!v.test(c)?e.em!=n||!F||"*"!==n&&k&&!v.test(f)||(D=!1):D=!0),1<d&&(e.strong||!k||"*"!==n&&F&&!v.test(c)?e.strong!=n||!F||"*"!==n&&k&&!v.test(f)||(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);l=q(e);return!1===D&&(e.em=!1),!1===p&&(e.strong=!1),l}}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");l=q(e);return e.strikethrough=!1,l}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 w(t,e){if(">"!==t.next())return t.match(/^[^>]+/,!0),C.linkInline;e.f=e.inline=b,x.highlightFormatting&&(e.formatting="link");var i=q(e);return i?i+=" ":i="",i+C.linkInline}function y(t,e){if(t.eatSpace())return null;var n,i=t.next();return"("===i||"["===i?(e.f=e.inline=(n="("===i?")":"]",function(t,e){if(t.next()!==n)return t.match(r[n]),e.linkHref=!0,q(e);e.f=e.inline=b,x.highlightFormatting&&(e.formatting="link-string");var i=q(e);return e.linkHref=!1,i}),x.highlightFormatting&&(e.formatting="link-string"),e.linkHref=!0,q(e)):"error"}var r={")":/^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,"]":/^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\]]|\\.)*\])*?(?=\])/};function H(t,e){return t.match(/^([^\]\\]|\\.)*\]:/,!1)?(e.f=o,t.next(),x.highlightFormatting&&(e.formatting="link"),e.linkText=!0,q(e)):B(t,e,b)}function o(t,e){if(t.match(/^\]:/,!0)){e.f=e.inline=l,x.highlightFormatting&&(e.formatting="link");var i=q(e);return e.linkText=!1,i}return t.match(/^([^\]\\]|\\.)+/,!0),C.linkText}function l(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=b,C.linkHref+" url")}var h={startState:function(){return{f:a,prevLine:{stream:null},thisLine:{stream:null},block:a,htmlState:null,indentation:0,inline:b,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&&j.copyState(A,t.htmlState),indentation:t.indentation,localMode:t.localMode,localState:t.localMode?j.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!=T)){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==T?{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==T&&A.indent?A.indent(t.htmlState,e,i):t.localState&&t.localMode.indent?t.localMode.indent(t.localState,e,i):j.Pass},blankLine:n,getType:q,blockCommentStart:"\x3c!--",blockCommentEnd:"--\x3e",closeBrackets:"()[]{}''\"\"``",fold:"markdown"};return h},"xml"),j.defineMIME("text/markdown","markdown"),j.defineMIME("text/x-markdown","markdown")});
|