[e-book editor] Transform HTML > Wrapping <i> tag fails
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
calibre |
Invalid
|
Undecided
|
Unassigned |
Bug Description
Calibre 6.29 on Windows 10 (specific version below)
Edition Windows 10 Home
Version 22H2
Installed on 7/23/2020
OS build 19045.3636
Experience Windows Feature Experience Pack 120.2212.3920.0
Summary:
When attempting to wrap an <i> tag using the Transform HTML feature in the ebook editor throws a 'list index out of range error'.
Conditions:
I have attempted to use both the standard 'if tag is' with the value 'i', and wrapping with 'p', as well as identifying via xpath with value '//h:i', and it makes no difference.
Inserting HTML before or after, adding a class, or changing the tag name options work without issue.
I tried this with a number of different files, but eventually narrowed it down to replicate with the simple html file attached (exported directly from a ePub 2.0 file via the editor).
Steps to replicate:
1. Open any epub file that includes xhtml files containing an <i> tag anywhere in the file
2. Select 'Transform HTML' from the Tools menu
3. Click 'Add rule'
4. Set the If criteria to 'Tag is' with a value of 'i' OR 'matches XPath selector' with a value of '//h:i'
5. Set the Then action to 'Wrap the tag' and enter the value as 'p' or any other tag.
6. Click Ok
7. Click Ok again
8. Observe that this action generates an error window with a message of 'IndexError:list index out of range'
Error Details:
calibre, version 6.29.0
ERROR: Unhandled exception: <b>IndexError<
calibre 6.29 embedded-python: True
Windows-
('Windows', '10', '10.0.19045')
Python 3.10.1
Windows: ('10', '10.0.19045', 'SP0', 'Multiprocessor Free')
Interface language: None
Successfully initialized third party plugins: Gather KFX-ZIP (from KFX Input) (2, 5, 0) && DeDRM (10, 0, 3) && Package KFX (from KFX Input) (2, 5, 0) && Action Chains (1, 18, 15) && Audit Log (1, 0, 19) && Author Book Count Hierarchy (1, 2, 5) && CalibreSpy (1, 0, 92) && Check Books (0, 1, 8) && Comments Cleaner (1, 11, 1) && Count Pages (1, 13, 4) && DOC Input (1, 0, 1) && Editor Chains (0, 9, 1) && EpubCheck (0, 2, 5) && EpubMerge (2, 16, 0) && EpubSplit (3, 6, 0) && Extract ISBN (1, 6, 0) && FanFicFare (4, 29, 0) && Fantastic Fiction (1, 6, 4) && Fantastic Fiction Adults (1, 3, 0) && Favourites Menu (1, 3, 0) && FictionDB (1, 4, 1) && Find Duplicates (1, 10, 8) && Generate Cover (2, 3, 3) && Goodreads (1, 7, 9) && Goodreads More Tags (1, 2, 1, 2) && Goodreads Sync (1, 16, 3) && Import List (1, 9, 1) && Job Spy (1, 0, 239) && KFX metadata reader (from KFX Input) (2, 5, 0) && KFX Input (2, 5, 0) && Kindle hi-res covers (0, 5, 0) && Kobo Books (1, 9, 2) && Library Codes (1, 0, 65) && Manage Series (1, 5, 1) && Mass Search-Replace (1, 7, 5) && Modify ePub (1, 8, 2) && MultiColumnSearch (1, 0, 96) && Open With (1, 8, 1) && Quality Check (1, 13, 6) && Reading List (1, 15, 1) && Search The Internet (1, 10, 4) && Smashwords Metadata (1, 0, 2) && View Manager (1, 10, 2) && ePub Extended Metadata {Writer} (0, 10, 2) && ePub Extended Metadata {Reader} (0, 10, 2) && ePub Extended Metadata (0, 10, 2)
Traceback (most recent call last):
File "calibre\
File "calibre\
File "calibre\
File "calibre\
File "calibre\
File "calibre\
File "calibre\
File "src/lxml/
IndexError: list index out of range
Works for me. Note that when you enter the wrapping tag, you need to
enter the full thing, <p> not just p. This is because you can add
attributes as well, for example <p class="something">
I should probably add a check for this when the rule is created.