For those who feel as Turtle91 does, you will hopefully be happy to learn that barring any unforeseen technical difficulties, we have just now integrated Python Function Replace into Sigil master in an experimental form. It is integrated with both Find and Replace and Saved Searches, has its own Python Function editor with Python syntax highlighting and line numbers. BeckyEbook nicely donated the icon gui support that integrates it into Find Replace.
Note: The Sigil version does NOT use a Function Replace "mode". It is invoked any time the F&R Replace field has a new "escape" like the following:
\F<YOURFUNCTIONNAMEHERE>
And in that way it is automatically already supported by Saved Searches, F&R histories, etc.
FYI, this was not as simple as it is when done in pure python inside a plugin. The diff of the changes needed was over 3200 lines long and required a lot of infrastructure support because positions and lengths of strings inside Qt/C++ differ from the lengths and positions of the identical strings in Python as one is utf-16 encoded (Qt) and the other is utf-32 encoded. So all non-BMP characters need to be accounted for.
I just do not have any good testcases of epubs that use many non-BMP chars to test with. So if anyone can point me to an epub that uses lots of emojis preferably (or Asian languages with non-BMP chars) please let me know.
So this is still all very experimental. There will be bugs. Help testing will be needed. Those who build their own can check out Sigil master now.
At some point, we will make CI builds available for more testers to play with.
Hope this helps.
KevinH
ps. FYI - if unforeseen technical difficulties do arise or the code maintenance support turns out to be too much for this feature's incremental usefulness for the majority of users we will simply revert it before the final actual release and will fall back to the newly revised plugin for those users who still need this feature.
I hope to make CI builds this weekend and post them for those interested.
KevinH
Quote:
Originally Posted by Turtle91
RE: Function Replace plugin
In my testing so far I haven’t found any issues with the actual function replace… the default functions seem to work as expected. One detractor I found using a plugin was that I can’t interact with the rest of Sigil’s functionality the way you can if it is a built-in feature. eg. Using a clip to fill in the Find field, or copying the highlighted portion into the Find field like you can by selecting the magnifying glass in the ribbon.
This is certainly usable, just not as nice/consistent as having it built-in to the find/replace window.
I will keep working with it and see how it does when making my own functions.
|