Skip to main content

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 DataMap subclass that maps color name tokens to ANSI escape codes or Minecraft color codes using angle-bracket syntax (<color>). It is the primary way to apply terminal or in-game color formatting through a MapResolver pipeline — every color field resolves to its corresponding escape sequence at resolution time.

Import

from mapres import ColorMap, ascii_colors, mc_colors, strip_colors
# or via the maps namespace:
from mapres import maps
maps.ascii_colors
maps.mc_colors
maps.strip_colors

ColorMap class

ColorMap extends DataMap and is decorated with @datamap(syntax=syntax.angles), which sets its placeholder syntax to <name> (angle brackets). All 19 color fields are defined as annotated string attributes with default values equal to their ANSI escape codes.

Constructor

**field_overrides
str
Any of the 19 named color fields (black, dark_blue, dark_green, etc.) passed as keyword arguments to override their default ANSI values. Used internally to produce mc_colors and strip_colors.
# Default instance (ANSI codes)
cm = ColorMap()

# Override individual fields
cm = ColorMap(red="\033[31m", bold="")

Methods

as_dict() -> dict

Returns a dictionary keyed by <name> tokens rather than plain field names, mapping each token to its current value.
cm = ColorMap()
cm.as_dict()
# {"<black>": "\033[30m", "<dark_blue>": "\033[34m", ...}

Fields

All 19 fields defined on ColorMap, with their default ANSI values:
FieldTypeDefault (ANSI)
blackstr\033[30m
dark_bluestr\033[34m
dark_greenstr\033[32m
dark_aquastr\033[36m
dark_redstr\033[31m
dark_purplestr\033[35m
goldstr\033[33m
graystr\033[37m
dark_graystr\033[90m
bluestr\033[94m
greenstr\033[92m
aquastr\033[96m
redstr\033[91m
light_purplestr\033[95m
yellowstr\033[93m
whitestr\033[97m
resetstr\033[0m
boldstr\033[1m
italicstr\033[3m

Built-in instances

Three ready-to-use ColorMap instances are exported from mapres and the maps namespace:
InstanceDescriptionExample value for red
ascii_colorsMaps all color names to ANSI \033[...m escape codes for terminal output\033[91m
mc_colorsMaps all color names to Minecraft §X color codes for in-game text formatting§c
strip_colorsMaps all color names to an empty string, effectively removing color tokens from the output""

Color reference table

Full mapping of every color name to its ANSI code and Minecraft code:
Color nameANSI codeMinecraft 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

Usage example with MapResolver

Pass any ColorMap instance as a layer to a MapResolver to resolve color tokens inside your strings:
from mapres import MapResolver, ascii_colors, mc_colors, strip_colors

resolver = MapResolver(ascii_colors)
print(resolver.res("<red>Hello, world!<reset>"))
# \033[91mHello, world!\033[0m

# Switch to Minecraft codes by swapping the layer
mc_resolver = MapResolver(mc_colors)
print(mc_resolver.res("<gold>Welcome<reset>"))
# §6Welcome§r

# Strip all color tokens entirely
strip_resolver = MapResolver(strip_colors)
print(strip_resolver.res("<bold>Clean text<reset>"))
# Clean text
ColorMap uses angle-bracket syntax — only tokens wrapped in < and > are matched and substituted. Strings containing {braces} or ${dollars} placeholders are not affected by ColorMap substitution and pass through unchanged.

Build docs developers (and LLMs) love