Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
DeDiamondPro authored May 5, 2024
1 parent d55d334 commit aa81a95
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,43 @@ Java Markdown Rendering library
## Usage
MineMark is build in a modular system, `minemark-core` is the hearth of everything, it is responsible for parsing
the markdown and generating a layout for it. Then you need a rendering implementation to actually render the markdown.
Currently, only an elementa render system is provided, but it is relatively fast to create your own rendering
implementation if you wish to do that.
Currently, there is a Minecraft and Elementa rendering implementation available, but it is relatively easy to create your own if you wish!

Adding MineMark as a dependency:
Adding MineMark as a dependency (latest MineMark version: ![](https://img.shields.io/badge/dynamic/xml?label=%20&query=/metadata/versioning/versions/version[not(contains(text(),%27%2B%27))][last()]&url=https://maven.dediamondpro.dev/releases/dev/dediamondpro/minemark-core/maven-metadata.xml)):
```kt
repositories {
maven("https://maven.dediamondpro.dev/releases")
}

dependencies {
// Add the core as a dependency
implementation("dev.dediamondpro:minemark-core:1.0.0")
// Add elementa rendering implementation as a dependency
implementation("dev.dediamondpro:minemark-elementa:1.0.0")
// Add the core as a dependency, replace {version} with the most recent version of MineMark
implementation("dev.dediamondpro:minemark-core:1{version}")

// Example to add the Minecraft rendering implementation as a dependency,
// replace {platform} with the Minecraft version and mod loader (example: 1.20.4-fabric)
modImplementation("dev.dediamondpro:minemark-minecraft-{platform}:{version}")

// Example to add the elementa rendering implementation as a dependency
implementation("dev.dediamondpro:minemark-elementa:{version}")
}
```
It is recommended to **shade and relocate MineMark** if you are using it in a Minecraft mod since no guarantees will be
provided regarding backwards compatibility.

How you render a markdown element will differ from one rendering implementation to another, here is an example of how
you would do it with the elementa rendering implementation:
## Minecraft rendering implementation

To use the Minecraft rendering implementation you first have to create a markdown drawable like this
```java
MineMarkDrawable markdown = new MineMarkDrawable("This *is* **where** you input your markdown!");
```
Then to render it call the draw method.
```java
markdown.draw(x, y, width, mouseX, mouseY, drawContext);
```

## Elementa rendering implementation

You can create an MineMark elementa component like this, it will act like any other elementa component.
```kt
MineMarkComponent("This *is* **where** you input your markdown!").constrain {
x = 0.pixels()
Expand All @@ -37,6 +53,7 @@ MineMarkComponent("This *is* **where** you input your markdown!").constrain {
```

## Creating your own rendering implementation

To create your own rendering implementation, you first have to implement the rendering of the elements you want to
support. You can choose what elements you implement, the only requirement is that **you have to provide a text element**.
To implement an element, you have to extend its abstract form, for an example for each element I would recommend you
Expand All @@ -57,4 +74,4 @@ MineMarkCore<MyStyle, MyRenderObject> core = MineMarkCore.<MyStyle, MyRenderObje
```

Then you have to call `core.parse(myStyle, markdown)` to parse the markdown, this will return a `MineMarkElement`.
This element has a `draw`, `beforeDraw` and `onMouseClick` method that should be called by your rendering implementation.
This element has a `draw`, `beforeDraw` and `onMouseClick` method that should be called by your rendering implementation.

0 comments on commit aa81a95

Please sign in to comment.