Bookshelf | Reports | Community | KDP Select

Home » Amazon KDP Support » Ask the Community » Formatting

Thread: html, Programming book, code samples, appropriateness


This question is answered. Helpful answers available: 2. Correct answers available: 1.

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 8 - Pages: 1 - Last Post: Jun 14, 2012 7:21 PM Last Post By: punchygonzales
lancairflyer

Posts: 8
Registered: 06/12/12
html, Programming book, code samples, appropriateness
Posted: Jun 12, 2012 3:53 PM
 
Click to report abuse...   Click to reply to this thread Reply
I've just completed a programming language book. Formatted 8-1/2 x 11 in Open Office it's 400+ pages. I tried to output it in html and it's awful. Way too much white space surrounding everything and lots of pre lines are broken. I tried hand editing it but gave up. Too much rubbish to deal with. I exported the doc as .txt .

I've decide to hand code a new xhtml version complete with custom css. I've read conflicting things on tables. I use two column tables with a code line number on the left and a technical description of what that line of code does on the right. Works fine, but is it legit on a kindle?

I also need to include a zip of source code with the book for the user to upload on to his/her computer. How is that handled? Is it even possible?

Candidly, I can't see anyone using a kindle to read this type of technical book. I use color, and limit code lines to 120 characters in a mono font. I'm expecting purchasers to use an ereader on a computer to read and test all on one platform.

Comments? I don't own a Kindle or any other hardware based ereader device, so I have no first hand experience with them.
punchygonzales

Posts: 2,853
Registered: 11/26/11
Re: html, Programming book, code samples, appropriateness
Posted: Jun 12, 2012 5:23 PM   in response to: lancairflyer in response to: lancairflyer
 
Click to report abuse...   Click to reply to this thread Reply
First let me say that I'm glad you've have the good sense to see that most people wouldn't buy this in e-book form unless they owned a larger device like an iPad or Kindle DX. On the other hand, it costs you only your time to try it. But obviously a print book is going to sell better with something like this.

