codemirror 4.0.3 (new upstream major release)

This commit is contained in:
ilvalle
2014-03-25 12:56:39 +01:00
parent f9ad11473d
commit 7cd3ffbcbd
53 changed files with 4662 additions and 2561 deletions
+25 -8
View File
@@ -1,7 +1,18 @@
(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("xml", function(config, parserConfig) {
var indentUnit = config.indentUnit;
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag || true;
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
var Kludges = parserConfig.htmlMode ? {
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
@@ -33,14 +44,16 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
},
doNotIndent: {"pre": true},
allowUnquoted: true,
allowMissing: true
allowMissing: true,
caseFold: true
} : {
autoSelfClosers: {},
implicitlyClosed: {},
contextGrabbers: {},
doNotIndent: {},
allowUnquoted: false,
allowMissing: false
allowMissing: false,
caseFold: false
};
var alignCDATA = parserConfig.alignCDATA;
@@ -76,6 +89,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
tagName = "";
var c;
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
if (Kludges.caseFold) tagName = tagName.toLowerCase();
if (!tagName) return "tag error";
type = isClose ? "closeTag" : "openTag";
state.tokenize = inTag;
@@ -188,7 +202,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
if (!state.context) {
return;
}
parentTagName = state.context.tagName.toLowerCase();
parentTagName = state.context.tagName;
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
return;
@@ -206,7 +220,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
var err = false;
if (state.context) {
if (state.context.tagName != tagName) {
if (Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName.toLowerCase()))
if (Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
popContext(state);
err = !state.context || state.context.tagName != tagName;
}
@@ -219,6 +233,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
return baseState;
}
}
function closeState(type, _stream, state) {
if (type != "endTag") {
setStyle = "error";
@@ -240,10 +255,10 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
var tagName = state.tagName, tagStart = state.tagStart;
state.tagName = state.tagStart = null;
if (type == "selfcloseTag" ||
Kludges.autoSelfClosers.hasOwnProperty(tagName.toLowerCase())) {
maybePopContext(state, tagName.toLowerCase());
Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
maybePopContext(state, tagName);
} else {
maybePopContext(state, tagName.toLowerCase());
maybePopContext(state, tagName);
state.context = new Context(state, tagName, tagStart == state.indented);
}
return baseState;
@@ -330,3 +345,5 @@ CodeMirror.defineMIME("text/xml", "xml");
CodeMirror.defineMIME("application/xml", "xml");
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
});