![]() |
#61 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Let's take a trivial, rather contrived example. How would a user write a custom function that wraps certain words in a <span> tag with the search expression as a title attribute? Find:(word1|word2|word3) The result should be <span title="word1">word1</span>. |
|
![]() |
![]() |
![]() |
#62 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
No hunspell dictionary support is planned as the interface to spell checking in a python environment requires too much work for something better done in a real plugin.
As for numbering sections, any time you use ReplaceAll you can in fact number anything you like inside your replace function. You have access to the bookpath and the number parameters which can be used with the func data dict to keep track of numbering and which file you are working in. No additional support code is needed. |
![]() |
![]() |
![]() |
#63 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
|
|
![]() |
![]() |
![]() |
#64 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
Your find term must be a regex that looks for the words you want outside of tags. Add capture groups for the word you caught. Then your replace should add the span tag and the word as you specified.
So the smarts is in the regex find, and the replace function you write looks at the capture group to build the replacement any way you want. |
![]() |
![]() |
![]() |
#65 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
Yes here is a very silly contrived example to sequentially number all of the words "the" in all xhtml spine order in all xhtml files.
Find: (?sm)\s(the)\s Replace \F<numberthes> Where the numberthes is the following replace function: Code:
def replace(match, number, file_name, metadata, data): if match: return ' ' + match.group(1) + str(number) + ' ' Then you must use ReplaceAll not one by one replace as no number history is kept if not a finite set of replacements in a single down direction is knowable. I just tried this and it worked as expected for me. If you want more complicated numbering, then instead of using the "number" parameter, initialize your own variable called "mycount" as follows: Code:
if number == 1: data['mycount'] = 1 data['cur_file'] = file_name Last edited by KevinH; 03-01-2025 at 12:24 PM. |
![]() |
![]() |
![]() |
#66 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
Quote:
Code:
def replace(match, number, file_name, metadata, data): if match: return '<span title="' + match.group(1) +'">' + match.group(1) + '</span>' in F&R and close the Editor. If you have trouble making your own functions, then my guess is you are missing some changes from your build as this works in Sigil master but did not in the original version of my repo. So maybe try a clean build from normal Sigil master? |
|
![]() |
![]() |
![]() |
#67 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
Thanks for the example! I must have made a typo when I tested my own version.
|
![]() |
![]() |
![]() |
#68 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
You may want to pull from master as bad syntax in the replace function was being caught an an exception dialog shown but then causing a crash. At least on Windows and Linux (not on Mac for some reason). Either way that has just now been fixed in master.
I will wait a few days and produce new test Betas in case other issues are detected. |
![]() |
![]() |
![]() |
#69 | |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
Quote:
They were designed to render well under both dark and light themes and do on my MacOS machine and on BeckyEbook's Windows machine. She designed them to do so. I have no idea what colour is meant to indicate a disabled button on your Linux box so I am unsure what if anything to change. As for section numbering, the code in Calibre's documents with small changes would work just as well in Sigil (once limited to the parameters available for Sigil's version). Since this now has nothing to do with Plugins at all anymore, the Plugin Framework guide is not the place for any documentation. I am kind of hoping once this gets into final form, that some kind soul will volunteer to create a new chapter documenting it for our Sigil User's Guide - hint, hint, Turtle91 ... cough cough. ![]() Last edited by KevinH; 03-01-2025 at 12:36 PM. |
|
![]() |
![]() |
![]() |
#70 |
A Hairy Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 3,349
Karma: 20171571
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
|
lol. I’d be glad to!
|
![]() |
![]() |
![]() |
#71 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
New Beta4 Version Now Available
For those willing to test and report back on new Sigil features, there is now a Beta4 build of the next version of Sigil available.
Notable changes from Beta 1 include: - prevents bad function replace python from crashing Sigil - improvements for Linux theming of the F&R buttons - a new AlertBox is used for Python Error messages that is now resizeable and that can be copied from to make it easier to see your error messages - The Python Function Editor "Use" button now auto-closes out to make running your new function replace easier./faster. - more consistent line numbering in the Python Function Editor - initialize Function Editor to open current replace value if it is a function name: Special thanks to BeckyEbook for contributing the code for this. - added in bug fix to prevent double images - added a new tool "Use Standard File Extension" to Sigil that will walk all files and if they do not have the standard file extension for their declared media-type, the extension is fixed. This tool is Automatable. Again these are Beta builds that are **NOT** signed or notarized that are built form our github CI actions. The repository is my personal repo here: https://github.com/kevinhendricks/Bu...OnMac/releases The files you want are called: Sigil-Beta4-Mac-x86_64.tar.xz Sigil-Beta4-Mac-arm64.tar.xz Sigil-Beta4-Windows-x64-Setup.exe Last edited by KevinH; 03-05-2025 at 07:56 AM. Reason: Updated from Beta 3 to Beta 4 |
![]() |
![]() |
![]() |
#72 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() Posts: 265
Karma: 516
Join Date: Nov 2015
Location: Europe EEC
Device: Kindle Fire HD6 & HD8
|
In the spirit of the name of this thread, I've got a tiny suggestion for a change which could improve the experience of 'novice' users of Sigil.
It concerns the Clips Help. When you right-click in Code View, the first item you see in the drop-down is Clips which when highlighted exposes three options. The first is Clips Help. I know several users who've clicked on clips help only to find that the help message gets printed into code view. Some haven't noticed that until they read through their edits later. Most computer users expect that clicking on a help item will open a dialog box. They don't expect the help section to get printed into their working document. The same happens if you click rather than hover on help in the Clips View. My workaround is simply to delete the help text in the Clips Editor but this prevents the help from showing when hovering on clips help in the Clips View. That's no loss once you know what clips are about but a shame for new users of Sigil. Is there a way to keep the hover help but stop it from printing in Code View? |
![]() |
![]() |
![]() |
#73 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
All clips insert something into CodeView as that is their function. So the first time a new user clicks on any clip "something" will be inserted. And they will click on it without understanding. Do you suggest it be something small and almost impossible to find without a Checkpoint being made prior, or something larger that obviously is not part of the book text text that can be found with any quick proof read?
Maybe we remove the word Help from it? But I am not sure. A clip's tooltip is always its contents so people can see it in advance. So when you remove that clip people will have no idea what clips are or how the work, since they never bother to read the Users Guide before editing their book. Last edited by KevinH; 03-05-2025 at 08:40 AM. |
![]() |
![]() |
![]() |
#74 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() Posts: 265
Karma: 516
Join Date: Nov 2015
Location: Europe EEC
Device: Kindle Fire HD6 & HD8
|
Quote:
My objection is that Sigil's behaviour of dropping the contents of help into the current document when the user clicks on help runs counter to the general practice in all other software. I, at least, have never encountered this behaviour in any other software. I suggest simply removing any mention of help from the right-click dropdown in Code View. After all, if a user is puzzled about how something works, there is a 'Help' item on the main menu bar which will provide the expected action of taking him to the User Guide. |
|
![]() |
![]() |
![]() |
#75 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
|
I removed the word "Help" from the first Example clips ini file and reworded it. This clip-entries.ini file will only get loaded by new Sigil users. This will not impact existing users.
The new first entry now says: 1\Name=Insert Clip 1\Text=Clips will insert their text at the current paste target when clicked. Right click for menu to add groups and entries. Edit or re-order any item. Handy for quickly inserting often used text clips. KevinH Last edited by KevinH; 03-06-2025 at 09:12 AM. |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Improvements/bugs/features | dontcrash | KOReader | 10 | 10-23-2019 10:05 AM |
Touch HD, Future features or dead features? | ElWorm | PocketBook | 4 | 02-07-2018 11:36 AM |
[FREE]Innovative Ideas to Ignite Your Mind: Business Ideas to Start Entrepreneurship | amazon author | Self-Promotions by Authors and Publishers | 0 | 04-01-2015 04:09 AM |
How many 'improvements' do we really need? | Fozzybear | General Discussions | 61 | 04-15-2012 12:38 PM |
ideas for calibre features | smarties86 | Recipes | 3 | 07-01-2011 10:23 AM |