diff options
Diffstat (limited to 'src/format.rs')
-rw-r--r-- | src/format.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/format.rs b/src/format.rs index 88c81c3..83c63a1 100644 --- a/src/format.rs +++ b/src/format.rs @@ -257,8 +257,12 @@ fn format_ex_furigana<'a>(dict_idx: &DictIndex<'a>, ex: &Example) -> String { } let keb_suffix = keb.chars().skip(common_cnt).collect::<String>(); - let reb = reb.strip_suffix(&keb_suffix).unwrap_or(reb); - //println!(" >> common reb: {}, common_word: {}", reb, word.chars().take(common_cnt).collect::<String>()); + let word_suffix = word.chars().skip(common_cnt).collect::<String>(); + let reb = reb + .strip_suffix(&keb_suffix) + .or(reb.strip_suffix(&word_suffix)) + .unwrap_or(reb); + //println!(" common reb: {}, common word: {}", reb, word.chars().take(common_cnt).collect::<String>()); let wchars = Vec::from_iter(word.chars().take(common_cnt)); let rchars = Vec::from_iter(reb.chars()); @@ -327,7 +331,7 @@ fn format_ex_furigana<'a>(dict_idx: &DictIndex<'a>, ex: &Example) -> String { write!(&mut ret, "[[{}||{}]]", wbuf, rbuf).unwrap(); } - ret.extend(word.chars().skip(common_cnt)); + ret += &word_suffix; } ret } |