mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Make the HTML2ZIP file type plugin customizable. You can now tell calibre to assume the HTML files are in a particular encoding. Go to Preferences->Plugins->File type plugnis to customize the HTML2ZIP plugin
This commit is contained in:
parent
ba3157ce9f
commit
9163bb1eae
@ -27,8 +27,11 @@ every time you add an HTML file to the library.\
|
||||
from calibre.ebooks.epub import initialize_container
|
||||
|
||||
with TemporaryDirectory('_plugin_html2zip') as tdir:
|
||||
gui_convert(htmlfile, tdir, [('debug_input', tdir,
|
||||
OptionRecommendation.HIGH)])
|
||||
recs =[('debug_input', tdir, OptionRecommendation.HIGH)]
|
||||
if self.site_customization and self.site_customization.strip():
|
||||
recs.append(['input_encoding', self.site_customization.strip(),
|
||||
OptionRecommendation.HIGH])
|
||||
gui_convert(htmlfile, tdir, recs)
|
||||
of = self.temporary_file('_plugin_html2zip.zip')
|
||||
opf = glob.glob(os.path.join(tdir, '*.opf'))[0]
|
||||
ncx = glob.glob(os.path.join(tdir, '*.ncx'))
|
||||
@ -40,6 +43,10 @@ every time you add an HTML file to the library.\
|
||||
|
||||
return of.name
|
||||
|
||||
def customization_help(self, gui=False):
|
||||
return _('Character encoding for the input HTML files. Common choices '
|
||||
'include: cp1252, latin1, iso-8859-1 and utf-8.')
|
||||
|
||||
|
||||
class ComicMetadataReader(MetadataReaderPlugin):
|
||||
|
||||
|
@ -7,7 +7,7 @@ from PyQt4.Qt import QDialog, QMessageBox, QListWidgetItem, QIcon, \
|
||||
QStringListModel, QAbstractItemModel, QFont, \
|
||||
SIGNAL, QTimer, Qt, QSize, QVariant, QUrl, \
|
||||
QModelIndex, QInputDialog, QAbstractTableModel, \
|
||||
QDialogButtonBox, QTabWidget, QBrush
|
||||
QDialogButtonBox, QTabWidget, QBrush, QLineEdit
|
||||
|
||||
from calibre.constants import islinux, iswindows
|
||||
from calibre.gui2.dialogs.config_ui import Ui_Dialog
|
||||
@ -553,10 +553,14 @@ class ConfigDialog(QDialog, Ui_Dialog):
|
||||
self._plugin_model.refresh_plugin(plugin)
|
||||
else:
|
||||
help = plugin.customization_help()
|
||||
sc = plugin_customization(plugin)
|
||||
if not sc:
|
||||
sc = ''
|
||||
sc = sc.strip()
|
||||
text, ok = QInputDialog.getText(self, _('Customize %s')%plugin.name,
|
||||
help)
|
||||
help, QLineEdit.Normal, sc)
|
||||
if ok:
|
||||
customize_plugin(plugin, unicode(text))
|
||||
customize_plugin(plugin, unicode(text).strip())
|
||||
self._plugin_model.refresh_plugin(plugin)
|
||||
if op == 'remove':
|
||||
if remove_plugin(plugin):
|
||||
|
@ -57,8 +57,9 @@ Then just add this HTML file to the GUI and use the convert button to create you
|
||||
How do I convert my file containing non-English characters?
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
There are two aspects to this problem:
|
||||
1. Knowing the encoding of the source file: |app| tries to guess what character encoding your source files use, but often, this is impossible, so you need to tell it what encoding to use. This can be done in the GUI via the :guilabel:`Source encoding` field in the :guilabel:`Look & Feel` section. The command-line tools all have an :option:`--encoding` option.
|
||||
2. Embedding fonts: If you are generating an LRF file to read on your SONY Reader, you are limited by the fact that the Reader only supports a few non-English characters in the fonts it comes pre-loaded with. You can work around this problem by embedding a unicode-aware font that supports the character set your file uses into the LRF file. You should embed atleast a serif and a sans-serif font. Be aware that embedding fonts significantly slows down page-turn speed on the reader.
|
||||
1. Knowing the encoding of the source file: |app| tries to guess what character encoding your source files use, but often, this is impossible, so you need to tell it what encoding to use. This can be done in the GUI via the :guilabel:`Input character encoding` field in the :guilabel:`Look & Feel` section. The command-line tools all have an :option:`--input-encoding` option.
|
||||
2. When adding HTML files to |app|, you may need to tell |app| what encoding the files are in. To do this go to Preferences->Plugins->File Type plugins and customize the HTML2Zip plugin, telling it what encoding your HTML files are in. |app| will then automatically convert the HTML files into the UTF-8 encoding when adding them.
|
||||
3. Embedding fonts: If you are generating an LRF file to read on your SONY Reader, you are limited by the fact that the Reader only supports a few non-English characters in the fonts it comes pre-loaded with. You can work around this problem by embedding a unicode-aware font that supports the character set your file uses into the LRF file. You should embed atleast a serif and a sans-serif font. Be aware that embedding fonts significantly slows down page-turn speed on the reader.
|
||||
|
||||
|
||||
How do I use some of the advanced features of the conversion tools?
|
||||
|
Loading…
x
Reference in New Issue
Block a user