![]() |
#1381 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 6,251
Karma: 16539642
Join Date: Sep 2009
Location: UK
Device: ClaraHD, Forma, Libra2, Clara2E, LibraCol, PBTouchHD3
|
Quote:
|
|
![]() |
![]() |
![]() |
#1382 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,210
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
A minor nit but if it can be fixed, would be much appreciated. Basically, I need a line which reads: Code:
<item id="titlepage" href="xhtml/titlepage.xhtml" media-type="application/xhtml+xml"/> Code:
<item id="titlepage" href="xhtml/titlepage.xhtml" media-type="application/xhtml+xml" properties="svg"/> |
|
![]() |
![]() |
Advert | |
|
![]() |
#1383 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,210
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
I prefer Modify Epub as it does more for me than Polish does--I often remove unwanted spans by simply editing the <span class="blahblah"> to <span>, etc. and then let Modify Epub clean up the remnants. One common reason for this is the body sets a default font size of 1.0em, the paragraph sets a default size of 1.0em and then each covered in red body fluid paragraph has a span with a class that sets font size to 1.0em. |
|
![]() |
![]() |
![]() |
#1384 | ||
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
|
Quote:
Quote:
I mean, there’s nothing conceptually wrong with saying, in effect, “I’m changing the cover and specifying SVG markup, therefore I should check the EPUB version and see if I need to slap the properties attribute on it in the OPF” – but that still leaves the rest of the ebook unchecked, just waiting to generate those validation errors you want to avoid. And then, on top of all that, the code has to deal with the possibility that a properties attribute already exists, meaning it has to be checked and correctly modified… |
||
![]() |
![]() |
![]() |
#1385 | ||
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,210
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
Quote:
|
||
![]() |
![]() |
Advert | |
|
![]() |
#1386 |
null operator (he/him)
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 21,725
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
|
Just a reminder that the people maintaining kiwidude's plugins, are doing us a significant favour - voluntarily. Life support maintenance, i.e. ensuring a plugin continues to work on calibre's baseline must be the first priority.
If the original developer of a plugin declines to implement a functional change then so be it, same applies to maintainers of 'abandoned' plugins only more especially so. The plugin source is in the zip, you know the rest… BR |
![]() |
![]() |
![]() |
#1387 | |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
|
Quote:
But I also know that other users will see that the plugin addresses Case X and wonder why it doesn’t also handle the very similar Cases Y and Z, and I have to consider that. I’m not saying no. I just haven’t decided to say yes. |
|
![]() |
![]() |
![]() |
#1388 | |
Bibliophagist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 46,210
Karma: 168983734
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#1389 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 817
Karma: 6528026
Join Date: Sep 2012
Device: Kobo Elipsa
|
+1. If it's worth anything, I would also like properties="svg" inserted into the opf when a cover is added to an epub3. Right now I do it manually, but it would be really nice if the plugin took care of this and saved me an extra step. However, I also understand the concept of slippery slopes, so I understand if the answer is no.
|
![]() |
![]() |
![]() |
#1390 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,756
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
As long as were asking for fixes...
There is a bug where graphics get deleted if they are used in the CSS since Modify ePub is not checking the CSS. Can this please be fixed? Some eBooks specify graphics in the CSS for use as a section break marker. But Modify ePub deletes this since it thinks the graphic is unused. If Modify ePub checked the CSS for graphics, then this bug can be put to rest. |
![]() |
![]() |
![]() |
#1391 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
|
Feel free to write the code for it. I’ll be glad to take a look and consider the patch once you have a stable implementation.
|
![]() |
![]() |
![]() |
#1392 |
Resident Curmudgeon
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 79,756
Karma: 145864619
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
|
![]() |
![]() |
![]() |
#1393 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Oct 2016
Device: Kobo Glo HD
|
The plugin linked in the OP appears to not be compatible with Python 3. With Python 2 having effectively been EOL'd this year, a version that is compatible with Python 3 would be useful.
Here's my attempt at such a conversion: https://home.alfter.us/s/aQcprygAZLSpd2B I've bumped the version number to 1.4.2, set the minimum Calibre version to 4.0, and kept running the converter against an ePub until it ran without errors. These are my changes: Code:
diff -ur "Modify ePub.py2/common_utils.py" "Modify ePub.py3/common_utils.py" --- "Modify ePub.py2/common_utils.py" 2015-01-11 10:33:06.000000000 -0800 +++ "Modify ePub.py3/common_utils.py" 2020-08-15 12:49:43.422848052 -0700 @@ -438,7 +438,7 @@ def populate_combo(self, selected_key): self.clear() selected_idx = idx = -1 - for key, value in self.values.iteritems(): + for key, value in self.values.items(): idx = idx + 1 self.addItem(value) if key == selected_key: @@ -446,7 +446,7 @@ self.setCurrentIndex(selected_idx) def selected_key(self): - for key, value in self.values.iteritems(): + for key, value in self.values.items(): if value == unicode(self.currentText()).strip(): return key diff -ur "Modify ePub.py2/container.py" "Modify ePub.py3/container.py" --- "Modify ePub.py2/container.py" 2020-03-03 18:40:15.000000000 -0800 +++ "Modify ePub.py3/container.py" 2020-08-15 13:31:05.561700105 -0700 @@ -11,8 +11,8 @@ from lxml import etree from lxml.etree import XMLSyntaxError -from urlparse import urldefrag, urlparse, urlunparse -from urllib import unquote as urlunquote +from urllib.parse import urldefrag, urlparse, urlunparse +from urllib.parse import unquote as urlunquote from calibre import guess_type, prepare_string_for_xml from calibre.ebooks.chardet import xml_to_unicode @@ -170,11 +170,11 @@ if not base and rel_to_opf: base = self.opf_dir if not base: - return urllib.quote(name) + return urllib.parse.quote(name) href = posixpath.relpath(name, base) if href == '.': href = '' - return urllib.quote(href) + return urllib.parse.quote(href) def abshref(self, href, base_name): """Convert the URL provided in :param:`href` from a reference @@ -303,7 +303,7 @@ """Automatically decode :param:`data` into a `unicode` object.""" def fix_data(d): return d.replace('\r\n', '\n').replace('\r', '\n') - if isinstance(data, unicode): + if isinstance(data, str): return fix_data(data) bom_enc = None if data[:4] in ('\0\0\xfe\xff', '\xff\xfe\0\0'): @@ -682,7 +682,7 @@ self.dirtied.clear() with ZipFile(path, 'w', compression=ZIP_DEFLATED) as zf: # Write mimetype - zf.writestr('mimetype', bytes(guess_type('a.epub')[0]), + zf.writestr('mimetype', bytes(guess_type('a.epub')[0], "utf-8"), compression=ZIP_STORED) # Write everything else exclude_files = ['.DS_Store','mimetype'] @@ -863,7 +863,7 @@ data = self.get_parsed_etree(html_name) body = XPath('//h:body')(data) if body: - text = etree.tostring(body[0], method='text', encoding=unicode) + text = etree.tostring(body[0]).decode() else: text = '' text = re.sub(r'\s+', '', text) diff -ur "Modify ePub.py2/covers.py" "Modify ePub.py3/covers.py" --- "Modify ePub.py2/covers.py" 2012-07-03 09:11:08.000000000 -0700 +++ "Modify ePub.py3/covers.py" 2020-08-15 13:28:40.400708757 -0700 @@ -8,7 +8,8 @@ __docformat__ = 'restructuredtext en' import posixpath, os -from urllib import unquote +from urllib.parse import unquote +from functools import cmp_to_key from calibre import fit_image from calibre.utils.magick.draw import Image @@ -229,7 +230,7 @@ self.container.delete_from_guide(reference) # Sort by the largest size - covers.sort(cmp=lambda x,y:cmp(x[1], y[1]), reverse=True) + covers.sort(key=cmp_to_key(lambda x,y:cmp(x[1], y[1])), reverse=True) if covers: reference = covers[0][0] href = reference.get('href') @@ -367,7 +368,7 @@ tp = templ%unquote(rel_cover_href) with open(titlepage_path, 'wb') as f: - f.write(tp) + f.write(bytes(tp, "utf-8")) titlepage_name = os.path.relpath(titlepage_path, self.container.root).replace(os.sep, '/') return titlepage_name diff -ur "Modify ePub.py2/css.py" "Modify ePub.py3/css.py" --- "Modify ePub.py2/css.py" 2013-09-01 00:59:38.000000000 -0700 +++ "Modify ePub.py3/css.py" 2020-08-15 12:49:43.423848052 -0700 @@ -27,7 +27,7 @@ from calibre.ebooks.conversion.config import load_defaults ps = load_defaults('look_and_feel') # Only interested in the extra_css out of settings - prefs_css = dict((k,v) for k,v in ps.iteritems() if k == 'extra_css') + prefs_css = dict((k,v) for k,v in ps.items() if k == 'extra_css') return prefs_css.get('extra_css', '') def rewrite_css(self): diff -ur "Modify ePub.py2/dialogs.py" "Modify ePub.py3/dialogs.py" --- "Modify ePub.py2/dialogs.py" 2019-10-17 03:14:00.000000000 -0700 +++ "Modify ePub.py3/dialogs.py" 2020-08-15 12:49:43.424848051 -0700 @@ -195,7 +195,7 @@ def _save_clicked(self): self._set_options() - cfg.plugin_prefs[cfg.STORE_SAVED_SETTINGS] = [k for k,v in self.options.iteritems() if v] + cfg.plugin_prefs[cfg.STORE_SAVED_SETTINGS] = [k for k,v in self.options.items() if v] def _restore_clicked(self): self._select_none_clicked() diff -ur "Modify ePub.py2/__init__.py" "Modify ePub.py3/__init__.py" --- "Modify ePub.py2/__init__.py" 2020-03-12 16:08:36.000000000 -0700 +++ "Modify ePub.py3/__init__.py" 2020-08-15 12:45:15.147864042 -0700 @@ -24,8 +24,8 @@ description = 'Apply cleanup tasks and updates to an ePub without doing a conversion' supported_platforms = ['windows', 'osx', 'linux'] author = 'Grant Drake, with additions by Robert L. Hood and Leigh Parry' - version = (1, 4, 1) - minimum_calibre_version = (0, 8, 53) + version = (1, 4, 2) + minimum_calibre_version = (4, 0, 0) #: This field defines the GUI plugin class that contains all the code #: that actually does something. Its format is module_path:class_name diff -ur "Modify ePub.py2/margins.py" "Modify ePub.py3/margins.py" --- "Modify ePub.py2/margins.py" 2012-12-09 16:25:16.000000000 -0800 +++ "Modify ePub.py3/margins.py" 2020-08-15 12:49:43.424848051 -0700 @@ -33,7 +33,7 @@ from calibre.ebooks.conversion.config import load_defaults ps = load_defaults('page_setup') # Only interested in the margins out of page setup settings - prefs_margins = dict((k,v) for k,v in ps.iteritems() if k.startswith('margin_')) + prefs_margins = dict((k,v) for k,v in ps.items() if k.startswith('margin_')) if 'margin_top' not in prefs_margins: # The user has never changed their page setup defaults to save settings prefs_margins = calibre_default_margins @@ -41,7 +41,7 @@ def _prefs_to_css_properties(self, user_margins): css_margins = '' - for pref, value in user_margins.iteritems(): + for pref, value in user_margins.items(): # Negative margins mean we don't want the attribute written if value >= 0.0: property_name = re.sub('_', '-', pref) @@ -86,7 +86,7 @@ # If we got to here, then we found "some" margins in the style that are # either identical or a subset of our preferred margins - for pref, pref_value in self.user_margins.iteritems(): + for pref, pref_value in self.user_margins.items(): if pref_value < 0.0: # The user does not want this margin defined if pref in doc_defined_margins: # Currently is defined, so remove it return True diff -ur "Modify ePub.py2/modify.py" "Modify ePub.py3/modify.py" --- "Modify ePub.py2/modify.py" 2020-03-03 18:38:14.000000000 -0800 +++ "Modify ePub.py3/modify.py" 2020-08-15 12:49:43.425848051 -0700 @@ -918,7 +918,7 @@ else: prefs_margins = default_margins - for s, v in prefs_margins.iteritems(): + for s, v in prefs_margins.items(): setattr(self.opts, s, v) def get_epub_output_options(): @@ -935,7 +935,7 @@ else: prefs_options = default_values - for s, v in prefs_options.iteritems(): + for s, v in prefs_options.items(): setattr(self.opts, s, v) self.opts = OptionValues() |
![]() |
![]() |
![]() |
#1394 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,760
Karma: 9918418
Join Date: Feb 2013
Location: Here on the perimeter, there are no stars
Device: Kobo H2O, iPad mini 3, Kindle Touch
|
If I were conversant in Python 3, I’d be glad to evaluate this… but I’m not.
Any takers? |
![]() |
![]() |
![]() |
#1395 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1995558
Join Date: Aug 2015
Device: Kindle
|
I don't use this plugin myself, but here is a link for a version I sent to @salfter in a pm. It is partly based on his port, but modified to work on both python2 and python3.
I didn't test this one, so it should be treated as a base to build on, rather than a functional complete port. Edit: Trying out this version, it is obvious it needs a lot of work. This is better done by someone who is familiar with this plugin. Last edited by capink; 08-17-2020 at 04:49 PM. |
![]() |
![]() |
![]() |
Tags |
modify epub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] Quality Check | kiwidude | Plugins | 1251 | 07-07-2025 09:13 PM |
[GUI Plugin] Open With | kiwidude | Plugins | 404 | 02-21-2025 05:42 AM |
[GUI Plugin] Manage Series | kiwidude | Plugins | 167 | 07-28-2024 03:07 PM |
Modify ePub plugin dev thread | kiwidude | Development | 346 | 09-02-2013 05:14 PM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 12:27 PM |