Internal Links Disappear on Compile to Kindle

ch
chuckmiller
Posts: 72
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Tue Dec 05, 2017 4:19 pm Post

I'm proofing the final version of my book now on Kindle and I've just discovered that the internal links have disappeared. Links from one chapter to another are no longer in place. Is this a known bug?

I tried checking the compile option "Convert document links to HTML links and it corrupts my ToC (all that's visible is <$TOC> and a link to my endnotes). Has anyone else run into this and found a solution?

User avatar
AmberV
Posts: 20600
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Tue Dec 05, 2017 6:29 pm Post

Have you enabled Convert document links to HTML links in the gear tab of the compile overview screen? By default links are configured for internal use rather than public cross-referencing.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

ch
chuckmiller
Posts: 72
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Tue Dec 05, 2017 7:05 pm Post

In my original post I indicated that I had tried that in this statement...

"I tried checking the compile option "Convert document links to HTML links and it corrupts my ToC (all that's visible is <$TOC> and a link to my endnotes). "

When I do, the ToC looks like this...
toc-issue.jpeg
toc-issue.jpeg (80.9 KiB) Viewed 183 times

...stripped of everything except endnotes and showing the ToC code. On top of that, the internal links are still absent.

User avatar
AmberV
Posts: 20600
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Tue Dec 05, 2017 7:29 pm Post

Hmm, I don’t see a correlation between that setting and whether or not the placeholder works. I do see cases where that placeholder doesn’t work—if the contents placeholder document is using a type that is formatted with a layout for example, that can mess it up.

But to get the result you’re seeing with the checkbox triggering this behaviour, I’d need more configuration information. My result when toggling this checkbox on is:

  • Public cross-references using the internal links in body text I created for testing.
  • A functional ToC generated at the location of the ToC placeholder section.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

ch
chuckmiller
Posts: 72
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Tue Dec 05, 2017 8:02 pm Post

When I uncheck the "Convert document links to HTML links" my ToC appears as below...
contents.jpeg
contents.jpeg (305.68 KiB) Viewed 171 times

As for the contents page itself, I totally deleted my page and let Scrivener generate a default ToC. I don't get the messed up ToC that way, but it also appears in the wrong place, right after the cover and before the title page. Even so, I'm still not getting the internal links when the "Convert document links to HTML links" box is checked.

Also it's not directly related to this issue, but how can I reduce the spacing between lines to tighten up the ToC. In other words, to use line breaks (⌘⌥↵) instead of hard returns?

And, why isn't the cover appearing in the ToC?

User avatar
AmberV
Posts: 20600
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Tue Dec 05, 2017 10:22 pm Post

Oh I believe you, I just don’t know how to get that result myself is what I’m saying. I tried around a half a dozen different tests and only got the expected results—so obviously I’m missing something and need your help finding it. Sample data, which checkboxes it takes to trigger the problem, etc.

Also it’s not directly related to this issue, but how can I reduce the spacing between lines to tighten up the ToC. In other words, to use line breaks (⌘⌥↵) instead of hard returns?

You could do that if you made your own ToC page, as described in chapter 22. I would advise handling that by reducing the paragraph spacing for the lines rather than making the ToC one long paragraph with line breaks inside of it, though. Semantically speaking, you might run into issues working that way. Incidentally that approach would also let you place the ToC wherever you prefer.

Of course you would need links working to do that.

And, why isn’t the cover appearing in the ToC?

There is no way to do that. I’ve never heard of referring to the cover of a book in the table of contents. You typically just close the book if you want to see the cover, no? ;) Or the digital equivalent, use the “Cover” navigation option in the menu.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

User avatar
Bridey
Posts: 179
Joined: Wed Nov 22, 2017 2:24 pm
Platform: Mac

Tue Dec 05, 2017 10:49 pm Post

AmberV wrote:There is no way to do that. I’ve never heard of referring to the cover of a book in the table of contents. You typically just close the book if you want to see the cover, no? ;) Or the digital equivalent, use the “Cover” navigation option in the menu.


I have got iBooks that list covers in the TOC. I think they fudge a cover by inserting a graphic into a page and then adding that to the TOC and listing it as Cover. There are some books which have a thumbnail cover that expands on opening, is then replaced by text, and is impossible to call up from any navigation source—not even scrolling to the start of the book. Find that disappointing, as there are times when you do want to look at or read or study a cover.

