Skip to main content

Crate badness_formatter

Crate badness_formatter 

Source
Expand description

badness-formatter — the deterministic, rule-based formatting engine behind badness, for LaTeX (.tex, .sty/.cls, .dtx, .ins) and BibTeX (.bib).

Layout is decided solely by the formatter’s rules and the Wadler/Prettier layout engine, on the lossless CST from badness_parser. The formatter changes only trivia — it never inserts, deletes, or rewrites a non-trivia token — and fmt(fmt(x)) == fmt(x).

This crate is embeddable (it builds for wasm32-unknown-unknown); the batch path-walking check API and the CLI live in the badness crate.

With the optional serde feature, FormatStyle and its enums are (de)serializable under badness.toml’s kebab-case spellings; the schema feature additionally derives schemars::JsonSchema for embedders that publish a config schema (see formatter::style).

Re-exports§

pub use formatter::FormatError;
pub use formatter::FormatStyle;
pub use formatter::ItemIndent;
pub use formatter::LineEnding;
pub use formatter::MathWrap;
pub use formatter::SentenceOptions;
pub use formatter::WrapMode;
pub use formatter::format;
pub use rowan;

Modules§

ast
Internal-path shim: the moved formatter sources keep addressing the typed AST as crate::ast.
bib
The BibTeX side of the formatter: badness-parser’s bib pipeline re-exported at the old paths, plus the .bib formatter itself.
declarations
Internal-path shim: a project’s declarations (badness_parser::declarations), re-exported so an embedder holding only this crate can build the value formatter::format_with_declarations_sentence takes without naming the parser crate.
directives
Internal-path shim: the comment-directive scanner lives in the parser crate, below both of its consumers (this crate and the root crate’s linter).
formatter
The formatter: parse → lower CST to a Wadler/Prettier Ir → print.
parser
Internal-path shim: the moved formatter sources keep addressing the parser as crate::parser.
semantic
Internal-path shim: the moved formatter sources keep addressing the semantic layer as crate::semantic.
syntax
Internal-path shim: the moved formatter sources keep addressing the syntax layer as crate::syntax.