如何在Ace编辑器中启用实时语法检查 [英] How do I enable Live Syntax Checking in the Ace Editor

查看:996
本文介绍了如何在Ace编辑器中启用实时语法检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Ace Editor有实时语法检查,它可以检查代码是否正常键入语法错误。

Ace Editor has Live Syntax Checking, which can check code as it's being typed for syntax errors.

我有一个Rails 3.2站点,每个编码页面都包含Ace文件。我在javascript中添加了一个require语句来告诉Ace工作文件在哪里,但它仍然无效。如何让实时语法检查工作?

I have a Rails 3.2 site with the Ace file included on each coding page. I added a require statement to the javascript to tell Ace where the worker file is, but it's still not working. How do I get Live Syntax checking to work?

每个编码页面包括:

<%= javascript_include_tag "ace-src/ace.js" %>
<%= javascript_include_tag "ace-editor" %>

Ace文件位于ace-src文件夹中。我将此代码添加到ace-editor.js:

The Ace files are located in the ace-src folder. I aded this code to ace-editor.js:

require("ace/config").set("workerPath", "/assets/ace-src");


推荐答案

语法检查是通过加载 http://www.learneroo.com/assets/ace-src/worker-javascript。 js 文件,但在您的网站中该文件似乎是空的。我只在其中看到;

在之前显示的jsfiddle http://jsbin.com/ojijeb/432/edit ,由于对网络工作者的交叉原始限制(因为运行chrome时我没注意到)所以它无效使用 - disable-web-security ),但是由于最新的Ace更新,它现在可以使用。

Syntax checking is done via webworker which loads http://www.learneroo.com/assets/ace-src/worker-javascript.js file, but in your site that file seems to be empty. I only see ; in it.
In the jsfiddle i showed earlier http://jsbin.com/ojijeb/432/edit, it didn't work because of cross origin restrictions on web workers (which i didn't notice since was running chrome with --disable-web-security), but thanks to latest Ace update, it works now.

这篇关于如何在Ace编辑器中启用实时语法检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