blade-syntax 0.1.0

Lossless parser for Laravel Blade templates
Documentation
# blade-syntax

A lossless parser for [Laravel Blade](https://laravel.com/docs/blade) templates, written in Rust.

```rust
let parse = blade_syntax::parse("@if($user) Hi {{ $user->name }} @endif");
assert!(parse.errors().is_empty());

// The tree reproduces the input exactly, byte for byte.
assert_eq!(parse.syntax().to_string(), "@if($user) Hi {{ $user->name }} @endif");

// Walk it like any rowan tree.
for node in parse.syntax().descendants() {
    println!("{:?} {:?}", node.kind(), node.text_range());
}
```

- **Lossless:** whitespace, comments, CRLF, a BOM and broken input all round-trip. Formatters and linters can share one tree.
- **Never fails:** problems such as an unclosed `@if` or `{{` become `ParseError`s with a byte range, and the tree is still built.
- **Follows Blade's real rules:** directive pairing (including `@forelse`/`@empty`, `@section`/`@show`, custom `Blade::if` conditionals), `@verbatim` and `@php` raw blocks, escaped `@{{ }}` and `@@`, and `{{{ }}}`.
- **Understands HTML structure:** tags, attributes, `<x-components>`, `<livewire:...>`, Alpine `@click` attributes, `<script>`/`<style>` raw text, and tags split across `@if` branches.
- **Tested on real code:** 879 templates from Laravel, Filament, Livewire, Breeze, Jetstream, Pulse, BookStack and laravel.io, plus property tests and fuzzing.

The tree is built on [rowan](https://crates.io/crates/rowan), the library behind rust-analyzer.

How it works: [docs/how-it-works](https://github.com/roderio/blade-rs/tree/main/docs/how-it-works).

## License

MIT or Apache-2.0, at your option.