User avatar
AmberV
Posts: 20600
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Tue Dec 05, 2017 11:45 pm Post

Kindle eBooks have a dedicated cover metadata, and the devices that read them tend to have an entry in the nav menu to call up that image.

ePub tends more toward loose conventions. It’s up to the reader to find the image as I understand it; most assume the first image in the book is the cover. Since the image would be on its own page, machine generated ToCs might list it as a result, since it would technically resemble a section.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

User avatar
Bridey
Posts: 179
Joined: Wed Nov 22, 2017 2:24 pm
Platform: Mac

Wed Dec 06, 2017 7:44 am Post

AmberV wrote:Since the image would be on its own page, machine generated ToCs might list it as a result, since it would technically resemble a section.


That circles the square, especially the difference between Kindle and ePub. Thanks. In iBooks I create with Scrivener, covers can be viewed if scrolled to the start of the books, but they don't get listed in the TOC or the navigation panels.

Here's a freebie example of an iBook where it seems to be (for me, at least) impossible to call up the full-page version of the cover. The thumbnail is there on the bookshelf, and that expands when the book opens, but after the text has hoved into view, the cover can only be seen again as a thumbnail on the bookshelf.

https://itunes.apple.com/gb/book/nichol ... 5025?mt=11

There are paid-for books like this as well.

In this example, from Anthony Doerr's All The Light We Cannot See, the cover is listed in the TOC but not in the navigation panel. Presumably the publisher has added an extra page with the cover embedded to force it into the TOC? The navigation panel says it is showing the TOC, but the cover isn't listed.

All The Light We Cannot See.jpg
All The Light We Cannot See.jpg (73.19 KiB) Viewed 132 times

ch
chuckmiller
Posts: 72
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Wed Dec 06, 2017 3:31 pm Post

So, back to the issue of internal links. I finally resolved the issue. As it turns out, I had separate front matter folders for my ebook and paperback (I was still determining which docs needed to be different between the versions). And, the links for my ebook were pointing to the pages in my paperback folder. At least it's working now.

The ToC is still misbehaving if I only provide a page with the <$toc> placeholder on it. With the "Convert document links to HTML links" box is checked, I still get a ToC that looks like the following...
toc-issue.jpg
toc-issue.jpg (80.9 KiB) Viewed 108 times

Just can't figure it out.

If I create my own ToC, everything falls under whatever happens to be the first item on the ToC as here...
toc.jpeg
toc.jpeg (185.32 KiB) Viewed 108 times

In this case, the whole book is listed a level under the Title page. It even shows up that way if I check the box for "Use flat table of contents" in the compile settings. Any thoughts?

When viewed in the Kindle app, there's also a space between the Title and Copyright listings and I have idea how to get rid of it. You can see what I mean here...
extra-space.jpeg
extra-space.jpeg (299.29 KiB) Viewed 101 times

I do know that it has something to do with that "Convert document links to HTML links" issue because when I uncheck it the space disappears. This has me completely stumped.

Also, I'm still struggling with one other thing keeping me from publishing my book. I have an image that refuses to be left justified. A signature in my forward needs left justification, but no matter what I do it always ends up center justified. Any solution to this?

User avatar
AmberV
Posts: 20600
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Wed Dec 06, 2017 6:56 pm Post

The flatness in the book’s spine is on account of your formatting on the ToC page. With each section centre-aligned in a single column like that, it is deriving no structure from the layout and produces a flat list. If for example you select the items you want in the ToC, and use the Edit/Copy Special/Copy Documents as Structured Link List and leave the indentation intact, you should see subsections in the ToC. Accordingly, I would say the flat centre-aligned column look is better for books that don’t need structure in the ToC.

I would also suggest putting a “Heading 1” title on this page. It may not be necessary for Mobi (it is for ePub), but in my testing it improves the layout. I got some strange results when I left a title off of this page as you did. Perhaps the title space glitch is a result of that.

If that doesn’t do the trick, to better see what is going on there, I would go into the gear tab in compile overview and check off Save source files in a folder with exported Kindle file. There will be a “contents.xhtml” file in the output folder, how does that look?

