| Crates.io | maudfmt |
| lib.rs | maudfmt |
| version | 0.1.8 |
| created_at | 2025-06-29 12:07:00.287766+00 |
| updated_at | 2025-12-01 16:03:05.442635+00 |
| description | An opinionated yet customizable Maud formatter. |
| homepage | https://github.com/jeosas/maudfmt |
| repository | https://github.com/jeosas/maudfmt |
| max_upload_size | |
| id | 1730704 |
| size | 174,899 |
An opinionated yet customizable Maud formatter.
cargo install maudfmt
or for trying out unreleased features:
cargo install --git https://github.com/jeosas/maudfmt.git
maudfmt ./build.rs ./src/main.rs
maudfmt ./src
maudfmt ./{src, tests}/**/*
cat ./src/main.rs | maudfmt -s
$ maudfmt --help
An opinionated yet customizable Maud formatter.
Usage: maudfmt [OPTIONS] [FILE]...
Arguments:
[FILE]... A space separated list of file, directory or glob
Options:
-s, --stdin Format stdin and write to stdout
-m, --macro-names <MACRO_NAMES> Comma-separated list of macro names (overriding html and maud::html)
--rustfmt Run rustfmt after maudfmt
--line-length <LINE_LENGTH> Maximum line length
-h, --help Print help
-V, --version Print version
require("conform").setup({
formatters = {
maudfmt = {
command = "maudfmt",
args = { "-s" }, -- add any config you wish
},
},
formatters_by_ft = {
rust = { "rustfmt", "maudfmt" },
},
})
There are several reasons you might not want a specific macro block to be formatted:
maudfmt is broken and you'd like to keep the format in check while the issue is investigated.To do so, just add the rustfmt::skip attribute to the macro block.
#[rustfmt::skip]
html! {
p {
"my personal formatting"
}
}
To skip formatting for just one line, add a // maudfmt-ignore comment on the line before:
html! {
p { "formatted" }
// maudfmt-ignore
span class="unformatted" id="test" { "content" }
h1 { "also formatted" }
}
maudfmt automatically manages exanding and collapsing blocks depending on line length.
In some cases, would might prefer to expand a block even if it fits on a single line. To do this, you can use magic comments:
p { //
"Small text"
}
p {
// either on an empty line
"Small text" // or as a trailing comment
}
doesn't matter if there is an actual comment, the
//comment marker is enough.
Special thanks to the creators and contributors of the following projects for their awesome work and inspiration
Currently this formatter does not support non-doc comments in code blocks (Splices).
It uses prettyplease for formatting rust code, and prettyplease does not support this.
This means that you can use non-doc comments throughout your view macro, as long as they don't reside within code blocks.
A bit more context:
prettypleaseusessynto parse rust syntax. According to https://doc.rust-lang.org/reference/comments.html#non-doc-comments non-doc comments are interpreted as a form of whitespace by the parser;synbasically ignores/skips these comments and does not include them in the syntax tree.