Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-17-2016, 03:31 AM   #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,624
Karma: 3120635
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
To correct endnotes links: a proposal

Hi

To batch correct broken links

Kovid Goyal some months ago enabled the Editor to detect and repair broken links. However, the Editor does not repair yet the broken links due to a wrong chapter number that we may find for example in the file containing the return links.

This script below allows you to do it.
It has been written by pingouinux (Ubuntu). Doitsu helped to debug it (now repaired).
For your information, this script has been successfully tested for one EPUB with 106 xhtml files and 837 -broken- endnotes (two seconds).

Please find enclosed the test epub, the script and these comments.

Before using it, open it to check your version of python. It works with 3 and 3.5. I did not try 2.7
You can customize the variables "chapter" and "xhtml". check that the script is executable.

Testing the script
For this purpose, I join a demo lorem.epub (EPUB2) with seven broken links due to wrong chapter numbers.

1. - Check it. The errors are reported by the Calibre Editor which does not repair them.
2. - Unzip the EPUB. Put it aside.
3. - Open the FILES, then the OEBPS folder.
4. - Put yourself in the path and launch with a terminal (Linux)
Code:
$./pingouin3.py
The script creates a chapter3modif.xhtml file (it uses the highest file number), close to the original chapter3.xhtml
5. - Delete chapter3.xhtml
6. - Rename chapter3modif.xhtml to chapter3.xhtml
7. - Open the EPUB, select chapter3.xhtml and change it (right-click) for the new chapter3.xhtml file in the OEBPS folder. Save.
8. - Check you EPUB: the errors are gone.

Comment

This is a very slow but fool-proof method to use it because the renaming of files with the Calibre editor can be tricky for beginners (it can generate "../chapter" instead of "chapter" for example). Later, this process will of course be simplified, mainly at the steps 5 and 6.

Of course, the ideal would be to make this repair script work directly within the Calibre editor either as a function or otherwise. But for this, some expert help is needed.
Attached Files
File Type: zip pingouinux.zip (174.7 KB, 187 views)
roger64 is offline   Reply With Quote
Old 02-25-2016, 09:59 AM   #2
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,624
Karma: 3120635
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Hi

The joint zip includes a new version of the script named pingouin4.py

The former one did not process text file numbers beginning with 0, like chapter01.xhtml, chapter02.xhtml, etc. This has been corrected with this version.

EDIT: a small correction was needed. pingouin5.py is now in charge.
2nd of March 2016.

Sorry for this
Attached Files
File Type: zip pingouin5..zip (1.0 KB, 123 views)

Last edited by roger64; 03-02-2016 at 05:31 AM. Reason: new version
roger64 is offline   Reply With Quote
Advert
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Touch Normal links becomes footnotes links in epub made with Calibre il_mix Kobo Reader 15 08-10-2014 01:19 PM
Touch Gotta Improve Links to Endnotes SCION Kobo Reader 9 07-17-2011 08:48 AM
File splitting and endnotes links mtrahan ePub 11 05-01-2011 04:07 PM
Links to URLs work, internal links don't? NewDay ePub 36 10-27-2010 04:09 AM


All times are GMT -4. The time now is 03:08 AM.


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