在哪里可以找到 Java 语法突出显示库?

发布于 2024-07-19 04:41:27 字数 1542 浏览 7 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

自由范儿 2024-07-26 04:41:27

也许类似于 JSyntaxPane

一个非常易于使用和扩展的 JEditorKit,支持几种语言。 主要目标是轻松拥有美观的 Java Swing 编辑器并支持语法突出显示。

Something like JSyntaxPane, perhaps?

A very simple to use and extend JEditorKit that supports few languages. The main goal is to make it easy to have nice looking Java Swing Editors with support for Syntax Highlighting.

同展鸳鸯锦 2024-07-26 04:41:27

您首先应该考虑使用通用解析器从源创建 AST(抽象语法树)。 有一些工具,首先我发现谷歌搜索互联网是 javaparser。 看起来这个解析器还记录了行号和列,因此 javaparser 中的 AST 对于编辑器来说是一个很好的模型。

只需处理树,定义 AST 节点类型的颜色并打印它。

You first should think about using a common parser to create an AST (abstract syntax tree) from the sources. There are some tools around, first I find googling the internet was javaparser. It looks like this parser also records line numbers and columns, so the AST from javaparser can be a nice model for the editor.

Just process the tree, define colors for the AST node types and print it.

深海蓝天 2024-07-26 04:41:27

可能想查看现有的编辑器(例如 Notepad++ - http://notepad-plus .sourceforge.net/uk/site.htm)并查看用户定义的语法突出显示是如何完成的(要检查的插件之一 - Gmod 10 Lua 语法突出显示)。 我敢打赌 Java(和其他语言)也是类似的......

Might want to look at an existing editor (Notepad++ for example - http://notepad-plus.sourceforge.net/uk/site.htm) and see how user-defined syntax highlighting is done (oneo of the plugins to check - Gmod 10 Lua Syntax Highlighter). I'd wager that the Java (and other languages) are done similarly...

仄言 2024-07-26 04:41:27

您应该查看 Google 的 prettify.js。 其中有一些非常巧妙的技巧,您可能会对语法突出显示有更强大的感觉。

You should check Google's prettify.js out. Some pretty neat tricks in there, and you might get a more robust feel for syntax highlighting.

苦妄 2024-07-26 04:41:27

http://www.neathighlighter.com/ 是一个很好的 JavaScript 荧光笔

http://www.neathighlighter.com/ is a good JavaScript highlighter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文