fn generate_header_text(
    use_katakana: bool,
    use_move_terms: bool,
    kana: &str,
    pitch_accent: Option<&Vec<u32>>,
    jm_entry: &WordEntry,
) -> String {
    let mut text = format!(
        "{}",
        if use_katakana {
            hiragana_to_katakana(&kana)
        } else {
            katakana_to_hiragana(&kana)
        }
    );

    if let Some(accent_list) = pitch_accent {
        if !accent_list.is_empty() {
            text.push_str(" ");
            for a in accent_list.iter() {
                text.push_str(&format!("[{}]", a));
            }
        }
    }

    text.push_str(" &nbsp;&nbsp;&mdash; 【");
    let mut first = true;
    if jm_entry.usually_kana || jm_entry.writings.is_empty() {
        text.push_str(&jm_entry.readings[0]);
        first = false;
    }
    for w in jm_entry.writings.iter() {
        if !first {
            text.push_str("／");
        }
        text.push_str(&w);
        first = false;
    }
    text.push_str("】");

    const WORD_TYPE_START: &'static str =
        " <span style=\"font-size: 0.8em; font-style: italic; margin-left: 0; white-space: nowrap;\">";
    const WORD_TYPE_END: &'static str = "</span>";
    match jm_entry.pos {
        PartOfSpeech::Verb => {
            use ConjugationClass::*;
            let conj_type_text = match jm_entry.conj {
                IchidanVerb => ", ichidan",

                GodanVerbU
                | GodanVerbTsu
                | GodanVerbRu
                | GodanVerbKu
                | GodanVerbGu
                | GodanVerbNu
                | GodanVerbBu
                | GodanVerbMu
                | GodanVerbSu => ", godan",

                SuruVerb
                | SuruVerbSC
                | KuruVerb
                | IkuVerb
                | KureruVerb
                | AruVerb
                | SharuVerb
                | GodanVerbHu // Doesn't exist in modern Japanese, so we're calling it irregular.
                | IrregularVerb => ", irregular",

                _ => "",
            };

            let transitive = jm_entry.tags.contains("pos:vt");
            let intransitive = jm_entry.tags.contains("pos:vi");
            let transitive_text = match (transitive, intransitive) {
                (true, false) => {
                    if use_move_terms {
                        ", other-move"
                    } else {
                        ", transitive"
                    }
                }
                (false, true) => {
                    if use_move_terms {
                        ", self-move"
                    } else {
                        ", intransitive"
                    }
                }
                _ => "",
            };

            text.push_str(&format!(
                "{}verb{}{}{}",
                WORD_TYPE_START, conj_type_text, transitive_text, WORD_TYPE_END
            ));
        }

        PartOfSpeech::Adjective => {
            use ConjugationClass::*;
            let adjective_type_text = match jm_entry.conj {
                IAdjective => "i-adjective",

                IrregularIAdjective => "i-adjective, irregular",

                _ => "adjective",
            };

            text.push_str(&format!(
                "{}{}{}",
                WORD_TYPE_START, adjective_type_text, WORD_TYPE_END
            ));
        }

        _ => {}
    }

    text
}
/// Generate header text from the given entry information.
Generate header text from the given entry information.
Generate header text from the given entry information .
fn generate_header_text(
    use_katakana: bool,
    use_move_terms: bool,
    kana: &str,
    pitch_accent: Option<&Vec<u32>>,
    jm_entry: &WordEntry,
) -> String {
    let mut text = format!(
        "{}",
        if use_katakana {
            hiragana_to_katakana(&kana)
        } else {
            katakana_to_hiragana(&kana)
        }
    );
    if let Some(accent_list) = pitch_accent {
        if !accent_list.is_empty() {
            text.push_str(" ");
            for a in accent_list.iter() {
                text.push_str(&format!("[{}]", a));
            }
        }
    }
    text.push_str(" &nbsp;&nbsp;&mdash; 【");
    let mut first = true;
    if jm_entry.usually_kana || jm_entry.writings.is_empty() {
        text.push_str(&jm_entry.readings[0]);
        first = false;
    }
    for w in jm_entry.writings.iter() {
        if !first {
            text.push_str("／");
        }
        text.push_str(&w);
        first = false;
    }
    text.push_str("】");
    const WORD_TYPE_START: &'static str =
        " <span style=\"font-size: 0.8em; font-style: italic; margin-left: 0; white-space: nowrap;\">";
    const WORD_TYPE_END: &'static str = "</span>";
    match jm_entry.pos {
        PartOfSpeech::Verb => {
            use ConjugationClass::*;
            let conj_type_text = match jm_entry.conj {
                IchidanVerb => ", ichidan",
                GodanVerbU
                | GodanVerbTsu
                | GodanVerbRu
                | GodanVerbKu
                | GodanVerbGu
                | GodanVerbNu
                | GodanVerbBu
                | GodanVerbMu
                | GodanVerbSu => ", godan",
                SuruVerb
                | SuruVerbSC
                | KuruVerb
                | IkuVerb
                | KureruVerb
                | AruVerb
                | SharuVerb
                | GodanVerbHu // Doesn't exist in modern Japanese, so we're calling it irregular.
                | IrregularVerb => ", irregular",
                _ => "",
            };
            let transitive = jm_entry.tags.contains("pos:vt");
            let intransitive = jm_entry.tags.contains("pos:vi");
            let transitive_text = match (transitive, intransitive) {
                (true, false) => {
                    if use_move_terms {
                        ", other-move"
                    } else {
                        ", transitive"
                    }
                }
                (false, true) => {
                    if use_move_terms {
                        ", self-move"
                    } else {
                        ", intransitive"
                    }
                }
                _ => "",
            };
            text.push_str(&format!(
                "{}verb{}{}{}",
                WORD_TYPE_START, conj_type_text, transitive_text, WORD_TYPE_END
            ));
        }
        PartOfSpeech::Adjective => {
            use ConjugationClass::*;
            let adjective_type_text = match jm_entry.conj {
                IAdjective => "i-adjective",
                IrregularIAdjective => "i-adjective, irregular",
                _ => "adjective",
            };
            text.push_str(&format!(
                "{}{}{}",
                WORD_TYPE_START, adjective_type_text, WORD_TYPE_END
            ));
        }
        _ => {}
    }
    text
}
fn generate_header_text ( use_katakana : bool , use_move_terms : bool , kana : & str , pitch_accent : Option < & Vec < u32 > > , jm_entry : & WordEntry , ) -> String { let mut text = format ! ( " " if use_katakana { hiragana_to_katakana ( kana ) } else { katakana_to_hiragana ( kana ) } ) ; if let Some ( accent_list ) = pitch_accent { if ! accent_list . is_empty ( ) { text . push_str ( " " ) ; for a in accent_list . iter ( ) { text . push_str ( & format ! ( " " a ) ) ; } } } text . push_str ( " ; let mut first = true ; if jm_entry . usually_kana || jm_entry . writings . is_empty ( ) { text . push_str ( & jm_entry . readings [ 0 ] ) ; first = false ; } for w in jm_entry . writings . iter ( ) { if ! first { text . push_str ( " ; } text . push_str ( & w ) ; first = false ; } text . push_str ( " ; const WORD_TYPE_START : & ' static str = " \" \" " ; const WORD_TYPE_END : & ' static str = " " ; match jm_entry . pos { PartOfSpeech :: Verb => { use ConjugationClass :: * ; let conj_type_text = match jm_entry . conj { IchidanVerb => " " , GodanVerbU | GodanVerbTsu | GodanVerbRu | GodanVerbKu | GodanVerbGu | GodanVerbNu | GodanVerbBu | GodanVerbMu | GodanVerbSu => " " , SuruVerb | SuruVerbSC | KuruVerb | IkuVerb | KureruVerb | AruVerb | SharuVerb | GodanVerbHu // Doesn't exist in modern Japanese, so we're calling it irregular. | IrregularVerb => " " , _ => " " , } ; let transitive = jm_entry . tags . contains ( " " ) ; let intransitive = jm_entry . tags . contains ( " " ) ; let transitive_text = match ( transitive , intransitive ) { ( true , false ) => { if use_move_terms { " " } else { " " } } ( false , true ) => { if use_move_terms { " " } else { " " } } _ => " " , } ; text . push_str ( & format ! ( " " WORD_TYPE_START conj_type_text transitive_text WORD_TYPE_END ) ) ; } PartOfSpeech :: Adjective => { use ConjugationClass :: * ; let adjective_type_text = match jm_entry . conj { IAdjective => " " , IrregularIAdjective => " " , _ => " " , } ; text . push_str ( & format ! ( " " WORD_TYPE_START adjective_type_text WORD_TYPE_END ) ) ; } _ => { } } text }
Generate header text from the given entry information.
Generate header text from the given entry information .
use_katakana
bool
use_move_terms
bool
kana
&str
pitch_accent
Option<&Vec<u32>>
jm_entry
&WordEntry
use_katakana
bool
use_move_terms
bool
kana
&str
pitch_accent
Option<&Vec<u32>>
jm_entry
&WordEntry