Skip to content

Leanpub

Tim Steinbach edited this page Dec 15, 2012 · 9 revisions

Leanpub

Leanpub is further explained in chapter 20 of Markdown By Example

Leanpub allows to self-publish books written in Markdown. They are converted to PDF, epub and mobi formats. Leanpub uses Kramdown and adds its own, book-specific, extensions.

More information about writing and structuring a Leanpub book can also be found in the Leanpub Manual.

## Structure ##
### Parts ###

Parts are virtually H0 headlines (one level above H1). They group several chapters into parts.

-# Part 1 title
### Front-/Main-/Back matter ###

Chapters such as introductions, dedications and acknowledgments are usually called the front matter of a book. The main chapters are grouped into the main matter. The back matter consists of appendices and indices. Front matter pages are numbered with Roman numerals. Main and back matters use regular Arabic numbers.

{frontmatter}

Front matter text

{mainmatter}

Main matter text

{backmatter}

Back matter text
## Asides / Information ##
### Asides ###

Asides (or sidebars) are boxes for additional content that does not belong with the text flow.

A> This text will be
A> inside an aside.
### Custom boxes ###

There are variations of asides that provide a custom icon indicating their content.

W> Text in a warning box

T> Text in a tip box

E> Text in an error box

I> Text in an information box

Q> Text in a question box

D> Text in a discussion box

X> Text in an exercise box
## Code ##
### Code highlighting ###

By default, Leanpub's code highlighter (Pygments) is good at guessing a programming language. This behavior can be overridden (find languages at http://pygments.org/languages)

{lang="java"}
    this.code == "java"
### Code block titles ###

Code block titles are captions, similar to figure titles.

{title="Code block title"}
    Code block
### Modify line numbers ###

Line numbers for code snippets can be enforced. Also, they can start at a different number than 1.

{line-numbers=on,starting-line-number=32}
Code that will start at line 32
### External code snippets ###

Besides using the regular Markdown code syntax, code can be externalized.

<<[Code snippet title](code/snippet.scala)
## Links / Footnotes ##
### Footnotes ###

Footnotes use a modified hyperlink syntax.

This word[^note] has a footnote. 

[^note] This will be at the bottom of the page.

More text that follows the text having the footnote.
### Crosslinks ###

Crosslinks allow for links to lead to a location within the document / book.

# Headline # {#headline}
...
[Link to headline](#headline)
## Tables ##

Tables can be created using the Kramdown table syntax (more about it here).

The separator lines define how the text inside the individual cells is aligned.

The following example is taken from the Kramdown syntax manual referenced above.

|-----------------+------------+-----------------+----------------|
| Default aligned |Left aligned| Center aligned  | Right aligned  |
|-----------------|:-----------|:---------------:|---------------:|
| First body part |Second cell | Third cell      | fourth cell    |
| Second line     |foo         | **strong**      | baz            |
| Third line      |quux        | baz             | bar            |
|-----------------+------------+-----------------+----------------|
| Second body     |            |                 |                |
| 2 line          |            |                 |                |
|=================+============+=================+================|
| Footer row      |            |                 |                |
|-----------------+------------+-----------------+----------------|