用于源格式化的 Java API

发布于 2024-08-27 16:20:18 字数 260 浏览 3 评论 0原文

有几个 PHP 或 js 代码格式化库 - 有人知道 Java 中是否存在类似的库吗?

即,给定一串代码,返回带有语法着色等的格式化字符串。

如果它自动检测到语言,那就太理想了,但我可能会在那里碰碰运气......

文本最终将显示在 Flex 中应用程序,因此虽然我可以使用 js 库,但我们将解析大文件(最多 6000 行),因此我希望尽量减少客户端处理。

理想的输出是没有 CSS 的 HTML,尽管我会采取我能得到的。

There are several PHP or js code formatting libs out there -- does anyone know if similar libs exist in Java?

Ie., Given a string of code, return a formatted string with syntax colouring etc.

It'd be ideal if it auto detected the language, but I might be pushing my luck there...

The text will ultimately be displayed within a Flex application, so while I could use a js lib, we'll be parsing large files (up to 6000 lines), so I'd like to keep client side processing minimal.

Ideal output is HTML without CSS, although I'll take what I can get.

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

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

发布评论

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

评论(2

月下客 2024-09-03 16:20:18

这是两个不同的任务。关于代码格式,请使用关键字“java beautifier”查看。这是一个列表。我本人在 Jalopy 方面有过很好的经验,它也附带了一个 Eclipse 插件。关于语法突出显示,这取决于您想在哪里使用它。如果以编程方式,请使用 JHighlight,或者如果在网页上,请使用 Prettify (Stackoverflow 也使用它,它可以检测语言),或者作为 Eclipse 导出插件,使用 Java2HTML

That are two distinct tasks. With regard to code formatting, look around using the keyword "java beautifier". Here is a list. I myself have had good experiences with Jalopy which also ships with an Eclipse plugin. With regard to syntax highlighting, it depends on where you'd like to use it. If programmatically, use JHighlight, or if on a webpage, use Prettify (Stackoverflow also uses it and it can detect languages), or as an Eclipse export plugin, use Java2HTML.

不美如何 2024-09-03 16:20:18

也许尝试查看 Colorer 项目:http://colorer.sourceforge.net/

Perhaps try to see the Colorer Project: http://colorer.sourceforge.net/

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