Skip to main content

html_stylesheet

Function html_stylesheet 

Source
pub fn html_stylesheet(theme: &Theme, class_prefix: &str) -> String
Available on crate feature html only.
Expand description

Generates a swappable theme stylesheet for HtmlOptions::class_prefix.

Only the prefix must match the rendered HTML; the theme can be changed freely. The wrapper class is sm-{encoded_prefix}-root. Supply that class on your own container when include_wrapper is false. Prefix bytes except ASCII letters, digits, and hyphens become _xx hex escapes (including underscores). Each scope level has one class, sm-{encoded_prefix}-s-{encoded_scope}: dots become hyphens; other non-alphanumeric scope bytes become _xx escapes. CSS |= attribute selectors preserve ordered, dotted scope-prefix matching. Do not add other classes to the generated scope spans.

Parent selectors become descendants; comma lists become separate equivalent rules. Exclusions (- or -scope), child combinators (>), wildcards, and priority prefixes (L:/R:) are skipped. Other syntax rejected by Theme::from_json cannot reach this renderer. Rules use zero-specificity :where() selectors ordered by TextMate target depth, nearest-first parent lengths/count, then source order. This approximates TextMate through CSS inheritance and cascade; unsupported selectors and surrounding page CSS can differ from inline output. Font decorations use inherited custom properties applied only to text spans, allowing inner scopes to clear them. Requires CSS custom properties and :where().