Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[xml mode] Make tag names case-insensitive in html mode

Issue #2304
  • Loading branch information...
commit e5b0028ad63a1f2d40fc040c705a542ebb794801 1 parent 74c8d30
@marijnh marijnh authored
Showing with 11 additions and 8 deletions.
  1. +1 −1  mode/xml/index.html
  2. +10 −7 mode/xml/xml.js
View
2  mode/xml/index.html
@@ -38,7 +38,7 @@
</textarea></form>
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
- mode: {name: "xml", alignCDATA: true},
+ mode: "text/html",
lineNumbers: true
});
</script>
View
17 mode/xml/xml.js
@@ -34,14 +34,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;
@@ -77,6 +79,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;
@@ -189,7 +192,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;
@@ -207,7 +210,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;
}
@@ -241,10 +244,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;
Please sign in to comment.
Something went wrong with that request. Please try again.