[][src]Function sanitize_filename_reader_friendly::sanitize

pub fn sanitize(s: &str) -> String

Converts strings in a file-system friendly and human readable from.

  • Replace tab with one space.
  • Filter control characters.
  • Replace :\\/|?~,;= with underscore.
  • Replace `<>:"#%{}^[]+`` with space.
  • Filter space after space.
  • Filter period after period, space, underscore or beginning of string.
  • Filter underscore after period, space or underscore.
  • Trim whitespace and _- at the beginning and the end of the line.
  • Filter newline and insert line separator -.
  • Trim whitespace and _- at the beginning and the end of the whole string.
use sanitize_filename_reader_friendly::sanitize;
let output = sanitize("Read: http://blog.getreu.net/projects/tp-note/");
assert_eq!(output, "Read_ http_blog.getreu.net_projects_tp-note");