mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
comments editor: Do not insert unnecessary <p> tags
This commit is contained in:
parent
853f63934f
commit
ab2767ccde
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user