X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/f938afb8ab4cb091d12e0ef0311eaea14b774798..1024e7820ecb22cde464da17ae22b161adf75c3b:/redakcja/static/js/lib/codemirror/parsexml.js diff --git a/redakcja/static/js/lib/codemirror/parsexml.js b/redakcja/static/js/lib/codemirror/parsexml.js index 87fbf0c0..994efd3b 100644 --- a/redakcja/static/js/lib/codemirror/parsexml.js +++ b/redakcja/static/js/lib/codemirror/parsexml.js @@ -125,12 +125,12 @@ var XMLParser = Editor.Parser = (function() { // parseJavaScript in parsejavascript.js (there is actually a bit more // shared code than I'd like), but it is quite a bit simpler. function parseXML(source) { - var tokens = tokenizeXML(source); + var tokens = tokenizeXML(source), token; var cc = [base]; var tokenNr = 0, indented = 0; var currentTag = null, context = null; - var consume, marked; - + var consume; + function push(fs) { for (var i = fs.length - 1; i >= 0; i--) cc.push(fs[i]); @@ -144,13 +144,13 @@ var XMLParser = Editor.Parser = (function() { consume = false; } - function mark(style) { - marked = style; + function markErr() { + token.style += " xml-error"; } function expect(text) { return function(style, content) { if (content == text) cont(); - else mark("xml-error") || cont(arguments.callee); + else {markErr(); cont(arguments.callee);} }; } @@ -192,12 +192,12 @@ var XMLParser = Editor.Parser = (function() { cont(); } else if (harmlessTokens.hasOwnProperty(style)) cont(); - else mark("xml-error") || cont(); + else {markErr(); cont();} } function tagname(style, content) { if (style == "xml-name") { currentTag = content.toLowerCase(); - mark("xml-tagname"); + token.style = "xml-tagname"; cont(); } else { @@ -206,24 +206,22 @@ var XMLParser = Editor.Parser = (function() { } } function closetagname(style, content) { - if (style == "xml-name" && context && content.toLowerCase() == context.name) { - popContext(); - mark("xml-tagname"); - } - else { - mark("xml-error"); + if (style == "xml-name") { + token.style = "xml-tagname"; + if (context && content.toLowerCase() == context.name) popContext(); + else markErr(); } cont(); } function endtag(startOfLine) { return function(style, content) { if (content == "/>" || (content == ">" && UseKludges.autoSelfClosers.hasOwnProperty(currentTag))) cont(); - else if (content == ">") pushContext(currentTag, startOfLine) || cont(); - else mark("xml-error") || cont(arguments.callee); + else if (content == ">") {pushContext(currentTag, startOfLine); cont();} + else {markErr(); cont(arguments.callee);} }; } function attributes(style) { - if (style == "xml-name") mark("xml-attname") || cont(attribute, attributes); + if (style == "xml-name") {token.style = "xml-attname"; cont(attribute, attributes);} else pass(); } function attribute(style, content) { @@ -240,7 +238,7 @@ var XMLParser = Editor.Parser = (function() { indentation: function() {return indented;}, next: function(){ - var token = tokens.next(); + token = tokens.next(); if (token.style == "whitespace" && tokenNr == 0) indented = token.value.length; else @@ -254,20 +252,16 @@ var XMLParser = Editor.Parser = (function() { return token; while(true){ - consume = marked = false; + consume = false; cc.pop()(token.style, token.content); - if (consume){ - if (marked) - token.style = marked; - return token; - } + if (consume) return token; } }, copy: function(){ var _cc = cc.concat([]), _tokenState = tokens.state, _context = context; var parser = this; - + return function(input){ cc = _cc.concat([]); tokenNr = indented = 0;