Exemplo n.º 1
0
 def test_zhuyin_both_pinyin_both(self):
     self.assertEqual(
         html.to_html(self.s,
                      bottom=self.pi,
                      top=self.pi,
                      left=self.zh,
                      right=self.zh), self.zhuyin_both_pinyin_both)
Exemplo n.º 2
0
def generate_new_html_for_words(words):
    """
    Go through list of words, and generates the HTML + Ruby characters.

    *words* a list of chinese words
    """
    words_with_pinyin_html = ""

    for word in words:
        debug("{0} : {1}".format(word, "".join(words)))
        debug('CHARACTER: {0}'.format(word))
        if not is_entirely_chinese(word):
            pi = (' ' * len(word)).split(' ')
        else:
            zh = hanzi.to_zhuyin(word)
            debug('ZHUYIN: {0}'.format(zh))
            pi = trans.zhuyin_to_pinyin(
                zh, accented=not numbered_pinyin).split(' ')
            debug('PINYIN: {0}'.format(pi))
        debug("{0}={1}".format(word, "".join(pi)))
        words_with_pinyin_html += html.to_html(word, top=pi, minified=True)

    return words_with_pinyin_html
Exemplo n.º 3
0
def generate_new_html_for_words(words):
    """
    Go through list of words, and generates the HTML + Ruby characters.

    *words* a list of chinese words
    """
    words_with_pinyin_html = ""

    for word in words:
        debug("{0} : {1}".format(word, "".join(words)))
        debug('CHARACTER: {0}'.format(word))
        if not is_entirely_chinese(word):
            pi = (' '*len(word)).split(' ')
        else:
            zh = hanzi.to_zhuyin(word)
            debug('ZHUYIN: {0}'.format(zh))
            pi = trans.zhuyin_to_pinyin(
                zh,
                accented=not numbered_pinyin).split(' ')
            debug('PINYIN: {0}'.format(pi))
        debug("{0}={1}".format(word, "".join(pi)))
        words_with_pinyin_html += html.to_html(word, top=pi, minified=True)

    return words_with_pinyin_html
Exemplo n.º 4
0
 def test_pinyin_bottom(self):
     self.assertEqual(html.to_html(self.s, bottom=self.pi),
                      self.pinyin_bottom)
Exemplo n.º 5
0
 def test_zhuyin_top(self):
     self.assertEqual(html.to_html(self.s, top=self.zh), self.zhuyin_top)
Exemplo n.º 6
0
 def test_pinyin_top(self):
     self.assertEqual(html.to_html(self.s, top=self.pi), self.pinyin_top)
Exemplo n.º 7
0
 def test_indented_3(self):
     self.assertEqual(
         html.to_html(self.s, bottom=self.pi, top=self.zh, indentation=3),
         self.indented_3)
Exemplo n.º 8
0
 def test_indented_0(self):
     self.assertEqual(
         html.to_html(self.s, bottom=self.pi, right=self.zh, indentation=0),
         self.indented_0)
Exemplo n.º 9
0
 def test_indented_5(self):
     self.assertEqual(
         html.to_html(self.s, bottom=self.pi, left=self.zh, indentation=5),
         self.indented_5)
Exemplo n.º 10
0
 def test_jyutping_in_html(self):
     self.assertEqual(html.to_html(self.s2, top=self.jp2),
                      self.jyutping_html)
Exemplo n.º 11
0
 def test_manual_phonetics_input(self):
     self.assertEqual(html.to_html(self.s2, bottom=self.zh2_man),
                      self.manual_pinyin)