View Single Post
Old 12-13-2018, 11:32 AM   #7
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,741
Karma: 24031403
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by RbnJrg View Post
I didn't know that Calibre could work with RegEx inside a specific element. I'll do a research to see what can I get there. Thanks for the info.
I rarely use Calibe Editor, but the following should work for you.
  • Paste <h1([^>]*)>([^<]+)</h1> in the Find box.
  • Select Regex-function from the Mode drop-down box.
  • Click Create/Edit, paste the following code in the Code box:


    Code:
    def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
        return '<h1' + match.group(1) + '>'  + match.group(2).replace('  ', '§').replace(' ', '').replace('§', ' ') + '</h1>'
    enter a function name, e.g. Ruben, and click OK.
Doitsu is offline   Reply With Quote