Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-file-.../lib/codemirr.../mode/haml
File: haml.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"), require("../htmlmixed/htmlmixed"), require("../ruby/ruby"));
[5] Fix | Delete
else if (typeof define == "function" && define.amd) // AMD
[6] Fix | Delete
define(["../../lib/codemirror", "../htmlmixed/htmlmixed", "../ruby/ruby"], 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
// full haml mode. This handled embedded ruby and html fragments too
[13] Fix | Delete
CodeMirror.defineMode("haml", function(config) {
[14] Fix | Delete
var htmlMode = CodeMirror.getMode(config, {name: "htmlmixed"});
[15] Fix | Delete
var rubyMode = CodeMirror.getMode(config, "ruby");
[16] Fix | Delete
[17] Fix | Delete
function rubyInQuote(endQuote) {
[18] Fix | Delete
return function(stream, state) {
[19] Fix | Delete
var ch = stream.peek();
[20] Fix | Delete
if (ch == endQuote && state.rubyState.tokenize.length == 1) {
[21] Fix | Delete
// step out of ruby context as it seems to complete processing all the braces
[22] Fix | Delete
stream.next();
[23] Fix | Delete
state.tokenize = html;
[24] Fix | Delete
return "closeAttributeTag";
[25] Fix | Delete
} else {
[26] Fix | Delete
return ruby(stream, state);
[27] Fix | Delete
}
[28] Fix | Delete
};
[29] Fix | Delete
}
[30] Fix | Delete
[31] Fix | Delete
function ruby(stream, state) {
[32] Fix | Delete
if (stream.match("-#")) {
[33] Fix | Delete
stream.skipToEnd();
[34] Fix | Delete
return "comment";
[35] Fix | Delete
}
[36] Fix | Delete
return rubyMode.token(stream, state.rubyState);
[37] Fix | Delete
}
[38] Fix | Delete
[39] Fix | Delete
function html(stream, state) {
[40] Fix | Delete
var ch = stream.peek();
[41] Fix | Delete
[42] Fix | Delete
// handle haml declarations. All declarations that cant be handled here
[43] Fix | Delete
// will be passed to html mode
[44] Fix | Delete
if (state.previousToken.style == "comment" ) {
[45] Fix | Delete
if (state.indented > state.previousToken.indented) {
[46] Fix | Delete
stream.skipToEnd();
[47] Fix | Delete
return "commentLine";
[48] Fix | Delete
}
[49] Fix | Delete
}
[50] Fix | Delete
[51] Fix | Delete
if (state.startOfLine) {
[52] Fix | Delete
if (ch == "!" && stream.match("!!")) {
[53] Fix | Delete
stream.skipToEnd();
[54] Fix | Delete
return "tag";
[55] Fix | Delete
} else if (stream.match(/^%[\w:#\.]+=/)) {
[56] Fix | Delete
state.tokenize = ruby;
[57] Fix | Delete
return "hamlTag";
[58] Fix | Delete
} else if (stream.match(/^%[\w:]+/)) {
[59] Fix | Delete
return "hamlTag";
[60] Fix | Delete
} else if (ch == "/" ) {
[61] Fix | Delete
stream.skipToEnd();
[62] Fix | Delete
return "comment";
[63] Fix | Delete
}
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
if (state.startOfLine || state.previousToken.style == "hamlTag") {
[67] Fix | Delete
if ( ch == "#" || ch == ".") {
[68] Fix | Delete
stream.match(/[\w-#\.]*/);
[69] Fix | Delete
return "hamlAttribute";
[70] Fix | Delete
}
[71] Fix | Delete
}
[72] Fix | Delete
[73] Fix | Delete
// donot handle --> as valid ruby, make it HTML close comment instead
[74] Fix | Delete
if (state.startOfLine && !stream.match("-->", false) && (ch == "=" || ch == "-" )) {
[75] Fix | Delete
state.tokenize = ruby;
[76] Fix | Delete
return state.tokenize(stream, state);
[77] Fix | Delete
}
[78] Fix | Delete
[79] Fix | Delete
if (state.previousToken.style == "hamlTag" ||
[80] Fix | Delete
state.previousToken.style == "closeAttributeTag" ||
[81] Fix | Delete
state.previousToken.style == "hamlAttribute") {
[82] Fix | Delete
if (ch == "(") {
[83] Fix | Delete
state.tokenize = rubyInQuote(")");
[84] Fix | Delete
return state.tokenize(stream, state);
[85] Fix | Delete
} else if (ch == "{") {
[86] Fix | Delete
if (!stream.match(/^\{%.*/)) {
[87] Fix | Delete
state.tokenize = rubyInQuote("}");
[88] Fix | Delete
return state.tokenize(stream, state);
[89] Fix | Delete
}
[90] Fix | Delete
}
[91] Fix | Delete
}
[92] Fix | Delete
[93] Fix | Delete
return htmlMode.token(stream, state.htmlState);
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
return {
[97] Fix | Delete
// default to html mode
[98] Fix | Delete
startState: function() {
[99] Fix | Delete
var htmlState = CodeMirror.startState(htmlMode);
[100] Fix | Delete
var rubyState = CodeMirror.startState(rubyMode);
[101] Fix | Delete
return {
[102] Fix | Delete
htmlState: htmlState,
[103] Fix | Delete
rubyState: rubyState,
[104] Fix | Delete
indented: 0,
[105] Fix | Delete
previousToken: { style: null, indented: 0},
[106] Fix | Delete
tokenize: html
[107] Fix | Delete
};
[108] Fix | Delete
},
[109] Fix | Delete
[110] Fix | Delete
copyState: function(state) {
[111] Fix | Delete
return {
[112] Fix | Delete
htmlState : CodeMirror.copyState(htmlMode, state.htmlState),
[113] Fix | Delete
rubyState: CodeMirror.copyState(rubyMode, state.rubyState),
[114] Fix | Delete
indented: state.indented,
[115] Fix | Delete
previousToken: state.previousToken,
[116] Fix | Delete
tokenize: state.tokenize
[117] Fix | Delete
};
[118] Fix | Delete
},
[119] Fix | Delete
[120] Fix | Delete
token: function(stream, state) {
[121] Fix | Delete
if (stream.sol()) {
[122] Fix | Delete
state.indented = stream.indentation();
[123] Fix | Delete
state.startOfLine = true;
[124] Fix | Delete
}
[125] Fix | Delete
if (stream.eatSpace()) return null;
[126] Fix | Delete
var style = state.tokenize(stream, state);
[127] Fix | Delete
state.startOfLine = false;
[128] Fix | Delete
// dont record comment line as we only want to measure comment line with
[129] Fix | Delete
// the opening comment block
[130] Fix | Delete
if (style && style != "commentLine") {
[131] Fix | Delete
state.previousToken = { style: style, indented: state.indented };
[132] Fix | Delete
}
[133] Fix | Delete
// if current state is ruby and the previous token is not `,` reset the
[134] Fix | Delete
// tokenize to html
[135] Fix | Delete
if (stream.eol() && state.tokenize == ruby) {
[136] Fix | Delete
stream.backUp(1);
[137] Fix | Delete
var ch = stream.peek();
[138] Fix | Delete
stream.next();
[139] Fix | Delete
if (ch && ch != ",") {
[140] Fix | Delete
state.tokenize = html;
[141] Fix | Delete
}
[142] Fix | Delete
}
[143] Fix | Delete
// reprocess some of the specific style tag when finish setting previousToken
[144] Fix | Delete
if (style == "hamlTag") {
[145] Fix | Delete
style = "tag";
[146] Fix | Delete
} else if (style == "commentLine") {
[147] Fix | Delete
style = "comment";
[148] Fix | Delete
} else if (style == "hamlAttribute") {
[149] Fix | Delete
style = "attribute";
[150] Fix | Delete
} else if (style == "closeAttributeTag") {
[151] Fix | Delete
style = null;
[152] Fix | Delete
}
[153] Fix | Delete
return style;
[154] Fix | Delete
}
[155] Fix | Delete
};
[156] Fix | Delete
}, "htmlmixed", "ruby");
[157] Fix | Delete
[158] Fix | Delete
CodeMirror.defineMIME("text/x-haml", "haml");
[159] Fix | Delete
});
[160] Fix | Delete
[161] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function