08-18-2012, 02:42 AM | #1 |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
Centered lines and conversion to epub
I've used Calibre to format quite a few books (exporting from Word as filtered html and importing the html into Calibre). I've finally locked horns with a problem I've kind of been ignoring for a while: centered lines often do not display correctly in epubs direct from Calibre. The problem is the reading software treating the centered lines as though they are indented, so that the centered text is a little to the right of center. I first noticed it on the Nook, and in Aldiko on Android. I believe I've seen it in ADE, as well.
The problem starts with Word's export, which (even if you're very careful in defining your Word styles) does not specify "text-indent: 0" in centered styles. The solution, as I've learned, is to add that line to every style in the CSS stylesheet that's centered. I've started doing that with Sigil, after converting to epub. It's a picky job, prone to error, and maddeningly time consuming--especially if you have to go through repeated iterations as you discover errors to fix. It also seems like it should be unnecessary. Some reading software is smart enough to center text when the style says align center. But since a lot aren't smart enough, I wonder if Calibre could be, instead. Would it be possible to incorporate in the conversion a check for centered styles, and the addition of the "text-indent: 0" line in all styles that call for center alignment? It would save a heap of fiddly work afterward, and make the books look better. |
08-18-2012, 02:54 AM | #2 |
creator of calibre
Posts: 43,963
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
It's certainly possible to do this, but I'm not sure its a good idea. Doing it would be making calibre insist that any element which is aligned center have no text indent. That is not always correct. text-indent applies to only the first line of an element. So someone could, for some reason want to affect the indentation of the first line in a centered block. I cant think of a reason why they would want to do this, but experience has taught me that someone, somewhere will
It should be relatively simple to create a plugin (or add an option to the modify epub plugin) to do this to an existing epub witha couple of clicks. |
Advert | |
|
08-18-2012, 03:12 AM | #3 |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
Thanks, Kovid. I guess I assumed it would be the kind of thing one could select with a check box, much as one now can check to add an indentation. So those wild and crazy guys who want their centered text off-center for some reason could opt out.
|
08-18-2012, 03:48 AM | #4 |
creator of calibre
Posts: 43,963
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
This is the kind of specialist tweak that I dont want to start adding options to the calibre conversion for. I try to keep the options in the conversion dialog as generally applicable as possible.
|
08-18-2012, 10:13 AM | #5 |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
I understand. In that case, it seems to me that far more people are likely to want their centered text to actually appear centered, than not, yes?
|
Advert | |
|
08-18-2012, 11:53 AM | #6 |
creator of calibre
Posts: 43,963
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Then they should center their text in the input document, without an indent.
What you are asking for is that calibre make a destructive change to the document during conversion. Therefore that change needs an option to turn it on. And that option is only relevant to people whose input documents specify a text-indent for centered paragraphs where they are not wanted. Adding options for every little tweak like this is not a sustainable strategy. |
08-18-2012, 01:24 PM | #7 | |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
Quote:
Calibre leaves it that way, silent on the indentation--and some software (like the more recent ibooks app) is smart enough to assume, in absence of an actual indent command, that the text should be truly centered. Other software, like Nook and Aldiko, assume that every first line should be indented, regardless of alignment, unless explicitly told otherwise. That, to me, is dumb--but that's the way they seem to work. And I've seen many books in Nook and Aldiko with faulty centering. I'm asking that Calibre make allowance for that particular design deficiency by making explicit what can reasonably be assumed to be implied by the term center aligned. |
|
08-18-2012, 03:03 PM | #8 |
creator of calibre
Posts: 43,963
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Unfortunately, the text-indent property is inherited, which means that the assumption that word makes that not setting a text-indent on an individual element is equivalent to text-indent:0 is not actually true. And if calibre enforced that, then it could potentially break the layout in a document produced by someone who, correctly (unlike Word), assumes that not setting text-indent does not imply that text-indent is zero.
What I'm saying is that adding text-indent:0 to an elements style changes that style in a potentially destructive fashion, even in the presence of text-align:center. That change may well be desired in a majority of cases, but it should not be applied automatically. And as I said before I'm not willing to create a new option for this. |
08-18-2012, 03:05 PM | #9 |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
Come to think of it, when I looked at the original CSS in the epub, the only styles that had lines specifying text-indent were the ones that actually wanted an indent. So if Calibre looked for a centered style, and added the text-indent: 0 line only where no other indent specification was given, it wouldn't affect the style in a case where someone actually requested a first-line indent.
|
08-18-2012, 03:20 PM | #10 |
Resident Curmudgeon
Posts: 74,455
Karma: 129358310
Join Date: Nov 2006
Location: Roslindale, Massachusetts
Device: Kobo Libra 2, Kobo Aura H2O, PRS-650, PRS-T1, nook STR, PW3
|
If you look at your ePub under the hood, you will find a lot of mess. Use Sigil (after first turning off Tidy) to fix up the mess Word made of your ePub.
|
08-18-2012, 03:21 PM | #11 |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
Sorry, we cross-posted. What's the property inherited from?
Well, it's your program, obviously. And I know (now) how to fix it after the fact. But I do think it would add to the usefulness of the program, if you ever change your mind. Because a lot of people use Calibre who are not necessarily comfortable with going in and messing with the CSS of a finished ebook. And to me, it seems like a noticeable deficiency--not in Calibre, but in the Word/Calibre/reading-software system. Any one of the three could address the deficiency, but I don't have a good way to ask the developers of Word or the reading software. |
08-18-2012, 03:39 PM | #12 |
creator of calibre
Posts: 43,963
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
|
08-18-2012, 03:44 PM | #13 | |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
Quote:
Here's the thing. In my experience, making an ebook, even with good help, involves repeated iterations of building, finding things to fix, and rebuilding. If you have to go in and re-re-retweak everything after each build, it's just not worth the hassle. My point in bringing up this particular issue is that it seems (to me) like one place where repeated retweaking should not be required. |
|
08-18-2012, 03:50 PM | #14 |
Jeffrey A. Carver
Posts: 1,355
Karma: 1107383
Join Date: Aug 2008
Location: Massachusetts, USA
Device: Lenovo Yoga Tab Plus, Droid phone, Nook HD+
|
You mean, say, a centered style based on Normal? Or a centered style based on "Normal No Indent"? I can't see in the attributes where the ancestor is indicated. Here's one:
.Scenebreak { display: block; font-family: "Times New Roman", "serif"; font-size: 1em; line-height: 1.2; margin-bottom: 3pt; margin-left: 0; margin-right: 0; margin-top: 6pt; text-align: center; text-indent: 0 } (I added the indent 0 line.) I know, in Word, that it's based on Normal, with certain other elements defined, such as no indent, centering, and spacing above and below. But I can't tell that from looking at this part of the CSS. |
08-18-2012, 03:54 PM | #15 |
creator of calibre
Posts: 43,963
Karma: 22669822
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I mean any ancestor of the tag that the style is being applied to.
<div style="text-indent:2em"> <div> <p style="text-align:center">This para will also have text-indent</p> </div> </div> |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to adjust table spacing/lines in Calibre conversion? | mischko | Calibre | 5 | 03-02-2012 09:43 AM |
Blank Lines in MOBI-Conversion | ulrichbi | Conversion | 3 | 01-19-2012 04:50 AM |
Empty lines in epub without apparent reason | sinusLog | Conversion | 6 | 09-30-2011 01:19 AM |
Lines became paragraphs after .lit to .mobi conversion | Piper_ | Calibre | 11 | 09-19-2010 05:11 PM |
.epub hyperlinks, centered and non indented text. | Xabache | ePub | 2 | 09-13-2010 01:11 PM |