Format java code in html, imitating the style of the blue-J IDE.
Note
I have no affiliation or relationship with Blue-J. This is a personal project.
Caution
THIS CODE IS GIVEN WITHOUT ANY WARRANTY. Use at your own risk.
BlueJ-code-highlighter has the following dependencies :
- Python >= 3.10 (tested on 3.11)
- pygments (tested on 2.18.0)
To install pygments run :
>> pip install Pygments
Download the project :
>> git clone https://github.com/DArtagnant/blueJ-code-highlighter.git
Once you have downloaded the project, open or import highlight.py
. Then you can modify the call of the from_file
function.
The first argument is the path where is store the java code, the second the path where you want the html output to be.
By example :
from_file("input.txt", "output.html")
will read a file named input.txt
and located in the current directory and write the output in output.html
.
from_file
has three more optional parameters :
border_radius
set the radius of the rounded corners of the output. default 15.functions_always_in_class
whenTrue
, allows to render uncomplete code with a class indentation. You should not mix uncomplete code and classes. defaultTrue
change_escape_char
whenTrue
, allows to use classical characters for&
,<
,>
,"
and'
instead of an encoding like"
for"
. This functionality is based on a specific private implementation of pygmentsHtmlFormatter
and may not work in newer versions. defaultFalse
credits
whenFalse
allows to mask the credits at the bottom of the render. Please read About BlueJ-code-highlighter. If you disable this option, you have to mention the formatter source (link to the github page) and author's name (DArtagnant) somewhere in the page in accordance with the free license chosen for this project. defaultTrue
Example :
from_file("input.txt", "output.html", credits=True, border_radius=20, functions_always_in_class=False)
Feel free to open a github issue, I will reply as soon as possible.
Run build.bat
to build the GUI into a .exe
This project was originally a utility code written by DArtagnant as a favor to a friend.
It is therefore a hobby, and this code is given without any guarantee of operation or future support. It probably contains a few bugs. In any case, and without committing myself, I will do my best to avoid these inconveniences and improve this project while taking into account my other activities.
Note
Project under GPL-3.0 license.