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
pub(crate) fn consume_whitespace(pos: &mut usize, c: &[u8], significant_newline: bool) {
let mut p = *pos;
while p < c.len() {
let b0 = c[p];
match b0 {
0x0020 | 0x0009 => {
// U+0020 - space
// U+0009 - tab
p += 1;
continue;
}
0x000a if significant_newline => {
// U+000a - line feed
break;
}
0x000a..=0x000d => {
// U+000a - line feed
// U+000b - vertical tab
// U+000c - form feed
// U+000d - carriage return
p += 1;
continue;
}
0xc2 if p + 1 < c.len() => {
let b1 = c[p + 1];
if b1 == 0x85 {
// U+0085 - next line
p += 2;
continue;
}
}
0xe2 if p + 2 < c.len() => {
let b1 = c[p + 1];
if b1 == 0x80 {
let b2 = c[p + 2];
if matches!(b2, 0x8e | 0x8f | 0xa8 | 0xa9) {
// U+200e - left-to-right mark
// U+200f - right-to-left mark
// U+2028 - line separator
// U+2029 - paragraph separator
p += 3;
continue;
}
}
}
_ => {}
}
break;
}
*pos = p;
}