def test_ruby(self):
     self.assertEqual(colorize(['你[nǐ]']),
                      '你[<span class="tone3">nǐ</span>]')
     self.assertEqual(
         colorize(['你[nǐ]'], ruby_whole=True),
         '<span class="tone3">你[nǐ]</span>',
     )
Beispiel #2
0
 def test_bopomofo(self):
     self.assertEqual(
         colorize(['ㄊㄨˊ', 'ㄕㄨ', 'ㄍㄨㄢˇ']),
         ('<span class="tone2">ㄊㄨˊ</span> '
          '<span class="tone1">ㄕㄨ</span> '
          '<span class="tone3">ㄍㄨㄢˇ</span>'),
     )
 def test_cantonese(self):
     self.assertEqual(
         colorize(['soeng6 hoi2 jan4'], 'jyutping'),
         '<span class="tone6">soeng6</span>'
         '<span class="tone2">hoi2</span>'
         '<span class="tone4">jan4</span>',
     )
Beispiel #4
0
 def test_joined_syllables(self):
     self.assertEqual(
         colorize(['xiàn zài']),
         '<span class="tone4">xiàn</span><span class="tone4">zài</span>',
     )
Beispiel #5
0
 def test_separate_syllables(self):
     self.assertEqual(
         colorize(['xiàn', 'zài']),
         '<span class="tone4">xiàn</span> <span class="tone4">zài</span>',
     )
 def test_mixed_english_chinese(self):
     self.assertEqual(
         colorize(['Brian de']),
         '<span class="tone5">Brian</span><span class="tone5">de</span>',
     )
 def test_remove_whitespace(self):
     self.assertEqual(
         colorize(['xiàn zài']),
         '<span class="tone4">xiàn</span><span class="tone4">zài</span>')