View Single Post
Old 09-13-2018, 12:23 PM   #4
Klecks
Enthusiast
Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.Klecks never is beset by a damp, drizzly November in his or her soul.
 
Klecks's Avatar
 
Posts: 39
Karma: 59154
Join Date: May 2010
Location: Stuttgart, Germany
Device: Kobo H2O, PocketBook Touch HD, Tolino Vision 4
I don't have a solution for a sigil regex, but if you want to try the calibre editor, you can use the function mode.
The function mode gives you the possibility of more advanced text processing.
It should be perfect for your problem:

Open your book with the calibre editor.
Choose one of the html-files on the left panel and click Ctrl+F.
Insert "<table[^>]*>.*?</table>" in the field "Find:"
Choose Mode "Regex-function" and click create/edit.


In the new window you will have the basic structure of a function.
In the upper field you can insert a name (maybe "clean_tables") and the the given basic function you should replace with:

Code:
import regex
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    return regex.sub(r'<p[^>]*>(.*?)</p>',r'\1',match.group())
Confirm with OK and you can use the new function.

Klecks
Attached Thumbnails
Click image for larger version

Name:	function_1.JPG
Views:	192
Size:	53.8 KB
ID:	166277   Click image for larger version

Name:	function_structure.JPG
Views:	197
Size:	84.7 KB
ID:	166278   Click image for larger version

Name:	function_clean_table.JPG
Views:	174
Size:	98.7 KB
ID:	166279   Click image for larger version

Name:	function_ready.JPG
Views:	183
Size:	55.4 KB
ID:	166280  
Klecks is offline   Reply With Quote