Formatting
Formatting
Markdown
Most of the examples from this documentation are in Markdown. Markdown is default parser for GitBook, but one can also opt for the AsciiDoc syntax.
Here’s an overview of Markdown syntax that you can use with GitBook (same as GitHub with some additions).
Headings
To create a heading, add one to six #
symbols before your heading text. The number of # you use will determine the size of the heading.
GitBook supports a nice way for explicitly setting the header ID. If you follow the header text with an opening curly bracket (separated from the text with a least one space), a hash, the ID and a closing curly bracket, the ID is set on the header. If you use the trailing hash feature of atx style headers, the header ID has to go after the trailing hashes. For example:
Paragraphs and Line Breaks
A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line — a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.
Emphasis
Lists
Markdown supports ordered (numbered) and unordered (bulleted) lists.
Unordered
Unordered lists use asterisks, pluses, and hyphens — interchangably — as list markers:
Ordered
Ordered lists use numbers followed by periods:
Links
Markdown supports two style of links: inline and reference.
A simple link can be created by surrounding the text with square brackets and the link URL with parentheses:
Links can point to relative paths, anchors or absolute urls.
References
There is another way to create links which does not interrupt the text flow. The URL and title are defined using a reference name and this reference name is then used in square brackets instead of the link URL:
Then, anywhere in the document, you define your link label like this, on a line by itself:
Images
Images can be created in a similar way than links: just use an exclamation mark before the square brackets. The link text will become the alternative text of the image and the link URL specifies the image source:
Blockquotes
A blockquote is started using the >
marker followed by an optional space; all following lines that are also started with the blockquote marker belong to the blockquote. You can use any block-level elements inside a blockquote:
Tables
You can create tables by assembling a list of words and dividing them with hyphens -
(for the first row), and then separating each column with a pipe |
:
The pipes on either end of the table are optional. Cells can vary in width and do not need to be perfectly aligned within columns. There must be at least three hyphens in each column of the header row.
Code
Markdown supports two different code block styles. One uses lines indented with either four spaces or one tab whereas the other uses lines with tilde characters as delimiters – therefore the content does not need to be indented:
Fenced code blocks
You can create fenced code blocks by placing triple backticks ```
before and after the code block. We recommend placing a blank line before and after code blocks to make the raw formatting easier to read.
Syntax highlighting
You can add an optional language identifier to enable syntax highlighting in your fenced code block.
For example, to syntax highlight Ruby code:
Inline code
Text phrases can be marked up as code by surrounding them with backticks:
Footnotes
GitBook supports a simple syntax for such footnotes. Footnotes are relative to each pages.
HTML
GitBook supports use of raw HTML in your text, Markdown syntax in HTML is not processed:
Horizontal Rule
Horizontal Rules can be inserted using three or more asterisks, dashes or underscores, optionally separated by spaces or tabs, on an otherwise blank line:
Ignoring Markdown formatting
You can tell GitBook to ignore (or escape) Markdown formatting by using \
before the Markdown character.
Last updated