comments editor: Do not insert unnecessary <p> tags

This commit is contained in:
Kovid Goyal 2010-12-23 13:13:45 -07:00
parent 853f63934f
commit ab2767ccde

View File

@ -225,7 +225,7 @@ class EditorWidget(QWebView): # {{{
elems = [] elems = []
for body in root.xpath('//body'): for body in root.xpath('//body'):
if body.text: if body.text:
elems.append('<p>%s</p>'%body.text) elems.append(body.text)
elems += [html.tostring(x, encoding=unicode) for x in body if elems += [html.tostring(x, encoding=unicode) for x in body if
x.tag not in ('script', 'style')] x.tag not in ('script', 'style')]
@ -233,6 +233,8 @@ class EditorWidget(QWebView): # {{{
ans = u'<div>%s</div>'%(u''.join(elems)) ans = u'<div>%s</div>'%(u''.join(elems))
else: else:
ans = u''.join(elems) ans = u''.join(elems)
if not ans.startswith('<'):
ans = '<p>%s</p>'%ans
ans = xml_replace_entities(ans) ans = xml_replace_entities(ans)
except: except:
import traceback import traceback