View Single Post
Old 01-05-2019, 12:06 PM   #10
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,739
Karma: 24031403
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by Tex2002ans View Post
I doubt there are many legitimate 4+ single characters by themselves
Since there are no italics blackletter fonts, German printers had to use increased letter spacing for emphasis. I.e., there might be even longer words.

@famfam I found a suitable regex in a German forum and used it to create a simple throwaway plugin that should automatically remove all unwanted spaces. Please make a backup copy before running this plugin!

Note that if you uncomment the following line in plugin.py by removing the # sign:

Code:
#unspaced_word = '<span class="italics">{}</span>'.format(unspaced_word)
the plugin will wrap all replaced words in <span> tags.

And for completeness' sake here are instruction for Calibre Editor:
  • Paste (?<=[ ])([\w][ ]+){1,}[\w](?=[ .,:;!?]) 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):
        spaced_word = match.group(0)
        unspaced_word = spaced_word.replace(' ', '')
        #unspaced_word = '<span class="italics">{}</span>'.format(unspaced_word)
        return unspaced_word
  • enter a function name, e.g. Spacer, and click OK.

BTW, you also might want to post your question in the German MR subforum.
Attached Files
File Type: zip Spacer_v0.0.1.zip (1.2 KB, 272 views)

Last edited by Doitsu; 01-06-2019 at 06:42 AM.
Doitsu is offline   Reply With Quote