Python-Markdown 1.7 and Unicode Support
|Reported by:||Waylan Limberg||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
With the release of Python-Markdown 1.7, Unicode support for markdown is much stricter. Specifically the docs say:
Note that markdown() expects either a simple ascii string or unicode as input and returns output as unicode. Do not pass
encoded strings to it. If your input is encoded, e.g. as UTF8, it is your responsibility to decode it.
Here's an example using Django's Unicode methods:
s = "öäüß" print force_unicode(markdown.markdown(smart_str(s))) MARKDOWN-CRITICAL: "UnicodeDecodeError: Markdown only accepts unicode or ascii input." print force_unicode(markdown.markdown(smart_unicode(s))) <p>öäüß</p>
The first try, which produces the error, is what Django currently does. The second is what it probably should do.
Note: This report has been moved from the unrelated ticket #2910 comment 17.