From ce51f976dd1e8af0ef9da162ec5d6b37720ee325 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke <marijnh@gmail.com> Date: Wed, 14 Mar 2012 14:49:54 +0100 Subject: [PATCH] Update and integrate Smarty mode --- doc/compress.html | 1 + index.html | 1 + mode/smarty/smarty.js | 12 +++++++----- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/doc/compress.html b/doc/compress.html index 19c8155dd..ff2cb9349 100644 --- a/doc/compress.html +++ b/doc/compress.html @@ -82,6 +82,7 @@ <option value="http://codemirror.net/mode/rust/rust.js">rust.js</option> <option value="http://codemirror.net/mode/scheme/scheme.js">scheme.js</option> <option value="http://codemirror.net/mode/smalltalk/smalltalk.js">smalltalk.js</option> + <option value="http://codemirror.net/mode/smarty/smarty.js">smarty.js</option> <option value="http://codemirror.net/mode/sparql/sparql.js">sparql.js</option> <option value="http://codemirror.net/mode/stex/stex.js">stex.js</option> <option value="http://codemirror.net/mode/tiddlywiki/tiddlywiki.js">tiddlywiki.js</option> diff --git a/index.html b/index.html index 07c6998ce..f839c1395 100644 --- a/index.html +++ b/index.html @@ -66,6 +66,7 @@ <li><a href="mode/rust/index.html">Rust</a></li> <li><a href="mode/scheme/index.html">Scheme</a></li> <li><a href="mode/smalltalk/index.html">Smalltalk</a></li> + <li><a href="mode/smarty/index.html">Smarty</a></li> <li><a href="mode/sparql/index.html">SPARQL</a></li> <li><a href="mode/stex/index.html">sTeX, LaTeX</a></li> <li><a href="mode/tiddlywiki/index.html">Tiddlywiki</a></li> diff --git a/mode/smarty/smarty.js b/mode/smarty/smarty.js index 2cd557f12..9da7da626 100644 --- a/mode/smarty/smarty.js +++ b/mode/smarty/smarty.js @@ -63,7 +63,7 @@ CodeMirror.defineMode("smarty", function(config, parserConfig) { return ret("number", "number"); } else { - if (last == "variable") { + if (state.last == "variable") { if (ch == "@") { stream.eatWhile(regs.validIdentifier); return ret("property", "property"); @@ -73,11 +73,11 @@ CodeMirror.defineMode("smarty", function(config, parserConfig) { return ret("qualifier", "modifier"); } } - else if (last == "whitespace") { + else if (state.last == "whitespace") { stream.eatWhile(regs.validIdentifier); return ret("attribute", "modifier"); } - else if (last == "property") { + else if (state.last == "property") { stream.eatWhile(regs.validIdentifier); return ret("property", null); } @@ -134,10 +134,12 @@ CodeMirror.defineMode("smarty", function(config, parserConfig) { return { startState: function() { - return { tokenize: tokenizer, mode: "smarty" }; + return { tokenize: tokenizer, mode: "smarty", last: null }; }, token: function(stream, state) { - return state.tokenize(stream, state); + var style = state.tokenize(stream, state); + state.last = last; + return style; }, electricChars: "" } -- GitLab