Skip to content

Commit

Permalink
chore(crate): Handle hyphenated compound words in French
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Oct 29, 2024
1 parent c12caef commit 1cf0159
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/fr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ pub fn titlecase(chunk: Chunk, style: StyleGuide) -> String {
}

fn titlecase_fr(chunk: Chunk) -> String {
let mut segments: Vec<Segment> = Vec::new();
chunk.clone().segments.into_iter().for_each(|segment| {
match segment {
Segment::Separator(_) => segments.push(segment),
Segment::Word(ref word) => {
let mut segs = word.word.split("-").peekable();
while let Some(s) = segs.next() {
segments.push(Segment::Word(Word { word: s.into() }));
if segs.peek().is_some() {
segments.push(Segment::Separator("-".into()));
}
}
}
};
});
let mut chunk = chunk.clone();
let mut words = chunk
.segments
Expand Down

0 comments on commit 1cf0159

Please sign in to comment.