5 changes: 5 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ Andrey Lushnikov
Andy Joslin
Andy Kimball
Andy Li
Angelo
angelozerr
angelo.zerr@gmail.com
Ankit
Ankit Ahuja
Ansel Santosa
Anthony Dugois
Anthony Grimes
Anton Kovalyov
AQNOUCH Mohammed
Expand All @@ -71,6 +73,7 @@ Blaine G
blukat29
boomyjee
borawjm
Brad Metcalf
Brandon Frohs
Brandon Wamboldt
Brett Zamir
Expand Down Expand Up @@ -309,6 +312,7 @@ mbarkhau
Metatheos
Micah Dubinko
Michael Grey
Michael Kaminsky
Michael Lehenbauer
Michael Zhou
Michal Dorner
Expand Down Expand Up @@ -391,6 +395,7 @@ sandeepshetty
Sander AKA Redsandro
santec
Sascha Peilicke
satamas
satchmorun
sathyamoorthi
SCLINIC\jdecker
Expand Down
11 changes: 11 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ should be asked on the
- Submit a pull request
([how to create a pull request](https://help.github.com/articles/fork-a-repo))

By contributing code to CodeMirror you

- agree to license the contributed code under CodeMirror's [MIT
license](http://codemirror.net/LICENSE).

- confirm that you have the right to contribute and license the code
in question. (Either you hold all rights on the code, or the rights
holder has explicitly granted the right to use it like this,
through a compatible open source license or through a direct
agreement with you.)

### Coding standards

- 2 spaces per indentation level, no tabs.
Expand Down
8 changes: 4 additions & 4 deletions addon/edit/continuelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
})(function(CodeMirror) {
"use strict";

var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)\.)(\s*)/,
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)\.)(\s*)$/,
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,
unorderedListRE = /[*+-]\s/;

CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
Expand All @@ -37,10 +37,10 @@
});
replacements[i] = "\n";
} else {
var indent = match[1], after = match[4];
var indent = match[1], after = match[5];
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
? match[2]
: (parseInt(match[3], 10) + 1) + ".";
: (parseInt(match[3], 10) + 1) + match[4];

replacements[i] = "\n" + indent + bullet + after;
}
Expand Down
6 changes: 3 additions & 3 deletions addon/hint/sql-hint.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@

