1 个不稳定版本
0.1.0 | 2019年11月19日 |
---|
#13 in #would
7KB
smart_quotes
智能引号
这是一个提供简单启发式方法的微型辅助软件包,用于实现智能引号。
虽然这个软件包不转换任何符号,但它根据前一个字符提供启发式方法,判断下一个字符是否为开引号或闭引号。
示例用法
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);
许可:MIT OR Apache-2.0