Add inline style markup

This commit is contained in:
Nanaloveyuki
2026-05-10 14:41:57 +08:00
parent 90af009e93
commit b1b2235160
3 changed files with 271 additions and 3 deletions
+8 -1
View File
@@ -8,12 +8,17 @@ version 0.4.0
- feat: add ANSI level, target, timestamp, and field rendering to `format_text(...)`
- feat: add `color_mode` to `TextFormatter` and `TextFormatterConfig`
- feat: support `text_formatter.color_mode` in JSON config parsing and serialization
- feat: add inline style markup support in message text for ANSI text formatter output
- feat: support named color tags like `<red>...</>`, style tags like `<b>...</>`, and hex tags like `<#ff0000>...</>` / `<bg:#010203>...</>`
- feat: keep JSON formatter output unchanged and limit inline style parsing to text message rendering only
### Test
- test: cover ANSI text formatter rendering in `Always` mode
- test: cover `Auto` mode fallback behavior when `NO_COLOR` is present
- test: cover config parsing and serialization for `color_mode`
- test: cover named inline color tags in ANSI mode
- test: cover plain mode tag stripping, nested tags, hex tags, and unknown-tag fallback behavior
### Example
@@ -22,4 +27,6 @@ version 0.4.0
### Notes
- `Auto` currently uses a conservative rule: if `NO_COLOR` exists, ANSI is disabled; otherwise ANSI is enabled
- this batch only covers ANSI formatter output and does not yet include inline style markup or tag registry support
- inline style markup currently supports short close `</>` only
- unknown or invalid inline tags currently fall back to plain text and do not raise formatter errors
- tag registry override and configurable style aliases are planned for a later `0.4` batch