572 changes: 337 additions & 235 deletions mode/css/css.js

Large diffs are not rendered by default.

145 changes: 145 additions & 0 deletions mode/css/scss.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: SCSS mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: SCSS mode</h1>
<form><textarea id="code" name="code">
/* Some example SCSS */

@import "compass/css3";
$variable: #333;

$blue: #3bbfce;
$margin: 16px;

.content-navigation {
#nested {
background-color: black;
}
border-color: $blue;
color:
darken($blue, 9%);
}

.border {
padding: $margin / 2;
margin: $margin / 2;
border-color: $blue;
}

@mixin table-base {
th {
text-align: center;
font-weight: bold;
}
td, th {padding: 2px}
}

table.hl {
margin: 2em 0;
td.ln {
text-align: right;
}
}

li {
font: {
family: serif;
weight: bold;
size: 1.2em;
}
}

@mixin left($dist) {
float: left;
margin-left: $dist;
}

#data {
@include left(10px);
@include table-base;
}

.source {
@include flow-into(target);
border: 10px solid green;
margin: 20px;
width: 200px; }

.new-container {
@include flow-from(target);
border: 10px solid red;
margin: 20px;
width: 200px; }

body {
margin: 0;
padding: 3em 6em;
font-family: tahoma, arial, sans-serif;
color: #000;
}

@mixin yellow() {
background: yellow;
}

.big {
font-size: 14px;
}

.nested {
@include border-radius(3px);
@extend .big;
p {
background: whitesmoke;
a {
color: red;
}
}
}

#navigation a {
font-weight: bold;
text-decoration: none !important;
}

h1 {
font-size: 2.5em;
}

h2 {
font-size: 1.7em;
}

h1:before, h2:before {
content: "::";
}

code {
font-family: courier, monospace;
font-size: 80%;
color: #418A8A;
}
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-scss"
});
</script>

<p><strong>MIME types defined:</strong> <code>text/scss</code>.</p>

<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#scss_*">normal</a>, <a href="../../test/index.html#verbose,scss_*">verbose</a>.</p>

</body>
</html>
80 changes: 80 additions & 0 deletions mode/css/scss_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "text/x-scss");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1), "scss"); }

MT('url_with_quotation',
"[tag foo] { [property background][operator :][string-2 url]([string test.jpg]) }");

MT('url_with_double_quotes',
"[tag foo] { [property background][operator :][string-2 url]([string \"test.jpg\"]) }");

MT('url_with_single_quotes',
"[tag foo] { [property background][operator :][string-2 url]([string \'test.jpg\']) }");

MT('string',
"[def @import] [string \"compass/css3\"]");

MT('important_keyword',
"[tag foo] { [property background][operator :][string-2 url]([string \'test.jpg\']) [keyword !important] }");

MT('variable',
"[variable-2 $blue][operator :][atom #333]");

MT('variable_as_attribute',
"[tag foo] { [property color][operator :][variable-2 $blue] }");

MT('numbers',
"[tag foo] { [property padding][operator :][number 10px] [number 10] [number 10em] [number 8in] }");

MT('number_percentage',
"[tag foo] { [property width][operator :][number 80%] }");

MT('selector',
"[builtin #hello][qualifier .world]{}");

MT('singleline_comment',
"[comment // this is a comment]");

MT('multiline_comment',
"[comment /*foobar*/]");

MT('attribute_with_hyphen',
"[tag foo] { [property font-size][operator :][number 10px] }");

MT('string_after_attribute',
"[tag foo] { [property content][operator :][string \"::\"] }");

MT('directives',
"[def @include] [qualifier .mixin]");

MT('basic_structure',
"[tag p] { [property background][operator :][keyword red]; }");

MT('nested_structure',
"[tag p] { [tag a] { [property color][operator :][keyword red]; } }");

MT('mixin',
"[def @mixin] [tag table-base] {}");

MT('number_without_semicolon',
"[tag p] {[property width][operator :][number 12]}",
"[tag a] {[property color][operator :][keyword red];}");

MT('atom_in_nested_block',
"[tag p] { [tag a] { [property color][operator :][atom #000]; } }");

MT('interpolation_in_property',
"[tag foo] { [operator #{][variable-2 $hello][operator }:][atom #000]; }");

MT('interpolation_in_selector',
"[tag foo][operator #{][variable-2 $hello][operator }] { [property color][operator :][atom #000]; }");

MT('interpolation_error',
"[tag foo][operator #{][error foo][operator }] { [property color][operator :][atom #000]; }");

MT("divide_operator",
"[tag foo] { [property width][operator :][number 4] [operator /] [number 2] }");

MT('nested_structure_with_id_selector',
"[tag p] { [builtin #hello] { [property color][operator :][keyword red]; } }");
})();
11 changes: 9 additions & 2 deletions mode/css/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "css");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 2)); }
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }

// Requires at least one media query
MT("atMediaEmpty",
Expand Down Expand Up @@ -75,7 +75,11 @@
"[tag foo] { [property font-family][operator :] [string 'hello world']; }");

MT("tagColorKeyword",
"[tag foo] { [property color][operator :] [keyword black]; }");
"[tag foo] {" +
"[property color][operator :] [keyword black];" +
"[property color][operator :] [keyword navy];" +
"[property color][operator :] [keyword yellow];" +
"}");

MT("tagColorHex3",
"[tag foo] { [property background][operator :] [atom #fff]; }");
Expand Down Expand Up @@ -103,4 +107,7 @@

MT("tagTwoProperties",
"[tag foo] { [property margin][operator :] [number 0]; [property padding][operator :] [number 0]; }");

MT("commentSGML",
"[comment <!--comment-->]");
})();
1 change: 1 addition & 0 deletions mode/gfm/gfm.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ CodeMirror.defineMode("gfm", function(config) {
CodeMirror.defineMIME("gfmBase", {
name: "markdown",
underscoresBreakWords: false,
taskLists: true,
fencedCodeBlocks: true
});
return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
Expand Down
5 changes: 5 additions & 0 deletions mode/gfm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ <h1>CodeMirror: GFM mode</h1>
}
```

## Task Lists

- [ ] Incomplete task list item
- [x] **Completed** task list item

## A bit of GitHub spice

* SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
Expand Down
30 changes: 29 additions & 1 deletion mode/gfm/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"foo_bar_hello");

MT("emStrongUnderscore",
"[strong __][emstrong _foo__][em _] bar");
"[strong __][em&strong _foo__][em _] bar");

MT("fencedCodeBlocks",
"[comment ```]",
Expand All @@ -25,6 +25,34 @@
"[comment ```]",
"bar");

