How Markdown is Used in Leanpub

Even if you know Markdown, you need to learn a few things about how we use it at Leanpub.

Importing Markdown Files

To import Markdown files to Leanpub, you can just save them as .txt files, put them in your book’s manuscript folder, and refer to them in Book.txt (the list of files to be included in your book, in the order you’d like them to appear), and generate a new Preview of your book.

Heading Levels Become Chapters and Sections

First, we use # chapters, ## for sections and ### for sub-sections. (You can also use #### for sub-sub-sections, but don’t get carried away! Most technical books are good with just #, ## and ###, and most business and fiction books are good with just # and possibly ##.)

So, if you look at the top of the Markdown.txt file you’ll see that it has one #, meaning it is a Chapter.

Another thing this means is that one file can contain as many chapters or sections as you want: every # makes a new chapter; it has nothing to do with what file it is in. However, we strongly recommend having one file per chapter (or one file per chapter section), since it makes creating sample books easier and keeps your book directory cleaner. Since we recommend this, that’s what we’ll do in this example book.

We support Markdown syntax for links, as well as normal HTML links. Both of these are converted into functioning footnotes in the PDF. Here’s an example of a link to Leanpub.

And here’s what it looks like in Markdown (i.e., this is what you type in the text file to get that link):

[Leanpub](http://leanpub.com)

Markdown Extensions in Leanpub

We’ve made a few additions to Markdown for use in Leanpub. Two of the most important are tables and crosslinks. Furthermore, since Leanpub is so good for technical books, we also support extensions for external code samples, special directives for code syntnax highlighting, etc.

We use almost all of the Kramdown extensions (see http://kramdown.gettalong.org/syntax.html for a list of them). Two exceptions are:

1) HTML blocks – we don’t support HTML elements in our Markdown.

2) << becoming a left guillemet. We took this out when we created the external code sample syntax.

Email links are formatted by simply surrounding the address with < and >.

Just click on hello@leanpub.com to send us an email.

1 Just click on <hello@leanpub.com> to send us an email.