From c2805e03c84b6e598556fd06d1ede7aaeea7ce9c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 6 Mar 2012 16:17:54 -0800 Subject: Squashed commit FileIO-Build-Candidate into Master Fixing issues with HTML and CSS URLs. Adjusted RegEx logic. Also code a mirror update and undo/redo changes were merged into this request. Signed-off-by: Valerio Virgillito --- imports/codemirror/mode/xml/xml.js | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) mode change 100755 => 100644 imports/codemirror/mode/xml/xml.js (limited to 'imports/codemirror/mode/xml/xml.js') 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