Friday, June 3, 2011

Sexy eBooks

I finally formatted an eBook up the right way, and I just want to lay out what I did. My main text was Guido Henkel's Take Pride in Your eBook Formatting and I don't intend to repeat any of it. Consult that guide,just consider this a personalized companion article as well as a guide to people who are using jEdit to follow that series because they don't own a Mac. Your Mileage May Vary, I'm just muddling through while taking notes. If you want somebody to design your ebook for you, send Guido Henkel an e-mail. (Don't ask me.)

I don't really feel like waiting until Friday to post it. It still counts as my Friday article for this week, because it's really freakin' long, OK? Let's just jump into the freezing water.
UPDATE: I've formatted two more eBooks since I wrote this, so I'm updating the workflow to reflect what I actually do. I'll update the actual HTML head later, because I'm narrowing in on a universally useful one for my purposes.

Programs you will need:

Microsoft Word 2007 
or the word processor of your choice. If you're on Linux, you can use OpenOffice.


you should have this already if you own or publish eBooks. Get it now.


Word 2007
Make all the paragraphs, italics, and punctuation that you want, make sure the smart quotes and other auto-replace options are on and Find and Replace:

double quotes : " with "
single quotes : ' with '
em dash : -- with —
ellipses : ... with …

Just replace them with themselves and this will transform them into the appropriate special characters, and you won't have to think about changing all the straight quotes into curly quotes. Easy. If it doesn't happen, make sure the appropriate AutoFormat options are on in Word.

If you have a bunch of italics scattered through your text, do this!

italics : Ctrl-i to <i>^&</i>

Warning, when I did this, and there was a </i> at the end of the paragraph, when I later ran <p>$1</p> (see below) it put the </p> before the </i> and sent that to the start of the next paragraph. So, in addition to the jEdit stuff below, search for </i> and make sure your tags are closed.

jEdit Cleaning

Copy and paste your text into jEdit. Good. Now we want to put in our paragraph tags, so go to Search - Find, check the 'Regular Expressions' box, and Find and Replace like so:

paragraphs: ^(.+)$ with <p>$1</p>

Sexy. Now, save it as an html file. And make a backup for when you screw up. Then, if you took Option 1, you'll want to do all these Find and Replace
(DO NOT do & with &amp; at this time!)

“ with &ldquo;

” with &rdquo;

‘ with &lsquo;

’ with &rsquo;

… with &hellip;

— with &mdash;

Bold with <strong>Bold</strong>

In mine, I had these things too, so I assume you might too:

è with &egrave;

é with &eacute;

: <del>Strikethrough</del>

Good times, but now we have to make it look pretty.
jEdit Styles

Go Here for super details from Guido Henkel, so I'll just put the head I eventually cobbled together for a collection of short stories. (Feel free to steal it, if you can, but it's easy enough to make your own.)

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "">
     <style type="text/css">
       html, body, div, h1, h2, h3, h4, h5, h6, ul, ol, dl, li, dt, dd, p, pre, table, th, td, tr { margin: 0; padding: 0em; }
         text-indent: 1.5em;
         margin-bottom: 0.2em;
         text-indent: 0em;
         margin-bottom: 0.2em;
         font-size: 3em;
         font-weight: bold;
         margin-top: 5em;
         text-indent: 3em;
         font-size: 2em;
         page-break-before: always;
         text-indent: 1.5em;
         font-weight: bold;
         font-size: 2em;
         text-indent: 0em;
         text-align: center;
         text-indent: 0em;
         text-align: center;

Put </body> at the end of the html file.

Now we can put the appropriate chapter styles in (in this case, the title is "The Littlest Barnacle"):

<p class="chapter">The Littlest Barnacle</p>

We can find and replace our section dividers (replace *** below with whatever you happen to use):

*** with <p class="centered"><span class="centered">***</span></p>

Sprinkle the html file with the other appropriate style tags. Mostly I used "noindent" to remove the indentation for some paragraphs, but I also formatted the front and back matter to taste.

Finally I opened the saved html in a browser window and searched for &, then manually found it in jEdit and replaced:

& with &amp;

I only had three in the whole eBook, so it didn't take long.

So, now if you didn't do anything wrong, you have a sexy html to convert to various eBook formats. Thus:

Go Here (Part IX of Take Pride in Your eBook Formatting), Do That. Basically, in Level 1 TOC (XPath Expression) add:

//h:p[re:test(@class, "chapter", "i")]

I don't have anything to add, except to note that when it converts to MOBI, it will add a linked table of contents to the end of the ebook, so don't bother to put one in yourself. As for my actual html, I claim no special expertise, so if you spot any stupid errors, shout out!

Now put that MOBI up on Kindle and use the EPUB wherever they'll take it. It'll be pretty. Comment below with a link when you do, then consider joining me as I try to get Smashwords to take my pretty EPUB (or even PDF) instead of my utilitarian DOC.

And but so: check out my newest short story collection on Amazon. Preview it. It looks pretty damn good!
Related Posts Plugin for WordPress, Blogger...