aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--markdown/extensions/html_tidy.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/markdown/extensions/html_tidy.py b/markdown/extensions/html_tidy.py
index e1736eb..6aee083 100644
--- a/markdown/extensions/html_tidy.py
+++ b/markdown/extensions/html_tidy.py
@@ -40,6 +40,7 @@ class TidyExtension(markdown.Extension):
# Set defaults to match typical markdown behavior.
self.config = dict(output_xhtml=1,
show_body_only=1,
+ char_encoding='utf8'
)
# Merge in user defined configs overriding any present if nessecary.
for c in configs:
@@ -58,8 +59,10 @@ class TidyProcessor(markdown.postprocessors.Postprocessor):
def run(self, text):
# Pass text to Tidy. As Tidy does not accept unicode we need to encode
# it and decode its return value.
- return unicode(tidy.parseString(text.encode('utf-8'),
- **self.markdown.tidy_options))
+ enc = self.markdown.tidy_options.get('char_encoding', 'utf8')
+ return unicode(tidy.parseString(text.encode(enc),
+ **self.markdown.tidy_options),
+ encoding=enc)
def makeExtension(configs=None):