View Single Post
Old 01-15-2026, 03:50 PM   #56
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 9,419
Karma: 6733754
Join Date: Nov 2009
Device: many
@BeckyEbook,

Okay here is a new force_titlecase that should work no matter if in Current File or in Multiple Files and should work with ReplaceAll

It basically makes a SigilMatch object from a re match object. It worked in my testing. If this works under your test I will probably change functionsearch.py to make this a simple convenience function to make this even easier for people to use.

Code:
def replace(match, number, file_name, metadata, data):
    if match:
        #create a SigilMatch from the re match object
        grouplist = []
        n = len(match.groups())
        if  n > 0: n = n + 1
        s = match.start()
        for i in range(n):
            grouplist.append([match.span(i)[0] - s, match.span(i)[1] - s])
        new_match = SigilMatch(match.group(0), grouplist)
        new_match.string = replace_lowercase(match, number, file_name, metadata, data)
        return replace_titlecase(new_match, number, file_name, metadata, data)
KevinH is offline