#filename #sanitizer

bin+lib sanitize-filename-reader-friendly

A filename sanitizer aiming to produce reader friendly filenames

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

Download history 1019/week @ 2024-06-13 1121/week @ 2024-06-20 964/week @ 2024-06-27 1157/week @ 2024-07-04 1047/week @ 2024-07-11 993/week @ 2024-07-18 1130/week @ 2024-07-25 704/week @ 2024-08-01 553/week @ 2024-08-08 468/week @ 2024-08-15 556/week @ 2024-08-22 528/week @ 2024-08-29 544/week @ 2024-09-05 558/week @ 2024-09-12 503/week @ 2024-09-19 559/week @ 2024-09-26

2,269 downloads per month
Used in 5 crates (4 directly)

MIT/Apache

16KB
228 lines

sanitize-filename-reader-friendly

A filename sanitizer aiming to produce reader friendly filenames, while preserving as much information as possible.

Cargo Documentation License

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