私はカスタムオーバーレイを作成して、カスタム機能/スタイリングのためにタイプengage
のトークンを作成しています。 EXP=SOMETHING
、私は簡単に最初の引用符を省略して、EXP=SOMETHING"
ような何かを得るが、私は見つけることができないようすることができます:私は現在、私は二重引用符の間の唯一のものを手に入れるかの必要"EXP=SOMETHING"
として二重引用符の内側にあるトークンを、作成していCodemirror、doublequotesのdefineMode
最後の見積もりを飛ばす実行可能な方法、私はこの問題について私の頭をあまりにも長い間私はそれが実際には可能ではないと考え始めたと打ち明けている、文字でバックアップするとEXCEPTION: Uncaught (in promise): Error: Mode engage failed to advance stream.
は理にかなっています。私は何かが欠けていると確信しています、私はいくつかの入力が大好きです。
CodeMirror.defineMode("engage", function(config, parserConfig) {
var engageOverlay = {
startState: function() {return {inString: false};},
token: function(stream, state) {
// If we are not inside the engage token and we are peeking a "
if (!state.inString && stream.peek() == '"') {
// We move the stream to the next char
// Then mark the start of the string
// Then return null to avoid including the first " as part of the token
stream.next();
state.inString = true;
return null;
}
// We are inside the target token
if (state.inString)
{
if (stream.skipTo('"'))
{
stream.next();
state.inString = false;
}
else
{
stream.skipToEnd();
}
return "engage";
}
else
{
stream.skipTo('"') || stream.skipToEnd();
return null;
}
}
};
return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "xml"), engageOverlay);
});