有没有JavaScript实时语法荧光笔? [英] Are there any JavaScript live syntax highlighters?

查看:195
本文介绍了有没有JavaScript实时语法荧光笔?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了突出显示预先存在的代码的语法高亮显示,但我想在你用WYSIWYG风格的编辑器输入时这样做。我不需要自动完成的功能,只需突出显示。

I've found syntax highlighters that highlight pre-existing code, but I'd like to do it as you type with a WYSIWYG-style editor. I don't need auto-completed functions, just the highlighting.

作为后续问题,stackoverflow使用的WYSIWYG编辑器是什么?

As a follow-up question, what is the WYSIWYG editor that stackoverflow uses?

编辑:感谢下面的答案,我发现两个看起来可能符合我的需求:
EditArea CodePress

Thanks to the answer below, I found two that look like they might suit my needs: EditArea and CodePress

编辑:也看到这个问题:

https://stackoverflow.com/questions/379185/free-syntax-highlighting-editor-control-in-javascript

See this question also:
https://stackoverflow.com/questions/379185/free-syntax-highlighting-editor-control-in-javascript

推荐答案

这是一篇非常有趣的文章,关于如何编写一篇文章:(更好的是,他为JavaScript格式化程序和着色器提供了完整的源代码。)

Here is a really interesting article about how to write one: (Even better, he gives the full source to a JavaScript formatter and colorizer.)

Implem在JavaScript中使用语法高亮的JavaScript编辑器

DOM树黑暗面的残酷冒险

Implementing a syntax-higlighting JavaScript editor in JavaScript or A brutal odyssey to the dark side of the DOM tree


如何做出体面的语法
突出显示?一个非常简单的扫描
可以区分
字符串,注释,关键字和其他
代码。但这次我想
实际上能够识别常规的
表达式,这样我就不再有任何
明显错误的行为了。

How does one do decent syntax highlighting? A very simple scanning can tell the difference between strings, comments, keywords, and other code. But this time I wanted to actually be able to recognize regular expressions, so that I didn't have any blatant incorrect behaviour anymore.

重要的是,它正确处理正则表达式。同样令人感兴趣的是,他使用了延续传递样式词法分析器/解析器,而不是你将在野外看到的更典型的基于lex(或正则表达式)的词法分析器。

Importantly, it handles regex correctly. Also of interest is that he used a continuation passing style lexer/parser instead of the more typical lex (or regex) based lexers that you'll see in the wild.

作为奖励,他讨论了在浏览器中使用JavaScript时遇到的许多实际问题。

As a bonus he discusses a lot of real-world issues you'll run into when working with JavaScript in the browser.

这篇关于有没有JavaScript实时语法荧光笔?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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