Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/xml
File: xml.js
// CodeMirror, copyright (c) by Marijn Haverbeke and others
[0] Fix | Delete
// Distributed under an MIT license: http://codemirror.net/LICENSE
[1] Fix | Delete
[2] Fix | Delete
(function(mod) {
[3] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[4] Fix | Delete
mod(require("../../lib/codemirror"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror"], mod);
[7] Fix | Delete
else // Plain browser env
[8] Fix | Delete
mod(CodeMirror);
[9] Fix | Delete
})(function(CodeMirror) {
[10] Fix | Delete
"use strict";
[11] Fix | Delete
[12] Fix | Delete
var htmlConfig = {
[13] Fix | Delete
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
[14] Fix | Delete
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
[15] Fix | Delete
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
[16] Fix | Delete
'track': true, 'wbr': true, 'menuitem': true},
[17] Fix | Delete
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
[18] Fix | Delete
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
[19] Fix | Delete
'th': true, 'tr': true},
[20] Fix | Delete
contextGrabbers: {
[21] Fix | Delete
'dd': {'dd': true, 'dt': true},
[22] Fix | Delete
'dt': {'dd': true, 'dt': true},
[23] Fix | Delete
'li': {'li': true},
[24] Fix | Delete
'option': {'option': true, 'optgroup': true},
[25] Fix | Delete
'optgroup': {'optgroup': true},
[26] Fix | Delete
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
[27] Fix | Delete
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
[28] Fix | Delete
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
[29] Fix | Delete
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
[30] Fix | Delete
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
[31] Fix | Delete
'rp': {'rp': true, 'rt': true},
[32] Fix | Delete
'rt': {'rp': true, 'rt': true},
[33] Fix | Delete
'tbody': {'tbody': true, 'tfoot': true},
[34] Fix | Delete
'td': {'td': true, 'th': true},
[35] Fix | Delete
'tfoot': {'tbody': true},
[36] Fix | Delete
'th': {'td': true, 'th': true},
[37] Fix | Delete
'thead': {'tbody': true, 'tfoot': true},
[38] Fix | Delete
'tr': {'tr': true}
[39] Fix | Delete
},
[40] Fix | Delete
doNotIndent: {"pre": true},
[41] Fix | Delete
allowUnquoted: true,
[42] Fix | Delete
allowMissing: true,
[43] Fix | Delete
caseFold: true
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
var xmlConfig = {
[47] Fix | Delete
autoSelfClosers: {},
[48] Fix | Delete
implicitlyClosed: {},
[49] Fix | Delete
contextGrabbers: {},
[50] Fix | Delete
doNotIndent: {},
[51] Fix | Delete
allowUnquoted: false,
[52] Fix | Delete
allowMissing: false,
[53] Fix | Delete
caseFold: false
[54] Fix | Delete
}
[55] Fix | Delete
[56] Fix | Delete
CodeMirror.defineMode("xml", function(editorConf, config_) {
[57] Fix | Delete
var indentUnit = editorConf.indentUnit
[58] Fix | Delete
var config = {}
[59] Fix | Delete
var defaults = config_.htmlMode ? htmlConfig : xmlConfig
[60] Fix | Delete
for (var prop in defaults) config[prop] = defaults[prop]
[61] Fix | Delete
for (var prop in config_) config[prop] = config_[prop]
[62] Fix | Delete
[63] Fix | Delete
// Return variables for tokenizers
[64] Fix | Delete
var type, setStyle;
[65] Fix | Delete
[66] Fix | Delete
function inText(stream, state) {
[67] Fix | Delete
function chain(parser) {
[68] Fix | Delete
state.tokenize = parser;
[69] Fix | Delete
return parser(stream, state);
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
var ch = stream.next();
[73] Fix | Delete
if (ch == "<") {
[74] Fix | Delete
if (stream.eat("!")) {
[75] Fix | Delete
if (stream.eat("[")) {
[76] Fix | Delete
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
[77] Fix | Delete
else return null;
[78] Fix | Delete
} else if (stream.match("--")) {
[79] Fix | Delete
return chain(inBlock("comment", "-->"));
[80] Fix | Delete
} else if (stream.match("DOCTYPE", true, true)) {
[81] Fix | Delete
stream.eatWhile(/[\w\._\-]/);
[82] Fix | Delete
return chain(doctype(1));
[83] Fix | Delete
} else {
[84] Fix | Delete
return null;
[85] Fix | Delete
}
[86] Fix | Delete
} else if (stream.eat("?")) {
[87] Fix | Delete
stream.eatWhile(/[\w\._\-]/);
[88] Fix | Delete
state.tokenize = inBlock("meta", "?>");
[89] Fix | Delete
return "meta";
[90] Fix | Delete
} else {
[91] Fix | Delete
type = stream.eat("/") ? "closeTag" : "openTag";
[92] Fix | Delete
state.tokenize = inTag;
[93] Fix | Delete
return "tag bracket";
[94] Fix | Delete
}
[95] Fix | Delete
} else if (ch == "&") {
[96] Fix | Delete
var ok;
[97] Fix | Delete
if (stream.eat("#")) {
[98] Fix | Delete
if (stream.eat("x")) {
[99] Fix | Delete
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
[100] Fix | Delete
} else {
[101] Fix | Delete
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
[102] Fix | Delete
}
[103] Fix | Delete
} else {
[104] Fix | Delete
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
[105] Fix | Delete
}
[106] Fix | Delete
return ok ? "atom" : "error";
[107] Fix | Delete
} else {
[108] Fix | Delete
stream.eatWhile(/[^&<]/);
[109] Fix | Delete
return null;
[110] Fix | Delete
}
[111] Fix | Delete
}
[112] Fix | Delete
inText.isInText = true;
[113] Fix | Delete
[114] Fix | Delete
function inTag(stream, state) {
[115] Fix | Delete
var ch = stream.next();
[116] Fix | Delete
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
[117] Fix | Delete
state.tokenize = inText;
[118] Fix | Delete
type = ch == ">" ? "endTag" : "selfcloseTag";
[119] Fix | Delete
return "tag bracket";
[120] Fix | Delete
} else if (ch == "=") {
[121] Fix | Delete
type = "equals";
[122] Fix | Delete
return null;
[123] Fix | Delete
} else if (ch == "<") {
[124] Fix | Delete
state.tokenize = inText;
[125] Fix | Delete
state.state = baseState;
[126] Fix | Delete
state.tagName = state.tagStart = null;
[127] Fix | Delete
var next = state.tokenize(stream, state);
[128] Fix | Delete
return next ? next + " tag error" : "tag error";
[129] Fix | Delete
} else if (/[\'\"]/.test(ch)) {
[130] Fix | Delete
state.tokenize = inAttribute(ch);
[131] Fix | Delete
state.stringStartCol = stream.column();
[132] Fix | Delete
return state.tokenize(stream, state);
[133] Fix | Delete
} else {
[134] Fix | Delete
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
[135] Fix | Delete
return "word";
[136] Fix | Delete
}
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
function inAttribute(quote) {
[140] Fix | Delete
var closure = function(stream, state) {
[141] Fix | Delete
while (!stream.eol()) {
[142] Fix | Delete
if (stream.next() == quote) {
[143] Fix | Delete
state.tokenize = inTag;
[144] Fix | Delete
break;
[145] Fix | Delete
}
[146] Fix | Delete
}
[147] Fix | Delete
return "string";
[148] Fix | Delete
};
[149] Fix | Delete
closure.isInAttribute = true;
[150] Fix | Delete
return closure;
[151] Fix | Delete
}
[152] Fix | Delete
[153] Fix | Delete
function inBlock(style, terminator) {
[154] Fix | Delete
return function(stream, state) {
[155] Fix | Delete
while (!stream.eol()) {
[156] Fix | Delete
if (stream.match(terminator)) {
[157] Fix | Delete
state.tokenize = inText;
[158] Fix | Delete
break;
[159] Fix | Delete
}
[160] Fix | Delete
stream.next();
[161] Fix | Delete
}
[162] Fix | Delete
return style;
[163] Fix | Delete
};
[164] Fix | Delete
}
[165] Fix | Delete
function doctype(depth) {
[166] Fix | Delete
return function(stream, state) {
[167] Fix | Delete
var ch;
[168] Fix | Delete
while ((ch = stream.next()) != null) {
[169] Fix | Delete
if (ch == "<") {
[170] Fix | Delete
state.tokenize = doctype(depth + 1);
[171] Fix | Delete
return state.tokenize(stream, state);
[172] Fix | Delete
} else if (ch == ">") {
[173] Fix | Delete
if (depth == 1) {
[174] Fix | Delete
state.tokenize = inText;
[175] Fix | Delete
break;
[176] Fix | Delete
} else {
[177] Fix | Delete
state.tokenize = doctype(depth - 1);
[178] Fix | Delete
return state.tokenize(stream, state);
[179] Fix | Delete
}
[180] Fix | Delete
}
[181] Fix | Delete
}
[182] Fix | Delete
return "meta";
[183] Fix | Delete
};
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
function Context(state, tagName, startOfLine) {
[187] Fix | Delete
this.prev = state.context;
[188] Fix | Delete
this.tagName = tagName;
[189] Fix | Delete
this.indent = state.indented;
[190] Fix | Delete
this.startOfLine = startOfLine;
[191] Fix | Delete
if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
[192] Fix | Delete
this.noIndent = true;
[193] Fix | Delete
}
[194] Fix | Delete
function popContext(state) {
[195] Fix | Delete
if (state.context) state.context = state.context.prev;
[196] Fix | Delete
}
[197] Fix | Delete
function maybePopContext(state, nextTagName) {
[198] Fix | Delete
var parentTagName;
[199] Fix | Delete
while (true) {
[200] Fix | Delete
if (!state.context) {
[201] Fix | Delete
return;
[202] Fix | Delete
}
[203] Fix | Delete
parentTagName = state.context.tagName;
[204] Fix | Delete
if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
[205] Fix | Delete
!config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
[206] Fix | Delete
return;
[207] Fix | Delete
}
[208] Fix | Delete
popContext(state);
[209] Fix | Delete
}
[210] Fix | Delete
}
[211] Fix | Delete
[212] Fix | Delete
function baseState(type, stream, state) {
[213] Fix | Delete
if (type == "openTag") {
[214] Fix | Delete
state.tagStart = stream.column();
[215] Fix | Delete
return tagNameState;
[216] Fix | Delete
} else if (type == "closeTag") {
[217] Fix | Delete
return closeTagNameState;
[218] Fix | Delete
} else {
[219] Fix | Delete
return baseState;
[220] Fix | Delete
}
[221] Fix | Delete
}
[222] Fix | Delete
function tagNameState(type, stream, state) {
[223] Fix | Delete
if (type == "word") {
[224] Fix | Delete
state.tagName = stream.current();
[225] Fix | Delete
setStyle = "tag";
[226] Fix | Delete
return attrState;
[227] Fix | Delete
} else {
[228] Fix | Delete
setStyle = "error";
[229] Fix | Delete
return tagNameState;
[230] Fix | Delete
}
[231] Fix | Delete
}
[232] Fix | Delete
function closeTagNameState(type, stream, state) {
[233] Fix | Delete
if (type == "word") {
[234] Fix | Delete
var tagName = stream.current();
[235] Fix | Delete
if (state.context && state.context.tagName != tagName &&
[236] Fix | Delete
config.implicitlyClosed.hasOwnProperty(state.context.tagName))
[237] Fix | Delete
popContext(state);
[238] Fix | Delete
if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
[239] Fix | Delete
setStyle = "tag";
[240] Fix | Delete
return closeState;
[241] Fix | Delete
} else {
[242] Fix | Delete
setStyle = "tag error";
[243] Fix | Delete
return closeStateErr;
[244] Fix | Delete
}
[245] Fix | Delete
} else {
[246] Fix | Delete
setStyle = "error";
[247] Fix | Delete
return closeStateErr;
[248] Fix | Delete
}
[249] Fix | Delete
}
[250] Fix | Delete
[251] Fix | Delete
function closeState(type, _stream, state) {
[252] Fix | Delete
if (type != "endTag") {
[253] Fix | Delete
setStyle = "error";
[254] Fix | Delete
return closeState;
[255] Fix | Delete
}
[256] Fix | Delete
popContext(state);
[257] Fix | Delete
return baseState;
[258] Fix | Delete
}
[259] Fix | Delete
function closeStateErr(type, stream, state) {
[260] Fix | Delete
setStyle = "error";
[261] Fix | Delete
return closeState(type, stream, state);
[262] Fix | Delete
}
[263] Fix | Delete
[264] Fix | Delete
function attrState(type, _stream, state) {
[265] Fix | Delete
if (type == "word") {
[266] Fix | Delete
setStyle = "attribute";
[267] Fix | Delete
return attrEqState;
[268] Fix | Delete
} else if (type == "endTag" || type == "selfcloseTag") {
[269] Fix | Delete
var tagName = state.tagName, tagStart = state.tagStart;
[270] Fix | Delete
state.tagName = state.tagStart = null;
[271] Fix | Delete
if (type == "selfcloseTag" ||
[272] Fix | Delete
config.autoSelfClosers.hasOwnProperty(tagName)) {
[273] Fix | Delete
maybePopContext(state, tagName);
[274] Fix | Delete
} else {
[275] Fix | Delete
maybePopContext(state, tagName);
[276] Fix | Delete
state.context = new Context(state, tagName, tagStart == state.indented);
[277] Fix | Delete
}
[278] Fix | Delete
return baseState;
[279] Fix | Delete
}
[280] Fix | Delete
setStyle = "error";
[281] Fix | Delete
return attrState;
[282] Fix | Delete
}
[283] Fix | Delete
function attrEqState(type, stream, state) {
[284] Fix | Delete
if (type == "equals") return attrValueState;
[285] Fix | Delete
if (!config.allowMissing) setStyle = "error";
[286] Fix | Delete
return attrState(type, stream, state);
[287] Fix | Delete
}
[288] Fix | Delete
function attrValueState(type, stream, state) {
[289] Fix | Delete
if (type == "string") return attrContinuedState;
[290] Fix | Delete
if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
[291] Fix | Delete
setStyle = "error";
[292] Fix | Delete
return attrState(type, stream, state);
[293] Fix | Delete
}
[294] Fix | Delete
function attrContinuedState(type, stream, state) {
[295] Fix | Delete
if (type == "string") return attrContinuedState;
[296] Fix | Delete
return attrState(type, stream, state);
[297] Fix | Delete
}
[298] Fix | Delete
[299] Fix | Delete
return {
[300] Fix | Delete
startState: function(baseIndent) {
[301] Fix | Delete
var state = {tokenize: inText,
[302] Fix | Delete
state: baseState,
[303] Fix | Delete
indented: baseIndent || 0,
[304] Fix | Delete
tagName: null, tagStart: null,
[305] Fix | Delete
context: null}
[306] Fix | Delete
if (baseIndent != null) state.baseIndent = baseIndent
[307] Fix | Delete
return state
[308] Fix | Delete
},
[309] Fix | Delete
[310] Fix | Delete
token: function(stream, state) {
[311] Fix | Delete
if (!state.tagName && stream.sol())
[312] Fix | Delete
state.indented = stream.indentation();
[313] Fix | Delete
[314] Fix | Delete
if (stream.eatSpace()) return null;
[315] Fix | Delete
type = null;
[316] Fix | Delete
var style = state.tokenize(stream, state);
[317] Fix | Delete
if ((style || type) && style != "comment") {
[318] Fix | Delete
setStyle = null;
[319] Fix | Delete
state.state = state.state(type || style, stream, state);
[320] Fix | Delete
if (setStyle)
[321] Fix | Delete
style = setStyle == "error" ? style + " error" : setStyle;
[322] Fix | Delete
}
[323] Fix | Delete
return style;
[324] Fix | Delete
},
[325] Fix | Delete
[326] Fix | Delete
indent: function(state, textAfter, fullLine) {
[327] Fix | Delete
var context = state.context;
[328] Fix | Delete
// Indent multi-line strings (e.g. css).
[329] Fix | Delete
if (state.tokenize.isInAttribute) {
[330] Fix | Delete
if (state.tagStart == state.indented)
[331] Fix | Delete
return state.stringStartCol + 1;
[332] Fix | Delete
else
[333] Fix | Delete
return state.indented + indentUnit;
[334] Fix | Delete
}
[335] Fix | Delete
if (context && context.noIndent) return CodeMirror.Pass;
[336] Fix | Delete
if (state.tokenize != inTag && state.tokenize != inText)
[337] Fix | Delete
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
[338] Fix | Delete
// Indent the starts of attribute names.
[339] Fix | Delete
if (state.tagName) {
[340] Fix | Delete
if (config.multilineTagIndentPastTag !== false)
[341] Fix | Delete
return state.tagStart + state.tagName.length + 2;
[342] Fix | Delete
else
[343] Fix | Delete
return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
[344] Fix | Delete
}
[345] Fix | Delete
if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
[346] Fix | Delete
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
[347] Fix | Delete
if (tagAfter && tagAfter[1]) { // Closing tag spotted
[348] Fix | Delete
while (context) {
[349] Fix | Delete
if (context.tagName == tagAfter[2]) {
[350] Fix | Delete
context = context.prev;
[351] Fix | Delete
break;
[352] Fix | Delete
} else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
[353] Fix | Delete
context = context.prev;
[354] Fix | Delete
} else {
[355] Fix | Delete
break;
[356] Fix | Delete
}
[357] Fix | Delete
}
[358] Fix | Delete
} else if (tagAfter) { // Opening tag spotted
[359] Fix | Delete
while (context) {
[360] Fix | Delete
var grabbers = config.contextGrabbers[context.tagName];
[361] Fix | Delete
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
[362] Fix | Delete
context = context.prev;
[363] Fix | Delete
else
[364] Fix | Delete
break;
[365] Fix | Delete
}
[366] Fix | Delete
}
[367] Fix | Delete
while (context && context.prev && !context.startOfLine)
[368] Fix | Delete
context = context.prev;
[369] Fix | Delete
if (context) return context.indent + indentUnit;
[370] Fix | Delete
else return state.baseIndent || 0;
[371] Fix | Delete
},
[372] Fix | Delete
[373] Fix | Delete
electricInput: /<\/[\s\w:]+>$/,
[374] Fix | Delete
blockCommentStart: "<!--",
[375] Fix | Delete
blockCommentEnd: "-->",
[376] Fix | Delete
[377] Fix | Delete
configuration: config.htmlMode ? "html" : "xml",
[378] Fix | Delete
helperType: config.htmlMode ? "html" : "xml",
[379] Fix | Delete
[380] Fix | Delete
skipAttribute: function(state) {
[381] Fix | Delete
if (state.state == attrValueState)
[382] Fix | Delete
state.state = attrState
[383] Fix | Delete
}
[384] Fix | Delete
};
[385] Fix | Delete
});
[386] Fix | Delete
[387] Fix | Delete
CodeMirror.defineMIME("text/xml", "xml");
[388] Fix | Delete
CodeMirror.defineMIME("application/xml", "xml");
[389] Fix | Delete
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
[390] Fix | Delete
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
[391] Fix | Delete
[392] Fix | Delete
});
[393] Fix | Delete
[394] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function