Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 03-01-2025, 09:43 AM   #61
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by DiapDealer View Post
[...]all of the functionality can be coded within the custom replace. Unless I'm missing something else.
Unless I'm missing something it's currently not possible to add additional replace functions that don't use one of the predefined custom functions e.g. replace_uppercase, replace_lowercase etc.

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>.
Doitsu is offline   Reply With Quote
Old 03-01-2025, 10:27 AM   #62
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: 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.
KevinH is offline   Reply With Quote
Old 03-01-2025, 10:29 AM   #63
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
Posts: 5,727
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
Quote:
Originally Posted by KevinH View Post
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.
Could you please give an example for this?
Doitsu is offline   Reply With Quote
Old 03-01-2025, 10:32 AM   #64
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: 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.
KevinH is offline   Reply With Quote
Old 03-01-2025, 10:46 AM   #65
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: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by Doitsu View Post
Could you please give an example for this?
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
Then add to "mycount whenever you want and reset it when a new value of file_name is used. So if you want to number only h1 or all h1|h2|h3 title strings, you do that in the Find regex and make sure to capture anything you need to build the output you want.

Last edited by KevinH; 03-01-2025 at 12:24 PM.
KevinH is offline   Reply With Quote
Old 03-01-2025, 11:00 AM   #66
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: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by Doitsu View Post
Unless I'm missing something it's currently not possible to add additional replace functions that don't use one of the predefined custom functions e.g. replace_uppercase, replace_lowercase etc.

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>.
Off the top of my head I would try the following:

Code:
def replace(match, number, file_name, metadata, data):
	if match:
		return '<span title="' + match.group(1) +'">' + match.group(1) + '</span>'
You use the 'New' button to get a new empty function replace and then edit it to look like the above, then hit the "use button to initialize the replace field
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?
KevinH is offline   Reply With Quote
Old 03-01-2025, 11:10 AM   #67
Doitsu
Grand Sorcerer
Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.Doitsu ought to be getting tired of karma fortunes by now.
 
Doitsu's Avatar
 
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.
Doitsu is offline   Reply With Quote
Old 03-01-2025, 12:23 PM   #68
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: 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.
KevinH is offline   Reply With Quote
Old 03-01-2025, 12:29 PM   #69
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: 8,761
Karma: 5706256
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by Doitsu View Post
I just installed the beta and briefly tested the predefined functions, which are a great addition to Sigil!



Am I right in assuming that unlike the Calibre function mode, users won't be able to easily add their own custom functions, unless they add them to fr_utils.py and functionrep.py?

If so, could you could you please briefly document the interface in the Plugin Framework guide?

If it's not too much work, I'd recommend adding two additional custom functions that Kovid described in the Calibre function mode documentation.

Using a spelling dictionary to fix mis-hyphenated words
Auto numbering sections

I also have a minor nitpick about the GUI. On my Windows machine, both the X and �� buttons are rendered in a color that is usually used for disabled buttons. It might be helpful to display them in another color that is also visible in dark mode to indicate that they can be clicked.

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.
KevinH is offline   Reply With Quote
Old 03-01-2025, 09:29 PM   #70
Turtle91
A Hairy Wizard
Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.Turtle91 ought to be getting tired of karma fortunes by now.
 
Turtle91's Avatar
 
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!
Turtle91 is online now   Reply With Quote
Old 03-03-2025, 11:34 AM   #71
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: 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
KevinH is offline   Reply With Quote
Old 03-05-2025, 04:14 AM   #72
philja
Addict
philja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enough
 
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?
philja is offline   Reply With Quote
Old 03-05-2025, 08:03 AM   #73
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: 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.
KevinH is offline   Reply With Quote
Old 03-05-2025, 06:18 PM   #74
philja
Addict
philja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enoughphilja will become famous soon enough
 
Posts: 265
Karma: 516
Join Date: Nov 2015
Location: Europe EEC
Device: Kindle Fire HD6 & HD8
Quote:
Originally Posted by KevinH View Post
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.
When hovering over items in the Clips View, the tool tips can be/ are useful. But in Code View, there are no tool tips when you hover over an item in the right click menu.

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.
philja is offline   Reply With Quote
Old 03-06-2025, 08:58 AM   #75
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: 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.
KevinH is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
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


All times are GMT -4. The time now is 11:13 PM.


MobileRead.com is a privately owned, operated and funded community.