How does Leanpub use Markdown to make ebooks?

Leanpub launched in April 2010. We were the first website in the world to use Markdown to produce ebooks. We were the first, and we're still the best.

Over the past 14+ years, authors have written thousands of ebooks in Markdown on Leanpub. These ebooks weren't just written on Leanpub, they were previewed on Leanpub (with one click), and published on Leanpub (also with one click).

When you publish on Leanpub, your book is for sale in the Leanpub store. The Leanpub store is a great place to sell ebooks. We pay 80% royalties, and we've paid over $13 million USD in royalties to our authors.

When you use Leanpub to write and produce an ebook, you can sell it wherever you want. You own your work. So, you can sell it other places like Gumroad if you choose to, as well as (or even instead of) on Leanpub. (Learn more: how Leanpub compares to Gumroad.)

Now, how exactly does Leanpub use Markdown to make an ebook?

You can write a Leanpub book in 100% standard Markdown as defined here by John Gruber. For example, here's some completely standard Markdown text, including formatting in bold and italic:

# The First Chapter Name

This is the first paragraph in the chapter.

This is the second. This is *italic* and **bold**.

# Another Chapter

This is the first paragraph in the second chapter.

## A Section

This is a paragraph in a section in the second chapter.

Now, if you know Markdown, you'll know that the # character at the beginning of a line makes an h1, and the ## characters at the beginning of a line make an h2.

What Leanpub invented was a standard mapping between Markdown concepts and book concepts.

For example, the # heading creates a new chapter (with the heading text as its name), and the ## heading creates a new section (with the heading text as its name).

This standard mapping of Markdown concepts to book concepts is called Markua.

Markua was created and specified by Peter Armstrong, the founder of Leanpub. It evolved at Leanpub since we launched in 2010.

Now, books have some concepts (like index entries) which do not exist in Markdown. So, Markua adds some stuff to Markdown as well, in order to support those concepts. However, everything that Markua adds to Markdown is optional: you can write a book on Leanpub in standard Markdown, without any Markua extensions.

Markua = Markdown - inline HTML + optional extensions

Markua has a long history, which you can read about here.

The first version we shipped was called Leanpub Flavoured Markdown, which is documented here. Leanpub Flavoured Markdown evolved from 2010 to 2013.

The second version we shipped was called Markua 0.10. It is documented here.

The third version we shipped is the version of Markua which has a proper specification. You can read the Markua specification, which is an open standard which anyone can implement.

By the way, openness is the reason that "Markua" does not have "Leanpub" in its name: the Markua specification is freely available for anyone to implement; it is not tied to proprietary to Leanpub. So, we don't have Leanpub in the name.

In fact, the Markua specification is based on the CommonMark specification, which is the best documented and most widely adopted specification of Markdown.

(The version number of the Markua specification is a little weird: it tracks the major and minor version numbers of the CommonMark specification that it is based on, and adds a patch version number. So, as of this writing in May 2024, the version of the Markua specification is 0.31.37, since the version of the CommonMark specification that it is based on is 0.31.2 from 2024-01-28.)

If you look at the Markua specification and the CommonMark specification, you'll see that Markua adds a lot. All of it is optional, however.