Skip to content

Safe and fast JavaScript library to convert Minecraft-formatted text to DOM elements

License

Notifications You must be signed in to change notification settings

yusshu/mcformat

Repository files navigation

mcformat

mcformat is a fast and safe JavaScript library to format Minecraft-formatted string to DOM elements

Credits

Fonts weren't created by me, you can download them here

Installation

  1. Download mcformat.zip or clone the repository and execute the pack.sh script
  2. Unzip mcformat.zip in your project
  3. Add the script and the styles
     <script src="mcformat.min.js"></script>
     <link rel="stylesheet" href="mcformat.min.css">

Usage

JavaScript required code:

// Create the formatter
const formatter = new MCFormat(); // You can specify options using 'new MCFormat({ colorChar: "&", allowMagic: true });' 

// Convert any string text to an element
const element = formatter.format('&9&lSome text &7text');

CSS (Optional, only modify if you want to customize the result)

/* All classes are prefixed with 'mc-' */

.mc-root {
    /* This is the root span element */
}

/* Customizing formats */
.mc-red {
    color: #FF0000;
}

.mc-blue {
    color: #0000FF;
}

.mc-bold { ... }

/* etc... */

About

Safe and fast JavaScript library to convert Minecraft-formatted text to DOM elements

Topics

Resources

License

Stars

Watchers

Forks