Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
加载codemirror时是否可以突出显示搜索模式_Codemirror - Fatal编程技术网

加载codemirror时是否可以突出显示搜索模式

加载codemirror时是否可以突出显示搜索模式,codemirror,Codemirror,当页面加载时,codemirror是否有办法突出显示与模式匹配的代码(如使用搜索插件)?因此,我可以加载带有?search=my_模式的页面,并将该模式传递给codemirror 下面是一个示例代码和一个JSFIDLE。您可以使用CTRL+F来使用搜索插件 打印“hello world” var myTextArea=document.getElementById('myTextArea'); var mycodemiror=codemirr.fromTextArea(myTextArea{

当页面加载时,codemirror是否有办法突出显示与模式匹配的代码(如使用搜索插件)?因此,我可以加载带有?search=my_模式的页面,并将该模式传递给codemirror

下面是一个示例代码和一个JSFIDLE。您可以使用CTRL+F来使用搜索插件


打印“hello world”
var myTextArea=document.getElementById('myTextArea');
var mycodemiror=codemirr.fromTextArea(myTextArea{
'mode':'python',
“行号”:true
});

我通过查看


.cm highlightSearch{背景:黄色;}
打印“hello world”
var关键字='hello';
defineMode(“highlightSearch”,函数(config,parserConfig){
var searchOverlay={
令牌:函数(流、状态){
if(stream.match(关键字)){
返回“highlightSearch”;
}
while(stream.next()!=null&&!stream.match(关键字,false)){}
返回null;
}
};
返回codemirr.overlyMode(codemirr.getMode(config,parserConfig.background | | |“python”)、searchOverlay);
});
var myTextArea=document.getElementById('myTextArea');
var mycodemiror=codemirr.fromTextArea(myTextArea{
“模式”:“highlightSearch”,
“行号”:true
});