crate_cli/fmt/toml/fn.rs
1use super::*;
2
3/// Formats TOML files matching VS Code `tamasfe.even-better-toml` (Taplo 0.7.0 defaults with 4-space indentation).
4///
5/// # Arguments
6///
7/// - `&str` - Raw TOML source text.
8///
9/// # Returns
10///
11/// - `String` - Formatted TOML text, or unchanged input if syntax errors occur.
12pub fn format_toml(input: &str) -> String {
13 let opts: Options = vscode_tidy_options();
14 tidy::toml::format(input, &opts.toml).unwrap_or_else(|_: tidy::Error| input.to_string())
15}