Changeset 15 for formatflowed

Show
Ignore:
Timestamp:
09/07/05 08:23:50 (7 years ago)
Author:
mj
Message:

convertToWrapped is trying to do too much; just return \n-delimited unicode.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • formatflowed/trunk/formatflowed.py

    r14 r15  
    672672    return encoder.encode(chunks) 
    673673 
    674 def convertToWrapped(flowed, width=78, quote='>', newline='\n', 
    675                      encoding='ascii', wrap_fixed=True, **kwargs): 
     674def convertToWrapped(flowed, width=78, quote=u'>', wrap_fixed=True, **kwargs): 
    676675    """Covert flowed text to encoded and wrapped text 
    677676     
     
    682681      width (default: 78) 
    683682        The maximum line length at which to wrap paragraphs.  
    684       quote (default: '>') 
     683      quote (default: u'>') 
    685684        Character sequence to use to mark quote depths; it is multiplied with 
    686685        the quotedepth to quote a line. If this sequence does not end in a 
    687686        space a space is added between the quotemars and the line. 
    688       newline (default: '\n') 
    689         Lines are joined with the newline character sequence. 
    690       encoding (default: ascii) 
    691         Text chunks from the decoded flowed text are encoded to this encoding 
    692687      wrap_fixed (default: True) 
    693688        If true, fixed text chunks are wrapped to the given  width as well, 
     
    730725        type = info['type'] 
    731726        quotedepth = info['quotedepth'] 
    732         chunk = chunk.encode(encoding) 
    733         quotemarker = quotedepth and quote * quotedepth or '' 
    734         if quotemarker and quote[-1] != ' ': 
    735             quotemarker += ' ' 
     727        quotemarker = quotedepth and quote * quotedepth or u'' 
     728        if quotemarker and quote[-1] != u' ': 
     729            quotemarker += u' ' 
    736730        if type == FIXED and not wrap_fixed: 
    737731            result.append(quotemarker + chunk) 
     
    743737                                        initial_indent=quotemarker, 
    744738                                        subsequent_indent=quotemarker)) 
    745     return newline.join(result) 
     739    return u'\n'.join(result) 
    746740     
    747741