mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
More builtin search and replace functions
This commit is contained in:
parent
8ea08e2153
commit
c70b89e099
@ -119,3 +119,26 @@ def replace_lowercase(match, number, file_name, metadata, dictionaries, function
|
|||||||
return apply_func_to_match_groups(match, icu_lower)
|
return apply_func_to_match_groups(match, icu_lower)
|
||||||
replace_lowercase.name = 'Lower-case text'
|
replace_lowercase.name = 'Lower-case text'
|
||||||
|
|
||||||
|
def replace_capitalize(match, number, file_name, metadata, dictionaries, functions, *args, **kwargs):
|
||||||
|
'''Capitalize matched text. If the regular expression contains groups,
|
||||||
|
only the text in the groups will be changed, otherwise the entire text is
|
||||||
|
changed.'''
|
||||||
|
from calibre.utils.icu import capitalize
|
||||||
|
return apply_func_to_match_groups(match, capitalize)
|
||||||
|
replace_capitalize.name = 'Capitalize text'
|
||||||
|
|
||||||
|
def replace_titlecase(match, number, file_name, metadata, dictionaries, functions, *args, **kwargs):
|
||||||
|
'''Title-case matched text. If the regular expression contains groups,
|
||||||
|
only the text in the groups will be changed, otherwise the entire text is
|
||||||
|
changed.'''
|
||||||
|
from calibre.utils.titlecase import titlecase
|
||||||
|
return apply_func_to_match_groups(match, titlecase)
|
||||||
|
replace_titlecase.name = 'Title-case text'
|
||||||
|
|
||||||
|
def replace_swapcase(match, number, file_name, metadata, dictionaries, functions, *args, **kwargs):
|
||||||
|
'''Swap the case of the matched text. If the regular expression contains groups,
|
||||||
|
only the text in the groups will be changed, otherwise the entire text is
|
||||||
|
changed.'''
|
||||||
|
from calibre.utils.icu import swapcase
|
||||||
|
return apply_func_to_match_groups(match, swapcase)
|
||||||
|
replace_swapcase.name = 'Swap the case of text'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user