![]() |
#1 |
Member
![]() Posts: 12
Karma: 56
Join Date: Dec 2008
Device: None
|
Internal links not updating after file split (Sigil 0.9.3, Win 10)
I have an epub with internal links between HTML files, and Sigil <hr> split markers. When I run Split Markers:
* internal links in the split files update correctly; * links to the split files from other files do not update. Is this expected behaviour, or should Sigil be updating internal links in all files? Here are more details: I've attached two sample epubs: * test-pre-split.epub * test-post-split.epub They include a contents page (0-3-contents.html) with internal links to chapters (1.html). And each chapter has a linked footnote. I'm splitting 1.html into three files: 1.html (chapter 1), 1_0001.html (chapter 2), 1_0002.html (Notes). If I run Split Markers on test-pre-split.epub, the footnote links (within 1.html) update correctly, as does the NCX. But the links on the contents page to ID anchors in 1.html do not update when splitting. (See test-post-split.epub.) (Incidentally, while test-post-split.epub passes FlightCrew, EpubCheck 4.0.1 throws a 'fragment identifier is not defined' error at the Contents page file.) I'm using Sigil 0.9.3 on Windows 10. |
![]() |
![]() |
![]() |
#2 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,687
Karma: 24031401
Join Date: Dec 2010
Device: Kindle PW2
|
I just tested your files with Sigil 0.9.3 on my Windows machine and I wasn't able to reproduce your results.
The links in 0-3-contents.html are changed from: Code:
<ol> <li><a href="../Text/1.html#hello-world">Chapter 1 – Hello world</a></li> <li><a href="../Text/1.html#goodbye-world">Chapter 2 – Goodbye world</a></li> </ol> Code:
<ol> <li><a href="../Text/1.html#hello-world">Chapter 1 – Hello world</a></li> <li><a href="../Text/1_0001.html#goodbye-world">Chapter 2 – Goodbye world</a></li> </ol> However, I occasionally experienced broken links after file splitting with older Sigil versions, but I never could figure out what caused the problem. |
![]() |
![]() |
![]() |
#3 | |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 28,373
Karma: 203720150
Join Date: Jan 2010
Device: Nexus 7, Kindle Fire HD
|
Quote:
![]() |
|
![]() |
![]() |
![]() |
#4 |
Well trained by Cats
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 30,913
Karma: 60358908
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
I have occasionally had 'now broken' issues caused by deleted files
messing with/leaving behind those with relative anchors Code:
<a href="../Text/1.html#goodbye-world">Chapter 2 – Goodbye world</a> Code:
<a href="../#goodbye-world">Chapter 2 – Goodbye world</a> (I use both the 'at marker' method and the immediate split) ![]() |
![]() |
![]() |
![]() |
#5 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,493
Karma: 5703586
Join Date: Nov 2009
Device: many
|
I can not recreate this on Mac OS X either. All links are properly updated. I have been studying the split and merge code and it is reasonably complex using both regular expressions in some places as well as anchor updates throughout all xhtml files. Both the splitting and the updating of links use multiple threads to handle the updating more quickly and if split markers are put in more than one xhtml file at the same time, these two concurrent things could conceivably interfere where one is reading in from a file while the other is writing something to it. That said, the Qt Read/Write Locks should prevent this but I have no idea if these locks allow rentry by the same thread. Outside of that possibly non-existant issue, I can not see how updating can be skipped randomly.
So as DiapDealer said, if anyone can get this issue to happen in a repeatable manner, we should be able to "stomp" on it ;-) KevinH |
![]() |
![]() |
![]() |
#6 |
Guru
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 878
Karma: 2457540
Join Date: Nov 2011
Device: none
|
Does the book pass validation before the splitting?
|
![]() |
![]() |
![]() |
#7 |
Member
![]() Posts: 12
Karma: 56
Join Date: Dec 2008
Device: None
|
Thanks, everyone, for the lightning-fast replies. I'm sorry, it seems I was hasty and missed something important: the links do update correctly if I close and open the epub *before* running Split at Markers. That is, if I first let Sigil rewrite all internal link paths according to its `../Text/` folder structure.
In all my testing, I never tried closing and opening the epub in Sigil before running Split at Markers. I'm assembling epubs from standalone HTML files. My source HTML files' internal links are relative within their folder: href="1.html#hello-world" Upon opening an epub, Sigil (correctly) rewrites all existing internal links according to its folder structure: href="../Text/1.html#hello-world" But if I add files to an open epub in Sigil (using 'Add Existing Files…'), internal links in those files are not updated until I close and reopen the epub. If I close and reopen the epub, the paths update to `../Text/`. When running Split at Markers, only the `../Text/` paths are updated, and any relative links in the file being split. So if I've added HTML files to an epub, it's important to close and open the epub before running Split at Markers. I've attached a zip file containing two HTML files for testing with. Steps to get incorrect links: 1. Open blank epub in Sigil 2. Add files containing relative links 3. Run Split at Markers 4. Only links in the file being split (1.html) are updated to new paths. Links in 0-3-contents.html are not updated. Steps to get correct links: 1. Open blank epub in Sigil 2. Add files containing relative links 3. Save epub, close, reopen. Sigil rewrites all link paths by adding `../Text/` 4. Run Split at Markers 5. All links update to new paths correctly. The workaround (close, reopen, Split) is simple enough. I don't know whether it would be difficult to get Sigil to update relative links when new files are added to an epub, rather than just on opening an epub. Or, alternatively, to get Sigil to update all internal links first when Split at Markers is run. Or, of course, if I'm still missing something. |
![]() |
![]() |
![]() |
#8 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,493
Karma: 5703586
Join Date: Nov 2009
Device: many
|
Hi,
So something is broken. You should not need to save and close the epub. In what order are you adding existing html files? If you add an existing html file that has links to other htmlfiles, it should automatically pull them all in. Does this issue happen when you use the ImportHTML menu on a file with links to other html files? Does that approach automatically pull in all of the new html files? |
![]() |
![]() |
![]() |
#9 |
Member
![]() Posts: 12
Karma: 56
Join Date: Dec 2008
Device: None
|
Hi @KevinH
I've tried adding the files in different orders: files with links to other HTML files first, and the reverse. And I've tried using both 'Add Existing Files' and 'File > Open'. In all cases, internal link paths do not update, and linked HTML files are not automatically pulled in. Linked images and linked stylesheets *are* pulled in correctly. |
![]() |
![]() |
![]() |
#10 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,493
Karma: 5703586
Join Date: Nov 2009
Device: many
|
Hi,
I think the assumption made by earlier developers is that adding existing xhtml assumes no links to other unloaded xhtml pages. Not sure why they would make that assumption when they allow for links to unloaded images and stylesheets. KevinH Last edited by KevinH; 03-09-2016 at 07:52 PM. |
![]() |
![]() |
![]() |
#11 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,493
Karma: 5703586
Join Date: Nov 2009
Device: many
|
@arthurattwell
Yes, this is an issue. When added **sequentially** in any order there is no way to know those other targets exist and therefore the relative links are not updated (in other words why would a individual file you imported have valid relative links to files already inside the epub and visa versa. So we need to completely rewrite the ImportHTML to pull in multiple linked html files if they exist and then update the whole shebang together, much like how it loads an epub now. We are simply too close to Sigil-0.9.4 release to change that much code. I will add it to my to-do list for Sigil-0.9.5. So please continue to use your workaround. Thanks for your bug report. KevinH |
![]() |
![]() |
![]() |
#12 |
Member
![]() Posts: 12
Karma: 56
Join Date: Dec 2008
Device: None
|
Thanks, @KevinH. I'm very happy to use my workaround.
Just to mention: the links are not updated whether adding the files one at a time or adding multiple files at once with 'Add Existing Files'. Thanks for all the work on this great tool. |
![]() |
![]() |
![]() |
#13 |
Sigil Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 8,493
Karma: 5703586
Join Date: Nov 2009
Device: many
|
Yes, it seems Add Existing even with multiple files just adds them one by one.
KevinH |
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
split html files not updating links | ni_c | Editor | 4 | 11-24-2015 11:48 PM |
When you split a file does Sigil update links? | JimmyG | Sigil | 2 | 10-31-2013 01:02 PM |
Sigil TOC breaks internal links | LarsEighner | Sigil | 1 | 09-03-2013 10:23 AM |
Internal links not working after Packaging (copying) indb file | MHC | ePub | 6 | 03-09-2013 01:50 PM |
Links to URLs work, internal links don't? | NewDay | ePub | 36 | 10-27-2010 04:09 AM |