1
0
mirror of https://github.com/lise-henry/crowbook synced 2024-09-29 16:31:23 +02:00

Factorize code in french cleaner

This commit is contained in:
Elisabeth Henry 2016-05-07 14:14:42 +02:00
parent 81bee70877
commit 6cdc544178

@ -108,31 +108,23 @@ impl Cleaner for French {
new_s.push(current);
match current {
// handle nb space after char
'—' => {
'—' | '«' => {
if is_whitespace(next) {
let replacing_char = match current {
'—' => nb_char_em,
'«' => nb_char,
_ => unreachable!(),
};
if let Some(next) = chars.next() {
new_s.push(nb_char_em);
new_s.push(replacing_char);
current = next;
continue;
} else {
current = nb_char_em;
break;
}
}
},
'«' => {
if is_whitespace(next) {
if let Some(next) = chars.next() {
new_s.push(nb_char);
current = next;
continue;
} else {
current = nb_char;
// current will be added after the loop, do don't do it now
current = replacing_char;
break;
}
}
},
_ => (),
}