MT("taskListAsterisk",
"[variable-2 * []] foo]", // Invalid; must have space or x between []
"[variable-2 * [ ]]bar]", // Invalid; must have space after ]
"[variable-2 * [x]]hello]", // Invalid; must have space after ]
"[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested

MT("taskListPlus",
"[variable-2 + []] foo]", // Invalid; must have space or x between []
"[variable-2 + [ ]]bar]", // Invalid; must have space after ]
"[variable-2 + [x]]hello]", // Invalid; must have space after ]
"[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested

MT("taskListDash",
"[variable-2 - []] foo]", // Invalid; must have space or x between []
"[variable-2 - [ ]]bar]", // Invalid; must have space after ]
"[variable-2 - [x]]hello]", // Invalid; must have space after ]
"[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested

MT("taskListNumber",
"[variable-2 1. []] foo]", // Invalid; must have space or x between []
"[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
"[variable-2 3. [x]]hello]", // Invalid; must have space after ]
"[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
" [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested

MT("SHA",
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");

Expand Down
2 changes: 1 addition & 1 deletion mode/javascript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h1>CodeMirror: JavaScript mode</h1>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
matchBrackets: true,
extraKeys: {"Enter": "newlineAndIndentContinueComment"}
continueComments: "Enter"
});
</script>

Expand Down
23 changes: 17 additions & 6 deletions mode/javascript/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
"function": kw("function"), "catch": kw("catch"),
"for": kw("for"), "switch": kw("switch"), "case": kw("case"), "default": kw("default"),
"in": operator, "typeof": operator, "instanceof": operator,
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom
"true": atom, "false": atom, "null": atom, "undefined": atom, "NaN": atom, "Infinity": atom,
"this": kw("this")
};

// Extend the 'normal' keywords with the TypeScript language extensions
Expand Down Expand Up @@ -52,7 +53,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
return jsKeywords;
}();

var isOperatorChar = /[+\-*&%=<>!?|]/;
var isOperatorChar = /[+\-*&%=<>!?|~^]/;

function chain(stream, state, f) {
state.tokenize = f;
Expand Down Expand Up @@ -148,7 +149,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {

// Parser

var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true};
var atomicTypes = {"atom": true, "number": true, "variable": true, "string": true, "regexp": true, "this": true};

function JSLexical(indented, column, type, align, prev, info) {
this.indented = indented;
Expand Down Expand Up @@ -300,11 +301,21 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
function property(type) {
if (type == "variable") {cx.marked = "property"; return cont();}
}
function objprop(type) {
if (type == "variable") cx.marked = "property";
else if (type == "number" || type == "string") cx.marked = type + " property";
function objprop(type, value) {
if (type == "variable") {
cx.marked = "property";
if (value == "get" || value == "set") return cont(getterSetter);
} else if (type == "number" || type == "string") {
cx.marked = type + " property";
}
if (atomicTypes.hasOwnProperty(type)) return cont(expect(":"), expression);
}
function getterSetter(type) {
if (type == ":") return cont(expression);
if (type != "variable") return cont(expect(":"), expression);
cx.marked = "property";
return cont(functiondef);
}
function commasep(what, end) {
function proceed(type) {
if (type == ",") return cont(what, proceed);
Expand Down
23 changes: 23 additions & 0 deletions mode/livescript/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
The MIT License

Copyright (c) 2013 Kenneth Bentley
Modified from the CoffeeScript CodeMirror mode, Copyright (c) 2011 Jeff Pickhardt
Modified from the Python CodeMirror mode, Copyright (c) 2010 Timothy Farrell

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
446 changes: 446 additions & 0 deletions mode/livescript/index.html

Large diffs are not rendered by default.

267 changes: 267 additions & 0 deletions mode/livescript/livescript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
/**
* Link to the project's GitHub page:
* https://github.com/duralog/CodeMirror
*/
(function() {
CodeMirror.defineMode('livescript', function(){
var tokenBase, external;
tokenBase = function(stream, state){
var next_rule, nr, i$, len$, r, m;
if (next_rule = state.next || 'start') {
state.next = state.next;
if (Array.isArray(nr = Rules[next_rule])) {
for (i$ = 0, len$ = nr.length; i$ < len$; ++i$) {
r = nr[i$];
if (r.regex && (m = stream.match(r.regex))) {
state.next = r.next;
return r.token;
}
}
stream.next();
return 'error';
}
if (stream.match(r = Rules[next_rule])) {
if (r.regex && stream.match(r.regex)) {
state.next = r.next;
return r.token;
} else {
stream.next();
return 'error';
}
}
}
stream.next();
return 'error';
};
external = {
startState: function(){
return {
next: 'start',
lastToken: null
};
},
token: function(stream, state){
var style;
style = tokenBase(stream, state);
state.lastToken = {
style: style,
indent: stream.indentation(),
content: stream.current()
};
return style.replace(/\./g, ' ');
},
indent: function(state){
var indentation;
indentation = state.lastToken.indent;
if (state.lastToken.content.match(indenter)) {
indentation += 2;
}
return indentation;
}
};
return external;
});

var identifier = '(?![\\d\\s])[$\\w\\xAA-\\uFFDC](?:(?!\\s)[$\\w\\xAA-\\uFFDC]|-[A-Za-z])*';
var indenter = RegExp('(?:[({[=:]|[-~]>|\\b(?:e(?:lse|xport)|d(?:o|efault)|t(?:ry|hen)|finally|import(?:\\s*all)?|const|var|let|new|catch(?:\\s*' + identifier + ')?))\\s*$');
var keywordend = '(?![$\\w]|-[A-Za-z]|\\s*:(?![:=]))';
var stringfill = {
token: 'string',
regex: '.+'
};
var Rules = {
start: [
{
token: 'comment.doc',
regex: '/\\*',
next: 'comment'
}, {
token: 'comment',
regex: '#.*'
}, {
token: 'keyword',
regex: '(?:t(?:h(?:is|row|en)|ry|ypeof!?)|c(?:on(?:tinue|st)|a(?:se|tch)|lass)|i(?:n(?:stanceof)?|mp(?:ort(?:\\s+all)?|lements)|[fs])|d(?:e(?:fault|lete|bugger)|o)|f(?:or(?:\\s+own)?|inally|unction)|s(?:uper|witch)|e(?:lse|x(?:tends|port)|val)|a(?:nd|rguments)|n(?:ew|ot)|un(?:less|til)|w(?:hile|ith)|o[fr]|return|break|let|var|loop)' + keywordend
}, {
token: 'constant.language',
regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend
}, {
token: 'invalid.illegal',
regex: '(?:p(?:ackage|r(?:ivate|otected)|ublic)|i(?:mplements|nterface)|enum|static|yield)' + keywordend
}, {
token: 'language.support.class',
regex: '(?:R(?:e(?:gExp|ferenceError)|angeError)|S(?:tring|yntaxError)|E(?:rror|valError)|Array|Boolean|Date|Function|Number|Object|TypeError|URIError)' + keywordend
}, {
token: 'language.support.function',
regex: '(?:is(?:NaN|Finite)|parse(?:Int|Float)|Math|JSON|(?:en|de)codeURI(?:Component)?)' + keywordend
}, {
token: 'variable.language',
regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend
}, {
token: 'identifier',
regex: identifier + '\\s*:(?![:=])'
}, {
token: 'variable',
regex: identifier
}, {
token: 'keyword.operator',
regex: '(?:\\.{3}|\\s+\\?)'
}, {
token: 'keyword.variable',
regex: '(?:@+|::|\\.\\.)',
next: 'key'
}, {
token: 'keyword.operator',
regex: '\\.\\s*',
next: 'key'
}, {
token: 'string',
regex: '\\\\\\S[^\\s,;)}\\]]*'
}, {
token: 'string.doc',
regex: '\'\'\'',
next: 'qdoc'
}, {
token: 'string.doc',
regex: '"""',
next: 'qqdoc'
}, {
token: 'string',
regex: '\'',
next: 'qstring'
}, {
token: 'string',
regex: '"',
next: 'qqstring'
}, {
token: 'string',
regex: '`',
next: 'js'
}, {
token: 'string',
regex: '<\\[',
next: 'words'
}, {
token: 'string.regex',
regex: '//',
next: 'heregex'
}, {
token: 'string.regex',
regex: '\\/(?:[^[\\/\\n\\\\]*(?:(?:\\\\.|\\[[^\\]\\n\\\\]*(?:\\\\.[^\\]\\n\\\\]*)*\\])[^[\\/\\n\\\\]*)*)\\/[gimy$]{0,4}',
next: 'key'
}, {
token: 'constant.numeric',
regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'
}, {
token: 'lparen',
regex: '[({[]'
}, {
token: 'rparen',
regex: '[)}\\]]',
next: 'key'
}, {
token: 'keyword.operator',
regex: '\\S+'
}, {
token: 'text',
regex: '\\s+'
}
],
heregex: [
{
token: 'string.regex',
regex: '.*?//[gimy$?]{0,4}',
next: 'start'
}, {
token: 'string.regex',
regex: '\\s*#{'
}, {
token: 'comment.regex',
regex: '\\s+(?:#.*)?'
}, {
token: 'string.regex',
regex: '\\S+'
}
],
key: [
{
token: 'keyword.operator',
regex: '[.?@!]+'
}, {
token: 'identifier',
regex: identifier,
next: 'start'
}, {
token: 'text',
regex: '.',
next: 'start'
}
],
comment: [
{
token: 'comment.doc',
regex: '.*?\\*/',
next: 'start'
}, {
token: 'comment.doc',
regex: '.+'
}
],
qdoc: [
{
token: 'string',
regex: ".*?'''",
next: 'key'
}, stringfill
],
qqdoc: [
{
token: 'string',
regex: '.*?"""',
next: 'key'
}, stringfill
],
qstring: [
{
token: 'string',
regex: '[^\\\\\']*(?:\\\\.[^\\\\\']*)*\'',
next: 'key'
}, stringfill
],
qqstring: [
{
token: 'string',
regex: '[^\\\\"]*(?:\\\\.[^\\\\"]*)*"',
next: 'key'
}, stringfill
],
js: [
{
token: 'string',
regex: '[^\\\\`]*(?:\\\\.[^\\\\`]*)*`',
next: 'key'
}, stringfill
],
words: [
{
token: 'string',
regex: '.*?\\]>',
next: 'key'
}, stringfill
]
};
for (var idx in Rules) {
var r = Rules[idx];
if (Array.isArray(r)) {
for (var i = 0, len = r.length; i < len; ++i) {
var rr = r[i];
if (rr.regex) {
Rules[idx][i].regex = new RegExp('^' + rr.regex);
}
}
} else if (r.regex) {
Rules[idx].regex = new RegExp('^' + r.regex);
}
}
})();

CodeMirror.defineMIME('text/x-livescript', 'livescript');
266 changes: 266 additions & 0 deletions mode/livescript/livescript.ls
Original file line number Diff line number Diff line change
@@ -0,0 +1,266 @@
/**
* Link to the project's GitHub page:
* https://github.com/duralog/CodeMirror
*/
CodeMirror.defineMode 'livescript', (conf) ->
tokenBase = (stream, state) ->
#indent =
if next_rule = state.next or \start
state.next = state.next
if Array.isArray nr = Rules[next_rule]
for r in nr
if r.regex and m = stream.match r.regex
state.next = r.next
return r.token
stream.next!
return \error
if stream.match r = Rules[next_rule]
if r.regex and stream.match r.regex
state.next = r.next
return r.token
else
stream.next!
return \error
stream.next!
return 'error'
external = {
startState: (basecolumn) ->
{
next: \start
lastToken: null
}
token: (stream, state) ->
style = tokenBase stream, state #tokenLexer stream, state
state.lastToken = {
style: style
indent: stream.indentation!
content: stream.current!
}
style.replace /\./g, ' '
indent: (state, textAfter) ->
# XXX this won't work with backcalls
indentation = state.lastToken.indent
if state.lastToken.content.match indenter then indentation += 2
return indentation
}
external

### Highlight Rules
# taken from mode-ls.ls

indenter = // (?
: [({[=:]
| [-~]>
| \b (?: e(?:lse|xport) | d(?:o|efault) | t(?:ry|hen) | finally |
import (?:\s* all)? | const | var |
let | new | catch (?:\s* #identifier)? )
) \s* $ //

identifier = /(?![\d\s])[$\w\xAA-\uFFDC](?:(?!\s)[$\w\xAA-\uFFDC]|-[A-Za-z])*/$
keywordend = /(?![$\w]|-[A-Za-z]|\s*:(?![:=]))/$
stringfill = token: \string, regex: '.+'

Rules =
start:
* token: \comment.doc
regex: '/\\*'
next : \comment

* token: \comment
regex: '#.*'

* token: \keyword
regex: //(?
:t(?:h(?:is|row|en)|ry|ypeof!?)
|c(?:on(?:tinue|st)|a(?:se|tch)|lass)
|i(?:n(?:stanceof)?|mp(?:ort(?:\s+all)?|lements)|[fs])
|d(?:e(?:fault|lete|bugger)|o)
|f(?:or(?:\s+own)?|inally|unction)
|s(?:uper|witch)
|e(?:lse|x(?:tends|port)|val)
|a(?:nd|rguments)
|n(?:ew|ot)
|un(?:less|til)
|w(?:hile|ith)
|o[fr]|return|break|let|var|loop
)//$ + keywordend

* token: \constant.language
regex: '(?:true|false|yes|no|on|off|null|void|undefined)' + keywordend

* token: \invalid.illegal
regex: '(?
:p(?:ackage|r(?:ivate|otected)|ublic)
|i(?:mplements|nterface)
|enum|static|yield
)' + keywordend

* token: \language.support.class
regex: '(?
:R(?:e(?:gExp|ferenceError)|angeError)
|S(?:tring|yntaxError)
|E(?:rror|valError)
|Array|Boolean|Date|Function|Number|Object|TypeError|URIError
)' + keywordend

* token: \language.support.function
regex: '(?
:is(?:NaN|Finite)
|parse(?:Int|Float)
|Math|JSON
|(?:en|de)codeURI(?:Component)?
)' + keywordend

* token: \variable.language
regex: '(?:t(?:hat|il|o)|f(?:rom|allthrough)|it|by|e)' + keywordend

* token: \identifier
regex: identifier + /\s*:(?![:=])/$

* token: \variable
regex: identifier

* token: \keyword.operator
regex: /(?:\.{3}|\s+\?)/$

* token: \keyword.variable
regex: /(?:@+|::|\.\.)/$
next : \key

* token: \keyword.operator
regex: /\.\s*/$
next : \key

* token: \string
regex: /\\\S[^\s,;)}\]]*/$

* token: \string.doc
regex: \'''
next : \qdoc

* token: \string.doc
regex: \"""
next : \qqdoc

* token: \string
regex: \'
next : \qstring

* token: \string
regex: \"
next : \qqstring

* token: \string
regex: \`
next : \js

* token: \string
regex: '<\\['
next : \words

* token: \string.regex
regex: \//
next : \heregex

* token: \string.regex
regex: //
/(?: [^ [ / \n \\ ]*
(?: (?: \\.
| \[ [^\]\n\\]* (?:\\.[^\]\n\\]*)* \]
) [^ [ / \n \\ ]*
)*
)/ [gimy$]{0,4}
//$
next : \key

* token: \constant.numeric
regex: '(?:0x[\\da-fA-F][\\da-fA-F_]*
|(?:[2-9]|[12]\\d|3[0-6])r[\\da-zA-Z][\\da-zA-Z_]*
|(?:\\d[\\d_]*(?:\\.\\d[\\d_]*)?|\\.\\d[\\d_]*)
(?:e[+-]?\\d[\\d_]*)?[\\w$]*)'

* token: \lparen
regex: '[({[]'

* token: \rparen
regex: '[)}\\]]'
next : \key

* token: \keyword.operator
regex: \\\S+

* token: \text
regex: \\\s+

heregex:
* token: \string.regex
regex: '.*?//[gimy$?]{0,4}'
next : \start
* token: \string.regex
regex: '\\s*#{'
* token: \comment.regex
regex: '\\s+(?:#.*)?'
* token: \string.regex
regex: '\\S+'

key:
* token: \keyword.operator
regex: '[.?@!]+'
* token: \identifier
regex: identifier
next : \start
* token: \text
regex: '.'
next : \start

comment:
* token: \comment.doc
regex: '.*?\\*/'
next : \start
* token: \comment.doc
regex: '.+'

qdoc:
token: \string
regex: ".*?'''"
next : \key
stringfill

qqdoc:
token: \string
regex: '.*?"""'
next : \key
stringfill

qstring:
token: \string
regex: /[^\\']*(?:\\.[^\\']*)*'/$
next : \key
stringfill

qqstring:
token: \string
regex: /[^\\"]*(?:\\.[^\\"]*)*"/$
next : \key
stringfill

js:
token: \string
regex: /[^\\`]*(?:\\.[^\\`]*)*`/$
next : \key
stringfill

words:
token: \string
regex: '.*?\\]>'
next : \key
stringfill

# for optimization, precompile the regexps
for idx, r of Rules
if Array.isArray r
for rr, i in r
if rr.regex then Rules[idx][i].regex = new RegExp '^'+rr.regex
else if r.regex then Rules[idx].regex = new RegExp '^'+r.regex

CodeMirror.defineMIME 'text/x-livescript', 'livescript'
101 changes: 76 additions & 25 deletions mode/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,31 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
// Turn on fenced code blocks? ("```" to start/end)
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;

