(new): JSON HTML escaping control
Golang lint / lint (push) Successful in 45s

- add Formatter.JSONEscapeHTML and SetJSONEscapeHTML to let JSON writers preserve HTML-sensitive characters when needed while keeping escaping enabled by default.
- switch JSON output to json.Encoder, preserve existing Print/Println newline semantics, and cover the new escaping behavior in tests.
This commit is contained in:
2026-04-28 14:36:03 +03:00
parent a54a854a77
commit dd3c7286d2
5 changed files with 98 additions and 12 deletions
+23
View File
@@ -1,3 +1,26 @@
# v2.3.0
This release adds JSON HTML-escaping control while preserving the existing
JSON writer defaults and newline semantics.
### Added
- Added `Formatter.SetJSONEscapeHTML(bool)` and `Formatter.JSONEscapeHTML` to control whether JSON writers escape HTML-sensitive characters such as `<`, `>`, and `&`.
### Changed
- JSON writers now use `json.Encoder` internally so formatter-level HTML escaping can be configured.
### Fixed
- Preserved `Print` and `Println` newline behavior for JSON output while switching to `json.Encoder`.
### Compatibility
- No breaking API changes.
- HTML escaping remains enabled by default, matching the previous `encoding/json` behavior.
- `Print` still emits JSON without an added newline, and `Println` emits exactly one trailing newline.
# v2.2.0
This release expands the public LogLevel API, adds optional threshold-based