mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Better error message when ToC editor is opened to an non-HTML file
This commit is contained in:
parent
392b5f5771
commit
b388a91180
@ -397,6 +397,8 @@ class ItemEdit(QWidget):
|
|||||||
name = self.current_name = str(item.data(Qt.ItemDataRole.DisplayRole) or '')
|
name = self.current_name = str(item.data(Qt.ItemDataRole.DisplayRole) or '')
|
||||||
# Ensure encoding map is populated
|
# Ensure encoding map is populated
|
||||||
root = self.container.parsed(name)
|
root = self.container.parsed(name)
|
||||||
|
if not hasattr(root, 'xpath'):
|
||||||
|
return error_dialog(self, _('Not an HTML file'), _('The file {} is not marked as an HTML file in the OPF and cannot be displayed').format(name))
|
||||||
nasty = root.xpath('//*[local-name()="head"]/*[local-name()="p"]')
|
nasty = root.xpath('//*[local-name()="head"]/*[local-name()="p"]')
|
||||||
if nasty:
|
if nasty:
|
||||||
body = root.xpath('//*[local-name()="body"]')
|
body = root.xpath('//*[local-name()="body"]')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user