Expand description
dioxus-code-macro
Compile-time syntax highlighting macro for dioxus-code.
Implementation crate for the code! macro re-exported by 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, and expands to a static span tree. The runtime binary ships only the spans — no parser.
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.
code!(concat!(env!("CARGO_MANIFEST_DIR"), "/snippets/demo.rs"));§Explicit language
When the file extension isn’t enough to infer the language, pass language = "...":
code!("/snippets/Containerfile", language = "dockerfile");§License
MIT.
Macros§
- code
- Compile-time syntax highlighting.