我只想突出显示如下所示的关键字:(基本上是用单括号括{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);
});
但效果不是很好:)
有任何想法吗?