smart_quotes 0.1.0

Heuristic for implementing smart quotes.
Documentation
  • Coverage
  • 60%
    3 out of 5 items documented1 out of 3 items with examples
  • Size
  • Source code size: 5.7 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.46 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Robert42/smart_quotes
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • Robert42

smart_quotes

Smart Quotes

This is a tiny helper crate providing a simple heursitic for implementing smart quotes.

While this crate does not convert any glyphs, it gives a heuristic based on the previous character, wheter the next character would be an opening or closing quotation mark.

Example usage:

use smart_quotes::{decide_quote_after, Decision};

assert_eq!(decide_quote_after(None), Decision::Open);

assert_eq!(decide_quote_after(Some(' ')), Decision::Open);
assert_eq!(decide_quote_after(Some('\t')), Decision::Open);
assert_eq!(decide_quote_after(Some('\n')), Decision::Open);
assert_eq!(decide_quote_after(Some('\x0A')), Decision::Open);
assert_eq!(decide_quote_after(Some('\u{1680}')), Decision::Open);
assert_eq!(decide_quote_after(Some('\u{2005}')), Decision::Open);
assert_eq!(decide_quote_after(Some('\u{202F}')), Decision::Open);
assert_eq!(decide_quote_after(Some('\u{2029}')), Decision::Open);

assert_eq!(decide_quote_after(Some('(')), Decision::Open);
assert_eq!(decide_quote_after(Some('[')), Decision::Open);
assert_eq!(decide_quote_after(Some('{')), Decision::Open);
assert_eq!(decide_quote_after(Some('')), Decision::Open);

assert_eq!(decide_quote_after(Some('\u{2012}')), Decision::Open);
assert_eq!(decide_quote_after(Some('\u{2015}')), Decision::Open);

assert_eq!(decide_quote_after(Some('x')), Decision::Close);
assert_eq!(decide_quote_after(Some('')), Decision::Close);
assert_eq!(decide_quote_after(Some('')), Decision::Close);
assert_eq!(decide_quote_after(Some('.')), Decision::Close);
assert_eq!(decide_quote_after(Some(':')), Decision::Close);

License: MIT OR Apache-2.0