
On Thu, December 8, 2011 2:26 pm, James Simmons wrote:
I just submitted a book of poetry a week or so ago which looked great as HTML but was unreadable (bad indenting) if you just converted the HTML to a MOBI.
Most people know that MOBI is just HTML encapsulated in a compression format. Many people don't realize, however, that Kindle only understands HTML version 3.2, and does /not/ understand style sheets. Many people /believe/ that style sheets are supported because the KindleGen program goes through a limited number of styles and actually converts them to their HTML counterparts. Thus, if you create some centered division of text by doing: <div style="text-align:center">...</div> KindleGen will actually convert that to <center>...</center> before storing it. You attempted to indent your poetry by using style attributes, e.g.: <p> <span style="margin-left: 2em;"><i>Not my way of Salvation, to surrender the world!</i></span><br> <span style="margin-left: 4em;"><i>Rather for me the taste of Infinite Freedom,</i></span><br> ... I do not believe that KindleGen has any built in rule that can convert "style='margin-left:x'" into anything the Kindle can understand. In this case, you would have been better off using the tried and true method of using non-breaking spaces to do the indentation (or maybe create a new HTML-to-Kindle preprocessor that Marcello can run before running KindleGen). A second problem you have here is...(wait for it)...tag abuse. You have taken a quote from another source (the poem) and told the device that it was a paragraph just like any other paragraph in the book. KindleGen will believe you, and carry that markup forward. Then, when you tell your Kindle "indent all paragraphs 5 characters" it will look at the first line of your poem and say "we're starting a new paragraph, I'd better indent that first line 5 em." I would have marked that verse as: <blockquote class="poem"> <div class="verse"> <i>Not my way of Salvation, to surrender the world!<br /> Rather for me the taste of Infinite Freedom,<br> ... Unlike <p>, <div> contains no semantic baggage that could violate your expectations.
The HTML was designed to look as much as possible like the printed book.
I can certainly appreciate the desire, but there are better ways to go about it. We all want to use the latest and greatest technology, but practically we must understand that when we do some old applications are going to get left behind (and Kindle is definitely an old technology). My general rule is to be suspicious of any style attribute. Sometimes they're best solution, but whenever you use one stop and consider what will happen if the device/software can't handle them. Style definitions should be separate from the content. If a <blockquote> needs to be indented in a manner different than it's default, instead of adding a "style" attribute to the <blockquote> element, add a class definition (it's OK for an element to belong to several classes) and add a style sheet definition for that class. E.g.: <style> .poem { margin-left: 5em } </style> <blockquote class="poem">...</blockquote> I prefer making stylesheets external to the HTML file. One reason is so that I can easily substitute my own style preferences for those of the publisher. (Justified paragraphs on a handheld device? gross.) A second is for testing purposes. Try constructing your file using only element classifications and true HTML elements, and then add all the styling necessary to make it "look as much as possible like the printed book" into an external style sheet. At this point, rename the style sheet (.css) file so your browser cannot find it. Does it still look acceptable? This is probably how it's going to look in the Kindle. Fiddle around here as much as you need to to get an acceptable, even if not perfect, look. Then go back and edit your style sheet file to make the result "look as much as possible like the printed book." HTH