Edit File by line
/home/barbar84/www/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/dtd
File: dtd.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
/*
[3] Fix | Delete
DTD mode
[4] Fix | Delete
Ported to CodeMirror by Peter Kroon <plakroon@gmail.com>
[5] Fix | Delete
Report bugs/issues here: https://github.com/codemirror/CodeMirror/issues
[6] Fix | Delete
GitHub: @peterkroon
[7] Fix | Delete
*/
[8] Fix | Delete
[9] Fix | Delete
(function(mod) {
[10] Fix | Delete
if (typeof exports == "object" && typeof module == "object") // CommonJS
[11] Fix | Delete
mod(require("../../lib/codemirror"));
[12] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[13] Fix | Delete
define(["../../lib/codemirror"], mod);
[14] Fix | Delete
else // Plain browser env
[15] Fix | Delete
mod(CodeMirror);
[16] Fix | Delete
})(function(CodeMirror) {
[17] Fix | Delete
"use strict";
[18] Fix | Delete
[19] Fix | Delete
CodeMirror.defineMode("dtd", function(config) {
[20] Fix | Delete
var indentUnit = config.indentUnit, type;
[21] Fix | Delete
function ret(style, tp) {type = tp; return style;}
[22] Fix | Delete
[23] Fix | Delete
function tokenBase(stream, state) {
[24] Fix | Delete
var ch = stream.next();
[25] Fix | Delete
[26] Fix | Delete
if (ch == "<" && stream.eat("!") ) {
[27] Fix | Delete
if (stream.eatWhile(/[\-]/)) {
[28] Fix | Delete
state.tokenize = tokenSGMLComment;
[29] Fix | Delete
return tokenSGMLComment(stream, state);
[30] Fix | Delete
} else if (stream.eatWhile(/[\w]/)) return ret("keyword", "doindent");
[31] Fix | Delete
} else if (ch == "<" && stream.eat("?")) { //xml declaration
[32] Fix | Delete
state.tokenize = inBlock("meta", "?>");
[33] Fix | Delete
return ret("meta", ch);
[34] Fix | Delete
} else if (ch == "#" && stream.eatWhile(/[\w]/)) return ret("atom", "tag");
[35] Fix | Delete
else if (ch == "|") return ret("keyword", "seperator");
[36] Fix | Delete
else if (ch.match(/[\(\)\[\]\-\.,\+\?>]/)) return ret(null, ch);//if(ch === ">") return ret(null, "endtag"); else
[37] Fix | Delete
else if (ch.match(/[\[\]]/)) return ret("rule", ch);
[38] Fix | Delete
else if (ch == "\"" || ch == "'") {
[39] Fix | Delete
state.tokenize = tokenString(ch);
[40] Fix | Delete
return state.tokenize(stream, state);
[41] Fix | Delete
} else if (stream.eatWhile(/[a-zA-Z\?\+\d]/)) {
[42] Fix | Delete
var sc = stream.current();
[43] Fix | Delete
if( sc.substr(sc.length-1,sc.length).match(/\?|\+/) !== null )stream.backUp(1);
[44] Fix | Delete
return ret("tag", "tag");
[45] Fix | Delete
} else if (ch == "%" || ch == "*" ) return ret("number", "number");
[46] Fix | Delete
else {
[47] Fix | Delete
stream.eatWhile(/[\w\\\-_%.{,]/);
[48] Fix | Delete
return ret(null, null);
[49] Fix | Delete
}
[50] Fix | Delete
}
[51] Fix | Delete
[52] Fix | Delete
function tokenSGMLComment(stream, state) {
[53] Fix | Delete
var dashes = 0, ch;
[54] Fix | Delete
while ((ch = stream.next()) != null) {
[55] Fix | Delete
if (dashes >= 2 && ch == ">") {
[56] Fix | Delete
state.tokenize = tokenBase;
[57] Fix | Delete
break;
[58] Fix | Delete
}
[59] Fix | Delete
dashes = (ch == "-") ? dashes + 1 : 0;
[60] Fix | Delete
}
[61] Fix | Delete
return ret("comment", "comment");
[62] Fix | Delete
}
[63] Fix | Delete
[64] Fix | Delete
function tokenString(quote) {
[65] Fix | Delete
return function(stream, state) {
[66] Fix | Delete
var escaped = false, ch;
[67] Fix | Delete
while ((ch = stream.next()) != null) {
[68] Fix | Delete
if (ch == quote && !escaped) {
[69] Fix | Delete
state.tokenize = tokenBase;
[70] Fix | Delete
break;
[71] Fix | Delete
}
[72] Fix | Delete
escaped = !escaped && ch == "\\";
[73] Fix | Delete
}
[74] Fix | Delete
return ret("string", "tag");
[75] Fix | Delete
};
[76] Fix | Delete
}
[77] Fix | Delete
[78] Fix | Delete
function inBlock(style, terminator) {
[79] Fix | Delete
return function(stream, state) {
[80] Fix | Delete
while (!stream.eol()) {
[81] Fix | Delete
if (stream.match(terminator)) {
[82] Fix | Delete
state.tokenize = tokenBase;
[83] Fix | Delete
break;
[84] Fix | Delete
}
[85] Fix | Delete
stream.next();
[86] Fix | Delete
}
[87] Fix | Delete
return style;
[88] Fix | Delete
};
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
return {
[92] Fix | Delete
startState: function(base) {
[93] Fix | Delete
return {tokenize: tokenBase,
[94] Fix | Delete
baseIndent: base || 0,
[95] Fix | Delete
stack: []};
[96] Fix | Delete
},
[97] Fix | Delete
[98] Fix | Delete
token: function(stream, state) {
[99] Fix | Delete
if (stream.eatSpace()) return null;
[100] Fix | Delete
var style = state.tokenize(stream, state);
[101] Fix | Delete
[102] Fix | Delete
var context = state.stack[state.stack.length-1];
[103] Fix | Delete
if (stream.current() == "[" || type === "doindent" || type == "[") state.stack.push("rule");
[104] Fix | Delete
else if (type === "endtag") state.stack[state.stack.length-1] = "endtag";
[105] Fix | Delete
else if (stream.current() == "]" || type == "]" || (type == ">" && context == "rule")) state.stack.pop();
[106] Fix | Delete
else if (type == "[") state.stack.push("[");
[107] Fix | Delete
return style;
[108] Fix | Delete
},
[109] Fix | Delete
[110] Fix | Delete
indent: function(state, textAfter) {
[111] Fix | Delete
var n = state.stack.length;
[112] Fix | Delete
[113] Fix | Delete
if( textAfter.match(/\]\s+|\]/) )n=n-1;
[114] Fix | Delete
else if(textAfter.substr(textAfter.length-1, textAfter.length) === ">"){
[115] Fix | Delete
if(textAfter.substr(0,1) === "<") {}
[116] Fix | Delete
else if( type == "doindent" && textAfter.length > 1 ) {}
[117] Fix | Delete
else if( type == "doindent")n--;
[118] Fix | Delete
else if( type == ">" && textAfter.length > 1) {}
[119] Fix | Delete
else if( type == "tag" && textAfter !== ">") {}
[120] Fix | Delete
else if( type == "tag" && state.stack[state.stack.length-1] == "rule")n--;
[121] Fix | Delete
else if( type == "tag")n++;
[122] Fix | Delete
else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule" && type === ">")n--;
[123] Fix | Delete
else if( textAfter === ">" && state.stack[state.stack.length-1] == "rule") {}
[124] Fix | Delete
else if( textAfter.substr(0,1) !== "<" && textAfter.substr(0,1) === ">" )n=n-1;
[125] Fix | Delete
else if( textAfter === ">") {}
[126] Fix | Delete
else n=n-1;
[127] Fix | Delete
//over rule them all
[128] Fix | Delete
if(type == null || type == "]")n--;
[129] Fix | Delete
}
[130] Fix | Delete
[131] Fix | Delete
return state.baseIndent + n * indentUnit;
[132] Fix | Delete
},
[133] Fix | Delete
[134] Fix | Delete
electricChars: "]>"
[135] Fix | Delete
};
[136] Fix | Delete
});
[137] Fix | Delete
[138] Fix | Delete
CodeMirror.defineMIME("application/xml-dtd", "dtd");
[139] Fix | Delete
[140] Fix | Delete
});
[141] Fix | Delete
[142] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function