1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! Penmanship - Unicode character lookup library
//!
//! This library provides a simple, efficient API for converting text patterns
//! to Unicode characters. It uses compile-time perfect hash maps for zero-cost
//! lookups.
//!
//! This crate is `#![no_std]` compatible.
//!
//! # Examples
//!
//! ```no_run
//! use penmanship::lookup;
//!
//! // Look up Unicode characters by pattern
//! if let Some((character, description)) = lookup("...") {
//! assert_eq!(character, "…");
//! assert_eq!(description, "horizontal ellipsis");
//! }
//!
//! if let Some((character, _)) = lookup("alpha") {
//! assert_eq!(character, "α");
//! }
//!
//! if let Some((character, _)) = lookup("(c)") {
//! assert_eq!(character, "©");
//! }
//!
//! // Unknown patterns return None
//! assert_eq!(lookup("unknown"), None);
//! ```
//!
//! # Features
//!
//! The library supports feature flags for different character categories:
//!
//! - `punctuation` - Punctuation and typography symbols
//! - `math` - Mathematical operators and symbols
//! - `greek` - Greek letters (lowercase and uppercase)
//! - `fractions` - Fraction characters
//! - `currency` - Currency symbols
//! - `symbols` - Miscellaneous symbols
//! - `superscripts` - Superscript characters
//! - `subscripts` - Subscript characters
//! - `html` - HTML named character references (e.g., ` `, `©`)
//! - `emoji` - Emoji shortcode lookup (e.g., `:smile:`, `:heart:`)
//! - `full` (default) - All categories enabled
//!
//! # HTML Entity Support
//!
//! With the `html` feature enabled, the library supports HTML named character references
//! like ` `, `©`, `α`, etc. Use the `lookup()` function with these patterns.
//!
//! Note: Numeric HTML entities (e.g., `A` or `A`) are not supported because
//! they would require dynamic memory allocation, which conflicts with the library's
//! zero-allocation design using static strings.
/// Category-specific Unicode character mappings.
/// Core lookup functionality.
// Re-export main API
pub use lookup;