From: <rob...@us...> - 2010-12-23 22:52:48
|
Revision: 31635 http://tikiwiki.svn.sourceforge.net/tikiwiki/?rev=31635&view=rev Author: robertplummer Date: 2010-12-23 22:52:41 +0000 (Thu, 23 Dec 2010) Log Message: ----------- [ADD] More wicked cool syntax highlighting, more-so for plugins and their variables. Modified Paths: -------------- third_party/codemirror/css/tikiwikisyntaxcolors.css third_party/codemirror/js/parsetikisyntax.js Modified: third_party/codemirror/css/tikiwikisyntaxcolors.css =================================================================== --- third_party/codemirror/css/tikiwikisyntaxcolors.css 2010-12-23 18:20:56 UTC (rev 31634) +++ third_party/codemirror/css/tikiwikisyntaxcolors.css 2010-12-23 22:52:41 UTC (rev 31635) @@ -73,6 +73,24 @@ color: green; } +span.tw-center { + color: purple; +} + span.tw-plugin-container { color: blue; } + +span.tw-plugin-attributes { + color: #333366; +} + +span.tw-plugin-attribute-value { + color: #FF0033; +} + +span.tw-box { + border-style: solid; + border-width: 1px; + border-color: black; +} Modified: third_party/codemirror/js/parsetikisyntax.js =================================================================== --- third_party/codemirror/js/parsetikisyntax.js 2010-12-23 18:20:56 UTC (rev 31634) +++ third_party/codemirror/js/parsetikisyntax.js 2010-12-23 22:52:41 UTC (rev 31635) @@ -1,8 +1,6 @@ var TWParser = Editor.Parser = (function() { var tokenizeTW = (function() { function normal(source, setState, otherClass) { - otherClass = (otherClass ? otherClass : ""); - var ch = source.next(); switch (ch) { case "<": //comment @@ -77,12 +75,27 @@ setState(inListItem); return null; break; + case ":": + if (source.lookAhead(":", true)) { + setState(inCenter); + return null; + } + else { + // Normal wikitext + source.nextWhileMatches(/[^\n\[{<']/); + return "tw-text"; + } case "{": //plugin setState(inPluginContainer); return null; break; + case "^": //box + setState(inBox); + return null; + break; default: // Normal wikitext + source.inPlugin = null; source.nextWhileMatches(/[^\n\[{<']/); return "tw-text"; break; @@ -196,17 +209,85 @@ return "tw-listitem"; } - function inPluginContainer(source, setState) { + function inCenter(source, setState) { while (!source.endOfLine()) { var ch = source.next(); - if (ch == "}" || source.endOfLine()) { + if (ch == ":" && source.lookAhead(":", true)) { setState(normal); break; } } + return "tw-center"; + } + + function inPluginContainer(source, setState) { + var killStatus = false; + while (!source.endOfLine() && !killStatus) { + var ch = source.next(); + if (ch == "}") { + setState(normal); + break; + } else if (source.lookAhead("(", true)) { + if (!source.lookAhead(")")) { + killStatus = true; + setState(inPluginAttributes); + } + } + } return "tw-plugin-container"; } + function inPluginAttributes(source, setState) { + var killStatus = false; + while (!source.endOfLine() && !killStatus) { + var ch = source.next(); + if (source.lookAhead(")")) { + setState(inPluginContainer); + break; + } else if (source.lookAhead("=")) { + killStatus = true; + setState(inPluginAttributeEquals); + } + } + return "tw-plugin-attributes"; + } + + function inPluginAttributeEquals(source, setState) { + if (!source.endOfLine()) { + var ch = source.next(); + setState(inPluginAttributeValue); + } + return "tw-plugin-attribute-equals"; + } + + function inPluginAttributeValue(source, setState) { + var killStatus = false; + while (!source.endOfLine() && !killStatus) { + var ch = source.next(); + if (source.lookAhead(",")) { + killStatus = true; + setState(inPluginAttributes); + break; + } else if (source.lookAhead(")")) { + killStatus = true; + setState(inPluginContainer); + break; + } + } + return "tw-plugin-attribute-value"; + } + + function inBox(source, setState) { + while (!source.endOfLine()) { + var ch = source.next(); + if (ch == "^") { + setState(normal); + break; + } + } + return "tw-box"; + } + return function(source, startState) { return tokenizer(source, startState || normal); }; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |