Expand description
§indentkit — detect and convert indentation
Figure out whether a string is indented with tabs or N spaces, and
re-indent it from one style to another. Like Node’s detect-indent, but with
conversion built in — and zero dependencies, #![no_std].
use indentkit::{detect, reindent, IndentStyle};
let code = "fn main() {\n println!(\"hi\");\n}\n";
assert_eq!(detect(code), IndentStyle::Spaces(2));
let tabbed = reindent(code, IndentStyle::Tabs);
assert_eq!(tabbed, "fn main() {\n\tprintln!(\"hi\");\n}\n");Great for formatters, linters, code generators, and editor tooling.
Enums§
- Indent
Style - The indentation style of a block of text.