11 releases (stable)
2.2.1 | Nov 16, 2021 |
---|---|
2.1.1 | Aug 12, 2021 |
2.1.0 | May 9, 2021 |
1.1.1 | Mar 26, 2021 |
0.9.2 | Mar 21, 2020 |
#472 in Text processing
2,269 downloads per month
Used in 5 crates
(4 directly)
16KB
228 lines
sanitize-filename-reader-friendly
A filename sanitizer aiming to produce reader friendly filenames, while preserving as much information as possible.
Unlike Node's sanitize-filename, this library replaces
non-file-system-compatible characters with underscore and space. Both are
trimmed when they appear at the beginning or at the end of a line or when they
repeat within. Non-printable punctuation marks are replaced by underscores,
other non-printable characters by spaces, except the non-printable space
U+200b
which is filtered out. Newlines are replaced by dashes.
Sample usage:
extern crate sanitize_filename_reader_friendly;
use crate::sanitize_filename_reader_friendly::sanitize;
fn main() {
println!("{}",
sanitize("Read: http://blog.getreu.net/projects/tp-note/"));
// Prints: "Read_ http_blog.getreu.net_projects_tp-note"
}
This library comes with a simple command-line application. Usage:
cargo install sanitize-filename-reader-friendly
sanitize-filename <input.txt >output.txt
Dependencies
~535KB