Java 语法荧光笔

发布于 2024-08-13 09:00:54 字数 444 浏览 2 评论 0原文

如您所知,有一个名为 GeSHi 的 PHP 语法荧光笔,它支持大量编程语言或代码格式。

但是,我找不到这样一个支持我需要的编程语言(ADA、ASP、BNF、Bash、Brainfuck、C、C++、C#、CSS、Cobol、ColdFusion、D、Fortran、Haskell、HTML、 (Config)、Java、JavaScript、Lisp、Make、Objective C、PASCAL、Perl、PHP、PLSQL、Prolog、Python、Ruby、Scheme、SQL、VB.NET、Verilog、VHDL、Visual Basic、XML。)

INI 知道一种还是我应该更喜欢低效的方式,即通过 http 事务从远程 PHP 服务器检索突出显示的代码?有什么想法吗?

谢谢。

As you know there is a Syntax highlighter for PHP called GeSHi which supports a great number of Programming Languages or Code formats.

However, I couldn't find such a library for Java which supports programming languages that I need (ADA, ASP, BNF, Bash, Brainfuck, C, C++, C#, CSS, Cobol, ColdFusion, D, Fortran, Haskell, HTML, INI (Config), Java, JavaScript, Lisp, Make, Objective C, PASCAL, Perl, PHP, PLSQL, Prolog, Python, Ruby, Scheme, SQL, VB.NET, Verilog, VHDL, Visual Basic, XML.)

Do you know one or should I prefer inefficient way which is retrieving the highlighted code from a remote PHP server via http transaction? Any ideas?

Thanks.

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

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

发布评论

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

评论(6

寻找一个思念的角度 2024-08-20 09:00:54

看看 JHighlighterjEdit 语法包。所有提到的语言均不受开箱即用支持。但是,您有资源,所以我想应该可以添加语言支持。

不是直接答案,但是,如果可以选择客户端语法突出显示,那么 Alex Gorbatchev 的 SyntaxHighlighter 库是一个很棒的库javascript 库,支持多种语言并且是高度可扩展

Have a look at JHighlighter or jEdit Syntax Package. All mentioned languages aren't supported out of the box. However, you have the sources, so I guess it should be possible to add language support.

Not a direct answer but, if client-side syntax highlighting is an option, the SyntaxHighlighter library from Alex Gorbatchev is an awesome javascript library, supports lots of languages and is highly extensible.

我不吻晚风 2024-08-20 09:00:54

您可以通过 Jython 使用 Pygments。不会像 Java 解决方案那么快,但比与远程服务器交互快得多。

除此之外,您可以在本地运行 Geshi 并通过它传输源代码,这也将击败 HTTP 往返。

You could use Pygments through Jython. Won't be as fast as a Java solution, but much faster than interacting with a remote server.

Barring that, you could run Geshi locally and pipe source code through it, that would also beat an HTTP round trip.

千鲤 2024-08-20 09:00:54

似乎可以从 Java 运行 GeSHiGeSHi4J 它似乎是一个在 JVM 上运行 PHP 库的包装器。

It seems that it is possible to run GeSHi from Java: GeSHi4J it seems to be a wrapper that run the PHP library on the JVM.

冷月断魂刀 2024-08-20 09:00:54

有一个用于 Java 的 prettify.js 端口:java-prettify

它可以用来生成 HTML(用 Java 计算),正如我在这里讨论的:
使用 java-prettify 解析器创建 HTML

There is a port of prettify.js for Java: java-prettify.

It can be used to produce HTML (computed in Java), as I discussed here:
Use the java-prettify parser to create HTML

笑,眼淚并存 2024-08-20 09:00:54

jedit 是一个文本编辑器,通过“模式”支持约 170 多种语言的语法突出显示。它还允许您指定自己的语法。您可以在自己的应用程序中使用 StandaloneTextArea 组件,如下所示:

  • 提取源代码(例如:jedit4.3source.tar.bz2 到 d:\source\jedit)
  • 使用 ant 将所有 textarea 文件复制到 ..\textarea 例如:

    D:\Source\jedit\jEdit> ant prepare-textArea

  • 但是,它错过了文件 BufferUndoListener.java。通过执行手动复制此内容

    D:\Source\jedit\jEdit> copy org\gjt\sp\jedit\buffer\BufferUndoListener.java ..\textarea\src\org\gjt\sp\jedit\buffer\

  • 在 Eclipse 中,从目录 D:\Source 中的现有源创建一个 Java 项目\jedit\textarea

  • 导航到 org.gjt.sp.jedit.textarea.StandaloneTextArea.java
  • 更改行
mode.setProperty("文件","modes/xml.xml");

mode.setProperty("文件","src/modes/xml.xml");
  • 。将 XML 复制并粘贴到编辑器中,然后查看语法突出显示是否正常工作。

jedit is a text editor with syntax highlighting support for some 170+ languages via "modes". It also allows you to specify your own syntaxes. You can use the StandaloneTextArea component in your own application as follows:

  • Extract source (eg: jedit4.3source.tar.bz2 to d:\source\jedit)
  • Use ant to copy all the textarea files to ..\textarea eg:

    D:\Source\jedit\jEdit> ant prepare-textArea

  • However, it misses the file BufferUndoListener.java. Copy this manually by executing

    D:\Source\jedit\jEdit> copy org\gjt\sp\jedit\buffer\BufferUndoListener.java ..\textarea\src\org\gjt\sp\jedit\buffer\

  • In Eclipse create a Java Project from existing source in the directory D:\Source\jedit\textarea

  • Navigate to org.gjt.sp.jedit.textarea.StandaloneTextArea.java
  • Change the line
mode.setProperty("file","modes/xml.xml");

to

mode.setProperty("file","src/modes/xml.xml");
  • Run. Copy and paste an XML into the editor and see the syntax highlighting is working.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文