4 changes: 2 additions & 2 deletions mode/jinja2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="jinja2.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
13 changes: 11 additions & 2 deletions mode/julia/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="julia.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 Expand Up @@ -51,6 +51,14 @@ <h2>Julia mode</h2>
as123
function_name!

#unicode identifiers
# a = x\ddot
a⃗ = ẍ
# a = v\dot
a⃗ = v̇
#F\vec = m \cdotp a\vec
F⃗ = m·a⃗

#literal identifier multiples
3x
4[1, 2, 3]
Expand All @@ -60,6 +68,7 @@ <h2>Julia mode</h2>
x[end-1]
x={"julia"=>"language of technical computing"}


#exception handling
try
f()
Expand Down
2 changes: 1 addition & 1 deletion mode/julia/julia.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {

var operators = parserConf.operators || /^\.?[|&^\\%*+\-<>!=\/]=?|\?|~|:|\$|\.[<>]|<<=?|>>>?=?|\.[<>=]=|->?|\/\/|\bin\b/;
var delimiters = parserConf.delimiters || /^[;,()[\]{}]/;
var identifiers = parserConf.identifiers|| /^[_A-Za-z][_A-Za-z0-9]*!*/;
var identifiers = parserConf.identifiers|| /^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*!*/;
var blockOpeners = ["begin", "function", "type", "immutable", "let", "macro", "for", "while", "quote", "if", "else", "elseif", "try", "finally", "catch", "do"];
var blockClosers = ["end", "else", "elseif", "catch", "finally"];
var keywordList = ['if', 'else', 'elseif', 'while', 'for', 'begin', 'let', 'end', 'do', 'try', 'catch', 'finally', 'return', 'break', 'continue', 'global', 'local', 'const', 'export', 'import', 'importall', 'using', 'function', 'macro', 'module', 'baremodule', 'type', 'immutable', 'quote', 'typealias', 'abstract', 'bitstype', 'ccall'];
Expand Down
4 changes: 2 additions & 2 deletions mode/kotlin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="kotlin.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/livescript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="livescript.js"></script>
<style>.CodeMirror {font-size: 80%;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/lua/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<script src="lua.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/markdown/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
.cm-s-default .cm-trailing-space-new-line:before {position: absolute; content: "\21B5"; color: #777;}
</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: 4 additions & 3 deletions mode/markdown/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,15 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
state.formatting = false;

if (stream.sol()) {
var forceBlankLine = stream.match(/^\s*$/, true) || state.header;
var forceBlankLine = !!state.header;

// Reset state.header
state.header = 0;

if (forceBlankLine) {
if (stream.match(/^\s*$/, true) || forceBlankLine) {
state.prevLineHasContent = false;
return blankLine(state);
blankLine(state);
return forceBlankLine ? this.token(stream, state) : null;
} else {
state.prevLineHasContent = state.thisLineHasContent;
state.thisLineHasContent = true;
Expand Down
230 changes: 129 additions & 101 deletions mode/meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,106 +11,134 @@
})(function(CodeMirror) {
"use strict";

CodeMirror.modeInfo = [
{name: "APL", mime: "text/apl", mode: "apl"},
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk"},
{name: "C", mime: "text/x-csrc", mode: "clike"},
{name: "C++", mime: "text/x-c++src", mode: "clike"},
{name: "Cobol", mime: "text/x-cobol", mode: "cobol"},
{name: "Java", mime: "text/x-java", mode: "clike"},
{name: "C#", mime: "text/x-csharp", mode: "clike"},
{name: "Scala", mime: "text/x-scala", mode: "clike"},
{name: "Clojure", mime: "text/x-clojure", mode: "clojure"},
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript"},
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp"},
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher"},
{name: "CSS", mime: "text/css", mode: "css"},
{name: "D", mime: "text/x-d", mode: "d"},
{name: "diff", mime: "text/x-diff", mode: "diff"},
{name: "DTD", mime: "application/xml-dtd", mode: "dtd"},
{name: "Dylan", mime: "text/x-dylan", mode: "dylan"},
{name: "ECL", mime: "text/x-ecl", mode: "ecl"},
{name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel"},
{name: "Erlang", mime: "text/x-erlang", mode: "erlang"},
{name: "Fortran", mime: "text/x-fortran", mode: "fortran"},
{name: "F#", mime: "text/x-fsharp", mode: "mllike"},
{name: "Gas", mime: "text/x-gas", mode: "gas"},
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin"},
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm"},
{name: "Go", mime: "text/x-go", mode: "go"},
{name: "Groovy", mime: "text/x-groovy", mode: "groovy"},
{name: "HAML", mime: "text/x-haml", mode: "haml"},
{name: "Haskell", mime: "text/x-haskell", mode: "haskell"},
{name: "Haxe", mime: "text/x-haxe", mode: "haxe"},
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded"},
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded"},
{name: "JavaServer Pages", mime: "application/x-jsp", mode: "htmlembedded"},
{name: "HTML", mime: "text/html", mode: "htmlmixed"},
{name: "HTTP", mime: "message/http", mode: "http"},
{name: "Jade", mime: "text/x-jade", mode: "jade"},
{name: "JavaScript", mime: "text/javascript", mode: "javascript"},
{name: "JavaScript", mime: "application/javascript", mode: "javascript"},
{name: "JSON", mime: "application/x-json", mode: "javascript"},
{name: "JSON", mime: "application/json", mode: "javascript"},
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript"},
{name: "TypeScript", mime: "application/typescript", mode: "javascript"},
{name: "Jinja2", mime: null, mode: "jinja2"},
{name: "Julia", mime: "text/x-julia", mode: "julia"},
{name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin"},
{name: "LESS", mime: "text/x-less", mode: "css"},
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript"},
{name: "Lua", mime: "text/x-lua", mode: "lua"},
{name: "Markdown (GitHub-flavour)", mime: "text/x-markdown", mode: "markdown"},
{name: "mIRC", mime: "text/mirc", mode: "mirc"},
{name: "Modelica", mime: "text/x-modelica", mode: "modelica"},
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx"},
{name: "NTriples", mime: "text/n-triples", mode: "ntriples"},
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike"},
{name: "Octave", mime: "text/x-octave", mode: "octave"},
{name: "Pascal", mime: "text/x-pascal", mode: "pascal"},
{name: "PEG.js", mime: null, mode: "pegjs"},
{name: "Perl", mime: "text/x-perl", mode: "perl"},
{name: "PHP", mime: "text/x-php", mode: "php"},
{name: "PHP(HTML)", mime: "application/x-httpd-php", mode: "php"},
{name: "Pig", mime: "text/x-pig", mode: "pig"},
{name: "Plain Text", mime: "text/plain", mode: "null"},
{name: "Properties files", mime: "text/x-properties", mode: "properties"},
{name: "Python", mime: "text/x-python", mode: "python"},
{name: "Puppet", mime: "text/x-puppet", mode: "puppet"},
{name: "Cython", mime: "text/x-cython", mode: "python"},
{name: "R", mime: "text/x-rsrc", mode: "r"},
{name: "reStructuredText", mime: "text/x-rst", mode: "rst"},
{name: "Ruby", mime: "text/x-ruby", mode: "ruby"},
{name: "Rust", mime: "text/x-rustsrc", mode: "rust"},
{name: "Sass", mime: "text/x-sass", mode: "sass"},
{name: "Scheme", mime: "text/x-scheme", mode: "scheme"},
{name: "SCSS", mime: "text/x-scss", mode: "css"},
{name: "Shell", mime: "text/x-sh", mode: "shell"},
{name: "Sieve", mime: "application/sieve", mode: "sieve"},
{name: "Slim", mime: "text/x-slim", mode: "slim"},
{name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk"},
{name: "Smarty", mime: "text/x-smarty", mode: "smarty"},
{name: "SmartyMixed", mime: "text/x-smarty", mode: "smartymixed"},
{name: "Solr", mime: "text/x-solr", mode: "solr"},
{name: "SPARQL", mime: "application/x-sparql-query", mode: "sparql"},
{name: "SQL", mime: "text/x-sql", mode: "sql"},
{name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
{name: "sTeX", mime: "text/x-stex", mode: "stex"},
{name: "LaTeX", mime: "text/x-latex", mode: "stex"},
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog"},
{name: "Tcl", mime: "text/x-tcl", mode: "tcl"},
{name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
{name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
{name: "TOML", mime: "text/x-toml", mode: "toml"},
{name: "Turtle", mime: "text/turtle", mode: "turtle"},
{name: "VB.NET", mime: "text/x-vb", mode: "vb"},
{name: "VBScript", mime: "text/vbscript", mode: "vbscript"},
{name: "Velocity", mime: "text/velocity", mode: "velocity"},
{name: "Verilog", mime: "text/x-verilog", mode: "verilog"},
{name: "XML", mime: "application/xml", mode: "xml"},
{name: "XQuery", mime: "application/xquery", mode: "xquery"},
{name: "YAML", mime: "text/x-yaml", mode: "yaml"},
{name: "Z80", mime: "text/x-z80", mode: "z80"}
];
CodeMirror.modeInfo = [
{name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
{name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk"},
{name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]},
{name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "hpp", "h++"]},
{name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
{name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"]},
{name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj"]},
{name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"]},
{name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"]},
{name: "Cypher", mime: "application/x-cypher-query", mode: "cypher"},
{name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
{name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
{name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
{name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
{name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
{name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
{name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
{name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
{name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
{name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
{name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
{name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
{name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"]},
{name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
{name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
{name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm"},
{name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
{name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy"]},
{name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
{name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
{name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
{name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
{name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"]},
{name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"]},
{name: "HTTP", mime: "message/http", mode: "http"},
{name: "Jade", mime: "text/x-jade", mode: "jade", ext: ["jade"]},
{name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
{name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"]},
{name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
mode: "javascript", ext: ["js"]},
{name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"]},
{name: "JSON-LD", mime: "application/ld+json", mode: "javascript"},
{name: "Jinja2", mime: "null", mode: "jinja2"},
{name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
{name: "Kotlin", mime: "text/x-kotlin", mode: "kotlin", ext: ["kt"]},
{name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
{name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"]},
{name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
{name: "Markdown (GitHub-flavour)", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
{name: "mIRC", mime: "text/mirc", mode: "mirc"},
{name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
{name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
{name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
{name: "MySQL", mime: "text/x-mysql", mode: "sql"},
{name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx"},
{name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
{name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
{name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
{name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
{name: "PEG.js", mime: "null", mode: "pegjs"},
{name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
{name: "PHP", mime: "application/x-httpd-php", mode: "php", ext: ["php", "php3", "php4", "php5", "phtml"]},
{name: "Pig", mime: "text/x-pig", mode: "pig"},
{name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
{name: "PLSQL", mime: "text/x-plsql", mode: "sql"},
{name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"]},
{name: "Python", mime: "text/x-python", mode: "python", ext: ["py", "pyw"]},
{name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
{name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
{name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r"]},
{name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"]},
{name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"]},
{name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
{name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
{name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
{name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
{name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
{name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"]},
{name: "Sieve", mime: "application/sieve", mode: "sieve"},
{name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim"},
{name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
{name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
{name: "SmartyMixed", mime: "text/x-smarty", mode: "smartymixed"},
{name: "Solr", mime: "text/x-solr", mode: "solr"},
{name: "SPARQL", mime: "application/x-sparql-query", mode: "sparql", ext: ["sparql"]},
{name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
{name: "MariaDB", mime: "text/x-mariadb", mode: "sql"},
{name: "sTeX", mime: "text/x-stex", mode: "stex"},
{name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"]},
{name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
{name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
{name: "Textile", mime: "text/x-textile", mode: "textile"},
{name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
{name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
{name: "TOML", mime: "text/x-toml", mode: "toml"},
{name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
{name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
{name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"]},
{name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
{name: "VBScript", mime: "text/vbscript", mode: "vbscript"},
{name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
{name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
{name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd"]},
{name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
{name: "YAML", mime: "text/x-yaml", mode: "yaml", ext: ["yaml"]},
{name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]}
];
// Ensure all modes have a mime property for backwards compatibility
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
var info = CodeMirror.modeInfo[i];
if (info.mimes) info.mime = info.mimes[0];
}

CodeMirror.findModeByMIME = function(mime) {
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
var info = CodeMirror.modeInfo[i];
if (info.mime == mime) return info;
if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
if (info.mimes[j] == mime) return info;
}
};

CodeMirror.findModeByExtension = function(ext) {
for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
var info = CodeMirror.modeInfo[i];
if (info.ext) for (var j = 0; j < info.ext.length; j++)
if (info.ext[j] == ext) return info;
}
};
});
4 changes: 2 additions & 2 deletions mode/mirc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="mirc.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/mllike/index.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 href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/modelica/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
<script src="modelica.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/nginx/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 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/ntriples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,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
4 changes: 2 additions & 2 deletions mode/octave/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="octave.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/octave/octave.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ CodeMirror.defineMode("octave", function() {
var doubleDelimiters = new RegExp("^((!=)|(\\+=)|(\\-=)|(\\*=)|(/=)|(&=)|(\\|=)|(\\^=))");
var tripleDelimiters = new RegExp("^((>>=)|(<<=))");
var expressionEnd = new RegExp("^[\\]\\)]");
var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
var identifiers = new RegExp("^[_A-Za-z\xa1-\uffff][_A-Za-z0-9\xa1-\uffff]*");

var builtins = wordRegexp([
'error', 'eval', 'function', 'abs', 'acos', 'atan', 'asin', 'cos',
Expand Down
4 changes: 2 additions & 2 deletions mode/pascal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="pascal.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/pegjs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
</head>
<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 href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/perl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="perl.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/perl/perl.js
Original file line number Diff line number Diff line change
Expand Up @@ -788,8 +788,8 @@ CodeMirror.defineMode("perl",function(){
style:null,
tail:null};},
token:function(stream,state){
return (state.tokenize||tokenPerl)(stream,state);},
electricChars:"{}"};});
return (state.tokenize||tokenPerl)(stream,state);}
};});

CodeMirror.registerHelper("wordChars", "perl", /[\w$]/);

Expand Down
4 changes: 2 additions & 2 deletions mode/php/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
<script src="php.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
81 changes: 37 additions & 44 deletions mode/php/php.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,32 @@
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
function heredoc(delim) {
return function(stream, state) {
if (stream.match(delim)) state.tokenize = null;
else stream.skipToEnd();
return "string";
};
}

// Helper for stringWithEscapes
function matchSequence(list) {
if (list.length == 0) return stringWithEscapes;
function matchSequence(list, end) {
if (list.length == 0) return stringWithEscapes(end);
return function (stream, state) {
var patterns = list[0];
for (var i = 0; i < patterns.length; i++) if (stream.match(patterns[i][0])) {
state.tokenize = matchSequence(list.slice(1));
state.tokenize = matchSequence(list.slice(1), end);
return patterns[i][1];
}
state.tokenize = stringWithEscapes;
state.tokenize = stringWithEscapes(end);
return "string";
};
}
function stringWithEscapes(stream, state) {
var escaped = false, next, end = false;

if (stream.current() == '"') return "string";

function stringWithEscapes(closing) {
return function(stream, state) { return stringWithEscapes_(stream, state, closing); };
}
function stringWithEscapes_(stream, state, closing) {
// "Complex" syntax
if (stream.match("${", false) || stream.match("{$", false)) {
state.tokenize = null;
return "string";
}

// Simple syntax
if (stream.match(/\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
if (stream.match(/^\$[a-zA-Z_][a-zA-Z0-9_]*/)) {
// After the variable name there may appear array or object operator.
if (stream.match("[", false)) {
// Match array operator
Expand All @@ -59,31 +51,29 @@
[/\$[a-zA-Z_][a-zA-Z0-9_]*/, "variable-2"],
[/[\w\$]+/, "variable"]],
[["]", null]]
]);
], closing);
}
if (stream.match(/\-\>\w/, false)) {
// Match object operator
state.tokenize = matchSequence([
[["->", null]],
[[/[\w]+/, "variable"]]
]);
], closing);
}
return "variable-2";
}

var escaped = false;
// Normal string
while (
!stream.eol() &&
(!stream.match("{$", false)) &&
(!stream.match(/(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false) || escaped)
) {
next = stream.next();
if (!escaped && next == '"') { end = true; break; }
escaped = !escaped && next == "\\";
}
if (end) {
state.tokenize = null;
state.phpEncapsStack.pop();
while (!stream.eol() &&
(escaped || (!stream.match("{$", false) &&
!stream.match(/^(\$[a-zA-Z_][a-zA-Z0-9_]*|\$\{)/, false)))) {
if (!escaped && stream.match(closing)) {
state.tokenize = null;
state.tokStack.pop(); state.tokStack.pop();
break;
}
escaped = stream.next() == "\\" && !escaped;
}
return "string";
}
Expand Down Expand Up @@ -115,8 +105,12 @@
"<": function(stream, state) {
if (stream.match(/<</)) {
stream.eatWhile(/[\w\.]/);
state.tokenize = heredoc(stream.current().slice(3));
return state.tokenize(stream, state);
var delim = stream.current().slice(3);
if (delim) {
(state.tokStack || (state.tokStack = [])).push(delim, 0);
state.tokenize = stringWithEscapes(delim);
return "string";
}
}
return false;
},
Expand All @@ -131,22 +125,21 @@
}
return false;
},
'"': function(stream, state) {
if (!state.phpEncapsStack)
state.phpEncapsStack = [];
state.phpEncapsStack.push(0);
state.tokenize = stringWithEscapes;
return state.tokenize(stream, state);
'"': function(_stream, state) {
(state.tokStack || (state.tokStack = [])).push('"', 0);
state.tokenize = stringWithEscapes('"');
return "string";
},
"{": function(_stream, state) {
if (state.phpEncapsStack && state.phpEncapsStack.length > 0)
state.phpEncapsStack[state.phpEncapsStack.length - 1]++;
if (state.tokStack && state.tokStack.length)
state.tokStack[state.tokStack.length - 1]++;
return false;
},
"}": function(_stream, state) {
if (state.phpEncapsStack && state.phpEncapsStack.length > 0)
if (--state.phpEncapsStack[state.phpEncapsStack.length - 1] == 0)
state.tokenize = stringWithEscapes;
if (state.tokStack && state.tokStack.length > 0 &&
!--state.tokStack[state.tokStack.length - 1]) {
state.tokenize = stringWithEscapes(state.tokStack[state.tokStack.length - 2]);
}
return false;
}
}
Expand Down
6 changes: 6 additions & 0 deletions mode/php/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,10 @@
'[keyword echo] ' + m3[2] + ';',
'[keyword echo] [string "end"];',
'[meta ?>]');

MT("variable_interpolation_heredoc",
"[meta <?php]",
"[string <<<here]",
"[string doc ][variable-2 $]{[variable yay]}[string more]",
"[string here]; [comment // normal]");
})();
4 changes: 2 additions & 2 deletions mode/pig/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="pig.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/properties/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="properties.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
4 changes: 2 additions & 2 deletions mode/puppet/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
24 changes: 18 additions & 6 deletions mode/python/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="python.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 Expand Up @@ -65,13 +65,25 @@ <h2>Python mode</h2>
a.b
a.b.c

#Unicode identifiers on Python3
# a = x\ddot
a⃗ = ẍ
# a = v\dot
a⃗ = v̇

#F\vec = m \cdot a\vec
F⃗ = m•a⃗

# Operators
+ - * / % & | ^ ~ < >
== != <= >= <> << >> // **
and or not in is

#infix matrix multiplication operator (PEP 465)
A @ B

# Delimiters
() [] {} , : ` = ; @ . # Note that @ and . require the proper context.
() [] {} , : ` = ; @ . # Note that @ and . require the proper context on Python 2.
+= -= *= /= %= &= |= ^=
//= >>= <<= **=

Expand Down Expand Up @@ -146,7 +158,7 @@ <h2>Cython mode</h2>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: {name: "python",
version: 2,
version: 3,
singleLineStringErrors: false},
lineNumbers: true,
indentUnit: 4,
Expand All @@ -171,12 +183,12 @@ <h2>Configuration Options for Python mode:</h2>
<h2>Advanced Configuration Options:</h2>
<p>Usefull for superset of python syntax like Enthought enaml, IPython magics and questionmark help</p>
<ul>
<li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre></li>
<li>singleOperators - RegEx - Regular Expression for single operator matching, default : <pre>^[\\+\\-\\*/%&amp;|\\^~&lt;&gt;!]</pre> including <pre>@</pre> on Python 3</li>
<li>singleDelimiters - RegEx - Regular Expression for single delimiter matching, default : <pre>^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]</pre></li>
<li>doubleOperators - RegEx - Regular Expression for double operators matching, default : <pre>^((==)|(!=)|(&lt;=)|(&gt;=)|(&lt;&gt;)|(&lt;&lt;)|(&gt;&gt;)|(//)|(\\*\\*))</pre></li>
<li>doubleDelimiters - RegEx - Regular Expressoin for double delimiters matching, default : <pre>^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&amp;=)|(\\|=)|(\\^=))</pre></li>
<li>tripleDelimiters - RegEx - Regular Expression for triple delimiters matching, default : <pre>^((//=)|(&gt;&gt;=)|(&lt;&lt;=)|(\\*\\*=))</pre></li>
<li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre></li>
<li>identifiers - RegEx - Regular Expression for identifier, default : <pre>^[_A-Za-z][_A-Za-z0-9]*</pre> on Python 2 and <pre>^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*</pre> on Python 3.</li>
<li>extra_keywords - list of string - List of extra words ton consider as keywords</li>
<li>extra_builtins - list of string - List of extra words ton consider as builtins</li>
</ul>
Expand Down
21 changes: 17 additions & 4 deletions mode/python/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,20 @@
CodeMirror.defineMode("python", function(conf, parserConf) {
var ERRORCLASS = "error";

var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
var singleDelimiters = parserConf.singleDelimiters || new RegExp("^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]");
var doubleOperators = parserConf.doubleOperators || new RegExp("^((==)|(!=)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
var doubleDelimiters = parserConf.doubleDelimiters || new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
var tripleDelimiters = parserConf.tripleDelimiters || new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");

if (parserConf.version && parseInt(parserConf.version, 10) == 3){
// since http://legacy.python.org/dev/peps/pep-0465/ @ is also an operator
var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!@]");
var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z\u00A1-\uFFFF][_A-Za-z0-9\u00A1-\uFFFF]*");
} else {
var singleOperators = parserConf.singleOperators || new RegExp("^[\\+\\-\\*/%&|\\^~<>!]");
var identifiers = parserConf.identifiers|| new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
}

var hangingIndent = parserConf.hangingIndent || conf.indentUnit;

var myKeywords = commonKeywords, myBuiltins = commonBuiltins;
Expand Down Expand Up @@ -252,8 +260,13 @@
}

// Handle decorators
if (current == "@")
return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
if (current == "@"){
if(parserConf.version && parseInt(parserConf.version, 10) == 3){
return stream.match(identifiers, false) ? "meta" : "operator";
} else {
return stream.match(identifiers, false) ? "meta" : ERRORCLASS;
}
}

if ((style == "variable" || style == "builtin")
&& state.lastStyle == "meta")
Expand Down
4 changes: 2 additions & 2 deletions mode/q/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="q.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/r/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
.cm-s-default span.cm-arg-is { color: brown; }
</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/rpm/changes/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<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/rpm/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<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/rst/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="rst.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/ruby/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
23 changes: 12 additions & 11 deletions mode/ruby/ruby.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,16 @@ CodeMirror.defineMode("ruby", function(config) {
}

// Symbols can't start by a digit
if (stream.eat(/[a-zA-Z$@_]/)) {
stream.eatWhile(/[\w]/);
if (stream.eat(/[a-zA-Z$@_\xa1-\uffff]/)) {
stream.eatWhile(/[\w$\xa1-\uffff]/);
// Only one ? ! = is allowed and only as the last character
stream.eat(/[\?\!\=]/);
return "atom";
}
return "operator";
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_]/)) {
} else if (ch == "@" && stream.match(/^@?[a-zA-Z_\xa1-\uffff]/)) {
stream.eat("@");
stream.eatWhile(/[\w]/);
stream.eatWhile(/[\w\xa1-\uffff]/);
return "variable-2";
} else if (ch == "$") {
if (stream.eat(/[a-zA-Z_]/)) {
Expand All @@ -127,8 +127,8 @@ CodeMirror.defineMode("ruby", function(config) {
stream.next(); // Must be a special global like $: or $!
}
return "variable-3";
} else if (/[a-zA-Z_]/.test(ch)) {
stream.eatWhile(/[\w]/);
} else if (/[a-zA-Z_\xa1-\uffff]/.test(ch)) {
stream.eatWhile(/[\w\xa1-\uffff]/);
stream.eat(/[\?\!]/);
if (stream.eat(":")) return "atom";
return "ident";
Expand All @@ -149,17 +149,18 @@ CodeMirror.defineMode("ruby", function(config) {
}
}

function tokenBaseUntilBrace() {
var depth = 1;
function tokenBaseUntilBrace(depth) {
if (!depth) depth = 1;
return function(stream, state) {
if (stream.peek() == "}") {
depth--;
if (depth == 0) {
if (depth == 1) {
state.tokenize.pop();
return state.tokenize[state.tokenize.length-1](stream, state);
} else {
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth - 1);
}
} else if (stream.peek() == "{") {
depth++;
state.tokenize[state.tokenize.length - 1] = tokenBaseUntilBrace(depth + 1);
}
return tokenBase(stream, state);
};
Expand Down
4 changes: 2 additions & 2 deletions mode/rust/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="rust.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/rust/rust.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
CodeMirror.defineMode("rust", function() {
var indentUnit = 4, altIndentUnit = 2;
var valKeywords = {
"if": "if-style", "while": "if-style", "else": "else-style",
"if": "if-style", "while": "if-style", "loop": "else-style", "else": "else-style",
"do": "else-style", "ret": "else-style", "fail": "else-style",
"break": "atom", "cont": "atom", "const": "let", "resource": "fn",
"let": "let", "fn": "fn", "for": "for", "alt": "alt", "iface": "iface",
"impl": "impl", "type": "type", "enum": "enum", "mod": "mod",
"as": "op", "true": "atom", "false": "atom", "assert": "op", "check": "op",
"claim": "op", "native": "ignore", "unsafe": "ignore", "import": "else-style",
"export": "else-style", "copy": "op", "log": "op", "log_err": "op",
"use": "op", "bind": "op", "self": "atom"
"use": "op", "bind": "op", "self": "atom", "struct": "enum"
};
var typeKeywords = function() {
var keywords = {"fn": "fn", "block": "fn", "obj": "obj"};
Expand Down
4 changes: 2 additions & 2 deletions mode/sass/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="sass.js"></script>
<style>.CodeMirror {border: 1px solid #ddd; font-size:12px; 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 href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/scheme/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="scheme.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/shell/index.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 href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/sieve/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="sieve.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/slim/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
<script src="slim.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/smalltalk/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
.CodeMirror-gutter pre {color: white; font-weight: bold;}
</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/smarty/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="smarty.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/smartymixed/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
<script src="../../mode/smarty/smarty.js"></script>
<script src="../../mode/smartymixed/smartymixed.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
6 changes: 5 additions & 1 deletion mode/smartymixed/smartymixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,11 @@ CodeMirror.defineMode("smartymixed", function(config) {

var parsers = {
html: function(stream, state) {
if (!state.inLiteral && stream.match(regs.htmlHasLeftDelimeter, false) && state.htmlMixedState.htmlState.tagName === null) {
var htmlTagName = state.htmlMixedState.htmlState.context && state.htmlMixedState.htmlState.context.tagName
? state.htmlMixedState.htmlState.context.tagName
: null;

if (!state.inLiteral && stream.match(regs.htmlHasLeftDelimeter, false) && htmlTagName === null) {
state.tokenize = parsers.smarty;
state.localMode = smartyMode;
state.localState = smartyMode.startState(htmlMixedMode.indent(state.htmlMixedState, ""));
Expand Down
4 changes: 2 additions & 2 deletions mode/solr/index.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 href="../index.html">Language modes</a>
Expand Down
4 changes: 2 additions & 2 deletions mode/sparql/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="sparql.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/sql/index.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 href="../index.html">Language modes</a>
Expand Down
3 changes: 2 additions & 1 deletion mode/sql/sql.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ CodeMirror.defineMode("sql", function(config, parserConfig) {
while ((ch = stream.next()) != null) {
if (ch == "`" && !stream.eat("`")) return "variable-2";
}
return null;
stream.backUp(stream.current().length - 1);
return stream.eatWhile(/\w/) ? "variable-2" : null;
}

// variable token
Expand Down
4 changes: 2 additions & 2 deletions mode/stex/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="stex.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
3 changes: 2 additions & 1 deletion mode/stex/stex.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ CodeMirror.defineMode("stex", function() {
},
token: function(stream, state) {
return state.f(stream, state);
}
},
lineComment: "%"
};
});

Expand Down
4 changes: 2 additions & 2 deletions mode/tcl/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="tcl.js"></script>
<script src="../../addon/scroll/scrollpastend.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
2 changes: 1 addition & 1 deletion mode/tcl/tcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ CodeMirror.defineMode("tcl", function() {
return "comment";
}
else {
stream.eatWhile(/[\w\$_{}]/);
stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
var word = stream.current().toLowerCase();
if (keywords && keywords.propertyIsEnumerable(word))
return "keyword";
Expand Down
191 changes: 191 additions & 0 deletions mode/textile/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
<!doctype html>

<title>CodeMirror: Textile mode</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="textile.js"></script>
<style>.CodeMirror {background: #f8f8f8;}</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/marijnh/codemirror">Code</a>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class="active" href="#">Textile</a>
</ul>
</div>

<article>
<h2>Textile mode</h2>
<form><textarea id="code" name="code">
h1. Textile Mode

A paragraph without formatting.

p. A simple Paragraph.


h2. Phrase Modifiers

Here are some simple phrase modifiers: *strong*, _emphasis_, **bold**, and __italic__.

A ??citation??, -deleted text-, +inserted text+, some ^superscript^, and some ~subscript~.

A %span element% and @code element@

A "link":http://example.com, a "link with (alt text)":urlAlias

[urlAlias]http://example.com/

An image: !http://example.com/image.png! and an image with a link: !http://example.com/image.png!:http://example.com

A sentence with a footnote.[123]

fn123. The footnote is defined here.

Registered(r), Trademark(tm), and Copyright(c)


h2. Headers

h1. Top level
h2. Second level
h3. Third level
h4. Fourth level
h5. Fifth level
h6. Lowest level


h2. Lists

* An unordered list
** foo bar
*** foo bar
**** foo bar
** foo bar

# An ordered list
## foo bar
### foo bar
#### foo bar
## foo bar

- definition list := description
- another item := foo bar
- spanning ines :=
foo bar

foo bar =:


h2. Attributes

Layouts and phrase modifiers can be modified with various kinds of attributes: alignment, CSS ID, CSS class names, language, padding, and CSS styles.

h3. Alignment

div<. left align
div>. right align

h3. CSS ID and class name

You are a %(my-id#my-classname) rad% person.

h3. Language

p[en_CA]. Strange weather, eh?

h3. Horizontal Padding

p(())). 2em left padding, 3em right padding

h3. CSS styling

p{background: red}. Fire!


h2. Table

|_. Header 1 |_. Header 2 |
|{background:#ddd}. Cell with background| Normal |
|\2. Cell spanning 2 columns |
|/2. Cell spanning 2 rows |(cell-class). one |
| two |
|>. Right aligned cell |<. Left aligned cell |


h3. A table with attributes:

table(#prices).
|Adults|$5|
|Children|$2|


h2. Code blocks

bc.
function factorial(n) {
if (n === 0) {
return 1;
}
return n * factorial(n - 1);
}

pre..
,,,,,,
o#'9MMHb':'-,o,
.oH":HH$' "' ' -*R&o,
dMMM*""'`' .oM"HM?.
,MMM' "HLbd< ?&H\
.:MH ."\ ` MM MM&b
. "*H - &MMMMMMMMMH:
. dboo MMMMMMMMMMMM.
. dMMMMMMb *MMMMMMMMMP.
. MMMMMMMP *MMMMMP .
`#MMMMM MM6P ,
' `MMMP" HM*`,
' :MM .- ,
'. `#?.. . ..'
-. . .-
''-.oo,oo.-''

\. _(9>
\==_)
-'=

h2. Temporarily disabling textile markup

notextile. Don't __touch this!__

Surround text with double-equals to disable textile inline. Example: Use ==*asterisks*== for *strong* text.


h2. HTML

Some block layouts are simply textile versions of HTML tags with the same name, like @div@, @pre@, and @p@. HTML tags can also exist on their own line:

<section>
<h1>Title</h1>
<p>Hello!</p>
</section>

</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: "text/x-textile"
});
</script>

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

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

</article>
406 changes: 406 additions & 0 deletions mode/textile/test.js

Large diffs are not rendered by default.

553 changes: 553 additions & 0 deletions mode/textile/textile.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions mode/tiddlywiki/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<script src="tiddlywiki.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/tiki/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="tiki.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/toml/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="toml.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
63 changes: 63 additions & 0 deletions mode/tornado/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!doctype html>

<title>CodeMirror: Tornado template mode</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/overlay.js"></script>
<script src="../xml/xml.js"></script>
<script src="../htmlmixed/htmlmixed.js"></script>
<script src="tornado.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"><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>
</ul>
<ul>
<li><a href="../index.html">Language modes</a>
<li><a class=active href="#">Tornado</a>
</ul>
</div>

<article>
<h2>Tornado template mode</h2>
<form><textarea id="code" name="code">
<!doctype html>
<html>
<head>
<title>My Tornado web application</title>
</head>
<body>
<h1>
{{ title }}
</h1>
<ul class="my-list">
{% for item in items %}
<li>{% item.name %}</li>
{% empty %}
<li>You have no items in your list.</li>
{% end %}
</ul>
</body>
</html>
</textarea></form>

<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
lineNumbers: true,
mode: "tornado",
indentUnit: 4,
indentWithTabs: true
});
</script>

<p>Mode for HTML with embedded Tornado template markup.</p>

<p><strong>MIME types defined:</strong> <code>text/x-tornado</code></p>
</article>
68 changes: 68 additions & 0 deletions mode/tornado/tornado.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// 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"), require("../htmlmixed/htmlmixed"),
require("../../addon/mode/overlay"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../htmlmixed/htmlmixed",
"../../addon/mode/overlay"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";

CodeMirror.defineMode("tornado:inner", function() {
var keywords = ["and","as","assert","autoescape","block","break","class","comment","context",
"continue","datetime","def","del","elif","else","end","escape","except",
"exec","extends","false","finally","for","from","global","if","import","in",
"include","is","json_encode","lambda","length","linkify","load","module",
"none","not","or","pass","print","put","raise","raw","return","self","set",
"squeeze","super","true","try","url_escape","while","with","without","xhtml_escape","yield"];
keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");

function tokenBase (stream, state) {
stream.eatWhile(/[^\{]/);
var ch = stream.next();
if (ch == "{") {
if (ch = stream.eat(/\{|%|#/)) {
state.tokenize = inTag(ch);
return "tag";
}
}
}
function inTag (close) {
if (close == "{") {
close = "}";
}
return function (stream, state) {
var ch = stream.next();
if ((ch == close) && stream.eat("}")) {
state.tokenize = tokenBase;
return "tag";
}
if (stream.match(keywords)) {
return "keyword";
}
return close == "#" ? "comment" : "string";
};
}
return {
startState: function () {
return {tokenize: tokenBase};
},
token: function (stream, state) {
return state.tokenize(stream, state);
}
};
});

CodeMirror.defineMode("tornado", function(config) {
var htmlBase = CodeMirror.getMode(config, "text/html");
var tornadoInner = CodeMirror.getMode(config, "tornado:inner");
return CodeMirror.overlayMode(htmlBase, tornadoInner);
});

CodeMirror.defineMIME("text/x-tornado", "tornado");
});
4 changes: 2 additions & 2 deletions mode/turtle/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="turtle.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/vb/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
.CodeMirror pre { font-family: Inconsolata; font-size: 14px}
</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/vbscript/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="vbscript.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/velocity/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="velocity.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/verilog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<script src="verilog.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
38 changes: 36 additions & 2 deletions mode/verilog/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,49 @@
""
);

MT("export_function_does_not_indent",
MT("export_function_one_line_does_not_indent",
"[keyword export] [string \"DPI-C\"] [keyword function] [variable helloFromSV];",
""
);

MT("export_task_does_not_indent",
MT("export_task_one_line_does_not_indent",
"[keyword export] [string \"DPI-C\"] [keyword task] [variable helloFromSV];",
""
);

MT("export_function_two_lines_indents_properly",
"[keyword export]",
" [string \"DPI-C\"] [keyword function] [variable helloFromSV];",
""
);

MT("export_task_two_lines_indents_properly",
"[keyword export]",
" [string \"DPI-C\"] [keyword task] [variable helloFromSV];",
""
);

MT("import_function_one_line_does_not_indent",
"[keyword import] [string \"DPI-C\"] [keyword function] [variable helloFromC];",
""
);

MT("import_task_one_line_does_not_indent",
"[keyword import] [string \"DPI-C\"] [keyword task] [variable helloFromC];",
""
);

MT("import_package_single_line_does_not_indent",
"[keyword import] [variable p]::[variable x];",
"[keyword import] [variable p]::[variable y];",
""
);

MT("covergoup_with_function_indents_properly",
"[keyword covergroup] [variable cg] [keyword with] [keyword function] [variable sample][bracket (][keyword bit] [variable b][bracket )];",
" [variable c] : [keyword coverpoint] [variable c];",
"[keyword endgroup]: [variable cg]",
""
);

})();
23 changes: 14 additions & 9 deletions mode/verilog/verilog.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
// Block openings which are closed by a matching keyword in the form of ("end" + keyword)
// E.g. "task" => "endtask"
var blockKeywords = words(
"case checker class clocking config function generate group interface module package" +
"case checker class clocking config function generate interface module package" +
"primitive program property specify sequence table task"
);

Expand All @@ -94,11 +94,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
openClose["casez"] = "endcase";
openClose["do" ] = "while";
openClose["fork" ] = "join;join_any;join_none";

// This is a bit of a hack but will work to not indent after import/epxort statements
// as long as the function/task name is on the same line
openClose["import"] = "function;task";
openClose["export"] = "function;task";
openClose["covergroup"] = "endgroup";

for (var i in noIndentKeywords) {
var keyword = noIndentKeywords[i];
Expand All @@ -107,7 +103,8 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
}
}

var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else for foreach forever if initial repeat while");
// Keywords which open statements that are ended with a semi-colon
var statementKeywords = words("always always_comb always_ff always_latch assert assign assume else export for foreach forever if import initial repeat while");

function tokenBase(stream, state) {
var ch = stream.peek();
Expand Down Expand Up @@ -320,8 +317,16 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
else if (curPunc == "newstatement") {
pushContext(state, stream.column(), "statement");
} else if (curPunc == "newblock") {
var close = openClose[curKeyword];
pushContext(state, stream.column(), close);
if (curKeyword == "function" && ctx && (ctx.type == "statement" || ctx.type == "endgroup")) {
// The 'function' keyword can appear in some other contexts where it actually does not
// indicate a function (import/export DPI and covergroup definitions).
// Do nothing in this case
} else if (curKeyword == "task" && ctx && ctx.type == "statement") {
// Same thing for task
} else {
var close = openClose[curKeyword];
pushContext(state, stream.column(), close);
}
}

state.startOfLine = false;
Expand Down
4 changes: 2 additions & 2 deletions mode/xml/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="xml.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/xquery/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
4 changes: 2 additions & 2 deletions mode/yaml/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="yaml.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
4 changes: 2 additions & 2 deletions mode/z80/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
<script src="z80.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 package.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",
"description": "In-browser code editing made bearable",
"licenses": [{"type": "MIT",
Expand All @@ -9,12 +9,12 @@
"scripts": {"test": "node ./test/run.js"},
"devDependencies": {"node-static": "0.6.0",
"phantomjs": "1.9.2-5"},
"bugs": "http://github.com/marijnh/CodeMirror/issues",
"bugs": "http://github.com/codemirror/CodeMirror/issues",
"keywords": ["JavaScript", "CodeMirror", "Editor"],
"homepage": "http://codemirror.net",
"maintainers":[{"name": "Marijn Haverbeke",
"email": "marijnh@gmail.com",
"web": "http://marijnhaverbeke.nl"}],
"repository": {"type": "git",
"url": "https://github.com/marijnh/CodeMirror.git"}
"url": "https://github.com/codemirror/CodeMirror.git"}
}
6 changes: 4 additions & 2 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,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="#">Test suite</a>
Expand Down Expand Up @@ -102,6 +102,8 @@ <h2>Test Suite</h2>
<script src="../mode/shell/test.js"></script>
<script src="../mode/stex/stex.js"></script>
<script src="../mode/stex/test.js"></script>
<script src="../mode/textile/textile.js"></script>
<script src="../mode/textile/test.js"></script>
<script src="../mode/verilog/verilog.js"></script>
<script src="../mode/verilog/test.js"></script>
<script src="../mode/xquery/xquery.js"></script>
Expand Down
123 changes: 88 additions & 35 deletions test/vim_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,15 @@ testVim('dd_lastline', function(cm, vim, helpers) {
eq(expectedLineCount, cm.lineCount());
helpers.assertCursorAt(cm.lineCount() - 1, 0);
});
testVim('dd_only_line', function(cm, vim, helpers) {
cm.setCursor(0, 0);
var expectedRegister = cm.getValue() + "\n";
helpers.doKeys('d','d');
eq(1, cm.lineCount());
eq('', cm.getValue());
var register = helpers.getRegisterController().getRegister();
eq(expectedRegister, register.toString());
}, { value: "thisistheonlyline" });
// Yank commands should behave the exact same as d commands, expect that nothing
// gets deleted.
testVim('yw_repeat', function(cm, vim, helpers) {
Expand Down Expand Up @@ -902,6 +911,7 @@ testVim('c_visual_block', function(cm, vim, helpers) {
replacement.pop();
cm.replaceSelections(replacement);
eq('1hello\n5hello\nahellofg', cm.getValue());
helpers.doKeys('<Esc>');
cm.setCursor(2, 3);
helpers.doKeys('<C-v>', '2', 'k', 'h', 'C');
replacement = new Array(cm.listSelections().length+1).join('world ').split(' ');
Expand All @@ -916,7 +926,7 @@ testVim('c_visual_block_replay', function(cm, vim, helpers) {
replacement.pop();
cm.replaceSelections(replacement);
eq('1fo4\n5fo8\nafodefg', cm.getValue());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
cm.setCursor(0, 0);
helpers.doKeys('.');
eq('foo4\nfoo8\nfoodefg', cm.getValue());
Expand Down Expand Up @@ -1115,6 +1125,39 @@ testEdit('di]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'di]', 'a\t[]b');
testEdit('da[_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da[', 'a\tb');
testEdit('da]_middle_spc', 'a\t[\n\tbar\n]b', /r/, 'da]', 'a\tb');

function testSelection(name, before, pos, keys, sel) {
return testVim(name, function(cm, vim, helpers) {
var ch = before.search(pos)
var line = before.substring(0, ch).split('\n').length - 1;
if (line) {
ch = before.substring(0, ch).split('\n').pop().length;
}
cm.setCursor(line, ch);
helpers.doKeys.apply(this, keys.split(''));
eq(sel, cm.getSelection());
}, {value: before});
}
testSelection('viw_middle_spc', 'foo \tbAr\t baz', /A/, 'viw', 'bAr');
testSelection('vaw_middle_spc', 'foo \tbAr\t baz', /A/, 'vaw', 'bAr\t ');
testSelection('viw_middle_punct', 'foo \tbAr,\t baz', /A/, 'viw', 'bAr');
testSelection('vaW_middle_punct', 'foo \tbAr,\t baz', /A/, 'vaW', 'bAr,\t ');
testSelection('viw_start_spc', 'foo \tbAr\t baz', /b/, 'viw', 'bAr');
testSelection('viw_end_spc', 'foo \tbAr\t baz', /r/, 'viw', 'bAr');
testSelection('viw_eol', 'foo \tbAr', /r/, 'viw', 'bAr');
testSelection('vi{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'vi{', '\n\tbar\n\t');
testSelection('va{_middle_spc', 'a{\n\tbar\n\t}b', /r/, 'va{', '{\n\tbar\n\t}');

testVim('mouse_select', function(cm, vim, helpers) {
cm.setSelection(Pos(0, 2), Pos(0, 4), {origin: '*mouse'});
is(cm.state.vim.visualMode);
is(!cm.state.vim.visualLine);
is(!cm.state.vim.visualBlock);
helpers.doKeys('<Esc>');
is(!cm.somethingSelected());
helpers.doKeys('g', 'v');
eq('cd', cm.getSelection());
}, {value: 'abcdef'});

// Operator-motion tests
testVim('D', function(cm, vim, helpers) {
cm.setCursor(0, 3);
Expand Down Expand Up @@ -1210,15 +1253,16 @@ testVim('i', function(cm, vim, helpers) {
testVim('i_repeat', function(cm, vim, helpers) {
helpers.doKeys('3', 'i');
cm.replaceRange('test', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
eq('testtesttest', cm.getValue());
helpers.assertCursorAt(0, 11);
}, { value: '' });
testVim('i_repeat_delete', function(cm, vim, helpers) {
cm.setCursor(0, 4);
helpers.doKeys('2', 'i');
cm.replaceRange('z', cm.getCursor());
helpers.doInsertModeKeys('Backspace', 'Backspace', 'Esc');
helpers.doInsertModeKeys('Backspace', 'Backspace');
helpers.doKeys('<Esc>');
eq('abe', cm.getValue());
helpers.assertCursorAt(0, 1);
}, { value: 'abcde' });
Expand All @@ -1245,7 +1289,7 @@ testVim('I_repeat', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('3', 'I');
cm.replaceRange('test', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
eq('testtesttestblah', cm.getValue());
helpers.assertCursorAt(0, 11);
}, { value: 'blah' });
Expand All @@ -1268,7 +1312,7 @@ testVim('o_repeat', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('3', 'o');
cm.replaceRange('test', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
eq('\ntest\ntest\ntest', cm.getValue());
helpers.assertCursorAt(3, 3);
}, { value: '' });
Expand Down Expand Up @@ -1384,7 +1428,7 @@ testVim('r_visual_block', function(cm, vim, helpers) {
eq('1 l\n5 l\nalllefg', cm.getValue());
cm.setCursor(2, 0);
helpers.doKeys('o');
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
cm.replaceRange('\t\t', cm.getCursor());
helpers.doKeys('<C-v>', 'h', 'h', 'r', 'r');
eq('1 l\n5 l\nalllefg\nrrrrrrrr', cm.getValue());
Expand Down Expand Up @@ -1787,13 +1831,13 @@ testVim('reselect_visual_block', function(cm, vim, helpers) {
testVim('s_normal', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('s');
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
eq('ac', cm.getValue());
}, { value: 'abc'});
testVim('s_visual', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('v', 's');
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.assertCursorAt(0, 0);
eq('ac', cm.getValue());
}, { value: 'abc'});
Expand Down Expand Up @@ -1877,7 +1921,7 @@ testVim('v_paste_from_register', function(cm, vim, helpers) {
testVim('S_normal', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('j', 'S');
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.assertCursorAt(1, 0);
eq('aa\n\ncc', cm.getValue());
}, { value: 'aa\nbb\ncc'});
Expand Down Expand Up @@ -1927,7 +1971,7 @@ testVim('blockwise_paste_last_line', function(cm, vim, helpers) {
testVim('S_visual', function(cm, vim, helpers) {
cm.setCursor(0, 1);
helpers.doKeys('v', 'j', 'S');
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.assertCursorAt(0, 0);
eq('\ncc', cm.getValue());
}, { value: 'aa\nbb\ncc'});
Expand Down Expand Up @@ -2109,22 +2153,22 @@ testVim('macro_insert', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('q', 'a', '0', 'i');
cm.replaceRange('foo', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('q', '@', 'a');
eq('foofoo', cm.getValue());
}, { value: ''});
testVim('macro_insert_repeat', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('q', 'a', '$', 'a');
cm.replaceRange('larry.', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('a');
cm.replaceRange('curly.', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('q');
helpers.doKeys('a');
cm.replaceRange('moe.', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('@', 'a');
// At this point, the most recent edit should be the 2nd insert change
// inside the macro, i.e. "curly.".
Expand Down Expand Up @@ -2186,10 +2230,10 @@ testVim('macro_parens', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('q', 'z', 'i');
cm.replaceRange('(', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('e', 'a');
cm.replaceRange(')', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('q');
helpers.doKeys('w', '@', 'z');
helpers.doKeys('w', '@', 'z');
Expand All @@ -2199,13 +2243,13 @@ testVim('macro_overwrite', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('q', 'z', '0', 'i');
cm.replaceRange('I ', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('q');
helpers.doKeys('e');
// Now replace the macro with something else.
helpers.doKeys('q', 'z', 'a');
cm.replaceRange('.', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('q');
helpers.doKeys('e', '@', 'z');
helpers.doKeys('e', '@', 'z');
Expand Down Expand Up @@ -2296,11 +2340,11 @@ testVim('macro_register', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('q', 'a', 'i');
cm.replaceRange('gangnam', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('q');
helpers.doKeys('q', 'b', 'o');
cm.replaceRange('style', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('q');
cm.openDialog = helpers.fakeOpenDialog('registers');
cm.openNotification = helpers.fakeOpenNotification(function(text) {
Expand All @@ -2313,7 +2357,7 @@ testVim('._register', function(cm,vim,helpers) {
cm.setCursor(0,0);
helpers.doKeys('i');
cm.replaceRange('foo',cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
cm.openDialog = helpers.fakeOpenDialog('registers');
cm.openNotification = helpers.fakeOpenNotification(function(text) {
is(/\.\s+foo/.test(text));
Expand Down Expand Up @@ -2464,7 +2508,7 @@ testVim('._repeat', function(cm, vim, helpers) {
testVim('._insert', function(cm, vim, helpers) {
helpers.doKeys('i');
cm.replaceRange('test', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('.');
eq('testestt', cm.getValue());
helpers.assertCursorAt(0, 6);
Expand All @@ -2473,7 +2517,7 @@ testVim('._insert_repeat', function(cm, vim, helpers) {
helpers.doKeys('i');
cm.replaceRange('test', cm.getCursor());
cm.setCursor(0, 4);
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('2', '.');
eq('testesttestt', cm.getValue());
helpers.assertCursorAt(0, 10);
Expand All @@ -2482,7 +2526,7 @@ testVim('._repeat_insert', function(cm, vim, helpers) {
helpers.doKeys('3', 'i');
cm.replaceRange('te', cm.getCursor());
cm.setCursor(0, 2);
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('.');
eq('tetettetetee', cm.getValue());
helpers.assertCursorAt(0, 10);
Expand All @@ -2491,15 +2535,15 @@ testVim('._insert_o', function(cm, vim, helpers) {
helpers.doKeys('o');
cm.replaceRange('z', cm.getCursor());
cm.setCursor(1, 1);
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
helpers.doKeys('.');
eq('\nz\nz', cm.getValue());
helpers.assertCursorAt(2, 0);
}, { value: ''});
testVim('._insert_o_repeat', function(cm, vim, helpers) {
helpers.doKeys('o');
cm.replaceRange('z', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
cm.setCursor(1, 0);
helpers.doKeys('2', '.');
eq('\nz\nz\nz', cm.getValue());
Expand All @@ -2508,7 +2552,7 @@ testVim('._insert_o_repeat', function(cm, vim, helpers) {
testVim('._insert_o_indent', function(cm, vim, helpers) {
helpers.doKeys('o');
cm.replaceRange('z', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
cm.setCursor(1, 2);
helpers.doKeys('.');
eq('{\n z\n z', cm.getValue());
Expand All @@ -2517,7 +2561,7 @@ testVim('._insert_o_indent', function(cm, vim, helpers) {
testVim('._insert_cw', function(cm, vim, helpers) {
helpers.doKeys('c', 'w');
cm.replaceRange('test', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
cm.setCursor(0, 3);
helpers.doKeys('2', 'l');
helpers.doKeys('.');
Expand All @@ -2529,7 +2573,7 @@ testVim('._insert_cw_repeat', function(cm, vim, helpers) {
// changes. Will conform to that behavior.
helpers.doKeys('c', 'w');
cm.replaceRange('test', cm.getCursor());
helpers.doInsertModeKeys('Esc');
helpers.doKeys('<Esc>');
cm.setCursor(0, 4);
helpers.doKeys('l');
helpers.doKeys('2', '.');
Expand All @@ -2539,15 +2583,17 @@ testVim('._insert_cw_repeat', function(cm, vim, helpers) {
testVim('._delete', function(cm, vim, helpers) {
cm.setCursor(0, 5);
helpers.doKeys('i');
helpers.doInsertModeKeys('Backspace', 'Esc');
helpers.doInsertModeKeys('Backspace');
helpers.doKeys('<Esc>');
helpers.doKeys('.');
eq('zace', cm.getValue());
helpers.assertCursorAt(0, 1);
}, { value: 'zabcde'});
testVim('._delete_repeat', function(cm, vim, helpers) {
cm.setCursor(0, 6);
helpers.doKeys('i');
helpers.doInsertModeKeys('Backspace', 'Esc');
helpers.doInsertModeKeys('Backspace');
helpers.doKeys('<Esc>');
helpers.doKeys('2', '.');
eq('zzce', cm.getValue());
helpers.assertCursorAt(0, 1);
Expand Down Expand Up @@ -2664,7 +2710,7 @@ testVim('fc,;', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('f', '4');
cm.setCursor(0, 0);
helpers.doKeys('c', ';', 'Esc');
helpers.doKeys('c', ';', '<Esc>');
eq('56789', cm.getValue());
helpers.doKeys('u');
cm.setCursor(0, 9);
Expand All @@ -2675,7 +2721,7 @@ testVim('Fc,;', function(cm, vim, helpers) {
cm.setCursor(0, 9);
helpers.doKeys('F', '4');
cm.setCursor(0, 9);
helpers.doKeys('c', ';', 'Esc');
helpers.doKeys('c', ';', '<Esc>');
eq('01239', cm.getValue());
helpers.doKeys('u');
cm.setCursor(0, 0);
Expand All @@ -2686,7 +2732,7 @@ testVim('tc,;', function(cm, vim, helpers) {
cm.setCursor(0, 0);
helpers.doKeys('t', '4');
cm.setCursor(0, 0);
helpers.doKeys('c', ';', 'Esc');
helpers.doKeys('c', ';', '<Esc>');
eq('456789', cm.getValue());
helpers.doKeys('u');
cm.setCursor(0, 9);
Expand All @@ -2697,7 +2743,7 @@ testVim('Tc,;', function(cm, vim, helpers) {
cm.setCursor(0, 9);
helpers.doKeys('T', '4');
cm.setCursor(0, 9);
helpers.doKeys('c', ';', 'Esc');
helpers.doKeys('c', ';', '<Esc>');
eq('012349', cm.getValue());
helpers.doKeys('u');
cm.setCursor(0, 0);
Expand Down Expand Up @@ -3488,6 +3534,13 @@ testVim('ex_map_key2key_visual_api', function(cm, vim, helpers) {

CodeMirror.commands.save = tmp;
});
testVim('ex_imap', function(cm, vim, helpers) {
CodeMirror.Vim.map('jk', '<Esc>', 'insert');
helpers.doKeys('i');
is(vim.insertMode);
helpers.doKeys('j', 'k');
is(!vim.insertMode);
})

// Testing registration of functions as ex-commands and mapping to <Key>-keys
testVim('ex_api_test', function(cm, vim, helpers) {
Expand Down
4 changes: 2 additions & 2 deletions theme/base16-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/

.cm-s-base16-dark.CodeMirror {background: #151515; color: #e0e0e0;}
.cm-s-base16-dark div.CodeMirror-selected {background: #202020 !important;}
.cm-s-base16-dark div.CodeMirror-selected {background: #303030 !important;}
.cm-s-base16-dark .CodeMirror-gutters {background: #151515; border-right: 0px;}
.cm-s-base16-dark .CodeMirror-guttermarker { color: #ac4142; }
.cm-s-base16-dark .CodeMirror-guttermarker-subtle { color: #505050; }
Expand All @@ -32,5 +32,5 @@
.cm-s-base16-dark span.cm-link {color: #aa759f;}
.cm-s-base16-dark span.cm-error {background: #ac4142; color: #b0b0b0;}

.cm-s-base16-dark .CodeMirror-activeline-background {background: #2F2F2F !important;}
.cm-s-base16-dark .CodeMirror-activeline-background {background: #202020 !important;}
.cm-s-base16-dark .CodeMirror-matchingbracket { text-decoration: underline; color: white !important;}
2 changes: 1 addition & 1 deletion theme/mdn-like.css
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
MDN-LIKE Theme - Mozilla
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

The mdn-like theme is inspired on the displayed code examples at: https://developer.mozilla.org/en-US/docs/Web/CSS/animation
Expand Down