Java API for formatting source code

There are several PHP or js files for formatting the code - does anyone know if similar Java exists in Java?

That is, Given a line of code, return a formatted line with syntax coloring, etc.

It would be ideal if he automatically detected the language, but I could put on my luck ...

Ultimately, the text will be displayed in the Flex application, so although I could use js lib, we will parse large files (up to 6000 lines), so I would like the client processing to be minimal.

The ideal conclusion is HTML without CSS, although I will take what I can get.

+4
source share
2 answers

These are two different tasks. Regarding code formatting, look around using the "java beautifier" keyword. Here is a list . I had a good impression of Jalopy , which also comes with the Eclipse plugin. As for syntax highlighting, it depends on where you want to use it. If you 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 .

+5
source

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

+1
source

Source: https://habr.com/ru/post/1306128/


All Articles