if (columns) {
addMatches(result, string, columns, function(w) {
var tableInsert = table;
if (alias == true) tableInsert = aliasTable;
if (typeof w == "string") {
var tableInsert = table;
if (alias == true) tableInsert = aliasTable;
w = tableInsert + "." + w;
} else {
w = shallowClone(w);
w.text = table + "." + w.text;
w.text = tableInsert + "." + w.text;
}
return useBacktick ? insertBackticks(w) : w;
});
Expand Down
80 changes: 69 additions & 11 deletions addon/runmode/runmode.node.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,37 @@

/* Just enough of CodeMirror to run runMode under node.js */

// declare global: StringStream
function splitLines(string){return string.split(/\r\n?|\n/);};

function splitLines(string){ return string.split(/\r?\n|\r/); };
// Counts the column offset in a string, taking tabs into account.
// Used mostly to find indentation.
var countColumn = function(string, end, tabSize, startIndex, startValue) {
if (end == null) {
end = string.search(/[^\s\u00a0]/);
if (end == -1) end = string.length;
}
for (var i = startIndex || 0, n = startValue || 0;;) {
var nextTab = string.indexOf("\t", i);
if (nextTab < 0 || nextTab >= end)
return n + (end - i);
n += nextTab - i;
n += tabSize - (n % tabSize);
i = nextTab + 1;
}
};

function StringStream(string) {
function StringStream(string, tabSize) {
this.pos = this.start = 0;
this.string = string;
this.tabSize = tabSize || 8;
this.lastColumnPos = this.lastColumnValue = 0;
this.lineStart = 0;
}
};

StringStream.prototype = {
eol: function() {return this.pos >= this.string.length;},
sol: function() {return this.pos == 0;},
peek: function() {return this.string.charAt(this.pos) || null;},
sol: function() {return this.pos == this.lineStart;},
peek: function() {return this.string.charAt(this.pos) || undefined;},
next: function() {
if (this.pos < this.string.length)
return this.string.charAt(this.pos++);
Expand All @@ -42,8 +60,17 @@ StringStream.prototype = {
if (found > -1) {this.pos = found; return true;}
},
backUp: function(n) {this.pos -= n;},
column: function() {return this.start - this.lineStart;},
indentation: function() {return 0;},
column: function() {
if (this.lastColumnPos < this.start) {
this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
this.lastColumnPos = this.start;
}
return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
},
indentation: function() {
return countColumn(this.string, null, this.tabSize) -
(this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0);
},
match: function(pattern, consume, caseInsensitive) {
if (typeof pattern == "string") {
var cased = function(str) {return caseInsensitive ? str.toLowerCase() : str;};
Expand Down Expand Up @@ -94,11 +121,42 @@ exports.resolveMode = function(spec) {
if (typeof spec == "string") return {name: spec};
else return spec || {name: "null"};
};

function copyObj(obj, target, overwrite) {
if (!target) target = {};
for (var prop in obj)
if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
target[prop] = obj[prop];
return target;
}

// This can be used to attach properties to mode objects from
// outside the actual mode definition.
var modeExtensions = exports.modeExtensions = {};
exports.extendMode = function(mode, properties) {
var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
copyObj(properties, exts);
};

exports.getMode = function(options, spec) {
spec = exports.resolveMode(spec);
var spec = exports.resolveMode(spec);
var mfactory = modes[spec.name];
if (!mfactory) throw new Error("Unknown mode: " + spec);
return mfactory(options, spec);
if (!mfactory) return exports.getMode(options, "text/plain");
var modeObj = mfactory(options, spec);
if (modeExtensions.hasOwnProperty(spec.name)) {
var exts = modeExtensions[spec.name];
for (var prop in exts) {
if (!exts.hasOwnProperty(prop)) continue;
if (modeObj.hasOwnProperty(prop)) modeObj["_" + prop] = modeObj[prop];
modeObj[prop] = exts[prop];
}
}
modeObj.name = spec.name;
if (spec.helperType) modeObj.helperType = spec.helperType;
if (spec.modeProps) for (var prop in spec.modeProps)
modeObj[prop] = spec.modeProps[prop];

return modeObj;
};
exports.registerHelper = exports.registerGlobalHelper = Math.min;

Expand Down
6 changes: 4 additions & 2 deletions addon/tern/tern.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
this.options = options || {};
var plugins = this.options.plugins || (this.options.plugins = {});
if (!plugins.doc_comment) plugins.doc_comment = true;
this.docs = Object.create(null);
if (this.options.useWorker) {
this.server = new WorkerServer(this);
} else {
Expand All @@ -69,7 +70,6 @@
plugins: plugins
});
}
this.docs = Object.create(null);
this.trackChange = function(doc, change) { trackChange(self, doc, change); };

this.cachedArgHints = null;
Expand Down Expand Up @@ -124,6 +124,8 @@
var self = this;
var doc = findDoc(this, cm.getDoc());
var request = buildRequest(this, doc, query, pos);
var extraOptions = request.query && this.options.queryOptions && this.options.queryOptions[request.query.type]
if (extraOptions) for (var prop in extraOptions) request.query[prop] = extraOptions[prop];

this.server.request(request, function (error, data) {
if (!error && self.options.responseFilter)
Expand Down Expand Up @@ -442,7 +444,7 @@

function atInterestingExpression(cm) {
var pos = cm.getCursor("end"), tok = cm.getTokenAt(pos);
if (tok.start < pos.ch && (tok.type == "comment" || tok.type == "string")) return false;
if (tok.start < pos.ch && tok.type == "comment") return false;
return /[\w)\]]/.test(cm.getLine(pos.line).slice(Math.max(pos.ch - 1, 0), pos.ch + 1));
}

Expand Down
1 change: 0 additions & 1 deletion bin/release
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ function rewriteJSON(pack) {
return pack.replace(/"version":"\d+\.\d+\.\d+"/, "\"version\":\"" + number + "\"");
}
rewrite("package.json", rewriteJSON);
rewrite("bower.json", rewriteJSON);
rewrite("doc/manual.html", function(manual) {
return manual.replace(/>version \d+\.\d+\.\d+<\/span>/, ">version " + number + "</span>");
});
Expand Down
1 change: 0 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "codemirror",
"version":"5.3.0",
"main": ["lib/codemirror.js", "lib/codemirror.css"],
"ignore": [
"**/.*",
Expand Down
22 changes: 20 additions & 2 deletions demo/requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,32 @@ <h2>RequireJS module loading demo</h2>

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

<button id="markdown">Dynamically load Markdown mode</button>

<script type="text/javascript">
require(["../lib/codemirror", "../mode/htmlmixed/htmlmixed",
"../addon/hint/show-hint", "../addon/hint/html-hint"], function(CodeMirror) {
require.config({
packages: [{
name: "codemirror",
location: "../",
main: "lib/codemirror"
}]
});
require(["codemirror", "codemirror/mode/htmlmixed/htmlmixed",
"codemirror/addon/hint/show-hint", "codemirror/addon/hint/html-hint",
"codemirror/addon/mode/loadmode"], function(CodeMirror) {
editor = CodeMirror(document.getElementById("code"), {
mode: "text/html",
extraKeys: {"Ctrl-Space": "autocomplete"},
value: document.documentElement.innerHTML
});

CodeMirror.modeURL = "codemirror/mode/%N/%N";
document.getElementById("markdown").addEventListener("click", function() {
CodeMirror.requireMode("markdown", function() {
editor.replaceRange("This is **Markdown**.\n\n", {line: 0, ch: 0});
editor.setOption("mode", "markdown");
});
});
});
</script>
</article>
Expand Down
5 changes: 5 additions & 0 deletions doc/compress.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ <h2>Script compression helper</h2>
<input type="hidden" id="download" name="download" value="codemirror-compressed.js"/>
<p>Version: <select id="version" onchange="setVersion(this);" style="padding: 1px;">
<option value="http://codemirror.net/">HEAD</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.4.0;f=">5.4</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.3.0;f=">5.3</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.2.0;f=">5.2</option>
<option value="http://marijnhaverbeke.nl/git/codemirror?a=blob_plain;hb=5.1.0;f=">5.1</option>
Expand Down Expand Up @@ -127,7 +128,9 @@ <h2>Script compression helper</h2>
<option value="http://codemirror.net/mode/ebnf/ebnf.js">ebnf.js</option>
<option value="http://codemirror.net/mode/ecl/ecl.js">ecl.js</option>
<option value="http://codemirror.net/mode/eiffel/eiffel.js">eiffel.js</option>
<option value="http://codemirror.net/mode/elm/elm.js">eml.js</option>
<option value="http://codemirror.net/mode/erlang/erlang.js">erlang.js</option>
<option value="http://codemirror.net/mode/factor/factor.js">factor.js</option>
<option value="http://codemirror.net/mode/forth/forth.js">forth.js</option>
<option value="http://codemirror.net/mode/fortran/fortran.js">fortran.js</option>
<option value="http://codemirror.net/mode/gfm/gfm.js">gfm.js</option>
Expand Down Expand Up @@ -184,6 +187,7 @@ <h2>Script compression helper</h2>
<option value="http://codemirror.net/mode/solr/solr.js">solr.js</option>
<option value="http://codemirror.net/mode/soy/soy.js">soy.js</option>
<option value="http://codemirror.net/mode/sparql/sparql.js">sparql.js</option>
<option value="http://codemirror.net/mode/swift/swift.js">swift.js</option>
<option value="http://codemirror.net/mode/spreadsheet/spreadsheet.js">spreadsheet.js</option>
<option value="http://codemirror.net/mode/stylus/stylus.js">stylus.js</option>
<option value="http://codemirror.net/mode/sql/sql.js">sql.js</option>
Expand All @@ -198,6 +202,7 @@ <h2>Script compression helper</h2>
<option value="http://codemirror.net/mode/ttcn/ttcn.js">ttcn.js</option>
<option value="http://codemirror.net/mode/ttcn-cfg/ttcn-cfg.js">ttcn-cfg.js</option>
<option value="http://codemirror.net/mode/turtle/turtle.js">turtle.js</option>
<option value="http://codemirror.net/mode/twig/twig.js">twig.js</option>
<option value="http://codemirror.net/mode/vb/vb.js">vb.js</option>
<option value="http://codemirror.net/mode/vbscript/vbscript.js">vbscript.js</option>
<option value="http://codemirror.net/mode/velocity/velocity.js">velocity.js</option>
Expand Down
17 changes: 15 additions & 2 deletions doc/manual.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<section class=first id=overview>
<h2 style="position: relative">
User manual and reference guide
<span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 5.3.0</span>
<span style="color: #888; font-size: 1rem; position: absolute; right: 0; bottom: 0">version 5.4.0</span>
</h2>

<p>CodeMirror is a code-editor component that can be embedded in
Expand Down Expand Up @@ -181,7 +181,20 @@ <h3 id=modloader>Module loaders</h3>
});</pre>

<p>It will automatically load the modes that the mixed HTML mode
depends on (XML, JavaScript, and CSS).</p>
depends on (XML, JavaScript, and CSS). Do <em>not</em> use
RequireJS' <code>paths</code> option to configure the path to
CodeMirror, since it will break loading submodules through
relative paths. Use
the <a href="http://requirejs.org/docs/api.html#packages"><code>packages</code></a>
configuration option instead, as in:</p>

<pre data-lang=javascript>require.config({
packages: [{
name: "codemirror",
location: "../path/to/codemirror",
main: "lib/codemirror"
}]
});</pre>

</section>

Expand Down
2 changes: 1 addition & 1 deletion doc/realworld.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h2>CodeMirror real-world uses</h2>
<li><a href="http://jsbin.com">jsbin.com</a> (JS playground)</li>
<li><a href="http://tool.jser.com/preprocessor">JSER preprocessor</a></li>
<li><a href="https://github.com/kucherenko/jscpd">jscpd</a> (code duplication detector)</li>
<li><a href="http://jsfiddle.com">jsfiddle.com</a> (another JS playground)</li>
<li><a href="http://jsfiddle.net">JSFiddle</a> (another JS playground)</li>
<li><a href="http://www.jshint.com/">JSHint</a> (JS linter)</li>
<li><a href="http://jumpseller.com/">Jumpseller</a> (online store builder)</li>
<li><a href="http://kl1p.com/cmtest/1">kl1p</a> (paste service)</li>
Expand Down
13 changes: 11 additions & 2 deletions doc/releases.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,22 @@ <h2>Release notes and version history</h2>

<h2>Version 5.x</h2>

<p class="rel">25-06-2015: <a href="http://codemirror.net/codemirror-5.4.zip">Version 5.4</a>:</p>

<ul class="rel-note">
<li>New modes: <a href="../mode/twig/index.html">Twig</a>, <a href="../mode/elm/index.html">Elm</a>, <a href="../mode/factor/index.html">Factor</a>, <a href="../mode/swift/index.html">Swift</a></li>
<li>Prefer clipboard API (if available) when pasting</li>
<li>Refined definition highlighting in <a href="../mode/clike/index.html">clike</a> mode</li>
<li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.3.0...5.4.0">list of patches</a></li>
</ul>

<p class="rel">20-05-2015: <a href="http://codemirror.net/codemirror-5.3.zip">Version 5.3</a>:</p>

<ul class="rel-note">
<li>Fix several regressions in the <a href="manual.html#addon_show-hint"><code>show-hint</code></a> addon (<code>completeSingle</code> option, <code>"shown"</code> and <code>"close"</code> events)</li>
<li>The <a href="../demo/vim.html">vim mode</a> was <a href="manual.html#vimapi">documented</a></li>
<li>The <a href="../demo/vim.html">vim mode</a> API was <a href="manual.html#vimapi">documented</a></li>
<li>New modes: <a href="../mode/asn.1/index.html">ASN.1</a>, <a href="../mode/ttcn/index.html">TTCN</a>, and <a href="../mode/ttcn-cfg/index.html">TTCN-CFG</a></li>
<li>The <a href="../mode/clike/index.html">clike</a> mode can now deep-indent <code>switch</code> statements, and rougly recognizes types and defined identifiers</li>
<li>The <a href="../mode/clike/index.html">clike</a> mode can now deep-indent <code>switch</code> statements, and roughly recognizes types and defined identifiers</li>
<li>Full <a href="https://github.com/codemirror/CodeMirror/compare/5.2.0...5.3.0">list of patches</a></li>
</ul>

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h2>This is CodeMirror</h2>
</div>
</div>
<div class=actionsleft>
Get the current version: <a href="http://codemirror.net/codemirror.zip">5.3</a>.<br>
Get the current version: <a href="http://codemirror.net/codemirror.zip">5.4</a>.<br>
You can see the <a href="https://github.com/codemirror/codemirror" title="Github repository">code</a> or<br>
read the <a href="doc/releases.html">release notes</a>.<br>
There is a <a href="doc/compress.html">minification helper</a>.
Expand Down
Loading