mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 05:12:35 +02:00
HTML To Zip: Ignore user specified encoding if it is invalid
This commit is contained in:
parent
b1c059a6e9
commit
a430138f93
1 changed files with 9 additions and 4 deletions
|
|
@ -26,6 +26,8 @@ class HTML2ZIP(FileTypePlugin):
|
|||
on_import = True
|
||||
|
||||
def run(self, htmlfile):
|
||||
import codecs
|
||||
from calibre import prints
|
||||
from calibre.ptempfile import TemporaryDirectory
|
||||
from calibre.gui2.convert.gui_conversion import gui_convert
|
||||
from calibre.customize.conversion import OptionRecommendation
|
||||
|
|
@ -38,8 +40,12 @@ def run(self, htmlfile):
|
|||
sc = self.site_customization.strip()
|
||||
enc, _, bf = sc.partition('|')
|
||||
if enc:
|
||||
recs.append(['input_encoding', enc,
|
||||
OptionRecommendation.HIGH])
|
||||
try:
|
||||
codecs.lookup(enc)
|
||||
except Exception:
|
||||
prints('Ignoring invalid input encoding for HTML:', enc)
|
||||
else:
|
||||
recs.append(['input_encoding', enc, OptionRecommendation.HIGH])
|
||||
if bf == 'bf':
|
||||
recs.append(['breadth_first', True,
|
||||
OptionRecommendation.HIGH])
|
||||
|
|
@ -84,8 +90,7 @@ def size_dialog():
|
|||
help_text = self.customization_help(gui=True)
|
||||
help_text = QLabel(help_text, config_dialog)
|
||||
help_text.setWordWrap(True)
|
||||
help_text.setTextInteractionFlags(Qt.LinksAccessibleByMouse
|
||||
| Qt.LinksAccessibleByKeyboard)
|
||||
help_text.setTextInteractionFlags(Qt.LinksAccessibleByMouse | Qt.LinksAccessibleByKeyboard)
|
||||
help_text.setOpenExternalLinks(True)
|
||||
v.addWidget(help_text)
|
||||
bf = QCheckBox(_('Add linked files in breadth first order'))
|
||||
|
|
|
|||
Loading…
Reference in a new issue