Rosettes 0.2.0
content_hash, HighlightItem, HTML formatter improvements, thread-safety fixes
Released: February 13, 2026
Highlights
- content_hash() — Deterministic SHA-256 hash for (code, language) pairs, with optional
hl_linesandshow_linenosfor block-level cache keys - HighlightItem — Extended
highlight_many()supportshl_linesandshow_linenosfor full parallel batch highlighting - HTML Formatter — Pre-compute prefixed span templates; extract line-highlighting helpers for maintainability
- Theme Registry — Eager initialization with
threading.Lockonregister_palette()— thread-safety fix - Bounds checking —
_validate_range()forstart/endinhighlight()andtokenize()— raisesValueErroron invalid ranges
Added
content_hash(code, language, hl_lines=..., show_linenos=...)— cache key generationHighlightItemdataclass forhighlight_many()with line highlightinghighlight_many()acceptsHighlightItemwithhl_linesandshow_linenos_validate_range()bounds checking forstart/endparameters
Changed
- HTML formatter: pre-compute span templates from class mappings
- HTML formatter: extract
_format_with_hl_lines()and_resolve_span_table() - Theme registry: eager init with
threading.Lockonregister_palette() - CI: Replace mypy with ty for typechecking
Removed
- Dead
TYPE_CHECKINGblock in HTML formatter
Installation
pip install rosettes>=0.2.0
Requires Python 3.14+.