comparison src/plugins/plugin_misc_text_syntaxes.py @ 852:4cc55e05266d

plugin text syntaxes: fixed cleaners encoding
author Goffi <goffi@goffi.org>
date Thu, 20 Feb 2014 13:28:10 +0100
parents 831f208b4ea3
children 75f3b3b430ff
comparison
equal deleted inserted replaced
851:a8260ee88708 852:4cc55e05266d
180 add_nofollow=False, 180 add_nofollow=False,
181 safe_attrs=SAFE_ATTRS) 181 safe_attrs=SAFE_ATTRS)
182 xhtml_elt = cleaner.clean_html(xhtml_elt) 182 xhtml_elt = cleaner.clean_html(xhtml_elt)
183 for elt in xhtml_elt.xpath("//*[@style]"): 183 for elt in xhtml_elt.xpath("//*[@style]"):
184 elt.set("style", clean_style(elt.get('style'))) 184 elt.set("style", clean_style(elt.get('style')))
185 return html.tostring(xhtml_elt, method='xml') 185 return html.tostring(xhtml_elt, encoding=unicode, method='xml')
186 186
187 return deferToThread(blocking_cleaning, xhtml) 187 return deferToThread(blocking_cleaning, xhtml)
188 188
189 def convert(self, text, syntax_from, syntax_to=_SYNTAX_XHTML, safe=True, profile=None): 189 def convert(self, text, syntax_from, syntax_to=_SYNTAX_XHTML, safe=True, profile=None):
190 """ Convert a text between two syntaxes 190 """ Convert a text between two syntaxes
254 @param xhtml: the XHTML string to be cleaned 254 @param xhtml: the XHTML string to be cleaned
255 @return: the cleaned string 255 @return: the cleaned string
256 """ 256 """
257 cleaner = clean.Cleaner(kill_tags=['style']) 257 cleaner = clean.Cleaner(kill_tags=['style'])
258 cleaned = cleaner.clean_html(html.fromstring(xhtml)) 258 cleaned = cleaner.clean_html(html.fromstring(xhtml))
259 return html.tostring(cleaned, method="text") 259 return html.tostring(cleaned, encoding=unicode, method="text")