View Single Post
Old 11-25-2021, 01:59 PM   #4
lomkiri
Groupie
lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.lomkiri ought to be getting tired of karma fortunes by now.
 
lomkiri's Avatar
 
Posts: 170
Karma: 1497966
Join Date: Jul 2021
Device: N/A
If, e.g., your note-anchor is something like this :
Code:
<a class="noteAnchor" href="../Text/footnotes.xhtml#footnote-0003">[3]</a>
and you want to insert the note [80] (i.e. the old n. 80 (and over) will be renumbered)

— Make a backup of you book
— Put as a search string (you'll have to adapt it to the form of the note-anchors of your ebook) :
Code:
<a[^>]+>\[\K(\d+)(\])
— Set the search as regex-function and create the function with the code:
Code:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
    start_at = 80
    if (n := int(match.group(1))) >= start_at:
        return str(n+1) + match.group(2)
    return match.group(0)
Of course, you must change the var. "start_at" to feet your needs.
— Replace all
— Insert your own note as n. 80

Same process for the notes themselves, just adapt the regex to their form..
If you don't know how to adapt the regexes to your case, give an example of the note-anchor and of the body of the note.

Last edited by lomkiri; 11-25-2021 at 06:45 PM.
lomkiri is offline   Reply With Quote