Kindle Forum banner

KISS formatting using Markdown and Calibre, part 1 of 3

3230 Views 11 Replies 7 Participants Last post by  daringnovelist
Since I've had a few questions lately about how to do the easy Markdown-and-Calibre formatting I'm always yapping about, I thought it might be a good idea to do a quick basic intro - "for whom it may concern" ;D

Who WILL it concern? Anyone who wants to have a nice, comfy "fallback position" for formatting - meaning something that will work on all bookreaders, will look not-fancy-but-perfectly-OK - and is quick-and-easy to do.

Why Markdown? Because it's completely app-independent. It will work in any text editor you like, on any gadget you like. Markdown is nothing more than using a few special characters to "signal" headers, bold, italics, etc. within a basic .txt file. Meaning you can write on anything whenever you need to.

Working at home? Use your PC or Mac. On the bus or train with your iPad? Write away - and you can do so FULLY FORMATTED IMMEDIATELY - mail or DropBox it to yourself, and then later copy-paste into your master text on your home machine. Forgot your iPad and only have your Android phone? Write away, mail/DropBox it, etc. Sitting at Starbuck's with a borrowed Chromebook? Write away in Google Docs, copy-paste the day's work to mail/DropBox, etc.

Markdown-and-Calibre formatting has limitations, to be sure - the "worst" is that all paragraphs will be either indented or not-indented, and you can't add tables - and you can't center images (I know there are "dialects" of Markdown that can do that, but Calibre only "speaks" basic Markdown, so it's best to stay with that). Centering headers will take ONE line of CSS, to be added right there in Calibre's formatting-options popups.

BUT other than that, a little creativity will go a looong way - and if you check out the top-selling ebooks on Amazon, you will find that their formatting is not always state-of-the-art. Formatting just has to be "user-friendly", and Markdown is quite capable of that. And, more importantly, by sticking with basic Markdown, you will end up with a basic EPUB that will look and work the same across most if not all readers with no extra formatting or hacking needed!

And, once you have that Markdown'ed master text, you can format in Calibre to just about any other format you want - including nice, clean PDF if you want to be print-ready or offer that option to your readers. You're not even stuck with Calibre - multiple other formatting apps "talk" Markdown these days, so your hard work can be effortlessly transferred to other formatters if you should so prefer at any point.

One aside - if you DO want state-of-the-art formatting, and you're willing to do the work involved, get Guido Henkel's Zen of eBook Formatting - it's THE bible on formatting. BUT even if that's the way you choose to go, your Markdown can be formatted to html and THEN hacked according to Guido's bible -- starting in Markdown will still save you a lot of time and grief, IMHO.

So if you're still here, here's how you set up your WIP using Markdown-and-Calbre.

First, install Calibre on your PC/Mac/Linux - you'll find it here :

In the basic text editor on your PC/Mac/Linux, create and save a .txt file for your book - such as the WIP.txt shown here (pls type something more-or-less like the below into your WIP file, it will make sense in a few minutes) :

Save the file, then import the WIP.txt into Calibre :

With your new file/book selected, on the options below the book icon, click "Click to Open" to open the folder where Calibre has placed (a copy of) your text file :

Open the text file you see in the folder into your preferred text editor - the more basic the text editor, the better (gedit, NotPad, etc.)

Now you can write directly into the text file, or copy/paste from any and all other sources.

When done, save -- don't close the file, just save.

To see how your WIP will look when formatted, format it as step-by-step'ed below.

With your WIP selected, hit the 'c' key (shortcut for 'Convert books') :

Choose/set options for TXT-to-EPUB conversion as shown below under "Look and feel" :

... then set your input format to Markdown under "TXT input" :

Hit Enter, and wait for formatting to end.

Hit the 'v' key (shortcut for 'View book') and Calibre will open your EPUB in its built-in reader :

Check out your formatting. Notice the nice bolds - and the italics caused by a single asterisk instead of double, and the sizes of the ## and ### type headers (which, as you may have guessed, correspond to the html h1, h2, etc ... tags).

If you want to change something, close the reader, update the text file, save, switch to Calibre, and again hit 'c', Enter ... wait ... then 'v' -- that sequence will become second nature to you very fast ;o)

