Metadata editor: Fix adding an image to an empty comments block not working

This commit is contained in:
Kovid Goyal 2013-09-02 09:26:10 +05:30
parent 8d693050a5
commit 9d848e14a7

View File

@ -308,14 +308,14 @@ class EditorWidget(QWebView): # {{{
def fget(self):
ans = u''
check = unicode(self.page().mainFrame().toPlainText()).strip()
if not check:
return ans
try:
check = unicode(self.page().mainFrame().toPlainText()).strip()
raw = unicode(self.page().mainFrame().toHtml())
raw = xml_to_unicode(raw, strip_encoding_pats=True,
resolve_entities=True)[0]
raw = self.comments_pat.sub('', raw)
if not check and '<img' not in raw.lower():
return ans
try:
root = html.fromstring(raw)