View Single Post
Old 05-19-2022, 11:12 PM   #3
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
As mentioned in the other thread, you could do it using a regex function in the editor. A quick and dirty one would be:

Code:
import math
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    boldlen = math.ceil(len(match[0])/2)
    boldedword = '<b>' + match[0][:boldlen] + '</b>' + match[0][boldlen:]
    return boldedword
With the search as "\b\w+\b", it will make the changes. But, it does not distinguish between words in the text and tags. And doesn't handle if you have already made the changes.
davidfor is offline   Reply With Quote