From: Kent J. <ke...@td...> - 2007-10-30 20:11:43
|
Waylan Limberg wrote: > However, I see markdown.markdown() as a shortcut for the common case. > So maybe we could add some basic encoding/decoding for common cases. Seems reasonable. > The user must pass in the encoding (and perhaps an optional output > encoding) I think *two* encodings is overkill for both markdown() and markdownFromFile(). In the common case they will likely be the same and it is so easy to do the conversion yourself if you want them to be different. > and, assuming the encoding actually matches (the users > responsability - otherwise it fails gracefully) I hope by 'fails gracefully' you mean 'raises UnicodeDecodeError'. What else could you do? Start guessing encodings? > things work fine. If > the user has a situation that doesn't fit the common case, then we > would expect that the encoding/decoding will be done manually with > md.convert. As long as the differances are clearly documented, that > should work fine. Of course, the more I think about this, the more is > feels like extra work I don't want to do. Any input? It's easy. In markdown() change return md.convert(text) to if encoding is not None: text = text.decode(encoding) converted = md.convert(text) if encoding is not None: converted = converted.encode(encoding) return converted Kent |