Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Sigil

Notices

Reply
 
Thread Tools Search this Thread
Old 05-22-2025, 11:03 AM   #1
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,504
Karma: 5703586
Join Date: Nov 2009
Device: many
Volunteer to write new Chapter on Python Function Replace for Sigil User Guide

Hi @Turtle91 and All,

Quote:
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.

Well that time has come and I am looking for a volunteer or volunteers to create a new "Advanced Search - Python Function Replace" chapter that documents the new Sigil Python Function Replace tool that was available in the Betas (which can be used for screenshots) and will be available in the upcoming Sigil 2.5.0 release (real soon now!).

Please warn users as this is a very advanced techniques that requires knowledge of the Python programming language, regular expressions, etc.

Please include the screen caps to make it clear how to use it, when to use it, etc. And please document the new debug log file environment variable to capture debug output when trying to debug your python function.
And maybe include a simple trivial example.

If this is something you are willing to take a shot at, please let me know. If multiple people are interested we can use this thread to share xhtml source and screencaps.

Please use the styles already defined in the Sigil User Guide.

And when final, please make sure it passes epubcheck.

Thanks!

Kevin
KevinH is offline   Reply With Quote
Old 05-22-2025, 12:15 PM   #2
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,321
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
Oh dang! I completely forgot about volunteering for this after my hard drive crash, and the (literal) train wreck. I’ll need to download the beta again.
Turtle91 is offline   Reply With Quote
Advert
Old 05-22-2025, 01:03 PM   #3
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,504
Karma: 5703586
Join Date: Nov 2009
Device: many
No rush. The user's guide update can come after the new Sigil release too.
KevinH is offline   Reply With Quote
Old Yesterday, 08:33 AM   #4
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,321
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
Workin it...

Question though:
Is the function result referenceable in the replace field?

If I enter the find field with a normal search and use the regex function (as below) the function works, replacing the grouped section with the function result.

Click image for larger version

Name:	Screenshot 2025-05-23 075926.png
Views:	13
Size:	16.1 KB
ID:	215827

Code:
<h2>SUPER DUPER</h2>

returns

<h2>Super Duper</h2>

However, if I try and add any string before or after it in the replace field it simply treats the function as a string.

Click image for larger version

Name:	Screenshot 2025-05-23 075945.png
Views:	9
Size:	16.9 KB
ID:	215828
Code:
<h2>SUPER DUPER</h2>

returns

<h3>\F<titlecase_ignore_tags></h3>
Is there a way to treat the returned value like a normal \1 in the replace field so we can adjust the string around the function result?

Something like:
Code:
Replace: <h3>\1:F<titlecase_ignore_tags></h3>

to achieve

<h3>Super Duper</h3>
Turtle91 is offline   Reply With Quote
Old Yesterday, 08:43 AM   #5
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,504
Karma: 5703586
Join Date: Nov 2009
Device: many
No the function replace is the only thing specified in the replace field. It is not a substring replacement, it is a function doing the replacement.

All search match groups are provided to your function. So you get the entire string that was matched, plus all of the values for each match group to use as you see fit in your function.

So can use your own python code to replace anything you want with anything you want. You can build the entire replacement value. You just can not try to squeeze it into the replace field, your function should handle that.

Last edited by KevinH; Yesterday at 08:52 AM.
KevinH is offline   Reply With Quote
Advert
Old Yesterday, 08:51 AM   #6
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,321
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
okay. thanks!
Turtle91 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Looking for Volunteers for New Chapters for Sigil User's Guide KevinH Sigil 283 03-16-2021 12:43 PM
Sigil Find Replace Function d351r3d Sigil 5 06-09-2020 12:17 AM
Is Sigil 072 the latest User Guide? Gregg Bell Sigil 46 04-24-2018 05:54 PM
Sigil .9+ user guide cyteen Sigil 2 12-29-2017 02:31 PM
Sigil User Guide Not Working in IE9 TrevN Sigil 5 09-12-2012 09:54 PM


All times are GMT -4. The time now is 06:40 AM.


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