From 51ed781953bc44bba3c70938aa57b856394cbc88 Mon Sep 17 00:00:00 2001 From: Ananya Sen Date: Mon, 27 Feb 2012 14:41:21 -0800 Subject: updating to codemirror 2.22 Signed-off-by: Ananya Sen --- imports/codemirror/mode/xml/index.html | 0 imports/codemirror/mode/xml/xml.js | 35 ++++++++++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) mode change 100755 => 100644 imports/codemirror/mode/xml/index.html mode change 100755 => 100644 imports/codemirror/mode/xml/xml.js (limited to 'imports/codemirror/mode/xml') diff --git a/imports/codemirror/mode/xml/index.html b/imports/codemirror/mode/xml/index.html old mode 100755 new mode 100644 diff --git a/imports/codemirror/mode/xml/xml.js b/imports/codemirror/mode/xml/xml.js old mode 100755 new mode 100644 index 71e0e2b0..f467bddc --- a/imports/codemirror/mode/xml/xml.js +++ b/imports/codemirror/mode/xml/xml.js @@ -4,8 +4,9 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { autoSelfClosers: {"br": true, "img": true, "hr": true, "link": true, "input": true, "meta": true, "col": true, "frame": true, "base": true, "area": true}, doNotIndent: {"pre": true}, - allowUnquoted: true - } : {autoSelfClosers: {}, doNotIndent: {}, allowUnquoted: false}; + allowUnquoted: true, + allowMissing: false + } : {autoSelfClosers: {}, doNotIndent: {}, allowUnquoted: false, allowMissing: false}; var alignCDATA = parserConfig.alignCDATA; // Return variables for tokenizers @@ -47,9 +48,17 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { } } else if (ch == "&") { - stream.eatWhile(/[^;]/); - stream.eat(";"); - return "atom"; + var ok; + if (stream.eat("#")) { + if (stream.eat("x")) { + ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";"); + } else { + ok = stream.eatWhile(/[\d]/) && stream.eat(";"); + } + } else { + ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";"); + } + return ok ? "atom" : "error"; } else { stream.eatWhile(/[^&<]/); @@ -181,15 +190,21 @@ CodeMirror.defineMode("xml", function(config, parserConfig) { } function attributes(type) { - if (type == "word") {setStyle = "attribute"; return cont(attributes);} + if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);} + if (type == "endTag" || type == "selfcloseTag") return pass(); + setStyle = "error"; + return cont(attributes); + } + function attribute(type) { if (type == "equals") return cont(attvalue, attributes); - if (type == "string") {setStyle = "error"; return cont(attributes);} - return pass(); + if (!Kludges.allowMissing) setStyle = "error"; + return (type == "endTag" || type == "selfcloseTag") ? pass() : cont(); } function attvalue(type) { - if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();} if (type == "string") return cont(attvaluemaybe); - return pass(); + if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();} + setStyle = "error"; + return (type == "endTag" || type == "selfCloseTag") ? pass() : cont(); } function attvaluemaybe(type) { if (type == "string") return cont(attvaluemaybe); -- cgit v1.2.3