You may also simply want to change your formatting options (less/more indent, non-centered headers, etc.) -- for a quick experiment, just hit c, choose "Look and Feel", remove the "h1,h2,h3,h4,h5,h6{text-align:centered}, and format, then view again. Now the headers will be left-justified.

Rinse and repeat the update, save and c-Enter-wait-v sequence above until you're happy with your formatting option settings.

Then just go ahead and write your book. You can work in the text editor on the same machine as Calibre, or you can work anywhere else. To get the stuff into your WIP, just put it somewhere from where you can copy/paste to your WIP - then save, switch to Calibre and do the c-Enter-wait-v to check.

That's all for setting up your almost-WYSIWYG ebook creation. Upcoming part 2 will deal with easy setup of title page, chapters, copyright'n stuff page(s), page breaks and TOC, and conversion to MOBI (as simple as choosing that format and go). Part 3 will complete the stuff by showing the final complete book setup and EPUB verification (which will be about 5 minutes work for an entire book).

Meanwhile, you can learn the entire Markdown syntax interactively, for free, and in approx. 10 minutes here :

Have fun ;D
See less See more
1 - 12 of 12 Posts
Def bookmarking this for later use. I always appreciate tutorials of this kind, Thanks!

What would the benefits be of doing it this way instead of just using word and calibre ?
Trying it out will take about 15 minutes. After that, you'll be able to make up your own mind.

If you have a Word-based method that allows you to format an EPUB from scratch in less than ten minutes, and convert to most other formats in five, then you probably don't need to change anything ;o)
Excellent. Thanks for this fine, first part of your tutorial. The reason I like this kind of article is because it respects open writing tools. Personally I prefer open source tools that have been ported to most if not all of the major platforms. That includes the most excellent Calibre, which now appears to include an ePub editor that is a peer to Sigil.

Now I've been writing using low-cost or free Markdown editors for a while now - Mou on OS X, Atom, GitBook, Haroopad, Lightpaper, LookDown, MacDown, and Typora. Most if not all of them understand Markdown Extended which supports tables - a must-have feature IMHO.

Generally I prefer to avoid proprietary writing tools and for that reason refuse to use MS Word, though LibreOffice is right by me.

For the technical writers, Markdown Extended also lets you type in math formulas - oh yeah!

I registered at kboards a moment ago precisely because I wanted to thank you for writing this tutorial. Very good indeed.
See less See more
Thanks for posting this. I posted something similar two days ago,211637.msg2950800.html#msg2950800. I'm looking for a way to use Guido's book and Scrivener without using word to format with TextMate and Calibre.

After some discussion including Guido's comments, I came up with using multimarkdown in place of word. I've just started trying to figure this out. I'm also trying to use Marked 2 in this mix. Admittedly, I really don't know what I'm doing as this is my first time attempting to format. So yes, I need as much help as I can get trying to create a workflow that will work for me and maybe others.

If I'm reading your post right Markdown Fanatic, are you saying that Calibre won't recognize multimarkdown but will markdown?

I would appreciate any thoughts you have on what I'm attempting to do using multimarkdown with Scrivener. I know you don't use programs like Scrivener but hoping you will have some thoughts you can share.

I'm really looking forward to the next 2 parts of your post.


See less See more
There are many excellent variants of Markdown, but Calibre does not recognize any of them (unless you want to fiddle with plugins). So my own preference, and the subject of this 3-part tute, will be basic Markdown + Calibre.

Once a writer knows that, s/he will be able to branch out into any and all "higher" Markdown dialects and add html to selected spots in a Markdown-formatted doc to add those finer points that Markdown can't ;o)
What I do is write in Extended Markdown with Mou on OS X. Then I export to HTML and import the HTML into Calibre. Calibre will convert HTML to ePub just fine.
Thanks Johannesrexx,

sent you a pm, don't want to highjack this thread with my questions.

I love Markdown. It carries its intent across platforms and software so well.

I have my own workflow, but adjust it as I find new tools, so I'll be keeping this around.

The ultimate thing I would love is to have a filter that would turn Markdown into InDesign codes as well, so I could have ONE original that will go cleanly into everything I do.  I have found a website which will turn any kind of code into any other kind of code (including the basic Pagemaker Markup that lets you import styled plaintext into InDesign) but I don't recall where I put the book mark.

1 - 12 of 12 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.