diff --git a/addon/comment/comment.js b/addon/comment/comment.js
index c36e176912..1eb9a05c5d 100644
--- a/addon/comment/comment.js
+++ b/addon/comment/comment.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var noOptions = {};
@@ -159,4 +166,4 @@
});
return true;
});
-})();
+});
diff --git a/addon/comment/continuecomment.js b/addon/comment/continuecomment.js
index 0566c74e43..6db3b0a2b9 100644
--- a/addon/comment/continuecomment.js
+++ b/addon/comment/continuecomment.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
var modes = ["clike", "css", "javascript"];
for (var i = 0; i < modes.length; ++i)
CodeMirror.extendMode(modes[i], {blockCommentContinue: " * "});
@@ -59,4 +66,4 @@
cm.addKeyMap(map);
}
});
-})();
+});
diff --git a/addon/dialog/dialog.js b/addon/dialog/dialog.js
index 41d7bf8663..2c26542045 100644
--- a/addon/dialog/dialog.js
+++ b/addon/dialog/dialog.js
@@ -1,6 +1,13 @@
// Open simple dialogs on top of an editor. Relies on dialog.css.
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
function dialogDiv(cm, template, bottom) {
var wrap = cm.getWrapperElement();
var dialog;
@@ -119,4 +126,4 @@
if (duration)
doneTimer = setTimeout(close, options.duration);
});
-})();
+});
diff --git a/addon/display/fullscreen.js b/addon/display/fullscreen.js
index a442f6a433..e39c6e162f 100644
--- a/addon/display/fullscreen.js
+++ b/addon/display/fullscreen.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
@@ -28,4 +35,4 @@
window.scrollTo(info.scrollLeft, info.scrollTop);
cm.refresh();
}
-})();
+});
diff --git a/addon/display/placeholder.js b/addon/display/placeholder.js
index 748afe7275..0fdc9b0d5b 100644
--- a/addon/display/placeholder.js
+++ b/addon/display/placeholder.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
var prev = old && old != CodeMirror.Init;
if (val && !prev) {
@@ -45,4 +52,4 @@
function isEmpty(cm) {
return (cm.lineCount() === 1) && (cm.getLine(0) === "");
}
-})();
+});
diff --git a/addon/edit/closebrackets.js b/addon/edit/closebrackets.js
index 64c56f9530..84b2fc56f1 100644
--- a/addon/edit/closebrackets.js
+++ b/addon/edit/closebrackets.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
var DEFAULT_BRACKETS = "()[]{}''\"\"";
var DEFAULT_EXPLODE_ON_ENTER = "[]{}";
var SPACE_CHAR_REGEX = /\s/;
@@ -112,4 +119,4 @@
});
};
}
-})();
+});
diff --git a/addon/edit/closetag.js b/addon/edit/closetag.js
index 7047e27738..ac6c2fc6d4 100644
--- a/addon/edit/closetag.js
+++ b/addon/edit/closetag.js
@@ -22,7 +22,14 @@
* See demos/closetag.html for a usage example.
*/
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../fold/xml-fold"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
CodeMirror.defineOption("autoCloseTags", false, function(cm, val, old) {
if (old != CodeMirror.Init && old)
cm.removeKeyMap("autoCloseTags");
@@ -106,4 +113,4 @@
if (collection[i] == elt) return i;
return -1;
}
-})();
+});
diff --git a/addon/edit/continuelist.js b/addon/edit/continuelist.js
index a038345b4b..54c7340bbe 100644
--- a/addon/edit/continuelist.js
+++ b/addon/edit/continuelist.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var listRE = /^(\s*)([*+-]|(\d+)\.)(\s*)/,
@@ -25,4 +32,4 @@
cm.replaceSelections(replacements, null, "+insert");
};
-}());
+});
diff --git a/addon/edit/matchbrackets.js b/addon/edit/matchbrackets.js
index 4d0c853a52..dcdee7516b 100644
--- a/addon/edit/matchbrackets.js
+++ b/addon/edit/matchbrackets.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
(document.documentMode == null || document.documentMode < 8);
@@ -93,4 +100,4 @@
CodeMirror.defineExtension("findMatchingBracket", function(pos, strict){
return findMatchingBracket(this, pos, strict);
});
-})();
+});
diff --git a/addon/edit/matchtags.js b/addon/edit/matchtags.js
index f189c1f8ef..2b7d22ed84 100644
--- a/addon/edit/matchtags.js
+++ b/addon/edit/matchtags.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../fold/xml-fold"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../fold/xml-fold"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
CodeMirror.defineOption("matchTags", false, function(cm, val, old) {
@@ -53,4 +60,4 @@
if (other) cm.setSelection(other.to, other.from);
}
};
-})();
+});
diff --git a/addon/edit/trailingspace.js b/addon/edit/trailingspace.js
index f6bb02645d..ec07221e30 100644
--- a/addon/edit/trailingspace.js
+++ b/addon/edit/trailingspace.js
@@ -1,15 +1,24 @@
-CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
- if (prev == CodeMirror.Init) prev = false;
- if (prev && !val)
- cm.removeOverlay("trailingspace");
- else if (!prev && val)
- cm.addOverlay({
- token: function(stream) {
- for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
- if (i > stream.pos) { stream.pos = i; return null; }
- stream.pos = l;
- return "trailingspace";
- },
- name: "trailingspace"
- });
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ CodeMirror.defineOption("showTrailingSpace", false, function(cm, val, prev) {
+ if (prev == CodeMirror.Init) prev = false;
+ if (prev && !val)
+ cm.removeOverlay("trailingspace");
+ else if (!prev && val)
+ cm.addOverlay({
+ token: function(stream) {
+ for (var l = stream.string.length, i = l; i && /\s/.test(stream.string.charAt(i - 1)); --i) {}
+ if (i > stream.pos) { stream.pos = i; return null; }
+ stream.pos = l;
+ return "trailingspace";
+ },
+ name: "trailingspace"
+ });
+ });
});
diff --git a/addon/fold/brace-fold.js b/addon/fold/brace-fold.js
index 2560b2b94c..f0ee62029a 100644
--- a/addon/fold/brace-fold.js
+++ b/addon/fold/brace-fold.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.registerHelper("fold", "brace", function(cm, start) {
var line = start.line, lineText = cm.getLine(line);
var startCh, tokenType;
@@ -45,7 +55,6 @@ CodeMirror.registerHelper("fold", "brace", function(cm, start) {
return {from: CodeMirror.Pos(line, startCh),
to: CodeMirror.Pos(end, endCh)};
});
-CodeMirror.braceRangeFinder = CodeMirror.fold.brace; // deprecated
CodeMirror.registerHelper("fold", "import", function(cm, start) {
function hasImport(line) {
@@ -70,7 +79,6 @@ CodeMirror.registerHelper("fold", "import", function(cm, start) {
}
return {from: cm.clipPos(CodeMirror.Pos(start, has.startCh + 1)), to: end};
});
-CodeMirror.importRangeFinder = CodeMirror.fold["import"]; // deprecated
CodeMirror.registerHelper("fold", "include", function(cm, start) {
function hasInclude(line) {
@@ -90,4 +98,5 @@ CodeMirror.registerHelper("fold", "include", function(cm, start) {
return {from: CodeMirror.Pos(start, has + 1),
to: cm.clipPos(CodeMirror.Pos(end))};
});
-CodeMirror.includeRangeFinder = CodeMirror.fold.include; // deprecated
+
+});
diff --git a/addon/fold/comment-fold.js b/addon/fold/comment-fold.js
index 26e72f09f5..d72c5479a7 100644
--- a/addon/fold/comment-fold.js
+++ b/addon/fold/comment-fold.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
return mode.blockCommentStart && mode.blockCommentEnd;
}, function(cm, start) {
@@ -40,3 +50,5 @@ CodeMirror.registerGlobalHelper("fold", "comment", function(mode) {
return {from: CodeMirror.Pos(line, startCh),
to: CodeMirror.Pos(end, endCh)};
});
+
+});
diff --git a/addon/fold/foldcode.js b/addon/fold/foldcode.js
index 5c00d7093c..4627c81f9d 100644
--- a/addon/fold/foldcode.js
+++ b/addon/fold/foldcode.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
function doFold(cm, pos, options, force) {
@@ -83,4 +90,4 @@
if (cur) return cur;
}
});
-})();
+});
diff --git a/addon/fold/foldgutter.js b/addon/fold/foldgutter.js
index a4f3bb3186..9caba59aad 100644
--- a/addon/fold/foldgutter.js
+++ b/addon/fold/foldgutter.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("./foldcode"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "./foldcode"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
@@ -121,4 +128,4 @@
if (line >= state.from && line < state.to)
updateFoldInfo(cm, line, line + 1);
}
-})();
+});
diff --git a/addon/fold/indent-fold.js b/addon/fold/indent-fold.js
index 434c2bc5ca..d0130836a2 100644
--- a/addon/fold/indent-fold.js
+++ b/addon/fold/indent-fold.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.registerHelper("fold", "indent", function(cm, start) {
var tabSize = cm.getOption("tabSize"), firstLine = cm.getLine(start.line);
if (!/\S/.test(firstLine)) return;
@@ -27,4 +37,5 @@ CodeMirror.registerHelper("fold", "indent", function(cm, start) {
to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
};
});
-CodeMirror.indentRangeFinder = CodeMirror.fold.indent; // deprecated
+
+});
diff --git a/addon/fold/xml-fold.js b/addon/fold/xml-fold.js
index db5aed7041..d554e2fc42 100644
--- a/addon/fold/xml-fold.js
+++ b/addon/fold/xml-fold.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var Pos = CodeMirror.Pos;
@@ -136,8 +143,6 @@
}
}
});
- CodeMirror.tagRangeFinder = CodeMirror.fold.xml; // deprecated
-
CodeMirror.findMatchingTag = function(cm, pos, range) {
var iter = new Iter(cm, pos.line, pos.ch, range);
if (iter.text.indexOf(">") == -1 && iter.text.indexOf("<") == -1) return;
@@ -170,4 +175,4 @@
var iter = new Iter(cm, pos.line, pos.ch, end ? {from: 0, to: end} : null);
return !!findMatchingClose(iter, name);
};
-})();
+});
diff --git a/addon/hint/anyword-hint.js b/addon/hint/anyword-hint.js
index a144768c81..1570664c4f 100644
--- a/addon/hint/anyword-hint.js
+++ b/addon/hint/anyword-hint.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var WORD = /[\w$]+/, RANGE = 500;
@@ -29,4 +36,4 @@
}
return {list: list, from: CodeMirror.Pos(cur.line, start), to: CodeMirror.Pos(cur.line, end)};
});
-})();
+});
diff --git a/addon/hint/css-hint.js b/addon/hint/css-hint.js
index 6789c458ba..9e5b1e132d 100644
--- a/addon/hint/css-hint.js
+++ b/addon/hint/css-hint.js
@@ -1,4 +1,11 @@
-(function () {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../../mode/css/css"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../../mode/css/css"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var pseudoClasses = {link: 1, visited: 1, active: 1, hover: 1, focus: 1,
@@ -43,4 +50,4 @@
to: CodeMirror.Pos(cur.line, end)
};
});
-})();
+});
diff --git a/addon/hint/html-hint.js b/addon/hint/html-hint.js
index cf256851ef..cbe7c61ad4 100755
--- a/addon/hint/html-hint.js
+++ b/addon/hint/html-hint.js
@@ -1,4 +1,13 @@
-(function () {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
var langs = "ab aa af ak sq am ar an hy as av ae ay az bm ba eu be bn bh bi bs br bg my ca ch ce ny zh cv kw co cr hr cs da dv nl dz en eo et ee fo fj fi fr ff gl ka de el gn gu ht ha he hz hi ho hu ia id ie ga ig ik io is it iu ja jv kl kn kr ks kk km ki rw ky kv kg ko ku kj la lb lg li ln lo lt lu lv gv mk mg ms ml mt mi mr mh mn na nv nb nd ne ng nn no ii nr oc oj cu om or os pa pi fa pl ps pt qu rm rn ro ru sa sc sd se sm sg sr gd sn si sk sl so st es su sw ss sv ta te tg th ti bo tk tl tn to tr ts tt tw ty ug uk ur uz ve vi vo wa cy wo fy xh yi yo za zu".split(" ");
var targets = ["_blank", "_self", "_top", "_parent"];
var charsets = ["ascii", "utf-8", "utf-16", "latin1", "latin1"];
@@ -332,6 +341,5 @@
if (options) for (var opt in options) local[opt] = options[opt];
return CodeMirror.hint.xml(cm, local);
}
- CodeMirror.htmlHint = htmlHint; // deprecated
CodeMirror.registerHelper("hint", "html", htmlHint);
-})();
+});
diff --git a/addon/hint/javascript-hint.js b/addon/hint/javascript-hint.js
index c347c206ec..305bb85a29 100644
--- a/addon/hint/javascript-hint.js
+++ b/addon/hint/javascript-hint.js
@@ -1,4 +1,11 @@
-(function () {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
var Pos = CodeMirror.Pos;
function forEach(arr, f) {
@@ -47,7 +54,6 @@
function (e, cur) {return e.getTokenAt(cur);},
options);
};
- CodeMirror.javascriptHint = javascriptHint; // deprecated
CodeMirror.registerHelper("hint", "javascript", javascriptHint);
function getCoffeeScriptToken(editor, cur) {
@@ -71,7 +77,6 @@
function coffeescriptHint(editor, options) {
return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
}
- CodeMirror.coffeescriptHint = coffeescriptHint; // deprecated
CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
@@ -128,4 +133,4 @@
}
return found;
}
-})();
+});
diff --git a/addon/hint/pig-hint.js b/addon/hint/pig-hint.js
index 6c0c523774..02342f0246 100644
--- a/addon/hint/pig-hint.js
+++ b/addon/hint/pig-hint.js
@@ -1,4 +1,11 @@
-(function () {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
function forEach(arr, f) {
@@ -46,7 +53,6 @@
function pigHint(editor) {
return scriptHint(editor, pigKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
}
- CodeMirror.pigHint = pigHint; // deprecated
CodeMirror.registerHelper("hint", "pig", pigHint);
var pigKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "
@@ -118,4 +124,4 @@
}
return found;
}
-})();
+});
diff --git a/addon/hint/python-hint.js b/addon/hint/python-hint.js
index 248284e8c5..eebfcc76dc 100644
--- a/addon/hint/python-hint.js
+++ b/addon/hint/python-hint.js
@@ -1,4 +1,13 @@
-(function () {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
function forEach(arr, f) {
for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
}
@@ -40,7 +49,6 @@
function pythonHint(editor) {
return scriptHint(editor, pythonKeywordsU, function (e, cur) {return e.getTokenAt(cur);});
}
- CodeMirror.pythonHint = pythonHint; // deprecated
CodeMirror.registerHelper("hint", "python", pythonHint);
var pythonKeywords = "and del from not while as elif global or with assert else if pass yield"
@@ -88,4 +96,4 @@
}
return found;
}
-})();
+});
diff --git a/addon/hint/show-hint.js b/addon/hint/show-hint.js
index 831fe089da..6a4d74e360 100644
--- a/addon/hint/show-hint.js
+++ b/addon/hint/show-hint.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var HINT_ELEMENT_CLASS = "CodeMirror-hint";
@@ -332,4 +339,4 @@
});
CodeMirror.commands.autocomplete = CodeMirror.showHint;
-})();
+});
diff --git a/addon/hint/sql-hint.js b/addon/hint/sql-hint.js
index d00781cff9..736dbaea06 100644
--- a/addon/hint/sql-hint.js
+++ b/addon/hint/sql-hint.js
@@ -1,4 +1,11 @@
-(function () {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../../mode/sql/sql"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../../mode/sql/sql"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var tables;
@@ -143,4 +150,4 @@
};
}
CodeMirror.registerHelper("hint", "sql", sqlHint);
-})();
+});
diff --git a/addon/hint/xml-hint.js b/addon/hint/xml-hint.js
index 69f2b771fe..857564909a 100644
--- a/addon/hint/xml-hint.js
+++ b/addon/hint/xml-hint.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var Pos = CodeMirror.Pos;
@@ -64,6 +71,5 @@
};
}
- CodeMirror.xmlHint = getHints; // deprecated
CodeMirror.registerHelper("hint", "xml", getHints);
-})();
+});
diff --git a/addon/lint/coffeescript-lint.js b/addon/lint/coffeescript-lint.js
index 7f55a294dd..6df17f8f84 100644
--- a/addon/lint/coffeescript-lint.js
+++ b/addon/lint/coffeescript-lint.js
@@ -2,6 +2,16 @@
// declare global: coffeelint
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
var found = [];
var parseError = function(err) {
@@ -24,4 +34,5 @@ CodeMirror.registerHelper("lint", "coffeescript", function(text) {
}
return found;
});
-CodeMirror.coffeeValidator = CodeMirror.lint.coffeescript; // deprecated
+
+});
diff --git a/addon/lint/css-lint.js b/addon/lint/css-lint.js
index 1de71fbcbd..2a799ddc4f 100644
--- a/addon/lint/css-lint.js
+++ b/addon/lint/css-lint.js
@@ -2,6 +2,16 @@
// declare global: CSSLint
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.registerHelper("lint", "css", function(text) {
var found = [];
var results = CSSLint.verify(text), messages = results.messages, message = null;
@@ -17,3 +27,5 @@ CodeMirror.registerHelper("lint", "css", function(text) {
}
return found;
});
+
+});
diff --git a/addon/lint/javascript-lint.js b/addon/lint/javascript-lint.js
index 7123ab7e64..bbb51083b8 100644
--- a/addon/lint/javascript-lint.js
+++ b/addon/lint/javascript-lint.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
// declare global: JSHINT
@@ -19,7 +26,6 @@
}
CodeMirror.registerHelper("lint", "javascript", validator);
- CodeMirror.javascriptValidator = CodeMirror.lint.javascript; // deprecated
function cleanup(error) {
// All problems are warnings by default
@@ -123,4 +129,4 @@
}
}
}
-})();
+});
diff --git a/addon/lint/json-lint.js b/addon/lint/json-lint.js
index e10e11bcaf..1f5f82d0ca 100644
--- a/addon/lint/json-lint.js
+++ b/addon/lint/json-lint.js
@@ -2,6 +2,16 @@
// declare global: jsonlint
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.registerHelper("lint", "json", function(text) {
var found = [];
jsonlint.parseError = function(str, hash) {
@@ -14,4 +24,5 @@ CodeMirror.registerHelper("lint", "json", function(text) {
catch(e) {}
return found;
});
-CodeMirror.jsonValidator = CodeMirror.lint.json; // deprecated
+
+});
diff --git a/addon/lint/lint.js b/addon/lint/lint.js
index 6121735d3f..db5162ee7a 100644
--- a/addon/lint/lint.js
+++ b/addon/lint/lint.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var GUTTER_ID = "CodeMirror-lint-markers";
var SEVERITIES = /^(?:error|warning)$/;
@@ -178,7 +185,7 @@
}
}
- function optionHandler(cm, val, old) {
+ CodeMirror.defineOption("lint", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
clearMarks(cm);
cm.off("change", onChange);
@@ -196,8 +203,5 @@
startLinting(cm);
}
- }
-
- CodeMirror.defineOption("lintWith", false, optionHandler); // deprecated
- CodeMirror.defineOption("lint", false, optionHandler); // deprecated
-})();
+ });
+});
diff --git a/addon/merge/merge.js b/addon/merge/merge.js
index 89f852652b..99e5d075ba 100644
--- a/addon/merge/merge.js
+++ b/addon/merge/merge.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
// declare global: diff_match_patch, DIFF_INSERT, DIFF_DELETE, DIFF_EQUAL
@@ -476,4 +483,4 @@
function posMin(a, b) { return (a.line - b.line || a.ch - b.ch) < 0 ? a : b; }
function posMax(a, b) { return (a.line - b.line || a.ch - b.ch) > 0 ? a : b; }
function posEq(a, b) { return a.line == b.line && a.ch == b.ch; }
-})();
+});
diff --git a/addon/mode/loadmode.js b/addon/mode/loadmode.js
index 60fafbb178..e08c281321 100644
--- a/addon/mode/loadmode.js
+++ b/addon/mode/loadmode.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
if (!CodeMirror.modeURL) CodeMirror.modeURL = "../mode/%N/%N.js";
var loading = {};
@@ -48,4 +55,4 @@
instance.setOption("mode", instance.getOption("mode"));
});
};
-}());
+});
diff --git a/addon/mode/multiplex.js b/addon/mode/multiplex.js
index 614ab1add3..07385c35f2 100644
--- a/addon/mode/multiplex.js
+++ b/addon/mode/multiplex.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.multiplexingMode = function(outer /*, others */) {
// Others should be {open, close, mode [, delimStyle] [, innerStyle]} objects
var others = Array.prototype.slice.call(arguments, 1);
@@ -101,3 +111,5 @@ CodeMirror.multiplexingMode = function(outer /*, others */) {
}
};
};
+
+});
diff --git a/addon/mode/overlay.js b/addon/mode/overlay.js
index b7928a7bbf..6f556a13a7 100644
--- a/addon/mode/overlay.js
+++ b/addon/mode/overlay.js
@@ -6,8 +6,17 @@
// overlay wins, unless the combine argument was true, in which case
// the styles are combined.
-// overlayParser is the old, deprecated name
-CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, combine) {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+CodeMirror.overlayMode = function(base, overlay, combine) {
return {
startState: function() {
return {
@@ -57,3 +66,5 @@ CodeMirror.overlayMode = CodeMirror.overlayParser = function(base, overlay, comb
}
};
};
+
+});
diff --git a/addon/runmode/colorize.js b/addon/runmode/colorize.js
index 62286d21e4..0f9530b17b 100644
--- a/addon/runmode/colorize.js
+++ b/addon/runmode/colorize.js
@@ -1,4 +1,12 @@
-CodeMirror.colorize = (function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("./runmode"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "./runmode"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
var isBlock = /^(p|li|div|h\\d|pre|blockquote|td)$/;
@@ -10,7 +18,7 @@ CodeMirror.colorize = (function() {
}
}
- return function(collection, defaultMode) {
+ CodeMirror.colorize = function(collection, defaultMode) {
if (!collection) collection = document.body.getElementsByTagName("pre");
for (var i = 0; i < collection.length; ++i) {
@@ -26,4 +34,4 @@ CodeMirror.colorize = (function() {
node.className += " cm-s-default";
}
};
-})();
+});
diff --git a/addon/runmode/runmode-standalone.js b/addon/runmode/runmode-standalone.js
index ec06ba11cb..eaa2b8f2fb 100644
--- a/addon/runmode/runmode-standalone.js
+++ b/addon/runmode/runmode-standalone.js
@@ -1,5 +1,3 @@
-/* Just enough of CodeMirror to run runMode under node.js */
-
window.CodeMirror = {};
(function() {
diff --git a/addon/runmode/runmode.js b/addon/runmode/runmode.js
index 2cafa811f8..351840e08e 100644
--- a/addon/runmode/runmode.js
+++ b/addon/runmode/runmode.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.runMode = function(string, modespec, callback, options) {
var mode = CodeMirror.getMode(CodeMirror.defaults, modespec);
var ie = /MSIE \d/.test(navigator.userAgent);
@@ -54,3 +64,5 @@ CodeMirror.runMode = function(string, modespec, callback, options) {
}
}
};
+
+});
diff --git a/addon/scroll/scrollpastend.js b/addon/scroll/scrollpastend.js
index 58720ad413..467b7aa1cf 100644
--- a/addon/scroll/scrollpastend.js
+++ b/addon/scroll/scrollpastend.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
CodeMirror.defineOption("scrollPastEnd", false, function(cm, val, old) {
@@ -33,4 +40,4 @@
cm.setSize();
}
}
-})();
+});
diff --git a/addon/search/match-highlighter.js b/addon/search/match-highlighter.js
index a2eda2e614..d9c818b838 100644
--- a/addon/search/match-highlighter.js
+++ b/addon/search/match-highlighter.js
@@ -12,7 +12,16 @@
// actual CSS class name. showToken, when enabled, will cause the
// current token to be highlighted when nothing is selected.
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
var DEFAULT_MIN_CHARS = 2;
var DEFAULT_TOKEN_STYLE = "matchhighlight";
var DEFAULT_DELAY = 100;
@@ -88,4 +97,4 @@
stream.skipTo(query.charAt(0)) || stream.skipToEnd();
}};
}
-})();
+});
diff --git a/addon/search/search.js b/addon/search/search.js
index 38b488522f..3df006d4b7 100644
--- a/addon/search/search.js
+++ b/addon/search/search.js
@@ -6,7 +6,14 @@
// replace by making sure the match is no longer selected when hitting
// Ctrl-G.
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
function searchOverlay(query, caseInsensitive) {
var startChar;
@@ -139,4 +146,4 @@
CodeMirror.commands.clearSearch = clearSearch;
CodeMirror.commands.replace = replace;
CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
-})();
+});
diff --git a/addon/search/searchcursor.js b/addon/search/searchcursor.js
index 6afac80fb8..899f44c4ab 100644
--- a/addon/search/searchcursor.js
+++ b/addon/search/searchcursor.js
@@ -1,4 +1,12 @@
-(function(){
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
var Pos = CodeMirror.Pos;
function SearchCursor(doc, query, pos, caseFold) {
@@ -175,4 +183,4 @@
if (ranges.length)
this.setSelections(ranges, 0);
});
-})();
+});
diff --git a/addon/selection/active-line.js b/addon/selection/active-line.js
index c8b7001ced..a818f109b6 100644
--- a/addon/selection/active-line.js
+++ b/addon/selection/active-line.js
@@ -4,7 +4,14 @@
// active line's wrapping
the CSS class "CodeMirror-activeline",
// and gives its background
the class "CodeMirror-activeline-background".
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var WRAP_CLASS = "CodeMirror-activeline";
var BACK_CLASS = "CodeMirror-activeline-background";
@@ -56,4 +63,4 @@
function selectionChange(cm, sel) {
updateActiveLines(cm, sel.ranges);
}
-})();
+});
diff --git a/addon/selection/mark-selection.js b/addon/selection/mark-selection.js
index c40a9c99bd..ae0d393143 100644
--- a/addon/selection/mark-selection.js
+++ b/addon/selection/mark-selection.js
@@ -4,7 +4,14 @@
// selected text the CSS class given as option value, or
// "CodeMirror-selectedtext" when the value is not a string.
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
@@ -105,4 +112,4 @@
}
}
}
-})();
+});
diff --git a/addon/tern/tern.js b/addon/tern/tern.js
index fa2a2c3528..1cc7e972e5 100644
--- a/addon/tern/tern.js
+++ b/addon/tern/tern.js
@@ -40,7 +40,14 @@
// load. Or, if you minified those into a single script and included
// them in the workerScript, simply leave this undefined.
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
// declare global: tern
@@ -650,4 +657,4 @@
this.delFile = function(name) { send({type: "del", name: name}); };
this.request = function(body, c) { send({type: "req", body: body}, c); };
}
-})();
+});
diff --git a/addon/wrap/hardwrap.js b/addon/wrap/hardwrap.js
index f6d99212a8..f900d6e81b 100644
--- a/addon/wrap/hardwrap.js
+++ b/addon/wrap/hardwrap.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var Pos = CodeMirror.Pos;
@@ -108,4 +115,4 @@
});
return madeChange;
});
-})();
+});
diff --git a/demo/btree.html b/demo/btree.html
index 7635ca1bb4..b7bd39088d 100644
--- a/demo/btree.html
+++ b/demo/btree.html
@@ -58,7 +58,6 @@
B-Tree visualization
var gray = Math.min(line.text.length * 3, 230), col = gray.toString(16);
if (col.length == 1) col = "0" + col;
lineElt.style.background = "#" + col + col + col;
- console.log(line.height, line);
lineElt.style.width = Math.max(Math.round(line.height / 3), 1) + "px";
}
} else {
diff --git a/doc/compress.html b/doc/compress.html
index 55e25f3e68..d4c108c516 100644
--- a/doc/compress.html
+++ b/doc/compress.html
@@ -128,8 +128,7 @@
Script compression helper
python.js
q.js
r.js
-
rpm/changes.js
-
rpm/spec.js
+
rpm.js
rst.js
ruby.js
rust.js
diff --git a/doc/manual.html b/doc/manual.html
index 3e81b94c3a..9a2424eb48 100644
--- a/doc/manual.html
+++ b/doc/manual.html
@@ -91,6 +91,9 @@
Basic Usage
<link rel="stylesheet" href="../lib/codemirror.css">
<script src="mode/javascript/javascript.js"></script>
+
(Alternatively, use a module loader. More
+ about that later. )
+
Having done this, an editor instance can be created like
this:
@@ -135,7 +138,41 @@
Basic Usage
of a form) is submitted. See the
API
reference for a full description of this method.
+
Module loaders
+
+
The files in the CodeMirror distribution contain shims for
+ loading them (and their dependencies) in AMD or CommonJS
+ environments. If the variables exports
+ and module
exist and have type object, CommonJS-style
+ require will be used. If not, but there is a
+ function define
with an amd
property
+ present, AMD-style (RequireJS) will be used.
+
+
It is possible to
+ use Browserify or similar
+ tools to statically build modules using CodeMirror. Alternatively,
+ use RequireJS to dynamically
+ load dependencies at runtime. Both of these approaches have the
+ advantage that they don't use the global namespace and can, thus,
+ do things like load multiple versions of CodeMirror alongside each
+ other.
+
+
Here's a simple example of using RequireJS to load CodeMirror:
+
+
require([
+ "cm/lib/codemirror", "cm/mode/htmlmixed/htmlmixed"
+], function(CodeMirror) {
+ CodeMirror.fromTextArea(document.getElementById("code"), {
+ lineNumbers: true,
+ mode: "htmlmixed"
+ });
+});
+
+
It will automatically load the modes that the mixed HTML mode
+ depends on (XML, JavaScript, and CSS).
+
+
@@ -77,5 +78,20 @@
Upgrading to version 4
multiple
"change"
events. Existing code will probably continue to work unmodified.
+
+
+
Deprecated interfaces dropped
+
+A few properties that have been deprecated for a while are now
+gone. Most notably, the names for folding and completing functions
+(CodeMirror.braceRangeFinder
, CodeMirror.javascriptHint
,
+etc) are now gone
+(use CodeMirror.fold.brace
, CodeMirror.hint.javascript
).
+
+The className
property in the return value
+of getTokenAt
, which
+has been superseded by the type
property, is also no
+longer present.
+
diff --git a/keymap/emacs.js b/keymap/emacs.js
index c56d7eb7e7..35f199cb73 100644
--- a/keymap/emacs.js
+++ b/keymap/emacs.js
@@ -1,4 +1,11 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var Pos = CodeMirror.Pos;
@@ -395,4 +402,4 @@
}
for (var i = 0; i < 10; ++i) regPrefix(String(i));
regPrefix("-");
-})();
+});
diff --git a/keymap/multiselect.js b/keymap/multiselect.js
index f45f27254a..46379484a6 100644
--- a/keymap/multiselect.js
+++ b/keymap/multiselect.js
@@ -1,7 +1,14 @@
// A number of extra keybindings for multiple-selection handling
// Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
"use strict";
var pc = CodeMirror.keyMap.pcDefault, mac = CodeMirror.keyMap.macDefault;
@@ -44,4 +51,4 @@
cm.selectMatches(query);
});
};
-})();
+});
diff --git a/keymap/vim.js b/keymap/vim.js
index 9e5b257f4f..720ef4a2c3 100644
--- a/keymap/vim.js
+++ b/keymap/vim.js
@@ -56,7 +56,14 @@
* 8. Set up Vim to work as a keymap for CodeMirror.
*/
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
'use strict';
var defaultKeymap = [
@@ -3800,5 +3807,4 @@
};
// Initialize Vim and make it available as an API.
CodeMirror.Vim = Vim();
-}
-)();
+});
diff --git a/lib/codemirror.js b/lib/codemirror.js
index c5a332264f..c4adf99f65 100644
--- a/lib/codemirror.js
+++ b/lib/codemirror.js
@@ -1,5 +1,11 @@
-// CodeMirror is the only global var we claim
-window.CodeMirror = (function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ module.exports = mod();
+ else if (typeof define == "function" && define.amd) // AMD
+ return define([], mod);
+ else // Plain browser env
+ this.CodeMirror = mod();
+})(function() {
"use strict";
// BROWSER SNIFFING
@@ -3175,7 +3181,6 @@ window.CodeMirror = (function() {
return {start: stream.start,
end: stream.pos,
string: stream.current(),
- className: style || null, // Deprecated, use 'type' instead
type: style || null,
state: state};
},
@@ -6363,4 +6368,4 @@ window.CodeMirror = (function() {
CodeMirror.version = "4.0.0";
return CodeMirror;
-})();
+});
diff --git a/mode/apl/apl.js b/mode/apl/apl.js
index 5c23af85da..2ba74c18c2 100644
--- a/mode/apl/apl.js
+++ b/mode/apl/apl.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("apl", function() {
var builtInOps = {
".": "innerProduct",
@@ -158,3 +168,5 @@ CodeMirror.defineMode("apl", function() {
});
CodeMirror.defineMIME("text/apl", "apl");
+
+});
diff --git a/mode/asterisk/asterisk.js b/mode/asterisk/asterisk.js
index 60b689d1d5..c56fc0b38a 100644
--- a/mode/asterisk/asterisk.js
+++ b/mode/asterisk/asterisk.js
@@ -14,6 +14,16 @@
* =====================================================================================
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("asterisk", function() {
var atoms = ["exten", "same", "include","ignorepat","switch"],
dpcmd = ["#include","#exec"],
@@ -181,3 +191,5 @@ CodeMirror.defineMode("asterisk", function() {
});
CodeMirror.defineMIME("text/x-asterisk", "asterisk");
+
+});
diff --git a/mode/clike/clike.js b/mode/clike/clike.js
index 4e4988dd81..b869f72723 100644
--- a/mode/clike/clike.js
+++ b/mode/clike/clike.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("clike", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
@@ -379,3 +389,5 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
modeProps: {fold: ["brace", "include"]}
});
}());
+
+});
diff --git a/mode/clojure/clojure.js b/mode/clojure/clojure.js
index e3d87d23a6..dd2e2ce1b8 100644
--- a/mode/clojure/clojure.js
+++ b/mode/clojure/clojure.js
@@ -2,6 +2,17 @@
* Author: Hans Engel
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("clojure", function (options) {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword";
@@ -223,3 +234,5 @@ CodeMirror.defineMode("clojure", function (options) {
});
CodeMirror.defineMIME("text/x-clojure", "clojure");
+
+});
diff --git a/mode/cobol/cobol.js b/mode/cobol/cobol.js
index d92491dde8..e66e42a191 100644
--- a/mode/cobol/cobol.js
+++ b/mode/cobol/cobol.js
@@ -2,6 +2,16 @@
* Author: Gautam Mehta
* Branched from CodeMirror's Scheme mode
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("cobol", function () {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
@@ -238,3 +248,5 @@ CodeMirror.defineMode("cobol", function () {
});
CodeMirror.defineMIME("text/x-cobol", "cobol");
+
+});
diff --git a/mode/coffeescript/coffeescript.js b/mode/coffeescript/coffeescript.js
index 0e9e6352f8..c6da8f2a29 100644
--- a/mode/coffeescript/coffeescript.js
+++ b/mode/coffeescript/coffeescript.js
@@ -2,6 +2,16 @@
* Link to the project's GitHub page:
* https://github.com/pickhardt/coffeescript-codemirror-mode
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("coffeescript", function(conf) {
var ERRORCLASS = "error";
@@ -351,3 +361,5 @@ CodeMirror.defineMode("coffeescript", function(conf) {
});
CodeMirror.defineMIME("text/x-coffeescript", "coffeescript");
+
+});
diff --git a/mode/commonlisp/commonlisp.js b/mode/commonlisp/commonlisp.js
index 8fa08c8ac2..a0f0732bf6 100644
--- a/mode/commonlisp/commonlisp.js
+++ b/mode/commonlisp/commonlisp.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("commonlisp", function (config) {
var assumeBody = /^with|^def|^do|^prog|case$|^cond$|bind$|when$|unless$/;
var numLiteral = /^(?:[+\-]?(?:\d+|\d*\.\d+)(?:[efd][+\-]?\d+)?|[+\-]?\d+(?:\/[+\-]?\d+)?|#b[+\-]?[01]+|#o[+\-]?[0-7]+|#x[+\-]?[\da-f]+)/;
@@ -103,3 +113,5 @@ CodeMirror.defineMode("commonlisp", function (config) {
});
CodeMirror.defineMIME("text/x-common-lisp", "commonlisp");
+
+});
diff --git a/mode/css/css.js b/mode/css/css.js
index 06d73455da..d63bdd0827 100644
--- a/mode/css/css.js
+++ b/mode/css/css.js
@@ -1,6 +1,14 @@
-CodeMirror.defineMode("css", function(config, parserConfig) {
- "use strict";
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+CodeMirror.defineMode("css", function(config, parserConfig) {
if (!parserConfig.propertyKeywords) parserConfig = CodeMirror.resolveMode("text/css");
var indentUnit = config.indentUnit,
@@ -334,7 +342,6 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
};
});
-(function() {
function keySet(array) {
var keys = {};
for (var i = 0; i < array.length; ++i) {
@@ -689,4 +696,5 @@ CodeMirror.defineMode("css", function(config, parserConfig) {
name: "css",
helperType: "less"
});
-})();
+
+});
diff --git a/mode/d/d.js b/mode/d/d.js
index ab345f1a0d..3ab8b42838 100644
--- a/mode/d/d.js
+++ b/mode/d/d.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("d", function(config, parserConfig) {
var indentUnit = config.indentUnit,
statementIndentUnit = parserConfig.statementIndentUnit || indentUnit,
@@ -173,7 +183,6 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
};
});
-(function() {
function words(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
@@ -202,4 +211,5 @@ CodeMirror.defineMode("d", function(config, parserConfig) {
}
}
});
-}());
+
+});
diff --git a/mode/diff/diff.js b/mode/diff/diff.js
index 9a0d90ea55..d43f15d51a 100644
--- a/mode/diff/diff.js
+++ b/mode/diff/diff.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("diff", function() {
var TOKEN_NAMES = {
@@ -30,3 +40,5 @@ CodeMirror.defineMode("diff", function() {
});
CodeMirror.defineMIME("text/x-diff", "diff");
+
+});
diff --git a/mode/dtd/dtd.js b/mode/dtd/dtd.js
index 7033bf0f8b..b4a6cb3155 100644
--- a/mode/dtd/dtd.js
+++ b/mode/dtd/dtd.js
@@ -5,6 +5,16 @@
GitHub: @peterkroon
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("dtd", function(config) {
var indentUnit = config.indentUnit, type;
function ret(style, tp) {type = tp; return style;}
@@ -125,3 +135,5 @@ CodeMirror.defineMode("dtd", function(config) {
});
CodeMirror.defineMIME("application/xml-dtd", "dtd");
+
+});
diff --git a/mode/ecl/ecl.js b/mode/ecl/ecl.js
index 7601b189a0..2b841ff5f1 100644
--- a/mode/ecl/ecl.js
+++ b/mode/ecl/ecl.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("ecl", function(config) {
function words(str) {
@@ -190,3 +200,5 @@ CodeMirror.defineMode("ecl", function(config) {
});
CodeMirror.defineMIME("text/x-ecl", "ecl");
+
+});
diff --git a/mode/eiffel/eiffel.js b/mode/eiffel/eiffel.js
index 15f34a9325..c6c3c84600 100644
--- a/mode/eiffel/eiffel.js
+++ b/mode/eiffel/eiffel.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("eiffel", function() {
function wordObj(words) {
var o = {};
@@ -145,3 +155,5 @@ CodeMirror.defineMode("eiffel", function() {
});
CodeMirror.defineMIME("text/x-eiffel", "eiffel");
+
+});
diff --git a/mode/erlang/erlang.js b/mode/erlang/erlang.js
index bc3bdce860..79693fca22 100644
--- a/mode/erlang/erlang.js
+++ b/mode/erlang/erlang.js
@@ -12,6 +12,16 @@
// old guard/bif/conversion clashes (e.g. "float/1")
// type/spec/opaque
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMIME("text/x-erlang", "erlang");
CodeMirror.defineMode("erlang", function(cmCfg) {
@@ -605,3 +615,5 @@ CodeMirror.defineMode("erlang", function(cmCfg) {
lineComment: "%"
};
});
+
+});
diff --git a/mode/fortran/fortran.js b/mode/fortran/fortran.js
index 83fd8fde85..58dac127c1 100644
--- a/mode/fortran/fortran.js
+++ b/mode/fortran/fortran.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("fortran", function() {
function words(array) {
var keys = {};
@@ -171,3 +181,5 @@ CodeMirror.defineMode("fortran", function() {
});
CodeMirror.defineMIME("text/x-fortran", "fortran");
+
+});
diff --git a/mode/gas/gas.js b/mode/gas/gas.js
index a6e6892908..a21d5bbe1b 100644
--- a/mode/gas/gas.js
+++ b/mode/gas/gas.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("gas", function(_config, parserConfig) {
'use strict';
@@ -328,3 +338,5 @@ CodeMirror.defineMode("gas", function(_config, parserConfig) {
blockCommentEnd: "*/"
};
});
+
+});
diff --git a/mode/gfm/gfm.js b/mode/gfm/gfm.js
index 10d5e05c06..7bd5f5ab42 100644
--- a/mode/gfm/gfm.js
+++ b/mode/gfm/gfm.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../markdown/markdown"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../markdown/markdown"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("gfm", function(config, modeConfig) {
var codeDepth = 0;
function blankLine(state) {
@@ -100,3 +110,5 @@ CodeMirror.defineMode("gfm", function(config, modeConfig) {
CodeMirror.defineMIME("gfmBase", markdownConfig);
return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
}, "markdown");
+
+});
diff --git a/mode/gherkin/gherkin.js b/mode/gherkin/gherkin.js
index 685b373df7..41003641ec 100644
--- a/mode/gherkin/gherkin.js
+++ b/mode/gherkin/gherkin.js
@@ -13,6 +13,16 @@ Report bugs/issues here: https://github.com/marijnh/CodeMirror/issues
// keywords: /(Feature| {2}(Scenario|In order to|As|I)| {4}(Given|When|Then|And))/
//};
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("gherkin", function () {
return {
startState: function () {
@@ -161,3 +171,5 @@ CodeMirror.defineMode("gherkin", function () {
});
CodeMirror.defineMIME("text/x-feature", "gherkin");
+
+});
diff --git a/mode/go/go.js b/mode/go/go.js
index 862c091120..7ba780ead8 100644
--- a/mode/go/go.js
+++ b/mode/go/go.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("go", function(config) {
var indentUnit = config.indentUnit;
@@ -166,3 +176,5 @@ CodeMirror.defineMode("go", function(config) {
});
CodeMirror.defineMIME("text/x-go", "go");
+
+});
diff --git a/mode/groovy/groovy.js b/mode/groovy/groovy.js
index 6800e0aaf5..399452d536 100644
--- a/mode/groovy/groovy.js
+++ b/mode/groovy/groovy.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("groovy", function(config) {
function words(str) {
var obj = {}, words = str.split(" ");
@@ -209,3 +219,5 @@ CodeMirror.defineMode("groovy", function(config) {
});
CodeMirror.defineMIME("text/x-groovy", "groovy");
+
+});
diff --git a/mode/haml/haml.js b/mode/haml/haml.js
index 5ea4ed12c8..6b205b43e4 100644
--- a/mode/haml/haml.js
+++ b/mode/haml/haml.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../ruby/ruby"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../ruby/ruby"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
(function() {
"use strict";
@@ -147,3 +157,5 @@
CodeMirror.defineMIME("text/x-haml", "haml");
})();
+
+});
diff --git a/mode/haskell/haskell.js b/mode/haskell/haskell.js
index facfd00a65..2876172a95 100644
--- a/mode/haskell/haskell.js
+++ b/mode/haskell/haskell.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("haskell", function(_config, modeConfig) {
function switchState(source, setState, f) {
@@ -250,3 +260,5 @@ CodeMirror.defineMode("haskell", function(_config, modeConfig) {
});
CodeMirror.defineMIME("text/x-haskell", "haskell");
+
+});
diff --git a/mode/haxe/haxe.js b/mode/haxe/haxe.js
index cb761ad1ce..3f78a8d674 100644
--- a/mode/haxe/haxe.js
+++ b/mode/haxe/haxe.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("haxe", function(config, parserConfig) {
var indentUnit = config.indentUnit;
@@ -427,3 +437,5 @@ CodeMirror.defineMode("haxe", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-haxe", "haxe");
+
+});
diff --git a/mode/htmlembedded/htmlembedded.js b/mode/htmlembedded/htmlembedded.js
index c316cd3406..3a07c3432e 100644
--- a/mode/htmlembedded/htmlembedded.js
+++ b/mode/htmlembedded/htmlembedded.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
//config settings
@@ -69,3 +79,5 @@ CodeMirror.defineMIME("application/x-ejs", { name: "htmlembedded", scriptingMode
CodeMirror.defineMIME("application/x-aspx", { name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
CodeMirror.defineMIME("application/x-jsp", { name: "htmlembedded", scriptingModeSpec:"text/x-java"});
CodeMirror.defineMIME("application/x-erb", { name: "htmlembedded", scriptingModeSpec:"ruby"});
+
+});
diff --git a/mode/htmlmixed/htmlmixed.js b/mode/htmlmixed/htmlmixed.js
index e9eab3b92d..a2c3740d3d 100644
--- a/mode/htmlmixed/htmlmixed.js
+++ b/mode/htmlmixed/htmlmixed.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../xml/xml"), require("../javascript/javascript"), require("../css/css"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../xml/xml", "../javascript/javascript", "../css/css"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
var cssMode = CodeMirror.getMode(config, "css");
@@ -100,3 +110,5 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
}, "xml", "javascript", "css");
CodeMirror.defineMIME("text/html", "htmlmixed");
+
+});
diff --git a/mode/http/http.js b/mode/http/http.js
index 5a51636027..d2ad5994b6 100644
--- a/mode/http/http.js
+++ b/mode/http/http.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("http", function() {
function failFirstLine(stream, state) {
stream.skipToEnd();
@@ -96,3 +106,5 @@ CodeMirror.defineMode("http", function() {
});
CodeMirror.defineMIME("message/http", "http");
+
+});
diff --git a/mode/index.html b/mode/index.html
index 7c1f740615..29d120d012 100644
--- a/mode/index.html
+++ b/mode/index.html
@@ -80,7 +80,7 @@
Language modes
Python
Q
R
-
RPM spec and changelog
+
RPM
reStructuredText
Ruby
Rust
diff --git a/mode/jade/jade.js b/mode/jade/jade.js
index 61abb27ab7..020b93ec5d 100644
--- a/mode/jade/jade.js
+++ b/mode/jade/jade.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("jade", function () {
var symbol_regex1 = /^(?:~|!|%|\^|\*|\+|=|\\|:|;|,|\/|\?|&|<|>|\|)/;
var open_paren_regex = /^(\(|\[)/;
@@ -88,3 +98,5 @@ CodeMirror.defineMode("jade", function () {
});
CodeMirror.defineMIME('text/x-jade', 'jade');
+
+});
diff --git a/mode/javascript/javascript.js b/mode/javascript/javascript.js
index fbf574b4fe..8d6035de2c 100644
--- a/mode/javascript/javascript.js
+++ b/mode/javascript/javascript.js
@@ -1,5 +1,15 @@
// TODO actually recognize syntax of TypeScript constructs
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("javascript", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var statementIndent = parserConfig.statementIndent;
@@ -628,3 +638,5 @@ CodeMirror.defineMIME("application/json", {name: "javascript", json: true});
CodeMirror.defineMIME("application/x-json", {name: "javascript", json: true});
CodeMirror.defineMIME("text/typescript", { name: "javascript", typescript: true });
CodeMirror.defineMIME("application/typescript", { name: "javascript", typescript: true });
+
+});
diff --git a/mode/jinja2/jinja2.js b/mode/jinja2/jinja2.js
index b28af098d0..e30ce63478 100644
--- a/mode/jinja2/jinja2.js
+++ b/mode/jinja2/jinja2.js
@@ -1,4 +1,14 @@
-CodeMirror.defineMode("jinja2", function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ CodeMirror.defineMode("jinja2", function() {
var keywords = ["and", "as", "block", "endblock", "by", "cycle", "debug", "else", "elif",
"extends", "filter", "endfilter", "firstof", "for",
"endfor", "if", "endif", "ifchanged", "endifchanged",
@@ -15,38 +25,39 @@ CodeMirror.defineMode("jinja2", function() {
keywords = new RegExp("^((" + keywords.join(")|(") + "))\\b");
function tokenBase (stream, state) {
- var ch = stream.next();
- if (ch == "{") {
- if (ch = stream.eat(/\{|%|#/)) {
- stream.eat("-");
- state.tokenize = inTag(ch);
- return "tag";
- }
+ var ch = stream.next();
+ if (ch == "{") {
+ if (ch = stream.eat(/\{|%|#/)) {
+ stream.eat("-");
+ state.tokenize = inTag(ch);
+ return "tag";
}
+ }
}
function inTag (close) {
- if (close == "{") {
- close = "}";
+ if (close == "{") {
+ close = "}";
+ }
+ return function (stream, state) {
+ var ch = stream.next();
+ if ((ch == close || (ch == "-" && stream.eat(close)))
+ && stream.eat("}")) {
+ state.tokenize = tokenBase;
+ return "tag";
}
- return function (stream, state) {
- var ch = stream.next();
- if ((ch == close || (ch == "-" && stream.eat(close)))
- && stream.eat("}")) {
- state.tokenize = tokenBase;
- return "tag";
- }
- if (stream.match(keywords)) {
- return "keyword";
- }
- return close == "#" ? "comment" : "string";
- };
+ 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);
- }
+ startState: function () {
+ return {tokenize: tokenBase};
+ },
+ token: function (stream, state) {
+ return state.tokenize(stream, state);
+ }
};
+ });
});
diff --git a/mode/julia/julia.js b/mode/julia/julia.js
index 9ec2428cd4..b603713040 100644
--- a/mode/julia/julia.js
+++ b/mode/julia/julia.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("julia", function(_conf, parserConf) {
var ERRORCLASS = 'error';
@@ -260,3 +270,5 @@ CodeMirror.defineMode("julia", function(_conf, parserConf) {
CodeMirror.defineMIME("text/x-julia", "julia");
+
+});
diff --git a/mode/less/less.js b/mode/less/less.js
index da681ea67b..9f0d43e938 100644
--- a/mode/less/less.js
+++ b/mode/less/less.js
@@ -5,6 +5,16 @@
GitHub: @peterkroon
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("less", function(config) {
var indentUnit = config.indentUnit, type;
function ret(style, tp) {type = tp; return style;}
@@ -345,3 +355,5 @@ CodeMirror.defineMode("less", function(config) {
CodeMirror.defineMIME("text/x-less", "less");
if (!CodeMirror.mimeModes.hasOwnProperty("text/css"))
CodeMirror.defineMIME("text/css", "less");
+
+});
diff --git a/mode/livescript/livescript.js b/mode/livescript/livescript.js
index c000324b8c..9322ba8073 100644
--- a/mode/livescript/livescript.js
+++ b/mode/livescript/livescript.js
@@ -2,6 +2,17 @@
* Link to the project's GitHub page:
* https://github.com/duralog/CodeMirror
*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
(function() {
CodeMirror.defineMode('livescript', function(){
var tokenBase, external;
@@ -265,3 +276,5 @@
})();
CodeMirror.defineMIME('text/x-livescript', 'livescript');
+
+});
diff --git a/mode/lua/lua.js b/mode/lua/lua.js
index b8deaa2575..3673557c27 100644
--- a/mode/lua/lua.js
+++ b/mode/lua/lua.js
@@ -2,6 +2,16 @@
// CodeMirror 1 mode.
// highlights keywords, strings, comments (no leveling supported! ("[==[")), tokens, basic indenting
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("lua", function(config, parserConfig) {
var indentUnit = config.indentUnit;
@@ -142,3 +152,5 @@ CodeMirror.defineMode("lua", function(config, parserConfig) {
});
CodeMirror.defineMIME("text/x-lua", "lua");
+
+});
diff --git a/mode/markdown/markdown.js b/mode/markdown/markdown.js
index da2ba93fea..cfa56b911d 100644
--- a/mode/markdown/markdown.js
+++ b/mode/markdown/markdown.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror", require("../xml/xml")));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../xml/xml"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
@@ -744,3 +754,5 @@ CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
}, "xml");
CodeMirror.defineMIME("text/x-markdown", "markdown");
+
+});
diff --git a/mode/mirc/mirc.js b/mode/mirc/mirc.js
index fc88bc56fb..6b2a23a16c 100644
--- a/mode/mirc/mirc.js
+++ b/mode/mirc/mirc.js
@@ -1,4 +1,15 @@
//mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMIME("text/mirc", "mirc");
CodeMirror.defineMode("mirc", function() {
function parseWords(str) {
@@ -175,3 +186,5 @@ CodeMirror.defineMode("mirc", function() {
}
};
});
+
+});
diff --git a/mode/mllike/mllike.js b/mode/mllike/mllike.js
index 1d64789a19..d4d59fceb7 100644
--- a/mode/mllike/mllike.js
+++ b/mode/mllike/mllike.js
@@ -1,5 +1,14 @@
-CodeMirror.defineMode('mllike', function(_config, parserConfig) {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+CodeMirror.defineMode('mllike', function(_config, parserConfig) {
var words = {
'let': 'keyword',
'rec': 'keyword',
@@ -189,3 +198,5 @@ CodeMirror.defineMIME('text/x-fsharp', {
},
slashComments: true
});
+
+});
diff --git a/mode/nginx/nginx.js b/mode/nginx/nginx.js
index c98c8a1dd3..4e17cdb3c4 100644
--- a/mode/nginx/nginx.js
+++ b/mode/nginx/nginx.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("nginx", function(config) {
function words(str) {
@@ -161,3 +171,5 @@ CodeMirror.defineMode("nginx", function(config) {
});
CodeMirror.defineMIME("text/nginx", "text/x-nginx-conf");
+
+});
diff --git a/mode/ntriples/ntriples.js b/mode/ntriples/ntriples.js
index ed0cee34b0..cd5eb24f07 100644
--- a/mode/ntriples/ntriples.js
+++ b/mode/ntriples/ntriples.js
@@ -25,6 +25,17 @@
-> ERROR
}
*/
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("ntriples", function() {
var Location = {
@@ -168,3 +179,5 @@ CodeMirror.defineMode("ntriples", function() {
});
CodeMirror.defineMIME("text/n-triples", "ntriples");
+
+});
diff --git a/mode/octave/octave.js b/mode/octave/octave.js
index 23cd2fe222..0d8f610d1d 100644
--- a/mode/octave/octave.js
+++ b/mode/octave/octave.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("octave", function() {
function wordRegexp(words) {
return new RegExp("^((" + words.join(")|(") + "))\\b");
@@ -116,3 +126,5 @@ CodeMirror.defineMode("octave", function() {
});
CodeMirror.defineMIME("text/x-octave", "octave");
+
+});
diff --git a/mode/pascal/pascal.js b/mode/pascal/pascal.js
index 09d9b0617b..642dd9bf79 100644
--- a/mode/pascal/pascal.js
+++ b/mode/pascal/pascal.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("pascal", function() {
function words(str) {
var obj = {}, words = str.split(" ");
@@ -92,3 +102,5 @@ CodeMirror.defineMode("pascal", function() {
});
CodeMirror.defineMIME("text/x-pascal", "pascal");
+
+});
diff --git a/mode/pegjs/pegjs.js b/mode/pegjs/pegjs.js
index 6b2e273791..f74f2a4f22 100644
--- a/mode/pegjs/pegjs.js
+++ b/mode/pegjs/pegjs.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../javascript/javascript"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../javascript/javascript"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("pegjs", function (config) {
var jsMode = CodeMirror.getMode(config, "javascript");
@@ -97,3 +107,5 @@ CodeMirror.defineMode("pegjs", function (config) {
}
};
}, "javascript");
+
+});
diff --git a/mode/perl/perl.js b/mode/perl/perl.js
index 5954b1a61c..84392e4a81 100644
--- a/mode/perl/perl.js
+++ b/mode/perl/perl.js
@@ -1,5 +1,16 @@
// CodeMirror2 mode/perl/perl.js (text/x-perl) beta 0.10 (2011-11-08)
// This is a part of CodeMirror from https://github.com/sabaca/CodeMirror_mode_perl (mail@sabaca.com)
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("perl",function(){
// http://perldoc.perl.org
var PERL={ // null - magic touch
@@ -509,7 +520,7 @@ CodeMirror.defineMode("perl",function(){
return tokenSOMETHING(stream,state,'=cut');}
var ch=stream.next();
if(ch=='"'||ch=="'"){ // NOTE: ' or " or <<'SOMETHING'\n...\nSOMETHING\n or <<"SOMETHING"\n...\nSOMETHING\n
- if(stream.prefix(3)=="<<"+ch){
+ if(prefix(stream, 3)=="<<"+ch){
var p=stream.pos;
stream.eatWhile(/\w/);
var n=stream.current().substr(1);
@@ -518,94 +529,94 @@ CodeMirror.defineMode("perl",function(){
stream.pos=p;}
return tokenChain(stream,state,[ch],"string");}
if(ch=="q"){
- var c=stream.look(-2);
+ var c=look(stream, -2);
if(!(c&&/\w/.test(c))){
- c=stream.look(0);
+ c=look(stream, 0);
if(c=="x"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}
if(c=="{"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}
else if(c=="q"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],"string");}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],"string");}
if(c=="{"){
-stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],"string");}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],"string");}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],"string");}}
else if(c=="w"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],"bracket");}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],"bracket");}
if(c=="{"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],"bracket");}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],"bracket");}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],"bracket");}}
else if(c=="r"){
- c=stream.look(1);
+ c=look(stream, 1);
if(c=="("){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[")"],RXstyle,RXmodifiers);}
if(c=="["){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["]"],RXstyle,RXmodifiers);}
if(c=="{"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,["}"],RXstyle,RXmodifiers);}
if(c=="<"){
- stream.eatSuffix(2);
+ eatSuffix(stream, 2);
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}
if(/[\^'"!~\/]/.test(c)){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[stream.eat(c)],RXstyle,RXmodifiers);}}
else if(/[\^'"!~\/(\[{<]/.test(c)){
if(c=="("){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[")"],"string");}
if(c=="["){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,["]"],"string");}
if(c=="{"){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,["}"],"string");}
if(c=="<"){
- stream.eatSuffix(1);
+ eatSuffix(stream, 1);
return tokenChain(stream,state,[">"],"string");}
if(/[\^'"!~\/]/.test(c)){
return tokenChain(stream,state,[stream.eat(c)],"string");}}}}
if(ch=="m"){
- var c=stream.look(-2);
+ var c=look(stream, -2);
if(!(c&&/\w/.test(c))){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
@@ -620,7 +631,7 @@ stream.eatSuffix(2);
if(c=="<"){
return tokenChain(stream,state,[">"],RXstyle,RXmodifiers);}}}}
if(ch=="s"){
- var c=/[\/>\]})\w]/.test(stream.look(-2));
+ var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
@@ -634,7 +645,7 @@ stream.eatSuffix(2);
return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);
return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}
if(ch=="y"){
- var c=/[\/>\]})\w]/.test(stream.look(-2));
+ var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
if(c){
@@ -648,7 +659,7 @@ stream.eatSuffix(2);
return tokenChain(stream,state,[")",")"],RXstyle,RXmodifiers);
return tokenChain(stream,state,[c,c],RXstyle,RXmodifiers);}}}
if(ch=="t"){
- var c=/[\/>\]})\w]/.test(stream.look(-2));
+ var c=/[\/>\]})\w]/.test(look(stream, -2));
if(!c){
c=stream.eat("r");if(c){
c=stream.eat(/[(\[{<\^'"!~\/]/);
@@ -665,7 +676,7 @@ stream.eatSuffix(2);
if(ch=="`"){
return tokenChain(stream,state,[ch],"variable-2");}
if(ch=="/"){
- if(!/~\s*$/.test(stream.prefix()))
+ if(!/~\s*$/.test(prefix(stream)))
return "operator";
else
return tokenChain(stream,state,[ch],RXstyle,RXmodifiers);}
@@ -677,7 +688,7 @@ stream.eatSuffix(2);
stream.pos=p;}
if(/[$@%]/.test(ch)){
var p=stream.pos;
- if(stream.eat("^")&&stream.eat(/[A-Z]/)||!/[@$%&]/.test(stream.look(-2))&&stream.eat(/[=|\\\-#?@;:&`~\^!\[\]*'"$+.,\/<>()]/)){
+ if(stream.eat("^")&&stream.eat(/[A-Z]/)||!/[@$%&]/.test(look(stream, -2))&&stream.eat(/[=|\\\-#?@;:&`~\^!\[\]*'"$+.,\/<>()]/)){
var c=stream.current();
if(PERL[c])
return "variable-2";}
@@ -690,7 +701,7 @@ stream.eatSuffix(2);
else
return "variable";}}
if(ch=="#"){
- if(stream.look(-2)!="$"){
+ if(look(stream, -2)!="$"){
stream.skipToEnd();
return "comment";}}
if(/[:+\-\^*$&%@=<>!?|\/~\.]/.test(ch)){
@@ -702,23 +713,23 @@ stream.eatSuffix(2);
stream.pos=p;}
if(ch=="_"){
if(stream.pos==1){
- if(stream.suffix(6)=="_END__"){
+ if(suffix(stream, 6)=="_END__"){
return tokenChain(stream,state,['\0'],"comment");}
- else if(stream.suffix(7)=="_DATA__"){
+ else if(suffix(stream, 7)=="_DATA__"){
return tokenChain(stream,state,['\0'],"variable-2");}
- else if(stream.suffix(7)=="_C__"){
+ else if(suffix(stream, 7)=="_C__"){
return tokenChain(stream,state,['\0'],"string");}}}
if(/\w/.test(ch)){
var p=stream.pos;
- if(stream.look(-2)=="{"&&(stream.look(0)=="}"||stream.eatWhile(/\w/)&&stream.look(0)=="}"))
+ if(look(stream, -2)=="{"&&(look(stream, 0)=="}"||stream.eatWhile(/\w/)&&look(stream, 0)=="}"))
return "string";
else
stream.pos=p;}
if(/[A-Z]/.test(ch)){
- var l=stream.look(-2);
+ var l=look(stream, -2);
var p=stream.pos;
stream.eatWhile(/[A-Z_]/);
- if(/[\da-z]/.test(stream.look(0))){
+ if(/[\da-z]/.test(look(stream, 0))){
stream.pos=p;}
else{
var c=PERL[stream.current()];
@@ -742,7 +753,7 @@ stream.eatSuffix(2);
else
return "meta";}}
if(/[a-zA-Z_]/.test(ch)){
- var l=stream.look(-2);
+ var l=look(stream, -2);
stream.eatWhile(/\w/);
var c=PERL[stream.current()];
if(!c)
@@ -780,37 +791,37 @@ stream.eatSuffix(2);
CodeMirror.defineMIME("text/x-perl", "perl");
// it's like "peek", but need for look-ahead or look-behind if index < 0
-CodeMirror.StringStream.prototype.look=function(c){
- return this.string.charAt(this.pos+(c||0));};
+function look(stream, c){
+ return stream.string.charAt(stream.pos+(c||0));
+}
// return a part of prefix of current stream from current position
-CodeMirror.StringStream.prototype.prefix=function(c){
- if(c){
- var x=this.pos-c;
- return this.string.substr((x>=0?x:0),c);}
- else{
- return this.string.substr(0,this.pos-1);}};
+function prefix(stream, c){
+ if(c){
+ var x=stream.pos-c;
+ return stream.string.substr((x>=0?x:0),c);}
+ else{
+ return stream.string.substr(0,stream.pos-1);
+ }
+}
// return a part of suffix of current stream from current position
-CodeMirror.StringStream.prototype.suffix=function(c){
- var y=this.string.length;
- var x=y-this.pos+1;
- return this.string.substr(this.pos,(c&&c
=(y=this.string.length-1))
- this.pos=y;
- else
- this.pos=x;};
+function eatSuffix(stream, c){
+ var x=stream.pos+c;
+ var y;
+ if(x<=0)
+ stream.pos=0;
+ else if(x>=(y=stream.string.length-1))
+ stream.pos=y;
+ else
+ stream.pos=x;
+}
+
+});
diff --git a/mode/php/php.js b/mode/php/php.js
index 946f770c9f..7156dbba6f 100644
--- a/mode/php/php.js
+++ b/mode/php/php.js
@@ -1,4 +1,13 @@
-(function() {
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("../htmlmixed/htmlmixed"), require("../clike/clike"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../clike/clike"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
function keywords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
@@ -128,4 +137,4 @@
CodeMirror.defineMIME("application/x-httpd-php", "php");
CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
CodeMirror.defineMIME("text/x-php", phpConfig);
-})();
+});
diff --git a/mode/pig/pig.js b/mode/pig/pig.js
index 4b44e7ccc3..eaf525889c 100644
--- a/mode/pig/pig.js
+++ b/mode/pig/pig.js
@@ -4,6 +4,16 @@
* @link https://github.com/prasanthj/pig-codemirror-2
* This implementation is adapted from PL/SQL mode in CodeMirror 2.
*/
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("pig", function(_config, parserConfig) {
var keywords = parserConfig.keywords,
builtins = parserConfig.builtins,
@@ -169,3 +179,5 @@ CodeMirror.defineMode("pig", function(_config, parserConfig) {
types: keywords(pTypes)
});
}());
+
+});
diff --git a/mode/properties/properties.js b/mode/properties/properties.js
index d3a13c765d..6dfe06f128 100644
--- a/mode/properties/properties.js
+++ b/mode/properties/properties.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("properties", function() {
return {
token: function(stream, state) {
@@ -61,3 +71,5 @@ CodeMirror.defineMode("properties", function() {
CodeMirror.defineMIME("text/x-properties", "properties");
CodeMirror.defineMIME("text/x-ini", "properties");
+
+});
diff --git a/mode/python/python.js b/mode/python/python.js
index 8bea5d19d1..36cf951bef 100644
--- a/mode/python/python.js
+++ b/mode/python/python.js
@@ -1,3 +1,14 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
+
CodeMirror.defineMode("python", function(conf, parserConf) {
var ERRORCLASS = 'error';
@@ -361,14 +372,13 @@ CodeMirror.defineMode("python", function(conf, parserConf) {
CodeMirror.defineMIME("text/x-python", "python");
-(function() {
- "use strict";
- var words = function(str){return str.split(' ');};
-
- CodeMirror.defineMIME("text/x-cython", {
- name: "python",
- extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+
- "extern gil include nogil property public"+
- "readonly struct union DEF IF ELIF ELSE")
- });
-})();
+var words = function(str){return str.split(' ');};
+
+CodeMirror.defineMIME("text/x-cython", {
+ name: "python",
+ extra_keywords: words("by cdef cimport cpdef ctypedef enum except"+
+ "extern gil include nogil property public"+
+ "readonly struct union DEF IF ELIF ELSE")
+});
+
+});
diff --git a/mode/q/q.js b/mode/q/q.js
index 56017e30ad..d6e3b66610 100644
--- a/mode/q/q.js
+++ b/mode/q/q.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("q",function(config){
var indentUnit=config.indentUnit,
curPunc,
@@ -122,3 +132,5 @@ CodeMirror.defineMode("q",function(config){
};
});
CodeMirror.defineMIME("text/x-q","q");
+
+});
diff --git a/mode/r/r.js b/mode/r/r.js
index 690cf40502..7f4feb238b 100644
--- a/mode/r/r.js
+++ b/mode/r/r.js
@@ -1,3 +1,13 @@
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+"use strict";
+
CodeMirror.defineMode("r", function(config) {
function wordObj(str) {
var words = str.split(" "), res = {};
@@ -143,3 +153,5 @@ CodeMirror.defineMode("r", function(config) {
});
CodeMirror.defineMIME("text/x-rsrc", "r");
+
+});
diff --git a/mode/rpm/changes/changes.js b/mode/rpm/changes/changes.js
deleted file mode 100644
index 14a08d9700..0000000000
--- a/mode/rpm/changes/changes.js
+++ /dev/null
@@ -1,19 +0,0 @@
-CodeMirror.defineMode("changes", function() {
- var headerSeperator = /^-+$/;
- var headerLine = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ?\d{1,2} \d{2}:\d{2}(:\d{2})? [A-Z]{3,4} \d{4} - /;
- var simpleEmail = /^[\w+.-]+@[\w.-]+/;
-
- return {
- token: function(stream) {
- if (stream.sol()) {
- if (stream.match(headerSeperator)) { return 'tag'; }
- if (stream.match(headerLine)) { return 'tag'; }
- }
- if (stream.match(simpleEmail)) { return 'string'; }
- stream.next();
- return null;
- }
- };
-});
-
-CodeMirror.defineMIME("text/x-rpm-changes", "changes");
diff --git a/mode/rpm/changes/index.html b/mode/rpm/changes/index.html
deleted file mode 100644
index 18fe7ab7bf..0000000000
--- a/mode/rpm/changes/index.html
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
-CodeMirror: RPM changes mode
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-RPM changes mode
-
-
-
-
- MIME types defined: text/x-rpm-changes
.
-
diff --git a/mode/rpm/spec/index.html b/mode/rpm/index.html
similarity index 60%
rename from mode/rpm/spec/index.html
rename to mode/rpm/index.html
index 127b72ee9d..4257bc77e3 100644
--- a/mode/rpm/spec/index.html
+++ b/mode/rpm/index.html
@@ -1,34 +1,71 @@
-CodeMirror: RPM spec mode
+CodeMirror: RPM changes mode
-
-
-
-
-
+
+
+
+
-
+
+RPM changes mode
+
+
+
+
RPM spec mode
-