txt-cleaner 0.1.0

A smarter text cleanup library for Rust that trims whitespace, removes BOM/zero-width chars, and cleans markdown/html artifacts.
Documentation
  • Coverage
  • 61.9%
    13 out of 21 items documented0 out of 16 items with examples
  • Size
  • Source code size: 17.77 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 445.34 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • ZenStarDev

txt-cleaner

txt-cleaner is a small Rust library for smarter cleanup of text data. It goes beyond trim() to normalize whitespace, remove invisible characters, and strip stray markdown/html artifacts from the edges of a string.

Features

  • Remove BOM and zero-width characters like \u{200B}
  • Collapse consecutive spaces, tabs, and newlines
  • Preserve paragraph structure or collapse all whitespace to a single space
  • Strip common markdown/html edge artifacts such as headings, unclosed wrappers, and stray tags
  • Builder-style configuration API

Usage

use txt_cleaner::{clean, CleanOptions};

let raw = "\u{feff}**\n  Hello   \n\n\n  world!  **\u{200B} ";
let cleaned = clean(raw);
assert_eq!(cleaned, "Hello\n\nworld!");

let options = CleanOptions::builder()
    .strip_invisible_chars(true)
    .strip_markdown_artifacts(true)
    .preserve_paragraphs(false)
    .collapse_all_whitespace(true)
    .build();

let cleaned_single_line = txt_cleaner::clean_with_options(raw, options);
assert_eq!(cleaned_single_line, "Hello world!");

License

MIT