10-15-2021, 01:17 PM | #1 |
Morlock
Posts: 33
Karma: 2734796
Join Date: Oct 2021
Device: Kindle Paperwhite
|
BuiltinAdd template language function
Does anyone have an example of using the BuiltinAdd template language function in a search and replace? It looks like this in the manual...
add(x [, y]*) class calibre.utils.formatter_functions.BuiltinAdd I don't know enough about Python or Regex to build my own, but might be able to modify whatever help you can give to meet my need. That need is that I have an e-book where the note references are out of sync between the chapters and the notes page. I looks like this function might be able to add a few digits to every chapter reference to make them agree, instead of having to make 286 changes manually. Thanks in advance for any help you can give. In case you're tempted to tell me to just buckle down and learn this, I agree. But, I'm well into my seventies and my calcified brain learns new things so slowly now that I fear I'll be dead before I can figure this out on my own. |
10-15-2021, 01:50 PM | #2 | |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
Quote:
Are you looking for more information on regex functions by any chance? |
|
10-16-2021, 02:57 PM | #3 |
Morlock
Posts: 33
Karma: 2734796
Join Date: Oct 2021
Device: Kindle Paperwhite
|
Yes @doitsu, I am trying to learn more about regex functions. I'm not a programmer, so the best I can do is to take what others have done and make small changes that will work for me.
I have an e-book in which the note references are out of sync with the notes page. I used the sequential numbering function from the Calibre manual. But instead of renumbering the note references from the beginning of the book (which would have brought the references into sync) the numbering started with the second file and finished with the first. So, I thought I might find a function that would add a fixed number to all the references from file two through the end and simply renumber the first file by hand. BuiltinAdd sounded like a likely solution. |
10-16-2021, 03:52 PM | #4 |
Grand Sorcerer
Posts: 5,584
Karma: 22735033
Join Date: Dec 2010
Device: Kindle PW2
|
You might be able to use the Auto numbering sections example from the Calibre manual for this.
If you can't figure out how to modify the example code for your book, post the HTML code of the element(s) that you want to change. |
10-19-2021, 04:21 PM | #5 | |
Morlock
Posts: 33
Karma: 2734796
Join Date: Oct 2021
Device: Kindle Paperwhite
|
Quote:
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Using built-in template functions in a custom template function | ilovejedd | Library Management | 4 | 01-28-2018 12:20 PM |
Problem with contains function in save template | MicaOlaAdams | Calibre | 5 | 10-21-2016 10:25 AM |
how to use re() function in Template Program Mode? | msciwoj | Library Management | 3 | 07-07-2016 03:55 PM |
Template Language | phossler | Calibre | 8 | 01-12-2016 04:37 PM |
Help with template language | Pepin33 | Calibre | 8 | 11-11-2012 08:32 AM |