// Turn on task lists? ("- [ ] " and "- [x] ")
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;

var codeDepth = 0;
var prevLineHasContent = false
, thisLineHasContent = false;

var header = 'header'
, code = 'comment'
, quote = 'quote'
, list = 'string'
, quote1 = 'atom'
, quote2 = 'number'
, list1 = 'variable-2'
, list2 = 'variable-3'
, list3 = 'keyword'
, hr = 'hr'
, image = 'tag'
, linkinline = 'link'
, linkemail = 'link'
, linktext = 'link'
, linkhref = 'string'
, em = 'em'
, strong = 'strong'
, emstrong = 'emstrong';
, strong = 'strong';

var hrRE = /^([*\-=_])(?:\s*\1){2,}\s*$/
, ulRE = /^[*\-+]\s+/
, olRE = /^[0-9]+\.\s+/
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
, headerRE = /^(?:\={1,}|-{1,})$/
, textRE = /^[^!\[\]*_\\<>` "'(]+/;

Expand All @@ -94,23 +98,30 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
// Reset STRONG state
state.strong = false;
// Reset state.quote
state.quote = false;
state.quote = 0;
if (!htmlFound && state.f == htmlBlock) {
state.f = inlineNormal;
state.block = blockNormal;
}
// Mark this line as blank
state.thisLineHasContent = false;
return null;
}

function blockNormal(stream, state) {

var prevLineIsList = (state.list !== false);
if (state.list !== false && state.indentationDiff >= 0) { // Continued list
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
state.indentation -= state.indentationDiff;
}
state.list = null;
} else { // No longer a list
} else if (state.list !== false && state.indentation > 0) {
state.list = null;
state.listDepth = Math.floor(state.indentation / 4);
} else if (state.list !== false) { // No longer a list
state.list = false;
state.listDepth = 0;
}

if (state.indentationDiff >= 4) {
Expand All @@ -119,18 +130,27 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
return code;
} else if (stream.eatSpace()) {
return null;
} else if (stream.peek() === '#' || (prevLineHasContent && stream.match(headerRE)) ) {
} else if (stream.peek() === '#' || (state.prevLineHasContent && stream.match(headerRE)) ) {
state.header = true;
} else if (stream.eat('>')) {
state.indentation++;
state.quote = true;
state.quote = 1;
stream.eatSpace();
while (stream.eat('>')) {
stream.eatSpace();
state.quote++;
}
} else if (stream.peek() === '[') {
return switchInline(stream, state, footnoteLink);
} else if (stream.match(hrRE, true)) {
return hr;
} else if (stream.match(ulRE, true) || stream.match(olRE, true)) {
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, true) || stream.match(olRE, true))) {
state.indentation += 4;
state.list = true;
state.listDepth++;
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
state.taskList = true;
}
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```([\w+#]*)/, true)) {
// try switching mode
state.localMode = getMode(RegExp.$1);
Expand Down Expand Up @@ -174,16 +194,28 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
function getType(state) {
var styles = [];

if (state.strong) { styles.push(state.em ? emstrong : strong); }
else if (state.em) { styles.push(em); }
if (state.taskOpen) { return "meta"; }
if (state.taskClosed) { return "property"; }

if (state.strong) { styles.push(strong); }
if (state.em) { styles.push(em); }

if (state.linkText) { styles.push(linktext); }

if (state.code) { styles.push(code); }

if (state.header) { styles.push(header); }
if (state.quote) { styles.push(quote); }
if (state.list !== false) { styles.push(list); }
if (state.quote) { styles.push(state.quote % 2 ? quote1 : quote2); }
if (state.list !== false) {
var listMod = (state.listDepth - 1) % 3;
if (!listMod) {
styles.push(list1);
} else if (listMod === 1) {
styles.push(list2);
} else {
styles.push(list3);
}
}

return styles.length ? styles.join(' ') : null;
}
Expand All @@ -202,9 +234,20 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {

if (state.list) { // List marker (*, +, -, 1., etc)
state.list = null;
return list;
return getType(state);
}

if (state.taskList) {
var taskOpen = stream.match(taskListRE, true)[1] !== "x";
if (taskOpen) state.taskOpen = true;
else state.taskClosed = true;
state.taskList = false;
return getType(state);
}

state.taskOpen = false;
state.taskClosed = false;

var ch = stream.next();

if (ch === '\\') {
Expand Down Expand Up @@ -389,11 +432,12 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {

return {
startState: function() {
prevLineHasContent = false;
thisLineHasContent = false;
return {
f: blockNormal,

prevLineHasContent: false,
thisLineHasContent: false,

block: blockNormal,
htmlState: CodeMirror.startState(htmlMode),
indentation: 0,
Expand All @@ -406,15 +450,20 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
em: false,
strong: false,
header: false,
taskList: false,
list: false,
quote: false
listDepth: 0,
quote: 0
};
},

copyState: function(s) {
return {
f: s.f,

prevLineHasContent: s.prevLineHasContent,
thisLineHasContent: s.thisLineHasContent,

block: s.block,
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
indentation: s.indentation,
Expand All @@ -428,7 +477,9 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
em: s.em,
strong: s.strong,
header: s.header,
taskList: s.taskList,
list: s.list,
listDepth: s.listDepth,
quote: s.quote,
md_inside: s.md_inside
};
Expand All @@ -437,19 +488,19 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
token: function(stream, state) {
if (stream.sol()) {
if (stream.match(/^\s*$/, true)) {
prevLineHasContent = false;
state.prevLineHasContent = false;
return blankLine(state);
} else {
if(thisLineHasContent){
prevLineHasContent = true;
thisLineHasContent = false;
}
thisLineHasContent = true;
state.prevLineHasContent = state.thisLineHasContent;
state.thisLineHasContent = true;
}

// Reset state.header
state.header = false;

// Reset state.taskList
state.taskList = false;

// Reset state.code
state.code = false;

Expand Down
231 changes: 144 additions & 87 deletions mode/markdown/test.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions mode/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ CodeMirror.modeInfo = [
{name: 'TypeScript', mime: 'application/typescript', mode: 'javascript'},
{name: 'Jinja2', mime: 'jinja2', mode: 'jinja2'},
{name: 'LESS', mime: 'text/x-less', mode: 'less'},
{name: 'LiveScript', mime: 'text/x-livescript', mode: 'livescript'},
{name: 'Lua', mime: 'text/x-lua', mode: 'lua'},
{name: 'Markdown (GitHub-flavour)', mime: 'text/x-markdown', mode: 'markdown'},
{name: 'mIRC', mime: 'text/mirc', mode: 'mirc'},
{name: 'NTriples', mime: 'text/n-triples', mode: 'ntriples'},
{name: 'OCaml', mime: 'text/x-ocaml', mode: 'ocaml'},
{name: 'Pascal', mime: 'text/x-pascal', mode: 'pascal'},
Expand All @@ -47,17 +49,17 @@ CodeMirror.modeInfo = [
{name: 'Rust', mime: 'text/x-rustsrc', mode: 'rust'},
{name: 'Sass', mime: 'text/x-sass', mode: 'sass'},
{name: 'Scheme', mime: 'text/x-scheme', mode: 'scheme'},
{name: 'SCSS', mime: 'text/x-scss', mode: 'css'},
{name: 'Shell', mime: 'text/x-sh', mode: 'shell'},
{name: 'Sieve', mime: 'application/sieve', mode: 'sieve'},
{name: 'Smalltalk', mime: 'text/x-stsrc', mode: 'smalltalk'},
{name: 'Smarty', mime: 'text/x-smarty', mode: 'smarty'},
{name: 'SPARQL', mime: 'application/x-sparql-query', mode: 'sparql'},
{name: 'SQL', mime: 'text/x-sql', mode: 'sql'},
{name: 'MySQL', mime: 'text/x-mysql', mode: 'sql'},
{name: 'MariaDB', mime: 'text/x-mariadb', mode: 'sql'},
{name: 'PL/SQL', mime: 'text/x-plsql', mode: 'sql'},
{name: 'sTeX', mime: 'text/x-stex', mode: 'stex'},
{name: 'LaTeX', mime: 'text/x-latex', mode: 'stex'},
{name: 'Tcl', mime: 'text/x-tcl', mode: 'tcl'},
{name: 'TiddlyWiki ', mime: 'text/x-tiddlywiki', mode: 'tiddlywiki'},
{name: 'Tiki wiki', mime: 'text/tiki', mode: 'tiki'},
{name: 'VB.NET', mime: 'text/x-vb', mode: 'vb'},
Expand Down
149 changes: 149 additions & 0 deletions mode/mirc/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: mIRC mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="mirc.js"></script>
<link rel="stylesheet" href="../../theme/twilight.css">
<style>.CodeMirror {border: 1px solid black;}</style>
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: mIRC mode</h1>
<form><textarea id="code" name="code">
;AKA Nick Tracker by Ford_Lawnmower irc.GeekShed.net #Script-Help
;*****************************************************************************;
;**Start Setup
;Change JoinDisplay, below, for On Join AKA Display. On = 1 - Off = 0
alias -l JoinDisplay { return 1 }
;Change MaxNicks, below, to the number of nicknames you want to store for each hostmask. I wouldn't go over 400 with this ;/
alias -l MaxNicks { return 20 }
;Change AKALogo, below, To the text you want displayed before each AKA result.
alias -l AKALogo { return 06 05A06K07A 06 }
;**End Setup
;*****************************************************************************;
On *:Join:#: {
if ($nick == $me) { .timer 1 1 ialupdateCheck $chan }
NickNamesAdd $nick $+($network,$wildsite)
if ($JoinDisplay) { .timerNickNames $+ $nick 1 2 NickNames.display $nick $chan $network $wildsite }
}
on *:Nick: { NickNamesAdd $newnick $+($network,$wildsite) $nick }
alias -l NickNames.display {
if ($gettok($hget(NickNames,$+($3,$4)),0,126) > 1) {
echo -g $2 $AKALogo $+(09,$1) $AKALogo 07 $mid($replace($hget(NickNames,$+($3,$4)),$chr(126),$chr(44)),2,-1)
}
}
alias -l NickNamesAdd {
if ($hget(NickNames,$2)) {
if (!$regex($hget(NickNames,$2),/~\Q $+ $replacecs($1,\E,\E\\E\Q) $+ \E~/i)) {
if ($gettok($hget(NickNames,$2),0,126) <= $MaxNicks) {
hadd NickNames $2 $+($hget(NickNames,$2),$1,~)
}
else {
hadd NickNames $2 $+($mid($hget(NickNames,$2),$pos($hget(NickNames,$2),~,2)),$1,~)
}
}
}
else {
hadd -m NickNames $2 $+(~,$1,~,$iif($3,$+($3,~)))
}
}
alias -l Fix.All.MindUser {
var %Fix.Count = $hfind(NickNames,/[^~]+[0-9]{4}~/,0,r).data
while (%Fix.Count) {
if ($Fix.MindUser($hget(NickNames,$hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data))) {
echo -ag Record %Fix.Count - $v1 - Was Cleaned
hadd NickNames $hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data $v1
}
dec %Fix.Count
}
}
alias -l Fix.MindUser { return $regsubex($1,/[^~]+[0-9]{4}~/g,$null) }
menu nicklist,query {
-
.AKA
..Check $$1: {
if ($gettok($hget(NickNames,$+($network,$address($1,2))),0,126) > 1) {
NickNames.display $1 $active $network $address($1,2)
}
else { echo -ag $AKALogo $+(09,$1) 07has not been known by any other nicknames while I have been watching. }
}
..Cleanup $$1:hadd NickNames $+($network,$address($1,2)) $fix.minduser($hget(NickNames,$+($network,$address($1,2))))
..Clear $$1:hadd NickNames $+($network,$address($1,2)) $+(~,$1,~)
..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
-
}
menu status,channel {
-
.AKA
..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
..Clean All Records:Fix.All.Minduser
-
}
dialog AKA_Search {
title "AKA Search Engine"
size -1 -1 206 221
option dbu
edit "", 1, 8 5 149 10, autohs
button "Search", 2, 163 4 32 12
radio "Search HostMask", 4, 61 22 55 10
radio "Search Nicknames", 5, 123 22 56 10
list 6, 8 38 190 169, sort extsel vsbar
button "Check Selected", 7, 67 206 40 12
button "Close", 8, 160 206 38 12, cancel
box "Search Type", 3, 11 17 183 18
button "Copy to Clipboard", 9, 111 206 46 12
}
On *:Dialog:Aka_Search:init:*: { did -c $dname 5 }
On *:Dialog:Aka_Search:Sclick:2,7,9: {
if ($did == 2) && ($did($dname,1)) {
did -r $dname 6
var %search $+(*,$v1,*), %type $iif($did($dname,5).state,data,item), %matches = $hfind(NickNames,%search,0,w). [ $+ [ %type ] ]
while (%matches) {
did -a $dname 6 $hfind(NickNames,%search,%matches,w). [ $+ [ %type ] ]
dec %matches
}
did -c $dname 6 1
}
elseif ($did == 7) && ($did($dname,6).seltext) { echo -ga $AKALogo 07 $mid($replace($hget(NickNames,$v1),$chr(126),$chr(44)),2,-1) }
elseif ($did == 9) && ($did($dname,6).seltext) { clipboard $mid($v1,$pos($v1,*,1)) }
}
On *:Start:{
if (!$hget(NickNames)) { hmake NickNames 10 }
if ($isfile(NickNames.hsh)) { hload NickNames NickNames.hsh }
}
On *:Exit: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
On *:Disconnect: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
On *:Unload: { hfree NickNames }
alias -l ialupdateCheck {
inc -z $+(%,ialupdateCheck,$network) $calc($nick($1,0) / 4)
;If your ial is already being updated on join .who $1 out.
;If you are using /names to update ial you will still need this line.
.who $1
}
Raw 352:*: {
if ($($+(%,ialupdateCheck,$network),2)) haltdef
NickNamesAdd $6 $+($network,$address($6,2))
}
Raw 315:*: {
if ($($+(%,ialupdateCheck,$network),2)) haltdef
}

</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
tabMode: "indent",
theme: "twilight",
lineNumbers: true,
matchBrackets: true,
indentUnit: 4,
mode: "text/mirc"
});
</script>

<p><strong>MIME types defined:</strong> <code>text/mirc</code>.</p>

</body>
</html>
177 changes: 177 additions & 0 deletions mode/mirc/mirc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
//mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
CodeMirror.defineMIME("text/mirc", "mirc");
CodeMirror.defineMode("mirc", function() {
function parseWords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var specials = parseWords("$! $$ $& $? $+ $abook $abs $active $activecid " +
"$activewid $address $addtok $agent $agentname $agentstat $agentver " +
"$alias $and $anick $ansi2mirc $aop $appactive $appstate $asc $asctime " +
"$asin $atan $avoice $away $awaymsg $awaytime $banmask $base $bfind " +
"$binoff $biton $bnick $bvar $bytes $calc $cb $cd $ceil $chan $chanmodes " +
"$chantypes $chat $chr $cid $clevel $click $cmdbox $cmdline $cnick $color " +
"$com $comcall $comchan $comerr $compact $compress $comval $cos $count " +
"$cr $crc $creq $crlf $ctime $ctimer $ctrlenter $date $day $daylight " +
"$dbuh $dbuw $dccignore $dccport $dde $ddename $debug $decode $decompress " +
"$deltok $devent $dialog $did $didreg $didtok $didwm $disk $dlevel $dll " +
"$dllcall $dname $dns $duration $ebeeps $editbox $emailaddr $encode $error " +
"$eval $event $exist $feof $ferr $fgetc $file $filename $filtered $finddir " +
"$finddirn $findfile $findfilen $findtok $fline $floor $fopen $fread $fserve " +
"$fulladdress $fulldate $fullname $fullscreen $get $getdir $getdot $gettok $gmt " +
"$group $halted $hash $height $hfind $hget $highlight $hnick $hotline " +
"$hotlinepos $ial $ialchan $ibl $idle $iel $ifmatch $ignore $iif $iil " +
"$inelipse $ini $inmidi $inpaste $inpoly $input $inrect $inroundrect " +
"$insong $instok $int $inwave $ip $isalias $isbit $isdde $isdir $isfile " +
"$isid $islower $istok $isupper $keychar $keyrpt $keyval $knick $lactive " +
"$lactivecid $lactivewid $left $len $level $lf $line $lines $link $lock " +
"$lock $locked $log $logstamp $logstampfmt $longfn $longip $lower $ltimer " +
"$maddress $mask $matchkey $matchtok $md5 $me $menu $menubar $menucontext " +
"$menutype $mid $middir $mircdir $mircexe $mircini $mklogfn $mnick $mode " +
"$modefirst $modelast $modespl $mouse $msfile $network $newnick $nick $nofile " +
"$nopath $noqt $not $notags $notify $null $numeric $numok $oline $onpoly " +
"$opnick $or $ord $os $passivedcc $pic $play $pnick $port $portable $portfree " +
"$pos $prefix $prop $protect $puttok $qt $query $rand $r $rawmsg $read $readomo " +
"$readn $regex $regml $regsub $regsubex $remove $remtok $replace $replacex " +
"$reptok $result $rgb $right $round $scid $scon $script $scriptdir $scriptline " +
"$sdir $send $server $serverip $sfile $sha1 $shortfn $show $signal $sin " +
"$site $sline $snick $snicks $snotify $sock $sockbr $sockerr $sockname " +
"$sorttok $sound $sqrt $ssl $sreq $sslready $status $strip $str $stripped " +
"$syle $submenu $switchbar $tan $target $ticks $time $timer $timestamp " +
"$timestampfmt $timezone $tip $titlebar $toolbar $treebar $trust $ulevel " +
"$ulist $upper $uptime $url $usermode $v1 $v2 $var $vcmd $vcmdstat $vcmdver " +
"$version $vnick $vol $wid $width $wildsite $wildtok $window $wrap $xor");
var keywords = parseWords("abook ajinvite alias aline ame amsg anick aop auser autojoin avoice " +
"away background ban bcopy beep bread break breplace bset btrunc bunset bwrite " +
"channel clear clearall cline clipboard close cnick color comclose comopen " +
"comreg continue copy creq ctcpreply ctcps dcc dccserver dde ddeserver " +
"debug dec describe dialog did didtok disable disconnect dlevel dline dll " +
"dns dqwindow drawcopy drawdot drawfill drawline drawpic drawrect drawreplace " +
"drawrot drawsave drawscroll drawtext ebeeps echo editbox emailaddr enable " +
"events exit fclose filter findtext finger firewall flash flist flood flush " +
"flushini font fopen fseek fsend fserve fullname fwrite ghide gload gmove " +
"gopts goto gplay gpoint gqreq groups gshow gsize gstop gtalk gunload hadd " +
"halt haltdef hdec hdel help hfree hinc hload hmake hop hsave ial ialclear " +
"ialmark identd if ignore iline inc invite iuser join kick linesep links list " +
"load loadbuf localinfo log mdi me menubar mkdir mnick mode msg nick noop notice " +
"notify omsg onotice part partall pdcc perform play playctrl pop protect pvoice " +
"qme qmsg query queryn quit raw reload remini remote remove rename renwin " +
"reseterror resetidle return rlevel rline rmdir run ruser save savebuf saveini " +
"say scid scon server set showmirc signam sline sockaccept sockclose socklist " +
"socklisten sockmark sockopen sockpause sockread sockrename sockudp sockwrite " +
"sound speak splay sreq strip switchbar timer timestamp titlebar tnick tokenize " +
"toolbar topic tray treebar ulist unload unset unsetall updatenl url uwho " +
"var vcadd vcmd vcrem vol while whois window winhelp write writeint if isalnum " +
"isalpha isaop isavoice isban ischan ishop isignore isin isincs isletter islower " +
"isnotify isnum ison isop isprotect isreg isupper isvoice iswm iswmcs " +
"elseif else goto menu nicklist status title icon size option text edit " +
"button check radio box scroll list combo link tab item");
var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");
var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
}
function tokenBase(stream, state) {
var beforeParams = state.beforeParams;
state.beforeParams = false;
var ch = stream.next();
if (/[\[\]{}\(\),\.]/.test(ch)) {
if (ch == "(" && beforeParams) state.inParams = true;
else if (ch == ")") state.inParams = false;
return null;
}
else if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
else if (ch == "\\") {
stream.eat("\\");
stream.eat(/./);
return "number";
}
else if (ch == "/" && stream.eat("*")) {
return chain(stream, state, tokenComment);
}
else if (ch == ";" && stream.match(/ *\( *\(/)) {
return chain(stream, state, tokenUnparsed);
}
else if (ch == ";" && !state.inParams) {
stream.skipToEnd();
return "comment";
}
else if (ch == '"') {
stream.eat(/"/);
return "keyword";
}
else if (ch == "$") {
stream.eatWhile(/[$_a-z0-9A-Z\.:]/);
if (specials && specials.propertyIsEnumerable(stream.current().toLowerCase())) {
return "keyword";
}
else {
state.beforeParams = true;
return "builtin";
}
}
else if (ch == "%") {
stream.eatWhile(/[^,^\s^\(^\)]/);
state.beforeParams = true;
return "string";
}
else if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "operator";
}
else {
stream.eatWhile(/[\w\$_{}]/);
var word = stream.current().toLowerCase();
if (keywords && keywords.propertyIsEnumerable(word))
return "keyword";
if (functions && functions.propertyIsEnumerable(word)) {
state.beforeParams = true;
return "keyword";
}
return null;
}
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function tokenUnparsed(stream, state) {
var maybeEnd = 0, ch;
while (ch = stream.next()) {
if (ch == ";" && maybeEnd == 2) {
state.tokenize = tokenBase;
break;
}
if (ch == ")")
maybeEnd++;
else if (ch != " ")
maybeEnd = 0;
}
return "meta";
}
return {
startState: function() {
return {
tokenize: tokenBase,
beforeParams: false,
inParams: false
};
},
token: function(stream, state) {
if (stream.eatSpace()) return null;
return state.tokenize(stream, state);
}
};
});
43 changes: 0 additions & 43 deletions mode/mysql/index.html

This file was deleted.

203 changes: 0 additions & 203 deletions mode/mysql/mysql.js

This file was deleted.

64 changes: 0 additions & 64 deletions mode/plsql/index.html

This file was deleted.

216 changes: 0 additions & 216 deletions mode/plsql/plsql.js

This file was deleted.

21 changes: 21 additions & 0 deletions mode/rst/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License

Copyright (c) 2013 Hasan Karahan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
20 changes: 9 additions & 11 deletions mode/rst/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -508,17 +508,15 @@ <h1>CodeMirror: reStructuredText mode</h1>
lineNumbers: true,
});
</script>
<p>The reStructuredText mode supports one configuration parameter:</p>
<dl>
<dt><code>verbatim (string)</code></dt>
<dd>A name or MIME type of a mode that will be used for highlighting
verbatim blocks. By default, reStructuredText mode uses uniform color
for whole block of verbatim text if no mode is given.</dd>
</dl>
<p>If <code>python</code> mode is available,
it will be used for highlighting blocks containing Python/IPython terminal
sessions (blocks starting with <code>&gt;&gt;&gt;</code> (for Python) or
<code>In [num]:</code> (for IPython).
<p>
The <code>python</code> mode will be used for highlighting blocks
containing Python/IPython terminal sessions: blocks starting with
<code>&gt;&gt;&gt;</code> (for Python) or <code>In [num]:</code> (for
IPython).

Further, the <code>stex</code> mode will be used for highlighting
blocks containing LaTex code.
</p>

<p><strong>MIME types defined:</strong> <code>text/x-rst</code>.</p>
</body>
Expand Down
736 changes: 486 additions & 250 deletions mode/rst/rst.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mode/sql/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
var client = parserConfig.client || {},
atoms = parserConfig.atoms || {"false": true, "true": true, "null": true},
builtin = parserConfig.builtin || {},
keywords = parserConfig.keywords,
keywords = parserConfig.keywords || {},
operatorChars = parserConfig.operatorChars || /^[*+\-%<>!=&|~^]/,
support = parserConfig.support || {},
hooks = parserConfig.hooks || {},
Expand Down
313 changes: 192 additions & 121 deletions mode/stex/stex.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,95 +3,93 @@
* Licence: MIT
*/

CodeMirror.defineMode("stex", function()
{
CodeMirror.defineMode("stex", function() {
"use strict";

function pushCommand(state, command) {
state.cmdState.push(command);
state.cmdState.push(command);
}

function peekCommand(state) {
if (state.cmdState.length>0)
return state.cmdState[state.cmdState.length-1];
else
return null;
function peekCommand(state) {
if (state.cmdState.length > 0) {
return state.cmdState[state.cmdState.length - 1];
} else {
return null;
}
}

function popCommand(state) {
if (state.cmdState.length>0) {
var plug = state.cmdState.pop();
plug.closeBracket();
}
var plug = state.cmdState.pop();
if (plug) {
plug.closeBracket();
}
}

function applyMostPowerful(state) {
var context = state.cmdState;
for (var i = context.length - 1; i >= 0; i--) {
var plug = context[i];
if (plug.name=="DEFAULT")
continue;
return plug.styleIdentifier();
}
return null;
// returns the non-default plugin closest to the end of the list
function getMostPowerful(state) {
var context = state.cmdState;
for (var i = context.length - 1; i >= 0; i--) {
var plug = context[i];
if (plug.name == "DEFAULT") {
continue;
}
return plug;
}
return { styleIdentifier: function() { return null; } };
}

function addPluginPattern(pluginName, cmdStyle, brackets, styles) {
return function () {
this.name=pluginName;
this.bracketNo = 0;
this.style=cmdStyle;
this.styles = styles;
this.brackets = brackets;

this.styleIdentifier = function() {
if (this.bracketNo<=this.styles.length)
return this.styles[this.bracketNo-1];
else
return null;
};
this.openBracket = function() {
this.bracketNo++;
return "bracket";
};
this.closeBracket = function() {};
};
function addPluginPattern(pluginName, cmdStyle, styles) {
return function () {
this.name = pluginName;
this.bracketNo = 0;
this.style = cmdStyle;
this.styles = styles;
this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin

this.styleIdentifier = function() {
return this.styles[this.bracketNo - 1] || null;
};
this.openBracket = function() {
this.bracketNo++;
return "bracket";
};
this.closeBracket = function() {};
};
}

var plugins = new Array();
plugins["importmodule"] = addPluginPattern("importmodule", "tag", "{[", ["string", "builtin"]);
plugins["documentclass"] = addPluginPattern("documentclass", "tag", "{[", ["", "atom"]);
plugins["usepackage"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
plugins["begin"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
plugins["end"] = addPluginPattern("documentclass", "tag", "[", ["atom"]);
var plugins = {};

plugins["importmodule"] = addPluginPattern("importmodule", "tag", ["string", "builtin"]);
plugins["documentclass"] = addPluginPattern("documentclass", "tag", ["", "atom"]);
plugins["usepackage"] = addPluginPattern("usepackage", "tag", ["atom"]);
plugins["begin"] = addPluginPattern("begin", "tag", ["atom"]);
plugins["end"] = addPluginPattern("end", "tag", ["atom"]);

plugins["DEFAULT"] = function () {
this.name="DEFAULT";
this.style="tag";
this.name = "DEFAULT";
this.style = "tag";

this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
};

function setState(state, f) {
state.f = f;
state.f = f;
}

// called when in a normal (no environment) context
function normal(source, state) {
if (source.match(/^\\[a-zA-Z@]+/)) {
var cmdName = source.current();
cmdName = cmdName.substr(1, cmdName.length-1);
var plug;
if (plugins.hasOwnProperty(cmdName)) {
plug = plugins[cmdName];
} else {
plug = plugins["DEFAULT"];
}
plug = new plug();
pushCommand(state, plug);
setState(state, beginParams);
return plug.style;
}
var plug;
// Do we look like '\command' ? If so, attempt to apply the plugin 'command'
if (source.match(/^\\[a-zA-Z@]+/)) {
var cmdName = source.current().slice(1);
plug = plugins[cmdName] || plugins["DEFAULT"];
plug = new plug();
pushCommand(state, plug);
setState(state, beginParams);
return plug.style;
}

// escape characters
// escape characters
if (source.match(/^\\[$&%#{}_]/)) {
return "tag";
}
Expand All @@ -101,74 +99,147 @@ CodeMirror.defineMode("stex", function()
return "tag";
}

var ch = source.next();
if (ch == "%") {
// find if we're starting various math modes
if (source.match("\\[")) {
setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
return "keyword";
}
if (source.match("$$")) {
setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
return "keyword";
}
if (source.match("$")) {
setState(state, function(source, state){ return inMathMode(source, state, "$"); });
return "keyword";
}

var ch = source.next();
if (ch == "%") {
// special case: % at end of its own line; stay in same state
if (!source.eol()) {
setState(state, inCComment);
}
return "comment";
}
else if (ch=='}' || ch==']') {
plug = peekCommand(state);
if (plug) {
plug.closeBracket(ch);
setState(state, beginParams);
} else
return "error";
return "bracket";
} else if (ch=='{' || ch=='[') {
plug = plugins["DEFAULT"];
plug = new plug();
pushCommand(state, plug);
return "bracket";
}
else if (/\d/.test(ch)) {
source.eatWhile(/[\w.%]/);
return "atom";
}
else {
source.eatWhile(/[\w-_]/);
return applyMostPowerful(state);
}
return "comment";
}
else if (ch == '}' || ch == ']') {
plug = peekCommand(state);
if (plug) {
plug.closeBracket(ch);
setState(state, beginParams);
} else {
return "error";
}
return "bracket";
} else if (ch == '{' || ch == '[') {
plug = plugins["DEFAULT"];
plug = new plug();
pushCommand(state, plug);
return "bracket";
}
else if (/\d/.test(ch)) {
source.eatWhile(/[\w.%]/);
return "atom";
}
else {
source.eatWhile(/[\w\-_]/);
plug = getMostPowerful(state);
if (plug.name == 'begin') {
plug.argument = source.current();
}
return plug.styleIdentifier();
}
}

function inCComment(source, state) {
source.skipToEnd();
setState(state, normal);
return "comment";
source.skipToEnd();
setState(state, normal);
return "comment";
}

function inMathMode(source, state, endModeSeq) {
if (source.eatSpace()) {
return null;
}
if (source.match(endModeSeq)) {
setState(state, normal);
return "keyword";
}
if (source.match(/^\\[a-zA-Z@]+/)) {
return "tag";
}
if (source.match(/^[a-zA-Z]+/)) {
return "variable-2";
}
// escape characters
if (source.match(/^\\[$&%#{}_]/)) {
return "tag";
}
// white space control characters
if (source.match(/^\\[,;!\/]/)) {
return "tag";
}
// special math-mode characters
if (source.match(/^[\^_&]/)) {
return "tag";
}
// non-special characters
if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
return null;
}
if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
return "number";
}
var ch = source.next();
if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
return "bracket";
}

// eat comments here, because inCComment returns us to normal state!
if (ch == "%") {
if (!source.eol()) {
source.skipToEnd();
}
return "comment";
}
return "error";
}

function beginParams(source, state) {
var ch = source.peek();
if (ch == '{' || ch == '[') {
var lastPlug = peekCommand(state);
lastPlug.openBracket(ch);
source.eat(ch);
setState(state, normal);
return "bracket";
}
if (/[ \t\r]/.test(ch)) {
source.eat(ch);
return null;
}
setState(state, normal);
lastPlug = peekCommand(state);
if (lastPlug) {
popCommand(state);
}
var ch = source.peek(), lastPlug;
if (ch == '{' || ch == '[') {
lastPlug = peekCommand(state);
lastPlug.openBracket(ch);
source.eat(ch);
setState(state, normal);
return "bracket";
}
if (/[ \t\r]/.test(ch)) {
source.eat(ch);
return null;
}
setState(state, normal);
popCommand(state);

return normal(source, state);
}

return {
startState: function() { return { f:normal, cmdState:[] }; },
copyState: function(s) { return { f: s.f, cmdState: s.cmdState.slice(0, s.cmdState.length) }; },

token: function(stream, state) {
var t = state.f(stream, state);
return t;
}
};
startState: function() {
return {
cmdState: [],
f: normal
};
},
copyState: function(s) {
return {
cmdState: s.cmdState.slice(),
f: s.f
};
},
token: function(stream, state) {
return state.f(stream, state);
}
};
});

CodeMirror.defineMIME("text/x-stex", "stex");
Expand Down
13 changes: 13 additions & 0 deletions mode/stex/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,17 @@

MT("tagBracket",
"[tag \\newcommand][bracket {][tag \\pop][bracket }]");

MT("inlineMathTagFollowedByNumber",
"[keyword $][tag \\pi][number 2][keyword $]");

MT("inlineMath",
"[keyword $][number 3][variable-2 x][tag ^][number 2.45]-[tag \\sqrt][bracket {][tag \\$\\alpha][bracket }] = [number 2][keyword $] other text");

MT("displayMath",
"More [keyword $$]\t[variable-2 S][tag ^][variable-2 n][tag \\sum] [variable-2 i][keyword $$] other text");

MT("mathWithComment",
"[keyword $][variable-2 x] [comment % $]",
"[variable-2 y][keyword $] other text");
})();
129 changes: 129 additions & 0 deletions mode/tcl/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CodeMirror: Tcl mode</title>
<link rel="stylesheet" href="../../lib/codemirror.css">
<script src="../../lib/codemirror.js"></script>
<script src="tcl.js"></script>
<link rel="stylesheet" href="../../theme/night.css">
<link rel="stylesheet" href="../../doc/docs.css">
</head>
<body>
<h1>CodeMirror: Tcl mode</h1>
<form><textarea id="code" name="code">
##############################################################################################
## ## whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
##############################################################################################
## To use this script you must set channel flag +whois (ie .chanset #chan +whois) ##
##############################################################################################
## ____ __ ########################################### ##
## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
## /___/ /___/ /_/ ########################################### ##
## ########################################### ##
##############################################################################################
## ## Start Setup. ## ##
##############################################################################################
namespace eval whois {
## change cmdchar to the trigger you want to use ## ##
variable cmdchar "!"
## change command to the word trigger you would like to use. ## ##
## Keep in mind, This will also change the .chanset +/-command ## ##
variable command "whois"
## change textf to the colors you want for the text. ## ##
variable textf "\017\00304"
## change tagf to the colors you want for tags: ## ##
variable tagf "\017\002"
## Change logo to the logo you want at the start of the line. ## ##
variable logo "\017\00304\002\[\00306W\003hois\00304\]\017"
## Change lineout to the results you want. Valid results are channel users modes topic ## ##
variable lineout "channel users modes topic"
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
variable channel ""
setudef flag $whois::command
bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::list
bind raw -|- "311" whois::311
bind raw -|- "312" whois::312
bind raw -|- "319" whois::319
bind raw -|- "317" whois::317
bind raw -|- "313" whois::multi
bind raw -|- "310" whois::multi
bind raw -|- "335" whois::multi
bind raw -|- "301" whois::301
bind raw -|- "671" whois::multi
bind raw -|- "320" whois::multi
bind raw -|- "401" whois::multi
bind raw -|- "318" whois::318
bind raw -|- "307" whois::307
}
proc whois::311 {from key text} {
if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Host:${whois::textf} \
$nick \(${ident}@${host}\) ${whois::tagf}Realname:${whois::textf} $realname"
}
}
proc whois::multi {from key text} {
if {[regexp {\:(.*)$} $text match $key]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Note:${whois::textf} [subst $$key]"
return 1
}
}
proc whois::312 {from key text} {
regexp {([^\s]+)\s\:} $text match server
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Server:${whois::textf} $server"
}
proc whois::319 {from key text} {
if {[regexp {.+\:(.+)$} $text match channels]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Channels:${whois::textf} $channels"
}
}
proc whois::317 {from key text} {
if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Connected:${whois::textf} \
[ctime $signon] ${whois::tagf}Idle:${whois::textf} [duration $idle]"
}
}
proc whois::301 {from key text} {
if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg"
}
}
proc whois::318 {from key text} {
namespace eval whois {
variable channel ""
}
variable whois::channel ""
}
proc whois::307 {from key text} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Services:${whois::textf} Registered Nick"
}
proc whois::list {nick host hand chan text} {
if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} {
namespace eval whois {
variable channel ""
}
variable whois::channel $chan
putserv "WHOIS $text"
}
}
putlog "\002*Loaded* \017\00304\002\[\00306W\003hois\00304\]\017 \002by \
Ford_Lawnmower irc.GeekShed.net #Script-Help"
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
tabMode: "indent",
theme: "night",
lineNumbers: true,
indentUnit: 2,
mode: "text/x-tcl"
});
</script>

<p><strong>MIME types defined:</strong> <code>text/x-tcl</code>.</p>

</body>
</html>
131 changes: 131 additions & 0 deletions mode/tcl/tcl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
CodeMirror.defineMode("tcl", function() {
function parseWords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var keywords = parseWords("Tcl safe after append array auto_execok auto_import auto_load " +
"auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror " +
"binary break catch cd close concat continue dde eof encoding error " +
"eval exec exit expr fblocked fconfigure fcopy file fileevent filename " +
"filename flush for foreach format gets glob global history http if " +
"incr info interp join lappend lindex linsert list llength load lrange " +
"lreplace lsearch lset lsort memory msgcat namespace open package parray " +
"pid pkg::create pkg_mkIndex proc puts pwd re_syntax read regex regexp " +
"registry regsub rename resource return scan seek set socket source split " +
"string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord " +
"tcl_wordBreakAfter tcl_startOfPreviousWord tcl_wordBreakBefore tcltest " +
"tclvars tell time trace unknown unset update uplevel upvar variable " +
"vwait");
var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");
var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
}
function tokenBase(stream, state) {
var beforeParams = state.beforeParams;
state.beforeParams = false;
var ch = stream.next();
if ((ch == '"' || ch == "'") && state.inParams)
return chain(stream, state, tokenString(ch));
else if (/[\[\]{}\(\),;\.]/.test(ch)) {
if (ch == "(" && beforeParams) state.inParams = true;
else if (ch == ")") state.inParams = false;
return null;
}
else if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
else if (ch == "#" && stream.eat("*")) {
return chain(stream, state, tokenComment);
}
else if (ch == "#" && stream.match(/ *\[ *\[/)) {
return chain(stream, state, tokenUnparsed);
}
else if (ch == "#" && stream.eat("#")) {
stream.skipToEnd();
return "comment";
}
else if (ch == '"') {
stream.skipTo(/"/);
return "comment";
}
else if (ch == "$") {
stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);
stream.eatWhile(/}/);
state.beforeParams = true;
return "builtin";
}
else if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "comment";
}
else {
stream.eatWhile(/[\w\$_{}]/);
var word = stream.current().toLowerCase();
if (keywords && keywords.propertyIsEnumerable(word))
return "keyword";
if (functions && functions.propertyIsEnumerable(word)) {
state.beforeParams = true;
return "keyword";
}
return null;
}
}
function tokenString(quote) {
return function(stream, state) {
var escaped = false, next, end = false;
while ((next = stream.next()) != null) {
if (next == quote && !escaped) {
end = true;
break;
}
escaped = !escaped && next == "\\";
}
if (end) state.tokenize = tokenBase;
return "string";
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "#" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
function tokenUnparsed(stream, state) {
var maybeEnd = 0, ch;
while (ch = stream.next()) {
if (ch == "#" && maybeEnd == 2) {
state.tokenize = tokenBase;
break;
}
if (ch == "]")
maybeEnd++;
else if (ch != " ")
maybeEnd = 0;
}
return "meta";
}
return {
startState: function() {
return {
tokenize: tokenBase,
beforeParams: false,
inParams: false
};
},
token: function(stream, state) {
if (stream.eatSpace()) return null;
return state.tokenize(stream, state);
}
};
});
CodeMirror.defineMIME("text/x-tcl", "tcl");
4 changes: 2 additions & 2 deletions mode/tiki/tiki.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.cm-tw-syntaxerror {
color: #FFFFFF;
background-color: #990000;
color: #FFF;
background-color: #900;
}

.cm-tw-deleted {
Expand Down
Loading