Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-22-2011, 07:20 PM   #346
mostlynovels
Member
mostlynovels doesn't littermostlynovels doesn't littermostlynovels doesn't litter
 
Posts: 10
Karma: 228
Join Date: Jan 2011
Location: USA
Device: past: Bookeen (2yrs); present: laptop(WinXP), 3.5"phone(WinMob6.5)
Problem: calibre seems to force color of links

Kovid, thank you for calibre.

When converting from EPUB (Default Profile) to MOBI (Default Profile), calibre seems to force the color of links to dark blue, even when all color entries are removed from the input EPUB css files & from the html files. The problem is that dark blue links are very hard to see on my readers' black backgrounds. (I read on LCDs and use white text on black background to reduce eye strain, and also decrease the brightness of the screen to save battery power and decrease it even more if ambient light is dim.)

This has happened on multiple books. A very short, free is example is http://www.smashwords.com/books/view/18215 (1,400 words). A longer, free example is http://www.smashwords.com/books/view/7707 (24,000 words). (I did of course try to just use smashwords' mobis directly, but unfortunately many have the text color forced to black such that my reader software can't change the display of text to white.)

Things I've tried with the conversion process that haven't worked:
- Removed all color entries from input EPUB css files & checked that the the html files didn't have any.
- Added extra css to calibre " a {color: aqua !important;} "

Things I've tried on the resulting MOBI that haven't worked:
- In my reader software, set the display color of links to a visible color like aqua. (Note this DOES work on many of the epubs & mobis direct from smashwords.)

Results of using Debug in calibre:
- Note: 1st removed all color entries from input EPUB css files & checked that the the html files didn't have any. Nothing was entered in the calibre's extra css box.
- For both book examples, the Structure stage's css file had no color entries.
- For the very short book, the Processed stage's css file had 2 color entries:
.calibre4 {
color: blue;
cursor: pointer;
text-decoration: underline
}
.calibre5 {
color: blue;
cursor: pointer;
font-style: italic;
text-decoration: underline
}
- For the longer book, the Processed stage's css file had 3 color entries:
.calibre3 {
color: inherit;
cursor: default;
text-decoration: inherit
}
.calibre5 {
color: blue;
cursor: pointer;
text-decoration: underline
}
.western6 {
color: blue;
cursor: pointer;
font-weight: bold;
text-decoration: underline
}

Is there something else I can try? If there isn't, and you conclude that calibre is forcing the color of links, please would you modify how calibre does the conversion, either to not force the color, or to give the user a choice of the color?

Thank you very much.

calibre v. 0.7.21 on WinXP

Last edited by mostlynovels; 01-22-2011 at 07:23 PM. Reason: typos
mostlynovels is offline   Reply With Quote
Old 01-22-2011, 11:46 PM   #347
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
use extra css to override link colors.
kovidgoyal is offline   Reply With Quote
Old 01-23-2011, 11:39 AM   #348
mostlynovels
Member
mostlynovels doesn't littermostlynovels doesn't littermostlynovels doesn't litter
 
Posts: 10
Karma: 228
Join Date: Jan 2011
Location: USA
Device: past: Bookeen (2yrs); present: laptop(WinXP), 3.5"phone(WinMob6.5)
Re: Problem: calibre seems to force color of links

@Kovid: as mentioned in OP, extra css was tried to override link colors " a {color: aqua !important;} " , but it didn't work.

This morning I again converted with the extra css " a {color: aqua !important;} " and used debug. Here are the results:

- Note: 1st removed all color entries from input EPUB css files & checked that the the html files didn't have any.
- For both book examples, the Structure stage's css file had no color entries.
- For the very short book, the Processed stage's css file had 2 color entries:
.calibre4 {
color: blue;
cursor: pointer;
text-decoration: underline
}
.calibre5 {
color: blue;
cursor: pointer;
font-style: italic;
text-decoration: underline
}
- For the longer book, the Processed stage's css file had 3 color entries:
.calibre3 {
color: aqua;
cursor: default;
text-decoration: inherit
}
.calibre5 {
color: blue;
cursor: pointer;
text-decoration: underline
}
.western6 {
color: blue;
cursor: pointer;
font-weight: bold;
text-decoration: underline
}
mostlynovels is offline   Reply With Quote
Old 01-23-2011, 11:47 AM   #349
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Then you're out of luck.
kovidgoyal is offline   Reply With Quote
Old 01-23-2011, 06:25 PM   #350
mostlynovels
Member
mostlynovels doesn't littermostlynovels doesn't littermostlynovels doesn't litter
 
Posts: 10
Karma: 228
Join Date: Jan 2011
Location: USA
Device: past: Bookeen (2yrs); present: laptop(WinXP), 3.5"phone(WinMob6.5)
Re: Problem: calibre seems to force color of links

@Kovid: Is there nothing else I can try?

Do you think that calibre is forcing the color of links? Is it your intent for calibre to force the color of links?
mostlynovels is offline   Reply With Quote
Old 01-23-2011, 07:00 PM   #351
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,857
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
I don't really care enough about this issue to look into the code to find out. Off the top of my head, I'd suggest using a higher specificity selector to ensure your css is overriding the default css.
kovidgoyal is offline   Reply With Quote
Old 03-13-2011, 04:12 PM   #352
mostlynovels
Member
mostlynovels doesn't littermostlynovels doesn't littermostlynovels doesn't litter
 
