Java engine for HTML.
-
Before we start: This is still a WIP library, you might have to do MASSIVE changes to your codebase. This implementation is from scratch and things may not be 100% accurate to browser rendering.
-
Create a new source file.
-
Extend
HTMLDocument:public class YourClass extends HTMLDocument { }
-
Create a constructor:
public class YourClass extends HTMLDocument { public YourClass() { } }
-
Add a super() call:
public class YourClass extends HTMLDocument { public YourClass() { //You have 3 options super(/*your service of choice*/); //Empty document. super(/*your service of choice*/, "HTML goes here"); //Document with text as source. super(/*your service of choice*/, "myhtml.html"); //Document with asset as source. } }
-
Pick a service (eg: MCTML Service)
-
Call HTMLDocument.openAsScreen on your class:
new YourClass().openAsScreen();
-
Congrats! You have created a simple document.
- You can use the prefix
Translate->before a string to automatically translate it.
Example:
<span>Translate->menu.modded</span>This will get interpreted as:
<span> (Modded)</span>Note: This won't work on translations with parameters
- jsoup: Library used for parsing HTML
Since this implementation is from scratch, support for some elements/properties is missing.
JTML has an API for doing basically everything you can do with javascript, using java.
- Supported Elements
<span>
<br>
<button>
<div>
<label>
<input>
<textarea>
<a>
<b>
<i>
<canvas> (with 2d context)
<body>
<h1-6>- Supported properties
* means anything that works in normal css
display: inline | flex | grid;
background-color: *;
color: *;
text-decoration: strikethrough | underline | none;
font-weight: bold | italic | none;
border: 2px solid black;
border-radius: 10px 10px 10px 10px | 10px;
border-top-left-radius: 10px;
border-top-right-radius: 10px;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
justify-content: left | center | right;
align-items: start | center | end;
flex-direction: column | row;
grid-template-columns: 200px | 1fr;
grid-gap: *;
margin: *;
margin-top: *;
margin-bottom: *;
margin-left: *;
margin-right: *;
padding: *;
padding-top: *;
padding-bottom: *;
padding-left: *;
padding-right: *;- Custom properties to help with coding:
width-offset: 2px; (2px is default, this is the width offset of a text node)
- You don't need the entire html document, just the body is enough!