write2odt.py
def create_paragraph(string):
    """Create a paragraph element with rubi text."""
    paragraph_element = P()
    while 1:
        m = re.search(TOKENS_KANJI, string)  # detect kanji start position
        if m is not None:  # if first part of the string is non-kanji
            add_str(paragraph_element, string[:m.start()])
            string = string[m.start():]  # truncate non-kanji

        m = re.match(r'(.*?)\((.*?)\)(.*)', string)
        if m is None:
            add_str(paragraph_element, string)
            break
        else:
            add_rubi(paragraph_element, m.group(1), m.group(2))
            string = m.group(3)

    return paragraph_element
Create a paragraph element with rubi text.
Create a paragraph element with rubi text.
Create a paragraph element with rubi text .
def create_paragraph(string):
    paragraph_element = P()
    while 1:
        m = re.search(TOKENS_KANJI, string)  
        if m is not None:  
            add_str(paragraph_element, string[:m.start()])
            string = string[m.start():]  
        m = re.match(r'(.*?)\((.*?)\)(.*)', string)
        if m is None:
            add_str(paragraph_element, string)
            break
        else:
            add_rubi(paragraph_element, m.group(1), m.group(2))
            string = m.group(3)
    return paragraph_element
def create_paragraph ( string ) : paragraph_element = P ( ) while 1 : m = re . search ( TOKENS_KANJI , string ) if m is not None : add_str ( paragraph_element , string [ : m . start ( ) ] ) string = string [ m . start ( ) : ] m = re . match ( r'(.*?)\((.*?)\)(.*)' , string ) if m is None : add_str ( paragraph_element , string ) break else : add_rubi ( paragraph_element , m . group ( 1 ) , m . group ( 2 ) ) string = m . group ( 3 ) return paragraph_element
Create a paragraph element with rubi text.
Create a paragraph element with rubi text .
"""Create a paragraph element with rubi text.""" # detect kanji start position # if first part of the string is non-kanji # truncate non-kanji
string