{"id":42107,"library":"tm-text","title":"tm-text","description":"tm-text is a library for parsing and formatting Trackmania and ManiaPlanet game text, converting color codes and formatting tokens (e.g., $f00 for red, $o for bold) into HTML, human-readable strings, or tokenized structures. The current version is 1.1.0, released on npm. It supports both ESM and CommonJS, ships TypeScript types, and is actively maintained on GitHub by Brainshaker95. Compared to alternatives, it provides a simple interface with functions like humanize, htmlify, tokenize, and blockify, covering all documented tokens including color codes, bold, italic, links, and shadow.","status":"active","version":"1.1.0","language":"javascript","source_language":"en","source_url":"https://github.com/Brainshaker95/tm-text","tags":["javascript","formatter","gbx","maniaplanet","nadeo","parser","trackmania","typescript"],"install":[{"cmd":"npm install tm-text","lang":"bash","label":"npm"},{"cmd":"yarn add tm-text","lang":"bash","label":"yarn"},{"cmd":"pnpm add tm-text","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Default import is preferred for ESM. CommonJS users must use require('tm-text').default or destructure { tmText }.","wrong":"const tmText = require('tm-text')","symbol":"tmText","correct":"import tmText from 'tm-text'"},{"note":"htmlify is a named export, not the default.","wrong":"import htmlify from 'tm-text'","symbol":"htmlify","correct":"import { htmlify } from 'tm-text'"},{"note":"CommonJS destructuring works as require('tm-text').humanize; ESM named import is cleaner.","wrong":"const humanize = require('tm-text').humanize","symbol":"humanize","correct":"import { humanize } from 'tm-text'"},{"note":"Named export; no common mistake beyond the above patterns.","wrong":null,"symbol":"tokenize","correct":"import { tokenize } from 'tm-text'"},{"note":"Named export.","wrong":null,"symbol":"blockify","correct":"import { blockify } from 'tm-text'"}],"quickstart":{"code":"import tmText from 'tm-text';\n\nconst text = tmText('$f00R$fa2a$ff3i$0f0n$06fb$30fo$60fw');\nconsole.log(text.humanize()); // 'Rainbow'\nconsole.log(text.htmlify()); // '<span style=\"color: #ff0000;\">R</span><span style=\"color: #ffaa22;\">a</span>...'\nconsole.log(text.tokenize()); // [{ type: 'color', value: '$f00', ... }, ...]\nconsole.log(text.blockify()); // [{ type: 'text', content: 'R', ... }, ...]","lang":"typescript","description":"Parses Trackmania formatted text, then converts to human-readable string and HTML with color spans."},"warnings":[{"fix":"Use '$$' in the input string to represent a single '$' character.","message":"The dollar sign '$' in Trackmania text must be escaped as '$$' to display a literal dollar sign.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure all color tokens follow the pattern $[0-9a-fA-F]{3}.","message":"Color codes with fewer than 3 hex digits (e.g., '$00') are not valid; format is $\" followed by exactly 3 hex digits.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Check your Trackmania text for proper token nesting before using tm-text.","message":"The library does not handle nested or overlapping formatting tokens; input must be well-formed.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Plan migration to ESM imports for future versions.","message":"ESM-only from version 2.0.0 (future release); CommonJS support may be removed.","severity":"breaking","affected_versions":">=2.0.0"}],"env_vars":null,"search_vec":"'1.1.0':45 'activ':60 'altern':68 'blockifi':81 'bold':31,89 'brainshaker95':65 'code':21,88 'color':20,87 'commonj':54 'compar':66 'convert':19 'cover':82 'current':42 'document':84 'e.g':25 'esm':52 'f00':26 'format':13,23 'formatt':95 'function':75 'game':17 'gbx':96 'github':63 'html':33 'htmlifi':78 'human':35,77 'human-read':34 'includ':86 'interfac':73 'ital':90 'javascript':94 'librari':9 'like':76 'link':91 'maintain':61 'maniaplanet':16,97 'nadeo':98 'npm':48 'o':29 'pars':11 'parser':99 'provid':70 'readabl':36 'red':28 'releas':46 'shadow':93 'ship':55 'simpl':72 'string':37 'structur':40 'support':50 'text':3,6,18 'tm':2,5 'tm-text':1,4 'token':24,39,79,85 'trackmania':14,100 'type':57 'typescript':56,101 'version':43","created_at":"2026-06-04T18:55:39.094538+00:00","updated_at":"2026-06-04T18:55:39.094538+00:00","problems":[{"fix":"Use const tmText = require('tm-text').default; or const { tmText } = require('tm-text');","cause":"Using CommonJS require incorrectly; require('tm-text') returns an object, not a function.","error":"TypeError: tmText is not a function"},{"fix":"Run npm install tm-text and ensure import path is correct (no './').","cause":"Package not installed or environment resolution issue.","error":"Cannot find module 'tm-text'"},{"fix":"Ensure 'node_modules' is in typeRoots, or add 'tm-text' to 'types' in tsconfig.json.","cause":"TypeScript cannot locate type definitions; may need to install @types or check tsconfig.","error":"TS2307: Cannot find module 'tm-text' or its corresponding type declarations."},{"fix":"Use const { tmText } = require('tm-text'); instead of import.","cause":"Using ESM syntax in a CommonJS context without transpilation.","error":"SyntaxError: Unexpected token 'export'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/Brainshaker95/tm-text","github":"https://github.com/Brainshaker95/tm-text","docs":null,"changelog":null,"pypi":null,"npm":"tm-text","openapi_spec":null,"status_page":null,"smithery":null,"categories":["gaming"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-04","next_check":"2026-09-02","install_tag":null}}