Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre > Editor

Notices

Reply
 
Thread Tools Search this Thread
Old 12-03-2018, 11:08 PM   #1
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Regrouping all footnotes in the same folder

Hi

This is a practical problem I am facing when I try to rebuild footnotes. It's quite easy to do it when all your footnotes definitions are grouped within the same folder, presumably at the end or near end of the book.

Unhappily many times, the definitions are placed at the end of each chapter and are thus scattered through the book. And some books may have 100 chapters. Picking up manually all the footnotes and pasting them in a dedicated folder thus becomes a very tedious task.

Even if this ancillary task cannot be totally automated, I wish a middle ground could be found which would make this process a bit easier. After all the Calibre editor can use powerful functions which maybe could be used for this purpose (?).

Has somebody any idea how to improve this situation?

Last edited by roger64; 12-04-2018 at 08:27 AM.
roger64 is offline   Reply With Quote
Old 12-04-2018, 04:06 AM   #2
jbacelar
Interested in the matter
jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.jbacelar ought to be getting tired of karma fortunes by now.
 
jbacelar's Avatar
 
Posts: 421
Karma: 426094
Join Date: Dec 2011
Location: Spain, south coast
Device: Pocketbook InkPad 3
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.
jbacelar is offline   Reply With Quote
Old 12-04-2018, 05:42 AM   #3
roger64
Wizard
roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.roger64 ought to be getting tired of karma fortunes by now.
 
Posts: 2,608
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Hi

Thank you very much for this helpful solution that I'll test quickly.

As you probably know, there is a Sigil plugin named "FootnoteLinker" which creates (or recreates) the missing links in some few seconds using a semantically named single folder for definitions.

This function should handily complement this above plugin.
roger64 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reimport books from another folder to Calibre folder structure? mendhak Calibre 2 10-11-2013 01:18 AM
Footnotes dicknskip Sigil 11 12-14-2012 12:51 AM
Footnotes? S Otteson Sigil 11 01-26-2011 10:14 PM
sub-folder support for documents folder? sark666 Kobo Reader 5 08-31-2010 05:35 AM


All times are GMT -4. The time now is 12:16 PM.


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