comparison src/plugins/plugin_xep_0277.py @ 1732:cf11cfc87ef9

xml_tools, plugin XEP-0071, XEP-0277: add method expandNewLinesToXHTML: - \n in XHTML content should not be converted to <br /> by the frontend - save it directly in the Atom payload for better compatibility with other clients
author souliane <souliane@mailoo.org>
date Thu, 10 Dec 2015 14:00:21 +0100
parents 0eaa1a409dfb
children 3770d13776e8
comparison
equal deleted inserted replaced
1731:58ecc0e2e6fc 1732:cf11cfc87ef9
178 if data_elt.uri != NS_XHTML: 178 if data_elt.uri != NS_XHTML:
179 raise failure.Failure(exceptions.DataError(_('Content of type XHTML must declare its namespace!'))) 179 raise failure.Failure(exceptions.DataError(_('Content of type XHTML must declare its namespace!')))
180 key = check_conflict(u'{}_xhtml'.format(elem.name)) 180 key = check_conflict(u'{}_xhtml'.format(elem.name))
181 data = data_elt.toXml() 181 data = data_elt.toXml()
182 microblog_data[key] = yield self.host.plugins["TEXT-SYNTAXES"].clean_xhtml(data) 182 microblog_data[key] = yield self.host.plugins["TEXT-SYNTAXES"].clean_xhtml(data)
183 microblog_data[key] = xml_tools.expandNewLinesToXHTML(microblog_data[key])
183 else: 184 else:
184 key = check_conflict(elem.name) 185 key = check_conflict(elem.name)
185 microblog_data[key] = unicode(elem) 186 microblog_data[key] = unicode(elem)
186 187
187 188
366 converted = yield synt.convert(data[attr], synt.getCurrentSyntax(profile), "XHTML") 367 converted = yield synt.convert(data[attr], synt.getCurrentSyntax(profile), "XHTML")
367 if '{}_xhtml'.format(elem_name) in data: 368 if '{}_xhtml'.format(elem_name) in data:
368 raise failure.Failure(exceptions.DataError(_("Can't have xhtml and rich content at the same time"))) 369 raise failure.Failure(exceptions.DataError(_("Can't have xhtml and rich content at the same time")))
369 else: # clean the XHTML input 370 else: # clean the XHTML input
370 converted = yield synt.clean_xhtml(data[attr]) 371 converted = yield synt.clean_xhtml(data[attr])
372 converted = xml_tools.expandNewLinesToXHTML(converted)
371 373
372 xml_content = u'<div xmlns="{ns}">{converted}</div>'.format( 374 xml_content = u'<div xmlns="{ns}">{converted}</div>'.format(
373 ns=NS_XHTML, 375 ns=NS_XHTML,
374 converted=converted) 376 converted=converted)
375 elem.addChild(xml_tools.ElementParser()(xml_content)) 377 elem.addChild(xml_tools.ElementParser()(xml_content))