Documentation Index
Fetch the complete documentation index at: https://mintlify.com/iFamishedX/mapres/llms.txt
Use this file to discover all available pages before exploring further.
ColorMap is a built-in DataMap that uses angle-bracket syntax (<color>) to substitute color escape sequences into strings. Drop one of the pre-built instances into a Layer and any placeholder like <green> or <reset> is automatically replaced with the appropriate escape code at resolution time — no manual string formatting required.
Available instances
mapres exports three ready-to-useColorMap instances that cover the most common use cases:
| Instance | Description |
|---|---|
ascii_colors | ANSI escape codes for terminal / TTY output (e.g. \033[92m for green) |
mc_colors | Minecraft §-prefixed chat color codes (e.g. §a for green) |
strip_colors | Replaces every color tag with an empty string, producing plain unstyled text |
mapres package:
Color keys
All three instances share the same set of 19 keys. The table below lists each key together with its ANSI escape code and its Minecraft equivalent.| Key | ANSI code | Minecraft code |
|---|---|---|
black | \033[30m | §0 |
dark_blue | \033[34m | §1 |
dark_green | \033[32m | §2 |
dark_aqua | \033[36m | §3 |
dark_red | \033[31m | §4 |
dark_purple | \033[35m | §5 |
gold | \033[33m | §6 |
gray | \033[37m | §7 |
dark_gray | \033[90m | §8 |
blue | \033[94m | §9 |
green | \033[92m | §a |
aqua | \033[96m | §b |
red | \033[91m | §c |
light_purple | \033[95m | §d |
yellow | \033[93m | §e |
white | \033[97m | §f |
reset | \033[0m | §r |
bold | \033[1m | §l |
italic | \033[3m | §o |
strip_colors maps every key above to an empty string "", so all <color> tags are silently removed from the resolved output.The as_dict() method
Every ColorMap instance exposes an as_dict() helper that returns a plain Python dictionary keyed in the angle-bracket format that syntax.angles uses. Each key is wrapped in < and >, matching the placeholder form expected by MapResolver:
DataMap instances.
The maps namespace
All ColorMap exports are also available under the top-level maps namespace object for organised imports:
maps namespace is equivalent to importing each name directly from mapres — the objects are identical.
Usage with MapResolver
Wrapascii_colors (or any other instance) in a Layer, build a LayerStack, and pass it to MapResolver. Call resolver.res() with a string containing angle-bracket color placeholders:
result will contain the ANSI-coloured string ready for printing to a terminal:
ColorMap registers itself with syntax.angles — the regex <([^<>]+)>. Only text wrapped in angle brackets is treated as a placeholder; the rest of the string is passed through unchanged.Minecraft color codes
Swapascii_colors for mc_colors to produce strings formatted for Minecraft chat or server console messages. The API is identical:
§-prefixed codes that Minecraft’s text rendering engine understands natively.
Stripping colors
Usestrip_colors when you need a plain-text version of a colored template — for example, writing to a log file or sending to a downstream system that does not interpret escape codes:
"", all color tags disappear and the surrounding text is preserved exactly as written.
Custom ColorMap
ColorMap is itself a DataMap decorated with @datamap(syntax=syntax.angles), which means you can instantiate it with any combination of overridden field values to build your own color palette:
Layer exactly the same way as the built-in instances. All unspecified keys keep their default ANSI values.
ColorMap always uses angle-bracket syntax (syntax.angles) regardless of which instance you use or how you override individual color values. If you need a different delimiter, create a new class with @datamap(syntax=syntax.braces) (or another syntax variant) that mirrors the ColorMap field layout.