minecraft-text
TypeScript icon, indicating that this package has built-in type declarations

1.2.18 • Public • Published

minecraft-text

Parse Minecraft text into many formats including HTML.

Parse

Parse a string of encoded text to a JSON chat component. parse(String: text, String: delimiter = "§")

import { parse } from "minecraft-text";

const json = parse("&7[&c-&7] &3[&bWARRIOR&3]&b &fJack", "&");
{"text":"","extra":[{"text":"[","extra":[{"text":"-","extra":[{"text":"] ","extra":[{"text":"[","extra":[{"text":"WARRIOR","extra":[{"text":"]","extra":[{"text":" ","extra":[{"text":"Jack","extra":[],"color":"white"}],"color":"aqua"}],"color":"dark_aqua"}],"color":"aqua"}],"color":"dark_aqua"}],"color":"gray"}],"color":"red"}],"color":"gray"}]}

Render

Render a string of encoded text to HTML. render(String: text, String: delimiter = "§")

import { render } from "minecraft-text";
import "~minecraft-text/style.css"; // Browser only

const html = render("&7[&c-&7] &3[&bWARRIOR&3]&b &fJack", "&");
<span class="mc"><span><span class="mc-gray">[<span class="mc-red">-<span class="mc-gray">] <span class="mc-dark_aqua">[<span class="mc-aqua">WARRIOR<span class="mc-dark_aqua">]<span class="mc-aqua"> <span class="mc-white">Jack</span></span></span></span></span></span></span></span></span></span>

Strip Formats

Removes all formatting codes form a string. stripFormats(String: text, String: delimiter = "§")

import { stripFormats } from "minecraft-text";

const text = stripFormats("&7[&c-&7] &3[&bWARRIOR&3]&b &fJack", "&");
"[-] [WARRIOR] Jack"

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.2.1810latest

Version History

VersionDownloads (Last 7 Days)Published
1.2.1810
1.2.172
1.2.160
1.2.150
1.2.140
1.2.130
1.2.120
1.2.110
1.2.100
1.2.90
1.2.80
1.1.80
1.0.70
1.0.60
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i minecraft-text

Weekly Downloads

12

Version

1.2.18

License

ISC

Unpacked Size

19 kB

Total Files

26

Last publish

Collaborators

  • jmer05