Posts: 10
Karma: 228
Join Date: Jan 2011
Location: USA
Device: past: Bookeen (2yrs); present: laptop(WinXP), 3.5"phone(WinMob6.5)
Re: Problem: calibre seems to force color of links

3 CHOICES OF WORKAROUNDS

After a lot of trial and error, learning, and more trial and error:

- It's definite that when converting to mobi, calibre (as of 0.7.45) forces the color of links to the named-color blue, by coding it into the mobi file (via mobi's font element, <font color="blue">...</font> ). This includes the mobi-generated TOC.

- Eventually I trial-and-errored my way to 3 choices of workarounds:
Choice 1. Do an additional conversion, mobi-to-mobi, using calibre.
Choice 2. Edit the mobi file itself.
Choice 3. During calibre's first conversion to mobi.

Each has some cons (described below) but hopefully the choices will at least be good starting points for other people who might want to change/remove the dark blue link color.

If you identify improved/additional workarounds, please post.



****************************************
****************************************

WORKAROUND CHOICE 1
DO AN ADDITIONAL CONVERSION, MOBI-TO-MOBI, USING CALIBRE

- Pros: easy; fast; risk free; minimal learning curve;
- Cons: requires forcing the links to one color (of your choice), preventing the reader from setting it themselves;

1. It's always a good idea to make a backup copy of your original!

2. Decide on the link color you would like. It can be one of the named colors, e.g. aqua, or it can be in the form e.g. #00FFFF . Substitute your desired color for aqua in the Replacement Text in step 3.

3. In calibre's Search & Replace screen
- In the First expression's "Search Regular Expression" box add a regex similar to:

Code:
(<a[^>]*?href[^>]*>[\w\W]*?<font color=")blue(">[\w\W]*?</font>)
- In the First expression's "Replacement Text" box add a replace string similar to:

Code:
\1aqua\2
4. In calibre's MOBI Output screen
- Select "Do not add Table of Contents to book" (this WILL leave a mobi-generated TOC that's already there).

NOTE: I did also try a regex+replace that would just eliminate the font element entirely (similar to the one in Choice 2), but it didn't work ... not sure why. Seems like if the above one worked, then one similar to Choice 2 should also.

****************************************

WORKAROUND CHOICE 2
EDIT THE MOBI FILE ITSELF

- Pros: doesn't require forcing the links a new color, allowing the reader to set it themselves;
- Cons: less easy; less fast; has the risks associated with exploding/rebuilding a mobi file; can be time consuming to learn to explode/rebuild mobi files;

1. It's always a good idea to make a backup copy of your original.

2. Explode the mobi file using MobiUnpack or other tool/application (search MR for details).

3. Edit the mobi file with your favorite regex engine that also does replace (standalone or part of a text editor).
- Can remove the named-color blue from the links, or if prefered can force it to a color of your choice.
- To remove the named-color blue from the links, use search & replace similar to:

Code:
Search:  (<a[^>]*?href[^>]*>[\w\W]*?)<font color="blue">([\w\W]*?)</font>
Replace: $1$2
- To instead change the named-color blue of the links to another color:

- Decide on the link color you would like. It can be one of the named colors, e.g. aqua, or it can be in the form e.g. #00FFFF . Substitute your desired color for aqua in the below Replace text.

- Use search & replace similar to:

Code:
Search:  (<a[^>]*?href[^>]*>[\w\W]*?<font color=")blue(">[\w\W]*?</font>)
Replace: $1aqua$2
4. Rebuild the mobi file using Kindlegen or other tool/application (search MR for details).

****************************************

WORKAROUND CHOICE 3
DURING CALIBRE'S FIRST CONVERSION TO MOBI

- This is based on using a higher specificity selector, as Kovid suggested.

- Pros: easy; fast; risk free; minimal learning curve; no additional conversions/editing required;
- Cons: doesn't change the dark-blue color of mobi-generated TOCs; requires forcing the links to one color (of your choice), preventing the reader from setting it themselves;

1. It's always a good idea to make a backup copy of your original!

2. Decide on the link color you would like. It can be one of the named colors, e.g. aqua, or it can be in the form e.g. #00FFFF. Substitute your desired color for aqua in the CSS in step 3.

3. In calibre's Look & Feel screen
- In the Extra CSS box add CSS similar to:

Code:
.lnk_txt {
color: aqua !important;
text-decoration: underline !important;
}
4. In calibre's Search & Replace screen
- In the First expression's Search "Regular Expression" box add a regex similar to:

Code:
(<a[^>]*?href[^>]*>)([\w\W]*?)(</a>)
- In the First expression's "Replacement Text" box add a replace string similar to:

Code:
\1<span class="lnk_txt">\2</span>\3
****************************************
mostlynovels is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
main menu, section menu, css for calibre mobipocket output naisren Calibre 2 08-23-2010 11:42 PM
Trying to get consistent look to all output daveps Calibre 0 03-08-2010 02:18 PM
Anyone Have mobipocket desktop? Mobipocket server is down. Ireadfreely Kindle Formats 3 10-27-2008 10:29 AM
convert from 'new' mobipocket to 'old' mobipocket? Indigo Ink Kindle Formats 11 06-22-2008 01:43 AM
Mobipocket Reader 4.8 and Mobipocket eNews Creator Mobipocket Reading and Management 1 01-29-2004 08:03 AM


All times are GMT -4. The time now is 12:17 AM.


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