Likewise, if you examine the CSS/stylesheet.css file, you will find this line:

Code: Select all

/* Images */
img { display: block; margin: 1rem auto 1rem auto; }


That would explain why your images are centre-aligned. While you’re looking at the HTML files, you’ll note that images are identified by their file name—that would in theory give you a place to add an override in the CSS pane, for example:

Code: Select all

#imageid { margin: 1rem 0 1rem 0; }


But there is an unfortunate flaw in the implementation at the moment, whereby the file extension of the image is included in the ID, and the use of periods in an ID is invalid CSS—or rather #imageid.png technically means element with the ID “imageid” that is also assigned to the class “png”.

I’ll have to get back with you on that one. By the way so many of these things could be fixed with direct editing of the source files or an ePub->Mobi workfow with an editor in the middle. It’s nice to get things one-shot out of the compiler, but if you’re on a publication deadline I’d just be getting thing out. Up to you—but I always switch to post-compile antics when down to the wire on a project. I can get the process streamlined later for one-click updates.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

User avatar
AmberV
Posts: 20600
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Wed Dec 06, 2017 7:04 pm Post

Okay I think I found an approach that works:
  1. Throw a style on the image (I used “Left Image”).
  2. In your CSS settings, add this:

    Code: Select all

    .left-image img { margin: 1rem 0 1rem 0; }

.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

ch
chuckmiller
Posts: 72
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Wed Dec 06, 2017 7:44 pm Post

Well, I created a style as you suggested and assigned it to the image and gave

.left-image img { margin: 1rem 0 1rem 0; }

a shot, but it didn't work. I then modified it as

.left-image img { margin: 1rem 0 1rem 0; text-align: left; }

but it still didn't work. The image is still centered. Any other suggestions?

This is such a simple thing in practice. Why doesn't Scrivener offer image alignment after all this time?

User avatar
AmberV
Posts: 20600
Joined: Sun Jun 18, 2006 4:30 am
Platform: Mac + Linux
Location: Santiago de Compostela, Galiza
Contact:

Wed Dec 06, 2017 10:07 pm Post

Using the Mobi format will be considerably simpler in that regard, it’s more like a word processor conversion to HTML, like Scrivener has been in the past (so I don’t know what you mean about “after all this time”). If you want to make an image left-aligned, then you make it left aligned in the editor. That has worked for years.

The KF8 route is instead semantic and CSS based, so it does require a little more strategy and setup to work with. The advantage is that you do have more control, and the source material itself is cleaner and easier to work with (whereas working with RTF-HTML is a bit messy) in post-compile.

As for why the above isn’t working, I might have confused myself a bit as I was testing different methods at the time. I ran into an odd behaviour which I’ve made note of, and Keith mentions it will be fixed. Basically if you looked at your source files you may have noticed the paragraph your image was within ended up being classed as “left-image1”. For some reason it is intentionally dodging the CSS you added—and if you changed your code to “left-image1 img” then the compiler would switch to “left-image2”.

The reason it worked for me is something you can use as a work around: add a paragraph style to the Styles pane for “Left Image”. This will cause Scrivener to insert its own “.left-image” formatting in the Default Stylesheet. It won’t do anything about the image inside the paragraph, but for whatever reason it having done that to the paragraph makes it safe for you to add the “.left-image img” selector.

So to reiterate, there are a couple of early bird glitches here that are making this more complicated than it should be, but this work around won’t need to be undone later on given how it is set up.

We’ll get both the style selector and image ID problem fixed in the next update; thanks for helping us smooth out this workflow.
.:.
Ioa Petra'ka
“Whole sight, or all the rest is desolation.” —John Fowles

ch
chuckmiller
Posts: 72
Joined: Mon Nov 13, 2017 9:19 pm
Platform: Mac

Sat Dec 09, 2017 4:15 pm Post

Okay, so I followed the directions is the last post and setting a left-justified style woks fine for the text around the image, but the image is still center justified. I added your original .left-image img { margin: 1rem 0 1rem 0; } to the custom css and it didn't seem to have any effect.

I did note the renaming you spoke of in the compiled files, by the way.

I've also found that using Preserve Formatting seems to have no effect either here or elsewhere in my book. Is this not functioning in Scrivener 3? Or, could something in compile be overriding it?