Add builtin semantic style tags

This commit is contained in:
Nanaloveyuki
2026-05-10 15:10:29 +08:00
parent 20f79bbe2a
commit 4be861acce
7 changed files with 52 additions and 6 deletions
+1
View File
@@ -283,6 +283,7 @@ match logger.file_runtime_state() {
- `TextFormatter` and `TextFormatterConfig` now include `color_mode = Never | Auto | Always` for ANSI text coloring control.
- `TextFormatter` and `TextFormatterConfig` also include `style_markup = disabled | builtin | full` so callers can choose whether style markup is parsed and whether custom tags are active.
- `message` also supports lightweight inline style tags such as `<red>...</>`, `<b>...</>`, `<#ff0000>...</>`, and `<bg:#202020>...</>`.
- Builtin semantic tags now include `<accent>`, `<info>`, `<success>`, `<warning>`, `<danger>`, and `<muted>`.
- Runtime style-tag APIs now include `TextStyle`, `StyleTagRegistry`, `style_tag_registry()`, `default_style_tag_registry()`, `set_tag(...)`, and `define_alias(...)`.
- Style-tag lookup priority is formatter-local `style_tags` > global style tag registry > builtin tags.
- `sink.text_formatter.style_tags` now supports a minimal object mapping with `fg`, `bg`, `bold`, `dim`, `italic`, and `underline`.
+2
View File
@@ -16,6 +16,7 @@ version 0.4.0
- feat: support minimal `sink.text_formatter.style_tags` JSON config parsing and serialization for custom formatter tag styles
- feat: add `StyleMarkupMode = Disabled | Builtin | Full` plus formatter helpers so callers can explicitly disable style parsing or allow builtin-only parsing
- feat: support `sink.text_formatter.style_markup` in JSON config parsing and serialization
- feat: add builtin semantic style tags such as `accent`, `info`, `success`, `warning`, `danger`, and `muted`
### Test
@@ -27,6 +28,7 @@ version 0.4.0
- test: cover custom tags, builtin-tag override, formatter-vs-global priority, global registry fallback, and alias reuse
- test: cover formatter `style_tags` JSON parsing, config roundtrip, JSON helper export, and config-driven styled formatter rendering
- test: cover disabled markup mode, builtin-only mode, and config-driven `style_markup` behavior
- test: cover builtin semantic tag rendering and confirm user overrides still take precedence
### Example