Compiling for Kindle: underlines

bo
bostonquad
Posts: 9
Joined: Tue Nov 28, 2017 7:12 pm
Platform: Mac

Tue Jan 02, 2018 1:15 am Post

My Kindle came with a user manual that uses thick underlines for hyperlinks. Here's a closeup:
s2.jpg
s2.jpg (170.56 KiB) Viewed 431 times

When I compile to Kindle Mobi, my underlines look rather weak:
w2.jpg
w2.jpg (159.93 KiB) Viewed 431 times

If I compile to Kindle KF8, the underlines disappear completely.
Can someone suggest how to get underlines to appear on the Kindle as they do in the first photo?
Thanks!

User avatar
nontroppo
Posts: 868
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Tue Jan 02, 2018 1:38 am Post

You will need to add a bottom border to your links. Edit your current compile format and add this text to the custom CSS section:

Code: Select all

a { text-decoration: none!important; border-bottom: 2px solid black!important; }


Screen Shot 2018-01-02 at 09.35.27_SMALL.png
Screen Shot 2018-01-02 at 09.35.27_SMALL.png (129.12 KiB) Viewed 425 times


I don't own a kindle, but this works with EPub3 anyway...

bo
bostonquad
Posts: 9
Joined: Tue Nov 28, 2017 7:12 pm
Platform: Mac

Wed Jan 03, 2018 6:38 pm Post

This looks exactly like what I'm looking for; thank you!
Unfortunately, it doesn't seem to work (and I tried both mobi and epub compiles).
However, Scrivener is new to me, so I suspect I need to learn more about compiling in general.
I do understand CSS, so I have a chance of getting this to work if I can figure out the Scrivener part.

User avatar
nontroppo
Posts: 868
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Thu Jan 04, 2018 1:53 am Post

Check if this project works for you (it does for me for EPub3).

Scrivener Test.scriv.zip
(76.79 KiB) Downloaded 20 times


Screen Shot 2018-01-04 at 09.53.25.png
Screen Shot 2018-01-04 at 09.53.25.png (13.65 KiB) Viewed 344 times

bo
bostonquad
Posts: 9
Joined: Tue Nov 28, 2017 7:12 pm
Platform: Mac

Fri Jan 05, 2018 7:15 am Post

nontroppo wrote:Check if this project works for you


It's pretty close - thank you! (It looks like text-decoration: none is not being respected. Maybe a bug?)
This is closer than I got, and I can use this for now.

When I have more time, I expect to track down what I missed.
IMG_7420.jpg
IMG_7420.jpg (65.49 KiB) Viewed 290 times

User avatar
nontroppo
Posts: 868
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Fri Jan 05, 2018 8:07 am Post

Can you edit the mobi file that does what you want and see what the CSS says? text-decoration is the most basic of CSS rules, strange if it didn't support it! Perhaps there is another problem to do with the parent element of the links?
There are some very poorly supported extensions of the CSS text-decoration rules so maybe it is using those (which would make kindle an exception)?

https://developer.mozilla.org/en-US/doc ... e-position

bo
bostonquad
Posts: 9
Joined: Tue Nov 28, 2017 7:12 pm
Platform: Mac

Sun Jan 07, 2018 6:35 am Post

nontroppo wrote:Can you edit the mobi file that does what you want and see what the CSS says?


Thanks for the suggestion, but I can't even confirm the user manual is a mobi file. I don't see how to access it (or my other Kindle ebooks) at the file level.

bo
bostonquad
Posts: 9
Joined: Tue Nov 28, 2017 7:12 pm
Platform: Mac

Thu Jan 11, 2018 5:37 am Post

Ah! I have more insight, leading to a new question...

The insight: based on what I read here and here, I need to use Amazon's own non-standard <mbp:nu> tag to get the underline to not happen (nu means no underline). Apparently, Kindle ignoring text-decoration:none is a known issue.

So my new question...
How do I get this to be part of the Scrivener compile? I see how to add CSS, but not HTML tags.

User avatar
nontroppo
Posts: 868
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Thu Jan 11, 2018 6:12 am Post

You can use a character style in the editor to wrap your links:
Screen Shot 2018-01-11 at 14.01.55_SMALL.png
Screen Shot 2018-01-11 at 14.01.55_SMALL.png (32.21 KiB) Viewed 114 times


And use prefix/suffix to add the HTML tags:

Screen Shot 2018-01-11 at 14.02.51_SMALL.png
Screen Shot 2018-01-11 at 14.02.51_SMALL.png (13.99 KiB) Viewed 114 times


This creates this HTML in the .mobi:
Screen Shot 2018-01-11 at 14.08.07.png
Screen Shot 2018-01-11 at 14.08.07.png (23.29 KiB) Viewed 114 times


The problem is this won't apply to the automatically generated TOC, only text with this style applied manually. For the TOC, you could just create your TOC manually, or edit the mobi file to wrap the TOC in the <mbp:nu> tag.

Why Kindle doesn't support such a basic CSS rule, and forces authors to inject non-standard HTML is beyond me...

bo
bostonquad
Posts: 9
Joined: Tue Nov 28, 2017 7:12 pm
Platform: Mac

Mon Jan 15, 2018 6:39 am Post

That looks promising, but when I tried it, it didn't work. (And yes, I applied it to an underline in the body, not the TOC.)

Inspired by your illustration, I'd like to check my new mobi file's HTML. But it appears to be a binary file. What tool did you use to reveal the mobi's HTML?

User avatar
nontroppo
Posts: 868
Joined: Mon Mar 05, 2007 5:22 pm
Platform: Mac
Location: Airstrip One

Mon Jan 15, 2018 9:32 am Post

EPub/Mobi are zip files, so yes technically binary so you can either unzip them first or use Calibre: https://calibre-ebook.com/about that can edit them directly (including a comprehensive HTML+CSS debugging environment). Scrivener also allows you to "Save source files..." in the compiler for both kindle and EPub, which gives an uncompressed version to play with directly...
Screen Shot 2018-01-15 at 17.31.39_SMALL.png
Screen Shot 2018-01-15 at 17.31.39_SMALL.png (12.3 KiB) Viewed 33 times