Skip to content

Markdown syntax ​

Chapters are written in CommonMark with a few extensions: tables, strikethrough, callouts, and highlighted code and terminal blocks. The same Markdown produces the PDF, the EPUB and the web edition. For chapter files, headings, parts and code includes, see Writing chapters.

At a glance ​

SyntaxSupported
Headings ## to ######yes (# only as the chapter heading)
Paragraphs and line breaksyes
Bold, italic, inline codeyes
Strikethrough ~~text~~yes
Links and <https://…> autolinksyes
Ordered and unordered listsyes
Blockquotesyes
Callouts > [!NOTE], [!WARNING], [!TRY]yes
Tablesyes
Fenced and indented code blocksyes, highlighted by language
Terminal blocks (console)yes
Scene breaks ---yes
Inline HTMLpassed through; flagged by QA
Code includes <!-- include: … -->yes, see Code from files
Images ![alt](file.png)no; use cover and end_image
Footnotes [^1]no
Task lists - [ ]no
Sub- and superscript H~2~O, x^2^no
Bare URLs turned into linksno; wrap them in <…>
Smart quotes and dashesno; type the characters you want
Math, diagrams, emoji shortcodesno

Unsupported syntax is not an error: it is printed as plain text (a task list shows [ ] task), except images, which stop the PDF build.

Headings ​

markdown
# Chapter 1 - Getting Started

## A section

### A subsection

The first line of a chapter is its heading (see Chapters); do not use # anywhere else. ## headings are the chapter's sections: they are listed in the QA report and never left alone at the foot of a PDF page. Use ### to ###### for smaller headings.

A line of text directly followed by --- or === is also a heading (CommonMark "setext" headings); leave a blank line before a scene break.

Paragraphs and line breaks ​

Separate paragraphs with a blank line. Inside a paragraph, a line ending with a backslash \ (or two spaces) forces a line break; a plain line break is just a space.

markdown
First line\
second line of the same paragraph.

A new paragraph.

Emphasis and inline code ​

markdown
**bold**, _italic_, _**bold italic**_, ~~struck through~~ and `code`

Inline code is set in Noto Sans Mono, which also covers Burmese.

markdown
[the Python docs](https://docs.python.org/3/)
<https://docs.python.org/3/>

A bare https://… stays plain text; wrap it in <…> to make it a link. The QA report's HTML check also lists <…> autolinks, because they look like tags; [text](url) avoids that.

Lists ​

markdown
- An item
- Another item
  - A nested item

1. First
2. Second

Blockquotes ​

markdown
> A quotation, which can span
> several lines.

Callouts ​

A blockquote that starts with a marker becomes a boxed note. The marker is not case-sensitive; the titles come from strings.callout_titles.

markdown
> [!NOTE]
> A side remark.

> [!WARNING]
> Something that can go wrong.

> [!TRY]
> An exercise for the reader.
MarkerDefault title
[!NOTE]Note
[!WARNING]Warning
[!TRY]Try it yourself

Other GitHub markers such as [!TIP] or [!IMPORTANT] are not callouts; they stay ordinary blockquotes that show the marker text.

Tables ​

Pipe tables, with optional column alignment:

markdown
| Type    | Example | Size |
| :------ | :-----: | ---: |
| `int`   |  `42`   | 28 B |
| `float` | `3.14`  | 24 B |

Code blocks ​

Fence code with three backticks (or ~~~) and name the language:

markdown
```python
def greet(name):
    return f"မင်္ဂလာပါ {name}"
```

Highlighting uses Prism, so every Prism language name and alias works (python, py, ts, js, json, bash, yaml, sql, …). A block with no language, an unknown one, or indented by four spaces is set as plain code.

Long lines are set in a smaller monospace size so they fit the page; lines longer still wrap rather than overflow.

Terminal blocks ​

A console block (or terminal, shell-session) is drawn as a terminal window. Lines starting with $ are commands, highlighted as shell; the others are output.

markdown
```console
$ python3 hello.py
Hello
```

Scene breaks ​

A line with --- between paragraphs, with a blank line before and after it, is a scene break.

markdown
The end of one scene.

---

The start of the next.

Inline HTML ​

HTML in a chapter is passed through to every edition, so keep it simple and well-formed (EPUB is XHTML). The QA report lists each line that contains an HTML tag, so prefer Markdown where it exists.

markdown
Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to stop.

Images ​

Images inside chapters are not supported: the PDF build stops with unexpected request and the EPUB would reference a missing file. The book's images are the cover, the web edition's back_cover and the closing end_image, set in book.json.

Released under the MIT Licence.