1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-14 22:04:51 +00:00
TiddlyWiki5/plugins/tiddlywiki/codemirror-mode-markdown/files/mode/markdown/markdown.js

4 lines
13 KiB
JavaScript
Raw Normal View History

CodeMirror 5.36.0 modularized (#3184) * v5.35.1 * codemirror 5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * v5.35.1 * adding search&replace and autocomplete * update version number * add jump-to-line.js required for search&replace * adding show-hint.js required by autocomplete * adding basic autocomplete for any word * adding autocomplete css * adding new files to tiddlywiki.files * forgot adding search.js * minify 'em all * Delete vim.js * Delete sublime.js * Delete emacs.js * Delete anyword-hint.js * Delete show-hint.css * Delete show-hint.js * Update config.tid * Update tiddlywiki.files * Update tiddlywiki.files * Update config.tid * Update config.tid * Update config.tid * Delete dialog.js * Delete dialog.css * Delete jump-to-line.js * Delete search.js * Delete searchcursor.js * Update tiddlywiki.files * Update tiddlywiki.files * Update tiddlywiki.files * add search-and-replace cm-addon as plugin * add autocomplete cm-addon as plugin * add fullscreen-editing cm-addon as plugin * add keymaps as plugins + cleanup * add highlighting modes as plugins * small update on usage.tid * moved multiplex.js to htmlembedded mode - the only one using it * config/CodeMirror update * how to disable line numbers * how to change CM theme * add closebrackets and closetags addons * packaging a base-addon * move meta.js from codemirror to base addon * inputStyle: textarea -> prevents contenteditable on mobile browsers, keeps focus when clicking toolbar buttons, prevents import on paste * default config no line numbers * temporary add panel plugin for demo * put base-plugin back to codemirror editor * searchcursor to searchnreplace plugin * bad copypasta mistake * another typo * stripped down meta.js + moved matchbrackets to closebrackets plugin * remove panel * change module-type to codemirro and make init "require" dynamic. * make config handling dynamic with sensible defaults * make cm settings translateable * delete multids. they will be replaced * add auto-config tiddlers * dynamically create config structure for CM * fix filename * change typo * kitchensink config, plus change plugin description for better sorting. * add matchBrackets config tiddler * RIP codeblock * removed install instructions from readme - codemirror usage tiddler still todo * control panel settings for cm base * add setting for auto-close tags * adding fontfamily settings and theme settings * change tags for settings from $:/tags/ControlPanel/Settings to $:/tags/ControlPanel/Settings/CodeMirror * more usage info * more usage info * update to v5.36.0 * ugly hack enables highlighting and tag-closing for vnd.tiddlywiki and x-tiddlywiki * disable auto-indent for vnd.tiddlywiki & x-tiddlywiki and add some hidden settings * remove engine.js hack * meta.js -> tw-meta.js * codemirror settings tab * rename tiddler to tw-meta.js * make editor font monospace or sans-serif - dropdown select * make editor font monospace or sans-serif - dropdown select * now using correct tiddler for editor font setting * better usage doc * make markdown-mode require tw-meta * add more themes info * add active-line highlighting option * mini usage change * add integer type to engine.js config-getter * blink rate config type string * correct engine.js * license for base-plugin, usage link in settings tab * codemirrordemo hellothere update * codemirrordemo hellothere update * Update license.tid * codemirror demo sidebarlayout, license * license headers to addon files * license formatting & forgot what year we have * license formatting & forgot what year we have & codemirror demo sitetitle sitesubtitle * more informations 'try-this-style' for codemirrordemo hellothere * codemirror demo sitetitle & cm fontfamily * hellothere * font-family setting must be editor-font-family, not code-font-family * add basic keyboard shortcuts table * shortcuts change to not interfere with toolbar shortcuts - needs testing - vim and emacs todo * formatting * controlpanel change keymap - default keymap is default * ctrl-T becomes Alt-T in default keymap * adjustments for codemirror demo * demo: hellothere - hint for sidebar keymap cheatsheet * toolbar focus fix + remove console log * engine.js cleanup * formatting * reverting focus fix * indenting engine.js * hoping that indenting gets better
2018-04-06 16:34:50 +00:00
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://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","../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