09-22-2022, 03:21 PM | #16 |
Junior Member
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: IPad mini
|
I don't think I was "pissy" but if so I apologise.
Where did KevinH provide the solution using the plugin? I've re-read the posts and can't see it. |
09-22-2022, 04:42 PM | #17 | |
A Hairy Wizard
Posts: 3,161
Karma: 18843349
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
|
|
Advert | |
|
09-22-2022, 08:43 PM | #18 |
Junior Member
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: IPad mini
|
I didn't think I was being "pissy’ but if so I apologise.
I've gone through the comments that KevinH made and I can't see an example of the plug-in being used which is what celiapgt asked for and what I am interested in. Please point out where the example was provided. |
09-22-2022, 09:00 PM | #19 |
Junior Member
Posts: 6
Karma: 10
Join Date: Mar 2018
Device: IPad mini
|
Hi Turtle91 thanks for your response but I'm sorry but the blue highlighted part isn't providing an example.
The syntax for using the existing find and replace function is provided but not for using the plug-in to do that I'm not a coder so that statement doesn't tell me what the exact syntax for the solution would be. I'm not across Python and frankly no longer have the mental capacity to learn another coding language. I was hoping this plug-in would enable me to do somrthing like: if text="made to" then replace with "started to" else if text="making to" then replace with "began to" |
09-23-2022, 07:58 AM | #20 | |
A Hairy Wizard
Posts: 3,161
Karma: 18843349
Join Date: Dec 2012
Location: Charleston, SC today
Device: iPhone 15/11/X/6/iPad 1,2,Air & Air Pro/Surface Pro/Kindle PW & Fire
|
Quote:
Your example is not really a “function” either… or, at least, it is something that would be easier as two simple find/replace actions. As KevinH mentioned, the find phrase would be the same, but the replace portion would have to be some sort of function. Unfortunately you would need to know the language the plug-in uses. I haven’t used this plug-in yet, but I suspect it is similar to Calibre’s implementation. Here is an example of a replacement function that uses a spelling dictionary to replace mi-shyphenated words: Code:
import regex from calibre import replace_entities from calibre import prepare_string_for_xml def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs): def replace_word(wmatch): # Try to remove the hyphen and replace the words if the resulting # hyphen free word is recognized by the dictionary without_hyphen = wmatch.group(1) + wmatch.group(2) if dictionaries.recognized(without_hyphen): return without_hyphen return wmatch.group() # Search for words split by a hyphen text = replace_entities(match.group()[1:-1]) # Handle HTML entities like & corrected = regex.sub(r'(\w+)\s*-\s*(\w+)', replace_word, text, flags=regex.VERSION1 | regex.UNICODE) return '>%s<' % prepare_string_for_xml(corrected) # Put back required entities |
|
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] Mass Search/Replace | un_pogaz | Plugins | 39 | Today 09:56 AM |
[Plugin] ReworkChapterHeads - Add, replace and reformat chapter headings | slowsmile | Plugins | 87 | 08-03-2023 05:04 AM |
Editor plugin : problem with regex and special characters | EbookMakers | Development | 4 | 11-14-2019 07:52 AM |
[Plugin] QuickPrefsEdit - Edit plugin prefs json files. | slowsmile | Plugins | 3 | 07-25-2018 08:14 PM |
Goodread Perception Expander plugin not shown on plugin list (kobo h2o) | www | KOReader | 4 | 09-28-2017 10:34 AM |