<div align="center">
<h1>dioxus-code-macro</h1>
<p><strong>Compile-time syntax highlighting macro for <a href="https://crates.io/crates/dioxus-code">dioxus-code</a>.</strong></p>
</div>
<div align="center">
<a href="https://crates.io/crates/dioxus-code-macro">
<img src="https://img.shields.io/crates/v/dioxus-code-macro.svg?style=flat-square" alt="Crates.io version" />
</a>
<a href="https://crates.io/crates/dioxus-code-macro">
<img src="https://img.shields.io/crates/d/dioxus-code-macro.svg?style=flat-square" alt="Downloads" />
</a>
<a href="https://docs.rs/dioxus-code-macro">
<img src="https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square" alt="docs.rs" />
</a>
</div>
---
Implementation crate for the `code!` macro re-exported by [`dioxus-code`](https://crates.io/crates/dioxus-code) under its default `macro` feature. You usually depend on `dioxus-code` instead of pulling this in directly.
The macro reads a source file at compile time, parses it with [`arborium`](https://crates.io/crates/arborium), and expands to a static span tree. The runtime binary ships only the spans — no parser.
```rust
use dioxus_code::code;
let tree = code!("/snippets/demo.rs");
```
## Path resolution
Paths are resolved relative to the *consumer's* `CARGO_MANIFEST_DIR`. A leading `/` anchors to that directory; bare paths resolve from it as well. `concat!(...)` and `env!(...)` expressions are also accepted.
```rust
code!(concat!(env!("CARGO_MANIFEST_DIR"), "/snippets/demo.rs"));
```
## Explicit language
When the file extension isn't enough to infer the language, pass `language = "..."`:
```rust
code!("/snippets/Containerfile", language = "dockerfile");
```
## License
[MIT](LICENSE).