View Single Post
Old 12-14-2025, 04:47 AM   #9
Siavahda
Zealot
Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.Siavahda can eat soup with a fork.
 
Posts: 133
Karma: 9400
Join Date: Aug 2010
Location: Helsinki
Device: Kindle Paperwhite 2018
Quote:
Originally Posted by gbm View Post
I covert every ebook to epub then edit the epub when I have it the way I like then convert the epub to AZW3.

Here is how I fix Em dashes :

First in the calibre editor create a function name it Em dashes
Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    return match.group().replace(' – ', '—').replace(' –', '—').replace('– ', '—').replace('--', '—').replace(' - ', '—').replace(' —', '—').replace(' — ', '—').replace('— ', '—')

This is the search that I use:
Code:
<body.*?>.*?</body>

https://manual.calibre-ebook.com/function_mode.html

be sure to save it.

https://manual.calibre-ebook.com/edi...saved-searches

This change a - a to a—a and will remove all spaces before and after em dashes.
bernie
I didn't know we could make functions, so thank you! But this didn't accomplish anything, unfortunately, because the spaces are not in the file. (I think I wasn't clear enough about this in the original post, sorry for the confusion! I really appreciate learning about the functions, though!)
Siavahda is offline   Reply With Quote