Before you give up and go to a .txt file and lose all your formatting, try downloading Calibre (it's free). Bring your .odt file into it and save it as a .rtf file. Then open the .rtf file along with your html editor and copy & paste the entire .rtf document into the editor. (That usually works better than importing it.) This produces a halfway clean file (much cleaner than trying to save .rtf from OpenOffice). You'll have to go through and delete some formatting at the beginning of each paragraph. It's mostly just font and text alignment code. You can do a “search & replace,” replacing the code with blank space very quickly. If you already have tables set-up in Word, I doubt they will transfer, so you may have to redo those. But this way gives you some pretty clean html really fast with all your italics, bolding, underlines, quotes, and whatnot right where they should be. (Exporting HTML from Word or OO generates some really bad HTML and likes to place things like italics outside of paragraph tags instead of within them where they ought to be.)

As to the zip folders, you can hyperlink to them on the web somewhere, but that's about it. Besides, it's not like readers could (or would want to) open a zip folder on their e-reader anyway. It's not a computer, so it would be pointless.

Good luck!
mrlasers

Posts: 1,633
Registered: 07/06/11
Re: html, Programming book, code samples, appropriateness
Posted: Jun 12, 2012 6:45 PM   in response to: lancairflyer in response to: lancairflyer
 
Click to report abuse...   Click to reply to this thread Reply
I've read programming books on a Kindle. Primarily using Kindle for PC, as that makes the most sense given the standard use case for such books, but also on an eInk Kindle device. They're certainly readable when formatted properly in either scenario.

If you're looking for a specific example, I'd point you toward O'Reilly's [i]Javascript: The Good Parts[/i] as a very good example of a readable programming book on Kindle, though I'd guess that applies to all of the O'Reilly books. Unfortunately the sample doesn't really include any code listings, but it might be worth a look: http://www.amazon.com/JavaScript-The-Good-Parts-ebook/dp/B0026OR2ZY.

[b]Tables[/b]

Depending on how much information you're trying to fit into the table they may or may not work well for you. Tables have definitely improved with Kindle Format 8, but they're still not perfect and it's far too early to disregard Mobi7 entirely.

Do some tests and preview them using all of the device modes of Kindle Previewer before you go to the trouble of formatting your whole book. You may find that they work great, you may not. There are definitely other ways to present code line numbers and their descriptions if you find that the results are unsatisfactory.

[b]Code listings[/b]

Be sure to explicitly set left-alignment, in addition to the monospace font, for your code listings to prevent the automatic justification on Kindle.

[b]Zipped source[/b]

This should be handled with a link to your website where the source files can be downloaded. Make sure that the full URL for this page isn't something that is likely to change, as it'd be pretty annoying for customers to purchase the book at some point in the future only to discover that there is no easy way to access the example source files. There is no way to bundle arbitrary external content with Kindle books.

--
MrLasers
eBook Formatting & Production
http://www.mrlasers.com
skookumpete

Posts: 466
Registered: 07/25/11
Re: html, Programming book, code samples, appropriateness
Posted: Jun 12, 2012 9:23 PM   in response to: lancairflyer in response to: lancairflyer
 
Click to report abuse...   Click to reply to this thread Reply
If it's for use on a computer, what advantages do you see in an ebook format as opposed to ordinary HTML pages to be read in the browser?
lancairflyer

Posts: 8
Registered: 06/12/12
Re: html, Programming book, code samples, appropriateness
Posted: Jun 14, 2012 5:41 PM   in response to: punchygonzales in response to: punchygonzales
 
Click to report abuse...   Click to reply to this thread Reply
I tried using Calibre.

I took the OO document and had Calibre convert it to epub. Way too many issues with the presentation.

I'll give the rtf format a try, but I'm at least half way through converting the whole doc to hand adjusted xhtml.
lancairflyer

Posts: 8
Registered: 06/12/12
Re: html, Programming book, code samples, appropriateness
Posted: Jun 14, 2012 5:55 PM   in response to: mrlasers in response to: mrlasers
 
Click to report abuse...   Click to reply to this thread Reply
I see there's no way to answer a particular post.

mrlasers:

Some of my tables cells are large to explain a particularly tough line of snippet of code. The small form factor of the ereaders isn't really appropriate for this type of book. I assumed folks would use a PC based reader.

I had heard that the kindle could be hooked to a PC and items transferred from it. I guess I just assumed there was a way to load the kindle up via an ebook format and then xfer files to the PC.

Thanks for the heads up that my assumption was bogus.

What do you think about putting the source code in as X number of hidden paragraphs and having one non hidden routine that the purchaser copies to his disk and it has the brains to extract the source code from the hidden p's? Would that pass Amazon's inspection/rules/criteria/whatever?
lancairflyer

Posts: 8
Registered: 06/12/12
Re: html, Programming book, code samples, appropriateness
Posted: Jun 14, 2012 5:57 PM   in response to: skookumpete in response to: skookumpete
 
Click to report abuse...   Click to reply to this thread Reply
skookumpete

i like that handle.

The only reason to not have it pure html is because Amazon wants it in their format. If there were a way of selling it as pure html that would be great.
punchygonzales

Posts: 2,853
Registered: 11/26/11
Re: html, Programming book, code samples, appropriateness
Posted: Jun 14, 2012 7:15 PM   in response to: lancairflyer in response to: lancairflyer
 
Click to report abuse...   Click to reply to this thread Reply
"I took the OO document and had Calibre convert it to epub."

NO! Make your mobi file first with KindleGen or Previewer. Then you can use Calibre to make an epub copy from that mobi. But don't ever use Calibre to make a mobi or epub file from anything other than an already existing mobi or epub.

I only suggested it as a means of getting rid of some bad formatting in your .doc files before pasting the content into your HTML editor. Actually, now that I think of it, OO producers halfway decent .rtf files too, so you might be able to skip Calibre altogether.

Also, when you've got your finished HTML, make sure it can pass the validator at W3C before trying to make a mobi from it:

http://validator.w3.org
punchygonzales

Posts: 2,853
Registered: 11/26/11
Re: html, Programming book, code samples, appropriateness
Posted: Jun 14, 2012 7:19 PM   in response to: lancairflyer in response to: lancairflyer
 
Click to report abuse...   Click to reply to this thread Reply
"The only reason to not have it pure html is because Amazon wants it in their format. If there were a way of selling it as pure html that would be great."

The thing is, most people would like to have the code on a some kind of page they can access with their computer so they can just copy and paste it into their own HTML editor. You can't do that from an e-book. When people sell print books, they typically will also have some web pages that readers can go to and retrieve the same code that's in the print book. Or (and much better) they'll have a CD Rom attached to the inside flap of the book with all the codes on it. You obviously can't do the latter with an e-book. But you really need to think about having a website with the codes available somehow.
Legend
Helpful Answer
Correct Answer

Point your RSS reader here for a feed of the latest messages in all forums