210 changes: 210 additions & 0 deletions addon/mode/simple.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE

(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

CodeMirror.defineSimpleMode = function(name, states, props) {
CodeMirror.defineMode(name, function(config) {
return CodeMirror.simpleMode(config, states, props);
});
};

CodeMirror.simpleMode = function(config, states) {
ensureState(states, "start");
var states_ = {}, meta = states.meta || {}, hasIndentation = false;
for (var state in states) if (state != meta && states.hasOwnProperty(state)) {
var list = states_[state] = [], orig = states[state];
for (var i = 0; i < orig.length; i++) {
var data = orig[i];
list.push(new Rule(data, states));
if (data.indent || data.dedent) hasIndentation = true;
}
}
var mode = {
startState: function() {
return {state: "start", pending: null,
local: null, localState: null,
indent: hasIndentation ? [] : null};
},
copyState: function(state) {
var s = {state: state.state, pending: state.pending,
local: state.local, localState: null,
indent: state.indent && state.indent.slice(0)};
if (state.localState)
s.localState = CodeMirror.copyState(state.local.mode, state.localState);
if (state.stack)
s.stack = state.stack.slice(0);
for (var pers = state.persistentStates; pers; pers = pers.next)
s.persistentStates = {mode: pers.mode,
spec: pers.spec,
state: pers.state == state.localState ? s.localState : CodeMirror.copyState(pers.mode, pers.state),
next: s.persistentStates};
return s;
},
token: tokenFunction(states_, config),
innerMode: function(state) { return state.local && {mode: state.local.mode, state: state.localState}; },
indent: indentFunction(states_, meta)
};
if (meta) for (var prop in meta) if (meta.hasOwnProperty(prop))
mode[prop] = meta[prop];
return mode;
};

function ensureState(states, name) {
if (!states.hasOwnProperty(name))
throw new Error("Undefined state " + name + "in simple mode");
}

function toRegex(val, caret) {
if (!val) return /(?:)/;
var flags = "";
if (val instanceof RegExp) {
if (val.ignoreCase) flags = "i";
val = val.source;
} else {
val = String(val);
}
return new RegExp((caret === false ? "" : "^") + "(?:" + val + ")", flags);
}

function asToken(val) {
if (!val) return null;
if (typeof val == "string") return val.replace(/\./g, " ");
var result = [];
for (var i = 0; i < val.length; i++)
result.push(val[i] && val[i].replace(/\./g, " "));
return result;
}

function Rule(data, states) {
if (data.next || data.push) ensureState(states, data.next || data.push);
this.regex = toRegex(data.regex);
this.token = asToken(data.token);
this.data = data;
}

function tokenFunction(states, config) {
return function(stream, state) {
if (state.pending) {
var pend = state.pending.shift();
if (state.pending.length == 0) state.pending = null;
stream.pos += pend.text.length;
return pend.token;
}

if (state.local) {
if (state.local.end && stream.match(state.local.end)) {
var tok = state.local.endToken || null;
state.local = state.localState = null;
return tok;
} else {
var tok = state.local.mode.token(stream, state.localState), m;
if (state.local.endScan && (m = state.local.endScan.exec(stream.current())))
stream.pos = stream.start + m.index;
return tok;
}
}

var curState = states[state.state];
for (var i = 0; i < curState.length; i++) {
var rule = curState[i];
var matches = stream.match(rule.regex);
if (matches) {
if (rule.data.next) {
state.state = rule.data.next;
} else if (rule.data.push) {
(state.stack || (state.stack = [])).push(state.state);
state.state = rule.data.push;
} else if (rule.data.pop && state.stack && state.stack.length) {
state.state = state.stack.pop();
}

if (rule.data.mode)
enterLocalMode(config, state, rule.data.mode, rule.token);
if (rule.data.indent)
state.indent.push(stream.indentation() + config.indentUnit);
if (rule.data.dedent)
state.indent.pop();
if (matches.length > 2) {
state.pending = [];
for (var j = 2; j < matches.length; j++)
if (matches[j])
state.pending.push({text: matches[j], token: rule.token[j - 1]});
stream.backUp(matches[0].length - (matches[1] ? matches[1].length : 0));
return rule.token[0];
} else if (rule.token && rule.token.join) {
return rule.token[0];
} else {
return rule.token;
}
}
}
stream.next();
return null;
};
}

function cmp(a, b) {
if (a === b) return true;
if (!a || typeof a != "object" || !b || typeof b != "object") return false;
var props = 0;
for (var prop in a) if (a.hasOwnProperty(prop)) {
if (!b.hasOwnProperty(prop) || !cmp(a[prop], b[prop])) return false;
props++;
}
for (var prop in b) if (b.hasOwnProperty(prop)) props--;
return props == 0;
}

function enterLocalMode(config, state, spec, token) {
var pers;
if (spec.persistent) for (var p = state.persistentStates; p && !pers; p = p.next)
if (spec.spec ? cmp(spec.spec, p.spec) : spec.mode == p.mode) pers = p;
var mode = pers ? pers.mode : spec.mode || CodeMirror.getMode(config, spec.spec);
var lState = pers ? pers.state : CodeMirror.startState(mode);
if (spec.persistent && !pers)
state.persistentStates = {mode: mode, spec: spec.spec, state: lState, next: state.persistentStates};

state.localState = lState;
state.local = {mode: mode,
end: spec.end && toRegex(spec.end),
endScan: spec.end && spec.forceEnd !== false && toRegex(spec.end, false),
endToken: token && token.join ? token[token.length - 1] : token};
}

function indexOf(val, arr) {
for (var i = 0; i < arr.length; i++) if (arr[i] === val) return true;
}

function indentFunction(states, meta) {
return function(state, textAfter, line) {
if (state.local && state.local.mode.indent)
return state.local.mode.indent(state.localState, textAfter, line);
if (state.indent == null || state.local || meta.dontIndentStates && indexOf(state.state, meta.dontIndentStates) > -1)
return CodeMirror.Pass;

var pos = state.indent.length - 1, rules = states[state.state];
scan: for (;;) {
for (var i = 0; i < rules.length; i++) {
var rule = rules[i], m = rule.regex.exec(textAfter);
if (m && m[0]) {
if (rule.data.dedent && rule.data.dedentIfLineStart !== false) pos--;
if (rule.next || rule.push) rules = states[rule.next || rule.push];
textAfter = textAfter.slice(m[0].length);
continue scan;
}
}
break;
}
return pos < 0 ? 0 : state.indent[pos];
};
}
});
6 changes: 5 additions & 1 deletion addon/runmode/runmode-standalone.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ CodeMirror.startState = function (mode, a1, a2) {
};

