次のようなキーワードのみを強調したいと思います: (基本的には、単一の括弧で囲ま{KEYWORD}
れた大文字の単語){}
Mustache Overlay demoからコードをコピーし、二重かっこを単一のものに置き換えて、これを試しました。
CodeMirror.defineMode('mymode', function(config, parserConfig) {
var mymodeOverlay = {
token: function(stream, state) {
if (stream.match("{")) {
while ((ch = stream.next()) != null)
if (ch == "}" && stream.next() == "}") break;
return 'mymode';
}
while (stream.next() != null && !stream.match("{", false)) {}
return null;
}
};
return CodeMirror.overlayParser(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), mymodeOverlay);
});
しかし、それはあまりうまくいきません:)
何か案は?