I use a search/replace battery:
Code:
1- Search: <p>\[(\ d +)\] (or whatever may apply)
Replace with: <p class="nota" id="n\1">[\1]
2- Search: (<p class="nota")>\[(\d +)\]
Replace with this function:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
return match.group(1)+' id="n'+match.group(2)+'"><a href="../'+file_name+'#r'+match.group(2)+'">['+match.group(2)+']</a>'
3- Search: (<p class="nota".+?>.+?</p>)
Replace with this function:
def replace(match, number, file_name, metadata, dictionaries, data, functions, *args, **kwargs):
notas = open('e:/Libros/Taller/En curso/notas.txt', 'a')
texto = match.group()+'\n'
notas.write(texto)
return ''
replace.file_order = 'spine'
Due to my poor knowledge of Python, the last function puts all the notes in the file notas.txt, this can be improved if someone knows how to place them in the corresponding xhtml file of the ebook.
I manually create this last file, and make a copy/paste with the data of notas.txt.