var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
CodeMirror.defineMode = function (name, mode) { modes[name] = mode; };
CodeMirror.defineMode = function (name, mode) {
if (arguments.length > 2)
mode.dependencies = Array.prototype.slice.call(arguments, 2);
modes[name] = mode;
};
CodeMirror.defineMIME = function (mime, spec) { mimeModes[mime] = spec; };
CodeMirror.resolveMode = function(spec) {
if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
Expand Down
6 changes: 2 additions & 4 deletions addon/runmode/runmode.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ exports.startState = function(mode, a1, a2) {

var modes = exports.modes = {}, mimeModes = exports.mimeModes = {};
exports.defineMode = function(name, mode) {
if (arguments.length > 2) {
mode.dependencies = [];
for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
}
if (arguments.length > 2)
mode.dependencies = Array.prototype.slice.call(arguments, 2);
modes[name] = mode;
};
exports.defineMIME = function(mime, spec) { mimeModes[mime] = spec; };
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "codemirror",
"version":"4.6.0",
"version":"4.7.0",
"main": ["lib/codemirror.js", "lib/codemirror.css"],
"ignore": [
"**/.*",
Expand Down
4 changes: 2 additions & 2 deletions demo/activeline.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Active Line</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/anywordhint.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<script src="../addon/hint/anyword-hint.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Any Word Completion</a>
Expand Down
6 changes: 3 additions & 3 deletions demo/bidi.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Bi-directional Text</a>
Expand Down Expand Up @@ -67,7 +67,7 @@ <h2>Bi-directional Text Demo</h2>
blog post</a> for more background.</p>

<p><strong>Note:</strong> There is
a <a href="https://github.com/marijnh/CodeMirror/issues/1757">known
a <a href="https://github.com/codemirror/CodeMirror/issues/1757">known
bug</a> with cursor motion and mouse clicks in bi-directional lines
that are line wrapped.</p>

Expand Down
4 changes: 2 additions & 2 deletions demo/btree.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
.CodeMirror {border: 1px solid #aaa; height: 400px}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">B-Tree visualization</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/buffers.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
.CodeMirror {border: 1px solid black; height: 250px;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Multiple Buffer & Split View</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/changemode.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
.CodeMirror {border: 1px solid black;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Mode-Changing</a>
Expand Down
6 changes: 3 additions & 3 deletions demo/closebrackets.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/edit/closebrackets.js"></script>
<script src="../mode/javascript/javascript.js"></script>
<script src="../mode/xml/xml.js"></script>
<style type="text/css">
.CodeMirror {border-top: 1px solid #888; border-bottom: 1px solid #888;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Closebrackets</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/closetag.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
.CodeMirror {border-top: 1px solid #888; border-bottom: 1px solid #888;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Close-Tag</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="../mode/javascript/javascript.js"></script>

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Autocomplete</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/emacs.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
.CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Emacs bindings</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/folding.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@

<body>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Code Folding</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/fullscreen.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="../addon/display/fullscreen.js"></script>

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Full Screen Editing</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/hardwrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Hard-wrapping</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/html5complete.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@

<body>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">HTML completion</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/indentwrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
.CodeMirror pre > * { text-indent: 0px; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Indented wrapped line</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/lint.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
.CodeMirror {border: 1px solid black;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Linter</a>
Expand Down
33 changes: 28 additions & 5 deletions demo/loadmode.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/mode/loadmode.js"></script>
<script src="../mode/meta.js"></script>
<style type="text/css">
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Lazy Mode Loading</a>
Expand All @@ -25,12 +26,13 @@

<article>
<h2>Lazy Mode Loading Demo</h2>
<p style="color: gray">Current mode: <span id="modeinfo">text/plain</span></p>
<form><textarea id="code" name="code">This is the editor.
// It starts out in plain text mode,
# use the control below to load and apply a mode
"you'll see the highlighting of" this text /*change*/.
</textarea></form>
<p><input type=text value=javascript id=mode> <button type=button onclick="change()">change mode</button></p>
<p>Filename, mime, or mode name: <input type=text value=foo.js id=mode> <button type=button onclick="change()">change mode</button></p>

<script>
CodeMirror.modeURL = "../mode/%N/%N.js";
Expand All @@ -42,8 +44,29 @@ <h2>Lazy Mode Loading Demo</h2>
if (e.keyCode == 13) change();
});
function change() {
editor.setOption("mode", modeInput.value);
CodeMirror.autoLoadMode(editor, modeInput.value);
var val = modeInput.value, m, mode, spec;
if (m = /.+\.([^.]+)$/.exec(val)) {
var info = CodeMirror.findModeByExtension(m[1]);
if (info) {
mode = info.mode;
spec = info.mime;
}
} else if (/\//.test(val)) {
var info = CodeMirror.findModeByMIME(val);
if (info) {
mode = info.mode;
spec = val;
}
} else {
mode = spec = val;
}
if (mode) {
editor.setOption("mode", spec);
CodeMirror.autoLoadMode(editor, mode);
document.getElementById("modeinfo").textContent = spec;
} else {
alert("Could not find a mode corresponding to " + val);
}
}
</script>
</article>
4 changes: 2 additions & 2 deletions demo/marker.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
.CodeMirror {border: 1px solid #aaa;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Breakpoint</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/markselection.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
.styled-background { background-color: #ff7; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Selection Marking</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/matchhighlighter.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Match Highlighter</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/matchtags.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Tag Matcher</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/merge.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">merge view</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/multiplex.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
.cm-delimit {color: #fa4;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Multiplexing Parser</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/mustache.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
.cm-mustache {color: #0ca;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Overlay Parser</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/placeholder.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
.CodeMirror pre.CodeMirror-placeholder { color: #999; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Placeholder</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">HTML5 preview</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

<body>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>
<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">HTML completion</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/resize.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Autoresize</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/rulers.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
.CodeMirror {border-top: 1px solid #888; border-bottom: 1px solid #888;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Ruler demo</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/runmode.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="../addon/runmode/runmode.js"></script>
<script src="../mode/xml/xml.js"></script>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Mode Runner</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
dt {font-family: monospace; color: #666;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Search/Replace</a>
Expand Down
181 changes: 181 additions & 0 deletions demo/simplemode.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
<!doctype html>

<title>CodeMirror: Simple Mode Demo</title>
<meta charset="utf-8"/>
<link rel=stylesheet href="../doc/docs.css">

<link rel="stylesheet" href="../lib/codemirror.css">
<script src="../lib/codemirror.js"></script>
<script src="../addon/mode/simple.js"></script>
<script src="../mode/xml/xml.js"></script>
<style type="text/css">
.CodeMirror {border: 1px solid silver; margin-bottom: 1em; }
dt { text-indent: -2em; padding-left: 2em; margin-top: 1em; }
dd { margin-left: 1.5em; margin-bottom: 1em; }
dt {margin-top: 1em;}
</style>

<div id=nav>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Simple Mode</a>
</ul>
</div>

<article>
<h2>Simple Mode Demo</h2>

<p>The <a href="../addon/mode/simple.js"><code>mode/simple</code></a>
addon allows CodeMirror modes to be specified using a relatively simple
declarative format. This format is not as powerful as writing code
directly against the <a href="../doc/manual.html#modeapi">mode
interface</a>, but is a lot easier to get started with, and
sufficiently expressive for many simple language modes.</p>

<p>This interface is still in flux. It is unlikely to be scrapped or
overhauled completely, so do start writing code against it, but
details might change as it stabilizes, and you might have to tweak
your code when upgrading.</p>

<p>Simple modes (loosely based on
the <a href="https://github.com/mozilla/skywriter/wiki/Common-JavaScript-Syntax-Highlighting-Specification">Common
JavaScript Syntax Highlighting Specification</a>, which never took
off), are state machines, where each state has a number of rules that
match tokens. A rule describes a type of token that may occur in the
current state, and possibly a transition to another state caused by
that token.</p>

<p>The <code>CodeMirror.defineSimpleMode(name, states)</code> method
takes a mode name and an object that describes the mode's states. The
editor below shows an example of such a mode (and is itself
highlighted by the mode shown in it).</p>

<div id="code"></div>

<p>Each state is an array of rules. A rule may have the following properties:</p>

<dl>
<dt><code><strong>regex</strong>: string | RegExp</code></dt>
<dd>The regular expression that matches the token. May be a string
or a regex object. When a regex, the <code>ignoreCase</code> flag
will be taken into account when matching the token. This regex
should only capture groups when the <code>token</code> property is
an array.</dd>
<dt><code><strong>token</strong></code>: string | null</dt>
<dd>An optional token style. Multiple styles can be specified by
separating them with dots or spaces. When the <code>regex</code> for
this rule captures groups, it must capture <em>all</em> of the
string (since JS provides no way to find out where a group matched),
and this property must hold an array of token styles that has one
style for each matched group.</dd>
<dt><code><strong>next</strong>: string</code></dt>
<dd>When a <code>next</code> property is present, the mode will
transfer to the state named by the property when the token is
encountered.</dd>
<dt><code><strong>push</strong>: string</code></dt>
<dd>Like <code>next</code>, but instead replacing the current state
by the new state, the current state is kept on a stack, and can be
returned to with the <code>pop</code> directive.</dd>
<dt><code><strong>pop</strong>: bool</code></dt>
<dd>When true, and there is another state on the state stack, will
cause the mode to pop that state off the stack and transition to
it.</dd>
<dt><code><strong>mode</strong>: {spec, end, persistent}</code></dt>
<dd>Can be used to embed another mode inside a mode. When present,
must hold an object with a <code>spec</code> property that describes
the embedded mode, and an optional <code>end</code> end property
that specifies the regexp that will end the extent of the mode. When
a <code>persistent</code> property is set (and true), the nested
mode's state will be preserved between occurrences of the mode.</dd>
<dt><code><strong>indent</strong>: bool</code></dt>
<dd>When true, this token changes the indentation to be one unit
more than the current line's indentation.</dd>
<dt><code><strong>dedent</strong>: bool</code></dt>
<dd>When true, this token will pop one scope off the indentation
stack.</dd>
<dt><code><strong>dedentIfLineStart</strong>: bool</code></dt>
<dd>If a token has its <code>dedent</code> property set, it will, by
default, cause lines where it appears at the start to be dedented.
Set this property to false to prevent that behavior.</dd>
</dl>

<p>The <code>meta</code> property of the states object is special, and
will not be interpreted as a state. Instead, properties set on it will
be set on the mode, which is useful for properties
like <a href="../doc/manual.html#addon_comment"><code>lineComment</code></a>,
which sets the comment style for a mode. The simple mode addon also
recognizes a few such properties:</p>

<dl>
<dt><code><strong>dontIndentStates</strong>: array&lt;string&gt;</code></dt>
<dd>An array of states in which the mode's auto-indentation should
not take effect. Usually used for multi-line comment and string
states.</dd>
</dl>

<script id="modecode">/* Example definition of a simple mode that understands a subset of
* JavaScript:
*/

CodeMirror.defineSimpleMode("simplemode", {
// The start state contains the rules that are intially used
start: [
// The regex matches the token, the token property contains the type
{regex: /"(?:[^\\]|\\.)*?"/, token: "string"},
// You can match multiple tokens at once. Note that the captured
// groups must span the whole string in this case
{regex: /(function)(\s+)([a-z$][\w$]*)/,
token: ["keyword", null, "variable-2"]},
// Rules are matched in the order in which they appear, so there is
// no ambiguity between this one and the one above
{regex: /(?:function|var|return|if|for|while|else|do|this)\b/,
token: "keyword"},
{regex: /true|false|null|undefined/, token: "atom"},
{regex: /0x[a-f\d]+|[-+]?(?:\.\d+|\d+\.?\d*)(?:e[-+]?\d+)?/i,
token: "number"},
{regex: /\/\/.*/, token: "comment"},
{regex: /\/(?:[^\\]|\\.)*?\//, token: "variable-3"},
// A next property will cause the mode to move to a different state
{regex: /\/\*/, token: "comment", next: "comment"},
{regex: /[-+\/*=<>!]+/, token: "operator"},
// indent and dedent properties guide autoindentation
{regex: /[\{\[\(]/, indent: true},
{regex: /[\}\]\)]/, dedent: true},
{regex: /[a-z$][\w$]*/, token: "variable"},
// You can embed other modes with the mode property. This rule
// causes all code between << and >> to be highlighted with the XML
// mode.
{regex: /<</, token: "meta", mode: {spec: "xml", end: />>/}}
],
// The multi-line comment state.
comment: [
{regex: /.*?\*\//, token: "comment", next: "start"},
{regex: /.*/, token: "comment"}
],
// The meta property contains global information about the mode. It
// can contain properties like lineComment, which are supported by
// all modes, and also directives like dontIndentStates, which are
// specific to simple modes.
meta: {
dontIndentStates: ["comment"],
lineComment: "//"
}
});
</script>

<script>
var sc = document.getElementById("modecode");
var code = document.getElementById("code");
var editor = CodeMirror(code, {
value: (sc.textContent || sc.innerText || sc.innerHTML),
mode: "simplemode"
});
</script>

</article>
4 changes: 2 additions & 2 deletions demo/spanaffectswrapping_shim.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<link rel=stylesheet href="../doc/docs.css">

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Automatically derive odd wrapping behavior for your browser</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/sublime.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
.CodeMirror-linenumbers { padding: 0 8px; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Sublime bindings</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/tern.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@
.CodeMirror {border: 1px solid #ddd;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Tern</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/theme.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@
.CodeMirror {border: 1px solid black; font-size:13px}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Theme</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/trailingspace.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Trailing Whitespace</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/variableheight.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
.cm-strong { font-size: 140%; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Variable Height</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/vim.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
.CodeMirror {border-top: 1px solid #eee; border-bottom: 1px solid #eee;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Vim bindings</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/visibletabs.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Visible tabs</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/widget.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
.lint-error-icon {color: white; background-color: red; font-weight: bold; border-radius: 50%; padding: 0 3px; margin-right: 7px;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Inline Widget</a>
Expand Down
4 changes: 2 additions & 2 deletions demo/xmlcomplete.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
.CodeMirror { border: 1px solid #eee; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">XML Autocomplete</a>
Expand Down
8 changes: 6 additions & 2 deletions doc/compress.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
<link rel=stylesheet href="../lib/codemirror.css">

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Compression helper</a>
Expand All @@ -36,6 +36,7 @@ <h2>Script compression helper</h2>
<input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
<p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px;">
<option value="http://codemirror.net/">HEAD</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.7.0;f=">4.7</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.6.0;f=">4.6</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.5.0;f=">4.5</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=4.4.0;f=">4.4</option>
Expand Down Expand Up @@ -163,9 +164,11 @@ <h2>Script compression helper</h2>
<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/tcl/tcl.js">tcl.js</option>
<option value="http://codemirror.net/mode/textile/textile.js">textile.js</option>
<option value="http://codemirror.net/mode/tiddlywiki/tiddlywiki.js">tiddlywiki.js</option>
<option value="http://codemirror.net/mode/tiki/tiki.js">tiki.js</option>
<option value="http://codemirror.net/mode/toml/toml.js">toml.js</option>
<option value="http://codemirror.net/mode/tornado/tornado.js">tornado.js</option>
<option value="http://codemirror.net/mode/turtle/turtle.js">turtle.js</option>
<option value="http://codemirror.net/mode/vb/vb.js">vb.js</option>
<option value="http://codemirror.net/mode/vbscript/vbscript.js">vbscript.js</option>
Expand Down Expand Up @@ -217,6 +220,7 @@ <h2>Script compression helper</h2>
<option value="http://codemirror.net/addon/search/search.js">search.js</option>
<option value="http://codemirror.net/addon/search/searchcursor.js">searchcursor.js</option>
<option value="http://codemirror.net/addon/hint/show-hint.js">show-hint.js</option>
<option value="http://codemirror.net/addon/mode/simple.js">simple.js</option>
<option value="http://codemirror.net/addon/hint/sql-hint.js">sql-hint.js</option>
<option value="http://codemirror.net/addon/edit/trailingspace.js">trailingspace.js</option>
<option value="http://codemirror.net/addon/tern/tern.js">tern.js</option>
Expand Down
13 changes: 11 additions & 2 deletions doc/docs.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,23 @@ body {

p { margin-top: 0; }

h2, h3 {
h2, h3, h1 {
font-weight: normal;
margin-bottom: .7em;
}
h1 { font-size: 140%; }
h2 { font-size: 120%; }
h3 { font-size: 110%; }
article > h2:first-child, section:first-child > h2 { margin-top: 0; }

#nav h1 {
margin-right: 12px;
margin-top: 0;
margin-bottom: 2px;
color: #E30808;
letter-spacing: .5px;
}

a, a:visited, a:link, .quasilink {
color: #A21313;
text-decoration: none;
Expand Down Expand Up @@ -114,7 +123,7 @@ article {

#logo {
border: 0;
margin-right: 7px;
margin-right: 12px;
margin-bottom: 25px;
}

Expand Down
4 changes: 2 additions & 2 deletions doc/internals.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
<script src="activebookmark.js"></script>

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="#top">Introduction</a></li>
Expand Down
Binary file modified doc/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
280 changes: 157 additions & 123 deletions doc/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 36 additions & 8 deletions doc/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
</style>

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>
<ul>
<li><a href="../index.html">Home</a></li>
<li><a href="#overview" class=active data-default="true">Manual</a></li>
<li><a href="https://github.com/marijnh/codemirror">Code</a></li>
<li><a href="https://github.com/codemirror/codemirror">Code</a></li>
</ul>
<ul>
<li><a href="#usage">Basic Usage</a></li>
Expand Down Expand Up @@ -63,7 +63,7 @@
<section class=first id=overview>
<h2 style="position: relative">
User manual and reference guide
<span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 4.6.0</span>
<span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 4.7.0</span>
</h2>

<p>CodeMirror is a code-editor component that can be embedded in
Expand All @@ -72,7 +72,7 @@ <h2 style="position: relative">
functionality. It does provide a rich API on top of which such
functionality can be straightforwardly implemented. See
the <a href="#addons">addons</a> included in the distribution,
and the <a href="https://github.com/marijnh/CodeMirror/wiki/CodeMirror-addons">list
and the <a href="https://github.com/codemirror/CodeMirror/wiki/CodeMirror-addons">list
of externally hosted addons</a>, for reusable
implementations of extra features.</p>

Expand Down Expand Up @@ -481,7 +481,7 @@ <h2>Events</h2>
that used to be between <code>from</code> and <code>to</code>,
which is overwritten by this change.</dd>

<dt id="event_changes"><code><strong>"changes"</strong> (instance: CodeMirror, changes: array&lt;object&lt;)</code></dt>
<dt id="event_changes"><code><strong>"changes"</strong> (instance: CodeMirror, changes: array&lt;object&gt;)</code></dt>
<dd>Like the <a href="#event_change"><code>"change"</code></a>
event, but batched per <a href="#operation">operation</a>,
passing an array containing all the changes that happened in the
Expand Down Expand Up @@ -1205,7 +1205,7 @@ <h3 id="api_selection">Cursor and selection methods</h3>
selection). Omitting the argument is the same as
passing <code>"head"</code>. A <code>{line, ch}</code> object
will be returned.</dd>
<dt id="listSelections"><code><strong>doc.listSelections</strong>() → array&lt;{anchor, head}&lt;</code></dt>
<dt id="listSelections"><code><strong>doc.listSelections</strong>() → array&lt;{anchor, head}&gt;</code></dt>
<dd>Retrieves a list of all current selections. These will
always be sorted, and never overlap (overlapping selections are
merged). Each object in the array contains <code>anchor</code>
Expand Down Expand Up @@ -2045,7 +2045,7 @@ <h3 id="api_static">Static properties</h3>
</section>

<section id=addons>
<h2>Addons</h2>
<h2 id="addons">Addons</h2>

<p>The <code>addon</code> directory in the distribution contains a
number of reusable components that implement extra editor
Expand Down Expand Up @@ -2527,7 +2527,11 @@ <h2>Addons</h2>
should scan when completing (defaults to 500).</dd>

<dt id="addon_sql-hint"><a href="../addon/hint/sql-hint.js"><code>hint/sql-hint.js</code></a></dt>
<dd>A simple SQL hinter. Defines <code>CodeMirror.hint.sql</code>.</dd>
<dd>A simple SQL hinter. Defines <code>CodeMirror.hint.sql</code>.
Takes two optional options, <code>tables</code>, a object with
table names as keys and array of respective column names as values,
and <code>defaultTable</code>, a string corresponding to a
table name in <code>tables</code> for autocompletion.</dd>

<dt id="addon_match-highlighter"><a href="../addon/search/match-highlighter.js"><code>search/match-highlighter.js</code></a></dt>
<dd>Adds a <code>highlightSelectionMatches</code> option that
Expand Down Expand Up @@ -2585,6 +2589,25 @@ <h2>Addons</h2>
editor instance to refresh its mode when the loading
succeeded. See the <a href="../demo/loadmode.html">demo</a>.</dd>

<dt id="addon_meta"><a href="../mode/meta.js"><code>mode/meta.js</code></a></dt>
<dd>Provides meta-information about all the modes in the
distribution in a single file.
Defines <code>CodeMirror.modeInfo</code>, an array of objects
with <code>{name, mime, mode}</code> properties,
where <code>name</code> is the human-readable
name, <code>mime</code> the MIME type, and <code>mode</code> the
name of the mode file that defines this MIME. There are optional
properties <code>mimes</code>, which holds an array of MIME
types for modes with multiple MIMEs associated,
and <code>ext</code>, which holds an array of file extensions
associated with this mode. Two convenience
functions, <code>CodeMirror.findModeByMIME</code>
and <code>CodeMirror.findModeByExtension</code> are provided,
which return such an object given a MIME or extension string.
Note that, for historical reasons, this file resides in the
top-level <code>mode</code> directory, not
under <code>addon</code>. <a href="../demo/loadmode.html">Demo</a>.</dd>

<dt id="addon_continuecomment"><a href="../addon/comment/continuecomment.js"><code>comment/continuecomment.js</code></a></dt>
<dd>Adds a <code>continueComments</code> option, which sets whether the
editor will make the next line continue a comment when you press Enter
Expand Down Expand Up @@ -2692,6 +2715,11 @@ <h2>Writing CodeMirror Modes</h2>
advances it past a token, and returns a style for that token. More
advanced modes can also handle indentation for the language.</p>

<p>This section describes the low-level mode interface. Many modes
are written directly against this, since it offers a lot of
control, but for a quick mode definition, you might want to use
the <a href="../demo/simplemode.html">simple mode addon</a>.</p>

<p id="defineMode">The mode script should
call <code><strong>CodeMirror.defineMode</strong></code> to
register itself with CodeMirror. This function takes two
Expand Down
7 changes: 4 additions & 3 deletions doc/realworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<link rel=stylesheet href="docs.css">

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Real-world uses</a>
Expand All @@ -21,7 +21,7 @@

<h2>CodeMirror real-world uses</h2>

<p>Create a <a href="https://github.com/marijnh/codemirror">pull
<p>Create a <a href="https://github.com/codemirror/codemirror">pull
request</a> or <a href="mailto:marijnh@gmail.com">email me</a> if
you'd like your project to be added to this list.</p>

Expand Down Expand Up @@ -136,6 +136,7 @@ <h2>CodeMirror real-world uses</h2>
<li><a href="http://snippets.pro/">Snippets.pro</a> (code snippet sharing)</li>
<li><a href="http://www.solidshops.com/">SolidShops</a> (hosted e-commerce platform)</li>
<li><a href="http://sqlfiddle.com">SQLFiddle</a> (SQL playground)</li>
<li><a href="http://syframework.alwaysdata.net">SyBox</a> (PHP playground)</li>
<li><a href="http://www.tagspaces.org/">TagSpaces</a> (personal data manager)</li>
<li><a href="https://thefiletree.com">The File Tree</a> (collab editor)</li>
<li><a href="http://www.mapbox.com/tilemill/">TileMill</a> (map design tool)</li>
Expand Down
99 changes: 65 additions & 34 deletions doc/releases.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions doc/reporting.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<link rel=stylesheet href="docs.css">

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Reporting bugs</a>
Expand Down
4 changes: 2 additions & 2 deletions doc/upgrade_v2.2.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<link rel=stylesheet href="docs.css">

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">2.2 upgrade guide</a>
Expand Down
4 changes: 2 additions & 2 deletions doc/upgrade_v3.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
<script src="activebookmark.js"></script>

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#upgrade">Upgrade guide</a>
Expand Down
4 changes: 2 additions & 2 deletions doc/upgrade_v4.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<script src="activebookmark.js"></script>

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#upgrade">Upgrade guide</a>
Expand Down
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
</style>

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="doc/logo.png"></a>

<ul>
<li><a class=active data-default="true" href="#description">Home</a>
<li><a href="doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="#features">Features</a>
Expand All @@ -40,7 +40,7 @@
<section id=description class=first>
<p><strong>CodeMirror</strong> is a versatile text editor
implemented in JavaScript for the browser. It is specialized for
editing code, and comes with a number of language modes and addons
editing code, and comes with a number of <a href="mode/index.html">language modes</a> and <a href="doc/manual.html#addons">addons</a>
that implement more advanced editing functionality.</p>

<p>A rich <a href="doc/manual.html#api">programming API</a> and a
Expand Down Expand Up @@ -85,7 +85,7 @@ <h2>This is CodeMirror</h2>
</script>
<div style="position: relative; margin: 1em 0;">
<a class="bigbutton left" href="http://codemirror.net/codemirror.zip">DOWNLOAD LATEST RELEASE</a>
<div><strong>version 4.6</strong> (<a href="doc/releases.html">Release notes</a>)</div>
<div><strong>version 4.7</strong> (<a href="doc/releases.html">Release notes</a>)</div>
<div>or use the <a href="doc/compress.html">minification helper</a></div>
<div style="position: absolute; top: 0; right: 0; text-align: right">
<span class="bigbutton right" onclick="document.getElementById('paypal').submit();">DONATE WITH PAYPAL</span>
Expand Down Expand Up @@ -156,7 +156,7 @@ <h2>Community</h2>
and <a href="doc/realworld.html">many other projects</a>.</p>

<p>Development and bug tracking happens
on <a href="https://github.com/marijnh/CodeMirror/">github</a>
on <a href="https://github.com/codemirror/CodeMirror/">github</a>
(<a href="http://marijnhaverbeke.nl/git/codemirror">alternate git
repository</a>).
Please <a href="http://codemirror.net/doc/reporting.html">read these
Expand All @@ -175,7 +175,7 @@ <h2>Community</h2>

<p>A list of CodeMirror-related software that is not part of the
main distribution is maintained
on <a href="https://github.com/marijnh/CodeMirror/wiki/CodeMirror-addons">our
on <a href="https://github.com/codemirror/CodeMirror/wiki/CodeMirror-addons">our
wiki</a>. Feel free to add your project.</p>
</section>

Expand Down
979 changes: 425 additions & 554 deletions keymap/vim.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/codemirror.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
/* Can style cursor different in overwrite (non-insert) mode */
div.CodeMirror-overwrite div.CodeMirror-cursor {}

.cm-tab { display: inline-block; }
.cm-tab { display: inline-block; text-decoration: inherit; }

.CodeMirror-ruler {
border-left: 1px solid #ccc;
Expand Down
49 changes: 24 additions & 25 deletions lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
function CodeMirror(place, options) {
if (!(this instanceof CodeMirror)) return new CodeMirror(place, options);

this.options = options = options || {};
this.options = options = options ? copyObj(options) : {};
// Determine effective options based on given values and defaults.
copyObj(defaults, options, false);
setGuttersForLineNumbers(options);
Expand Down Expand Up @@ -96,21 +96,20 @@
registerEventHandlers(this);
ensureGlobalHandlers();

var cm = this;
runInOp(this, function() {
cm.curOp.forceUpdate = true;
attachDoc(cm, doc);
startOperation(this);
this.curOp.forceUpdate = true;
attachDoc(this, doc);

if ((options.autofocus && !mobile) || activeElt() == display.input)
setTimeout(bind(onFocus, cm), 20);
else
onBlur(cm);
if ((options.autofocus && !mobile) || activeElt() == display.input)
setTimeout(bind(onFocus, this), 20);
else
onBlur(this);

for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
optionHandlers[opt](cm, options[opt], Init);
maybeUpdateLineNumberWidth(cm);
for (var i = 0; i < initHooks.length; ++i) initHooks[i](cm);
});
for (var opt in optionHandlers) if (optionHandlers.hasOwnProperty(opt))
optionHandlers[opt](this, options[opt], Init);
maybeUpdateLineNumberWidth(this);
for (var i = 0; i < initHooks.length; ++i) initHooks[i](this);
endOperation(this);
}

// DISPLAY CONSTRUCTOR
Expand Down Expand Up @@ -723,9 +722,10 @@
// view, so that we don't interleave reading and writing to the DOM.
function getDimensions(cm) {
var d = cm.display, left = {}, width = {};
var gutterLeft = d.gutters.clientLeft;
for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
left[cm.options.gutters[i]] = n.offsetLeft;
width[cm.options.gutters[i]] = n.offsetWidth;
left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
width[cm.options.gutters[i]] = n.clientWidth;
}
return {fixedPos: compensateForHScroll(d),
gutterTotalWidth: d.gutters.offsetWidth,
Expand Down Expand Up @@ -3720,7 +3720,7 @@
// measured, the position of something may 'drift' during drawing).
function scrollPosIntoView(cm, pos, end, margin) {
if (margin == null) margin = 0;
for (;;) {
for (var limit = 0; limit < 5; limit++) {
var changed = false, coords = cursorCoords(cm, pos);
var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
Expand Down Expand Up @@ -3769,7 +3769,7 @@
var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
var screenw = display.scroller.clientWidth - scrollerCutOff - display.gutters.offsetWidth;
var tooWide = x2 - x1 > screenw;
if (tooWide) x2 = y1 + screen;
if (tooWide) x2 = x1 + screenw;
if (x1 < 10)
result.scrollLeft = 0;
else if (x1 < screenleft)
Expand Down Expand Up @@ -4570,10 +4570,8 @@
// load a mode. (Preferred mechanism is the require/define calls.)
CodeMirror.defineMode = function(name, mode) {
if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
if (arguments.length > 2) {
mode.dependencies = [];
for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
}
if (arguments.length > 2)
mode.dependencies = Array.prototype.slice.call(arguments, 2);
modes[name] = mode;
};

Expand Down Expand Up @@ -4865,7 +4863,7 @@
// are simply ignored.
keyMap.pcDefault = {
"Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
"Ctrl-Home": "goDocStart", "Ctrl-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd",
"Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
"Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
"Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
"Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
Expand All @@ -4880,7 +4878,7 @@
"Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
"Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
"Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
"Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection",
"Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
fallthrough: ["basic", "emacsy"]
};
// Very basic readline/emacs-style bindings, which are standard on Mac.
Expand Down Expand Up @@ -4988,6 +4986,7 @@
cm.save = save;
cm.getTextArea = function() { return textarea; };
cm.toTextArea = function() {
cm.toTextArea = isNaN; // Prevent this from being ran twice
save();
textarea.parentNode.removeChild(cm.getWrapperElement());
textarea.style.display = "";
Expand Down Expand Up @@ -7825,7 +7824,7 @@

// THE END

CodeMirror.version = "4.6.0";
CodeMirror.version = "4.7.0";

return CodeMirror;
});
4 changes: 2 additions & 2 deletions mode/apl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
.CodeMirror { border: 2px inset #dee; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/asterisk/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
.cm-s-default span.cm-arrow { color: red; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
33 changes: 28 additions & 5 deletions mode/clike/clike.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
blockKeywords = parserConfig.blockKeywords || {},
atoms = parserConfig.atoms || {},
hooks = parserConfig.hooks || {},
multiLineStrings = parserConfig.multiLineStrings;
multiLineStrings = parserConfig.multiLineStrings,
indentStatements = parserConfig.indentStatements !== false;
var isOperatorChar = /[+\-*&%=<>!?|\/]/;

var curPunc;
Expand Down Expand Up @@ -57,7 +58,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
Expand Down Expand Up @@ -151,7 +152,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
while (ctx.type == "statement") ctx = popContext(state);
}
else if (curPunc == ctx.type) popContext(state);
else if (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))
else if (indentStatements &&
(((ctx.type == "}" || ctx.type == "top") && curPunc != ';') ||
(ctx.type == "statement" && curPunc == "newstatement")))
pushContext(state, stream.column(), "statement");
state.startOfLine = false;
return style;
Expand Down Expand Up @@ -298,6 +301,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
},
modeProps: {fold: ["brace", "include"]}
});

def("text/x-java", {
name: "clike",
keywords: words("abstract assert boolean break byte case catch char class const continue default " +
Expand All @@ -315,6 +319,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
},
modeProps: {fold: ["brace", "import"]}
});

def("text/x-csharp", {
name: "clike",
keywords: words("abstract as base break case catch checked class const continue" +
Expand All @@ -341,6 +346,19 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
}
}
});

function tokenTripleString(stream, state) {
var escaped = false;
while (!stream.eol()) {
if (!escaped && stream.match('"""')) {
state.tokenize = null;
break;
}
escaped = stream.next() != "\\" && !escaped;
}
return "string";
}

def("text/x-scala", {
name: "clike",
keywords: words(
Expand All @@ -366,19 +384,24 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
"Compiler Double Exception Float Integer Long Math Number Object Package Pair Process " +
"Runtime Runnable SecurityManager Short StackTraceElement StrictMath String " +
"StringBuffer System Thread ThreadGroup ThreadLocal Throwable Triple Void"


),
multiLineStrings: true,
blockKeywords: words("catch class do else finally for forSome if match switch try while"),
atoms: words("true false null"),
indentStatements: false,
hooks: {
"@": function(stream) {
stream.eatWhile(/[\w\$_]/);
return "meta";
},
'"': function(stream, state) {
if (!stream.match('""')) return false;
state.tokenize = tokenTripleString;
return state.tokenize(stream, state);
}
}
});

def(["x-shader/x-vertex", "x-shader/x-fragment"], {
name: "clike",
keywords: words("float int bool void " +
Expand Down
31 changes: 26 additions & 5 deletions mode/clike/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="clike.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down Expand Up @@ -169,6 +169,21 @@ <h2>Java example</h2>
member = value;
}
}
</textarea></div>

<h2>Scala example</h2>

<div><textarea id="scala-code">
object FilterTest extends App {
def filter(xs: List[Int], threshold: Int) = {
def process(ys: List[Int]): List[Int] =
if (ys.isEmpty) ys
else if (ys.head < threshold) ys.head :: process(ys.tail)
else process(ys.tail)
process(xs)
}
println(filter(List(1, 9, 2, 8, 3, 7, 4), 5))
}
</textarea></div>

<script>
Expand All @@ -187,6 +202,11 @@ <h2>Java example</h2>
matchBrackets: true,
mode: "text/x-java"
});
var scalaEditor = CodeMirror.fromTextArea(document.getElementById("scala-code"), {
lineNumbers: true,
matchBrackets: true,
mode: "text/x-scala"
});
var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault;
CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete";
</script>
Expand All @@ -198,7 +218,8 @@ <h2>Java example</h2>
directives are recognized.</p>

<p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
(C code), <code>text/x-c++src</code> (C++
code), <code>text/x-java</code> (Java
code), <code>text/x-csharp</code> (C#).</p>
(C), <code>text/x-c++src</code> (C++), <code>text/x-java</code>
(Java), <code>text/x-csharp</code> (C#),
<code>text/x-scala</code> (Scala), <code>text/x-vertex</code>
and <code>x-shader/x-fragment</code> (shader programs).</p>
</article>
4 changes: 2 additions & 2 deletions mode/clike/scala.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="../../addon/edit/matchbrackets.js"></script>
<script src="clike.js"></script>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
8 changes: 5 additions & 3 deletions mode/clojure/clojure.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

CodeMirror.defineMode("clojure", function (options) {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable";
var INDENT_WORD_SKIP = options.indentUnit || 2;
var NORMAL_INDENT_UNIT = options.indentUnit || 2;

Expand Down Expand Up @@ -59,7 +59,7 @@ CodeMirror.defineMode("clojure", function (options) {
sign: /[+-]/,
exponent: /e/i,
keyword_char: /[^\s\(\[\;\)\]]/,
symbol: /[\w*+!\-\._?:<>\/]/
symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/
};

function stateStack(indent, type, prev) { // represents a state stack object
Expand Down Expand Up @@ -220,7 +220,9 @@ CodeMirror.defineMode("clojure", function (options) {
returnType = BUILTIN;
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
returnType = ATOM;
} else returnType = null;
} else {
returnType = VAR;
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions mode/clojure/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="clojure.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/cobol/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@
.CodeMirror-activeline-background {background: #555555 !important;}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
15 changes: 8 additions & 7 deletions mode/coffeescript/coffeescript.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
}

var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?)/;
var operators = /^(?:->|=>|\+[+=]?|-[\-=]?|\*[\*=]?|\/[\/=]?|[=!]=|<[><]?=?|>>?=?|%=?|&=?|\|=?|\^=?|\~|!|\?|(or|and|\|\||&&|\?)=)/;
var delimiters = /^(?:[()\[\]{},:`=;]|\.\.?\.?)/;
var identifiers = /^[_A-Za-z$][_A-Za-z$0-9]*/;
var properties = /^(@|this\.)[_A-Za-z$][_A-Za-z$0-9]*/;
Expand All @@ -34,7 +34,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {
"switch", "try", "catch", "finally", "class"];
var commonKeywords = ["break", "by", "continue", "debugger", "delete",
"do", "in", "of", "new", "return", "then",
"this", "throw", "when", "until"];
"this", "@", "throw", "when", "until", "extends"];

var keywords = wordRegexp(indentKeywords.concat(commonKeywords));

Expand Down Expand Up @@ -217,7 +217,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {
type = type || "coffee";
var offset = 0, align = false, alignOffset = null;
for (var scope = state.scope; scope; scope = scope.prev) {
if (scope.type === "coffee") {
if (scope.type === "coffee" || scope.type == "}") {
offset = scope.offset + conf.indentUnit;
break;
}
Expand Down Expand Up @@ -278,7 +278,7 @@ CodeMirror.defineMode("coffeescript", function(conf) {

// Handle scope changes.
if (current === "return") {
state.dedent += 1;
state.dedent = true;
}
if (((current === "->" || current === "=>") &&
!state.lambda &&
Expand Down Expand Up @@ -310,9 +310,10 @@ CodeMirror.defineMode("coffeescript", function(conf) {
if (state.scope.type == current)
state.scope = state.scope.prev;
}
if (state.dedent > 0 && stream.eol() && state.scope.type == "coffee") {
if (state.scope.prev) state.scope = state.scope.prev;
state.dedent -= 1;
if (state.dedent && stream.eol()) {
if (state.scope.type == "coffee" && state.scope.prev)
state.scope = state.scope.prev;
state.dedent = false;
}

return style;
Expand Down
4 changes: 2 additions & 2 deletions mode/coffeescript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="coffeescript.js"></script>
<style>.CodeMirror {border-top: 1px solid silver; border-bottom: 1px solid silver;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/commonlisp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="commonlisp.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/css/less.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="css.js"></script>
<style>.CodeMirror {border: 1px solid #ddd; line-height: 1.2;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/css/scss.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="css.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/cypher/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
}
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
2 changes: 1 addition & 1 deletion mode/d/d.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
Expand Down
4 changes: 2 additions & 2 deletions mode/d/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="d.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/diff/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
span.cm-error.cm-tag { background-color: #2b2; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/django/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="django.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
2 changes: 1 addition & 1 deletion mode/dtd/dtd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/*
DTD mode
Ported to CodeMirror by Peter Kroon <plakroon@gmail.com>
Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
GitHub: @peterkroon
*/

Expand Down
4 changes: 2 additions & 2 deletions mode/dtd/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="dtd.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/dylan/index.html
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="dylan.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/ecl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="ecl.js"></script>
<style>.CodeMirror {border: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/eiffel/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
.cm-s-default span.cm-arrow { color: red; }
</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/erlang/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<script src="erlang.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/fortran/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="fortran.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/gas/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="gas.js"></script>
<style>.CodeMirror {border: 2px inset #dee;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/gfm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<script src="../clike/clike.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
11 changes: 11 additions & 0 deletions mode/gfm/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,15 @@
"[comment `foo]",
"",
"[link http://www.example.com/]");

MT("headerCodeBlockGithub",
"[header&header-1 # heading]",
"",
"[comment ```]",
"[comment code]",
"[comment ```]",
"",
"Commit: [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2]",
"Issue: [link #1]",
"Link: [link http://www.example.com/]");
})();
2 changes: 1 addition & 1 deletion mode/gherkin/gherkin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

/*
Gherkin mode - http://www.cukes.info/
Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
*/

// Following Objs from Brackets implementation: https://github.com/tregusti/brackets-gherkin/blob/master/main.js
Expand Down
4 changes: 2 additions & 2 deletions mode/gherkin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="gherkin.js"></script>
<style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
2 changes: 1 addition & 1 deletion mode/go/go.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ CodeMirror.defineMode("go", function(config) {
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_]/);
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) {
if (cur == "case" || cur == "default") curPunc = "case";
Expand Down
4 changes: 2 additions & 2 deletions mode/go/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<script src="go.js"></script>
<style>.CodeMirror {border:1px solid #999; background:#ffc}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/groovy/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="groovy.js"></script>
<style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/haml/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<script src="haml.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
2 changes: 1 addition & 1 deletion mode/haskell/haskell.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ CodeMirror.defineMode("haskell", function(_config, modeConfig) {
var digitRE = /\d/;
var hexitRE = /[0-9A-Fa-f]/;
var octitRE = /[0-7]/;
var idRE = /[a-z_A-Z0-9']/;
var idRE = /[a-z_A-Z0-9'\xa1-\uffff]/;
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
var specialRE = /[(),;[\]`{}]/;
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
Expand Down
4 changes: 2 additions & 2 deletions mode/haskell/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<script src="haskell.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/haxe/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="haxe.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/htmlembedded/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<script src="htmlembedded.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/htmlmixed/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<script src="htmlmixed.js"></script>
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/http/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="http.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
6 changes: 4 additions & 2 deletions mode/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<link rel=stylesheet href="../doc/docs.css">

<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../doc/logo.png"></a>

<ul>
<li><a href="../index.html">Home</a>
<li><a href="../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a class=active href="#">Language modes</a>
Expand Down Expand Up @@ -105,9 +105,11 @@ <h2>Language modes</h2>
<li><a href="sparql/index.html">SPARQL</a></li>
<li><a href="stex/index.html">sTeX, LaTeX</a></li>
<li><a href="tcl/index.html">Tcl</a></li>
<li><a href="textile/index.html">Textile</a></li>
<li><a href="tiddlywiki/index.html">Tiddlywiki</a></li>
<li><a href="tiki/index.html">Tiki wiki</a></li>
<li><a href="toml/index.html">TOML</a></li>
<li><a href="tornado/index.html">Tornado</a> (templating language)</li>
<li><a href="turtle/index.html">Turtle</a></li>
<li><a href="vb/index.html">VB.NET</a></li>
<li><a href="vbscript/index.html">VBScript</a></li>
Expand Down
4 changes: 2 additions & 2 deletions mode/jade/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<script src="jade.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/javascript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="javascript.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
6 changes: 3 additions & 3 deletions mode/javascript/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
var jsonldMode = parserConfig.jsonld;
var jsonMode = parserConfig.json || jsonldMode;
var isTS = parserConfig.typescript;
var wordRE = parserConfig.wordCharacters || /[\w$]/;
var wordRE = parserConfig.wordCharacters || /[\w$\xa1-\uffff]/;

// Tokenizer

Expand Down Expand Up @@ -590,7 +590,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
}
function maybeArrayComprehension(type) {
if (type == "for") return pass(comprehension, expect("]"));
if (type == ",") return cont(commasep(expressionNoComma, "]"));
if (type == ",") return cont(commasep(maybeexpressionNoComma, "]"));
return pass(commasep(expressionNoComma, "]"));
}
function comprehension(type) {
Expand Down Expand Up @@ -656,7 +656,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
else return lexical.indented + (closing ? 0 : indentUnit);
},

electricChars: ":{}",
electricInput: /^\s*(?:case .*?:|default:|\{|\})$/,
blockCommentStart: jsonMode ? null : "/*",
blockCommentEnd: jsonMode ? null : "*/",
lineComment: jsonMode ? null : "//",
Expand Down
4 changes: 2 additions & 2 deletions mode/javascript/json-ld.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="javascript.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id="nav">
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"/></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"/></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
7 changes: 7 additions & 0 deletions mode/javascript/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@
MT("scary_regexp",
"[string-2 /foo[[/]]bar/];");

MT("indent_strange_array",
"[keyword var] [variable x] [operator =] [[",
" [number 1],,",
" [number 2],",
"]];",
"[number 10];");

var jsonld_mode = CodeMirror.getMode(
{indentUnit: 2},
{name: "javascript", jsonld: true}
Expand Down
4 changes: 2 additions & 2 deletions mode/javascript/typescript.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="javascript.js"></script>
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
<div id=nav>
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
<a href="http://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png"></a>

<ul>
<li><a href="../../index.html">Home</a>
<li><a href="../../doc/manual.html">Manual</a>
<li><a href="https://github.com/marijnh/codemirror">Code</a>
<li><a href="https://github.com/codemirror/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
Expand Down
Loading