コード例 #1
0
ファイル: xist.py プロジェクト: dvorberg/t4
    def words(text_elements):
        word = elements.word()
        for element in text_elements:
            if isinstance(element, xsc.Text):
                mystyle = None
                element = [ element, ]
            else:
                mystyle = style(element)

            for child in element:
                for (syllable, starts_word, ends_word,)  in syllables(
                        child, mystyle):
                    if starts_word and len(word) > 0:
                        word[-1]._whitespace_style = syllable._style
                        yield word
                        word = elements.word()
                        
                    word.append(syllable)
                    
                    if ends_word:
                        yield word
                        word = elements.word()
                        
        if len(word) > 0:
            yield word
コード例 #2
0
ファイル: old_style_markup.py プロジェクト: dvorberg/t4
        def words(bits):
            """
            Yields elements.word instances for each of the white-space
            separated words in bits.
            """
            word = elements.word()
            for letters, ends_in_whitespace, style, whitespace_style in bits:
                for part in syllable_parts(letters):
                    word.append(elements.syllable(part, style, whitespace_style))
                if ends_in_whitespace:
                    yield word
                    word = elements.word()

            if len(word) > 0:
                yield word