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-12-2016, 04:21 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,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Using the Editor function to activate links?

Hi

I give one example: I have a book with 40 footnotes (ftn). Links are broken or missing for any reason. The only thing is the notes are numbered in chapter 25 and the note anchors are present in the text.

To recreate the links I first use a regex within the notes text file which adds these two attributes into each link (with incremented numbers)
href="chapter25#ftn1a id=ftn1b

Then I use a second regex to fill the remaining 40 links scattered in the body text files (it's the same except that I permutated the letters a and b to create the couples of links).
href="chapter25#ftn1b id=ftn1a

But the recreated links now work only from body to notes because I did not write the exact body chapter number. Of course I can add it manually jumping from one to another, for 40 notes it's a matter of 20 minutes, if I have 400 though...

What I need is to indicate to each link which is in the notes text file the chapter number of its corresponding link in the body text.

I do not know if I can use a function of the Calibre Editor to do this task. If possible, could somebody give me a hand on this?

Last edited by roger64; 01-12-2016 at 06:58 AM. Reason: typo
roger64 is offline   Reply With Quote
Old 01-12-2016, 01:02 PM   #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 try to explain:
In notes, href="file1(or as you like).xhtml#ftn1a" id="ftn1b"
In the other files, href="notes(or as you like).xhtml#ftn1b" id="ftn1a"
Merge all files into one (file1)
Split file1 accordingly.
The editor is responsible for doing all the work.
Good luck! (and first make a backup)

Last edited by jbacelar; 01-12-2016 at 01:06 PM.
jbacelar is offline   Reply With Quote
Advert
Old 01-12-2016, 07:16 PM   #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,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Hi

Thank you for your reply. This is indeed one solution. Since I do not know the relevant chapter numbers, I give to all footnotes the same chapter number so that I do not have to look for it.

I did practice fusion between two files. For more, it could be either a tedious process (once at a time for many files) or a risky one (merging them all together?).

Splitting again all the files could be unpractical though if we have a lot of images in their own pages (for example in svg wrappers).

So, your proposal seems logical but probably not as easy as it sounds. I still listen if there are some other proposals.
roger64 is offline   Reply With Quote
Old 01-13-2016, 03:13 AM   #4
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
Okay...
I do it often, and really, it's fast and I see no problem in merging all the files and then divide them by chapters (images in this process are not affected).
jbacelar is offline   Reply With Quote
Old 01-13-2016, 03:25 AM   #5
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,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
That's sounds different with your first message. It looks more confident or more assertive. Then, I 'll try it.
roger64 is offline   Reply With Quote
Advert
Old 01-13-2016, 03:31 AM   #6
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
What is clear is that English is not my native language.
jbacelar is offline   Reply With Quote
Old 01-15-2016, 05:23 AM   #7
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,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
Hi

A friend of mine wrote a Python script (python 3.5 but you can change it to 3).

It works on the text files (xhtml) of an unzipped EPUB.
The books links have this shape

links in the text files
Code:
href="chapterX#ftn1" id=bodyftn1
return links (placed in the last numbered chapter X)
Code:
href="chapter14#bodyftn1" id=ftn1
If your last chapter X points to wrong chapters numbers, it scans the text files and correct these figures. Its output is a new chapterXmodif.xhtml file and it does not destroy anything.

However, when I tried to put back this new file within the EPUB I had some trouble (some entities appearing). I would probably need some advice on doing it.

If somebody wishes to test it, here it is. Thanks for any help or advice. The ultimate goal is to make a Calibre function out of this.
Attached Files
File Type: zip pingouin2.zip (1,020 Bytes, 133 views)

Last edited by roger64; 01-15-2016 at 05:35 AM. Reason: typo
roger64 is offline   Reply With Quote
Old 01-17-2016, 12:09 AM   #8
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,623
Karma: 3000161
Join Date: Jan 2009
Device: Kindle PW3 (wifi)
To all interested people:

This thread has now been moved to
https://www.mobileread.com/forums/sho...66&postcount=1

where a debugged version of the script is available.

Thanks to Doitsu

Last edited by roger64; 01-17-2016 at 03:34 AM.
roger64 is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Function mode in editor S&R -- coming soon eschwartz Editor 12 11-21-2014 08:26 AM
Error in function mode in editor S&R jbacelar Editor 3 11-21-2014 05:34 AM
Editor Information Links DoctorOhh Editor 0 12-22-2013 10:16 AM
Can the kindle 3 be used as a text editor with copy/paste function somehow? kinkle Amazon Kindle 3 05-19-2011 10:50 AM
Can i activate the reader in the UK barnetda Sony Reader 9 08-21-2007 09:00 AM


All times are GMT -4. The time now is 02:21 AM.


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