Adobe括号中的代码镜像简单模式
Code Mirror Simple Mode in Adobe Brackets
我正在尝试创建一个自定义的代码镜像模式,以便与Adobe Brackets代码编辑器一起使用。
目前,我可以突出显示{{code}},但我想使用代码镜像简单模式(更容易理解)。
我的Brackets扩展代码是(main.js):
define(function (require, exports, module) {
'use strict';
var LanguageManager = brackets.getModule("language/LanguageManager");
CodeMirror.defineMode("laravelblade", function (config, parserConfig) {
var mustacheOverlay = {
token: function (stream, state) {
var ch;
//Highlight Comments {{-- --}}
if (stream.match("{{--")) {
while ((ch = stream.next()) != null)
if (ch == "}" && stream.next() == "}") break;
stream.eat("}");
return "comment";
}
//--
//Highlight {{ $var }})
if (stream.match("{{")) {
while ((ch = stream.next()) != null)
if (ch == "}" && stream.next() == "}") break;
stream.eat("}");
return "def";
}
//Highlight {% $var %} (Laravel 5)
else if (stream.match('{%')) {
while ((ch = stream.next()) != null)
if (ch == "%" && stream.next() == "}") break;
stream.eat("}");
return "def";
}
//Highlight {% $var %} (Laravel 5)
else if (stream.match('{%')) {
while ((ch = stream.next()) != null)
if (ch == "%" && stream.next() == "}") break;
stream.eat("}");
return "def";
}
//Return Null if no condition was met.
else if (stream.next() != null) {
return null;
}
}
};
return CodeMirror.overlayMode(CodeMirror.getMode(config, parserConfig.backdrop || "php"), mustacheOverlay);
});
LanguageManager.defineLanguage("laravelblade", {
"name": "Laravel Blade",
"mode": "laravelblade",
"fileExtensions": ["blade.php"],
"blockComment": ["{{--", "--}}"]
});
});
你能为我提供一个代码镜像简单模式的简单例子吗?(我读过codemirror文档,我试着遵循这些例子,但我就是无法让它们使用Brackets语法高亮显示…)
谢谢。
编辑:实际的代码是有效的,但我想使用代码镜像简单模式来实现同样的效果。
我还复制了这个代码,并根据自己的需要进行了更改。但我无法让另一个代码镜像模式从头开始使用括号。。。所以我可能错过了什么。。。
我也遇到了类似的问题。
对于一个工作示例,请检查dockerfile模式(在OSX中,它位于Applications/Brackets/Contents/www/thirdparty/CodeMirror2/mode/dokerfile中)。
相关文章:
- IE中的CSS翻转动画:翻转的一面显示镜像内容
- Markdown模式代码镜像正在创建
- 更改代码镜像中TextArea的高度和宽度
- IE中的CSS翻转动画:翻转的一面显示镜像内容
- 什么CSS/JS技巧驱动镜像反转http://com.google愚人节页面
- jquery使2组单选按钮相互镜像
- Nodejs使用httpdispatcher提供静态镜像
- HTML5相机缓冲和延迟(延迟镜像)
- jQuery插件在本地主机上运行良好,但在web服务器上却与bg镜像混淆
- 镜像滚动效果打开.在两个容器之间单击
- 代码镜像批量更改
- 如何在代码镜像编辑器中设置隐藏值
- Selenium-使用换行符将文件写入代码镜像
- 默认情况下在代码镜像中启动全屏
- 如何在代码镜像编辑器中设置不同的维度
- 将变量中的文本放入代码镜像文本区域
- 多种模式代码镜像
- 如何在 Angular2 组件中访问代码镜像文本区域值
- 如何使用 NPM 镜像
- Adobe括号中的代码镜像简单模式