Skip to content

Commit 150ac6f

Browse files
Template aware parsing (#143)
* Add language-aware class sorting Keep template expressions opaque while sorting adjacent static runs. Infer profiles from paths and preserve legacy behavior for unknown sources. * Fix language-aware class extraction regressions Preserve template expressions across inferred and explicit language profiles while keeping valid Tailwind punctuation sortable in unknown files. Use indexed markup spans for large documents, respect Svelte component case semantics, and restore positional custom-regex captures. * Document language-aware sorting changes Record the new language profiles, template-safety fixes, compatibility behavior, performance work, and public API migrations. * Update cache and string dependencies * Bump Rust deps and add update task Upgrade several crate dependencies across `rustywind-core` and `xtask`, including benchmarking, allocator, CLI, networking, and archive tooling. Also add a `just update` recipe to refresh workspace dependencies more easily. * Adapt code to updated dependencies * Parse Astro and templates with Winnow Add typed markup extraction and first-class Astro handling while preserving template islands. Avoid repeated tag scans and keep legacy-compatible Lit and Ruby markup sortable. * Document Astro parsing and breaking changes * Add short CLI aliases Add single-letter aliases for common options to reduce command input cost while keeping full-length flags supported. Update README usage output, changelog notes, and parsing tests to cover the new -p, -l, and -f behavior. * Prevent class sorting from rewriting templates Validate wrapped captures and attribute names before sorting. Respect HTML casing, PHP comment delimiters, and escaped Blade directives so source expressions remain byte-exact. * Parse Svelte block tags for class sorting Separate document template islands from class-value expressions so Svelte closing tags no longer disable sorting for the entire file. Track Svelte block structure and preserve fail-closed behavior for malformed markup.
1 parent 3d7b936 commit 150ac6f

23 files changed

Lines changed: 4753 additions & 812 deletions

CHANGELOG.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,49 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Add language-aware class extraction for HTML, Svelte, Django, Jinja, Twig,
8+
Liquid, Handlebars, ERB, EJS, PHP, Blade, Lit, and Ruby
9+
- Add `--language` to override source-language inference and
10+
`--stdin-filename` to infer the language of standard input
11+
- Preserve template expressions as opaque boundaries while independently
12+
sorting adjacent static class runs
13+
14+
### Fixed
15+
16+
- Preserve Django and Jinja output expressions and control tags, including
17+
expressions attached to class names, [#138](https://github.com/avencera/rustywind/issues/138)
18+
- Prevent ERB ternaries and quoted expressions from being corrupted,
19+
[#140](https://github.com/avencera/rustywind/issues/140)
20+
- Prevent Svelte inline conditionals from being reordered as static classes,
21+
[#142](https://github.com/avencera/rustywind/issues/142)
22+
- Keep ambiguous template expressions in plain `.html` files unchanged unless
23+
an explicit template-language profile is selected
24+
- Sort valid Tailwind punctuation and quoted arbitrary values in files with
25+
unrecognized extensions while continuing to reject template expressions
26+
- Preserve nested class attributes inside capitalized Svelte components
27+
- Continue accepting the first positional capture in `--custom-regex`, as in
28+
RustyWind 0.24 and earlier, while also supporting a named `classes` capture
29+
30+
### Performance
31+
32+
- Index markup tag spans so class extraction no longer scans every tag for
33+
every class attribute in large documents
34+
35+
### Breaking changes
36+
37+
- `RustyWind::has_classes` now accepts a `SourceDocument`,
38+
`RustyWind::sort_file_contents` is replaced by `sort_document`, and
39+
`RustyWind::sort_classes` is replaced by `sort_class_list`, which requires a
40+
validated `PlainClassList`
41+
- `FinderRegex::CustomRegex` now contains a `CustomClassExtractor`; library
42+
callers constructing this variant must validate their `Regex` with
43+
`CustomClassExtractor::new`
44+
- Recognized markup languages only sort literal `class` and `className`
45+
attributes in actual tags. Class-like text in comments, raw-text elements,
46+
program strings, and dynamic or namespaced attributes is no longer rewritten
47+
548
## [0.25.2] - 2026-07-08
649

750
### Fixed

0 commit comments

Comments
 (0)