blob: 870fd33f75a9f880067b95c9ffd47837bebc7123 (
plain) (
blame)
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
|
//! To do.
/// To do.
pub fn normalize_identifier(value: &str) -> String {
let mut codes = vec![];
let mut at_start = true;
let mut at_whitespace = true;
// Collapse markdown whitespace and trim it.
for char in value.chars() {
match char {
'\t' | '\r' | '\n' | ' ' => {
at_whitespace = true;
}
_ => {
if at_whitespace && !at_start {
codes.push(' ');
}
codes.push(char);
at_start = false;
at_whitespace = false;
}
}
}
// To do: test if this matches unicode.
// Some characters are considered “uppercase”, but if their lowercase
// counterpart is uppercased will result in a different uppercase
// character.
// Hence, to get that form, we perform both lower- and uppercase.
codes
.iter()
.collect::<String>()
.to_uppercase()
.to_lowercase()
}
|