@sfirew/minecraft-motd-parser
Version:
Minecraft Server MOTD Parser, can convert to html, json, text.
32 lines (31 loc) • 1.02 kB
TypeScript
import { motdJsonType } from "./types";
/**
* Base color code regex
*/
export declare const baseColorCodeRegex: RegExp;
export declare function isMotdJSONType(object: unknown): object is motdJsonType;
/**
* Replace all HTML special characters with HTML entities
* Prevents HTML injection by safely encoding special characters
*/
export declare function htmlStringFormatting(text: string): string;
/**
* Clean HTML tags safely
*
* Safely removes HTML tags and prevents HTML injection vulnerabilities.
*
* @param text - Input text that may contain HTML tags
* @example `<span>hello world</span>` → `hello world`
*
* @returns Clean text without HTML tags
*/
export declare function cleanHtmlTags(text: string): string;
/**
* Clean MOTD color codes
*
* Clean all formatting codes from MOTD source string.
*
* @param {string} text - MOTD string with § formatting codes to be removed
* @returns {string} Text without MOTD formatting codes
*/
export declare function cleanCodes(text: string): string;