From 671d2b94996ac71d56b2d05d5fe694ed7d84fa59 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Wed, 4 Apr 2012 12:27:35 -0700 Subject: upgrading to CodeMirror 2.23, since it has an important fix to Not close Ninja, if backspace is pressed while autocomplete dropdown is open. Signed-off-by: Ananya Sen --- imports/codemirror/mode/tiddlywiki/tiddlywiki.js | 72 ++++++++++++++---------- 1 file changed, 41 insertions(+), 31 deletions(-) (limited to 'imports/codemirror/mode/tiddlywiki/tiddlywiki.js') diff --git a/imports/codemirror/mode/tiddlywiki/tiddlywiki.js b/imports/codemirror/mode/tiddlywiki/tiddlywiki.js index e07124c2..1d26967e 100644 --- a/imports/codemirror/mode/tiddlywiki/tiddlywiki.js +++ b/imports/codemirror/mode/tiddlywiki/tiddlywiki.js @@ -1,18 +1,18 @@ /*** - |''Name''|tiddlywiki.js| - |''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror2| - |''Author''|PMario| - |''Version''|0.1.6| - |''Status''|''beta''| - |''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]| - |''Documentation''|http://codemirror.tiddlyspace.com/| - |''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]| - |''CoreVersion''|2.5.0| - |''Requires''|codemirror.js| - |''Keywords''|syntax highlighting color code mirror codemirror| - ! Info - CoreVersion parameter is needed for TiddlyWiki only! - ***/ +|''Name''|tiddlywiki.js| +|''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror| +|''Author''|PMario| +|''Version''|0.1.7| +|''Status''|''stable''| +|''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]| +|''Documentation''|http://codemirror.tiddlyspace.com/| +|''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]| +|''CoreVersion''|2.5.0| +|''Requires''|codemirror.js| +|''Keywords''|syntax highlighting color code mirror codemirror| +! Info +CoreVersion parameter is needed for TiddlyWiki only! +***/ //{{{ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { var indentUnit = config.indentUnit; @@ -47,20 +47,20 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { }(); var isSpaceName = /[\w_\-]/i, - reHR = /^\-\-\-\-+$/, + reHR = /^\-\-\-\-+$/, //
reWikiCommentStart = /^\/\*\*\*$/, // /*** reWikiCommentStop = /^\*\*\*\/$/, // ***/ reBlockQuote = /^<<<$/, - reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ - reJsCodeStop = /^\/\/\}\}\}$/, // //}}} - reXmlCodeStart = /^$/, - reXmlCodeStop = /^$/, + reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start + reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop + reXmlCodeStart = /^$/, // xml block start + reXmlCodeStop = /^$/, // xml stop - reCodeBlockStart = /^\{\{\{$/, - reCodeBlockStop = /^\}\}\}$/, + reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start + reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop - reCodeStart = /\{\{\{/, + reCodeStart = /\{\{\{/, // {{{ code span start reUntilCodeStop = /.*?\}\}\}/; function chain(stream, state, f) { @@ -95,9 +95,9 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { state.block = false; // indicates the start of a code block. - ch = stream.peek(); // don't eat, to make match simpler + ch = stream.peek(); // don't eat, to make matching simpler - // check start of blocks + // check start of blocks if (sol && /[<\/\*{}\-]/.test(ch)) { if (stream.match(reCodeBlockStart)) { state.block = true; @@ -116,7 +116,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { return ret('hr', 'hr'); } } // sol - var ch = stream.next(); + ch = stream.next(); if (sol && /[\/\*!#;:>|]/.test(ch)) { if (ch == "!") { // tw header @@ -131,11 +131,11 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { stream.eatWhile('#'); return ret("list", "list"); } - if (ch == ";") { // tw list + if (ch == ";") { // definition list, term stream.eatWhile(';'); return ret("list", "list"); } - if (ch == ":") { // tw list + if (ch == ":") { // definition list, description stream.eatWhile(':'); return ret("list", "list"); } @@ -162,6 +162,9 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { if (ch == '"') { return ret('string', 'string'); } + if (ch == '~') { // _no_ CamelCase indicator should be bold + return ret('text', 'brace'); + } if (/[\[\]]/.test(ch)) { // check for [[..]] if (stream.peek() == ch) { stream.next(); @@ -189,9 +192,15 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { return chain(stream, state, twTokenUnderline); } } - if (ch == "-") { // tw strikethrough TODO looks ugly .. different handling see below; + // strikethrough and mdash handling + if (ch == "-") { if (stream.eat("-")) { - return chain(stream, state, twTokenStrike); + // if strikethrough looks ugly, change CSS. + if (stream.peek() != ' ') + return chain(stream, state, twTokenStrike); + // mdash + if (stream.peek() == ' ') + return ret('text', 'brace'); } } if (ch == "'") { // tw bold @@ -208,6 +217,7 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { return ret(ch); } + // core macro handling stream.eatWhile(/[\w\$_]/); var word = stream.current(), known = textwords.propertyIsEnumerable(word) && textwords[word]; @@ -301,8 +311,8 @@ CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) { return ret("text", "underlined"); } - // tw strike through text looks ugly - // TODO just strike through the first and last 2 chars if possible. + // tw strike through text looks ugly + // change CSS if needed function twTokenStrike(stream, state) { var maybeEnd = false, ch, nr; -- cgit v1.2.3