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 optionalhl_lines and show_linenosfor block-level cache keys
  • HighlightItem — Extendedhighlight_many() supports hl_lines and show_linenosfor full parallel batch highlighting
  • HTML Formatter — Pre-compute prefixed span templates; extract line-highlighting helpers for maintainability
  • Theme Registry — Eager initialization withthreading.Lock on register_palette()— thread-safety fix
  • Bounds checking_validate_range() for start/end in highlight() and tokenize() — raises ValueErroron invalid ranges

Added

  • content_hash(code, language, hl_lines=..., show_linenos=...)— cache key generation
  • HighlightItem dataclass for highlight_many()with line highlighting
  • highlight_many() accepts HighlightItem with hl_lines and show_linenos
  • _validate_range() bounds checking for start/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 withthreading.Lock on register_palette()
  • CI: Replace mypy with ty for typechecking

Removed

  • DeadTYPE_CHECKINGblock in HTML formatter

Installation

pip install rosettes>=0.2.0

Requires Python 3.14+.