Add ANSI color support fallback modes

This commit is contained in:
Nanaloveyuki
2026-05-10 15:32:48 +08:00
parent 2d2388c79f
commit 4b54005401
8 changed files with 234 additions and 29 deletions
+3
View File
@@ -19,6 +19,7 @@ version 0.4.0
- feat: add builtin semantic style tags such as `accent`, `info`, `success`, `warning`, `danger`, and `muted`
- feat: add independent `target_style_markup` and `fields_style_markup` controls for `TextFormatter` and `TextFormatterConfig`
- feat: support named closing tags like `</red>` alongside the existing short close `</>`
- feat: add `ColorSupport = Basic | TrueColor` and support `sink.text_formatter.color_support` so hex / RGB styles can downgrade to basic ANSI colors
### Test
@@ -33,6 +34,7 @@ version 0.4.0
- test: cover builtin semantic tag rendering and confirm user overrides still take precedence
- test: cover target and field markup rendering, plus config roundtrip for the new formatter markup scopes
- test: cover named closing tags, mixed short/named closing, and unmatched named-close fallback behavior
- test: cover basic color-support downgrade for hex foreground/background rendering in runtime and config paths
### Example
@@ -49,3 +51,4 @@ version 0.4.0
- JSON config currently supports concrete style objects only; alias-style declarations remain runtime-only
- users can now decide whether custom style parsing is enabled through runtime formatter APIs or `sink.text_formatter.style_markup`
- `fields_style_markup` currently styles field values only and intentionally leaves field keys raw
- `basic` color support currently keeps ANSI styling but downgrades hex / RGB colors to the nearest basic ANSI color family