Block elements
Paragraphs and linebreaks
Paragraphs are separated by a blank line, while a line break can be forced by ending a line in two or more spaces. A blank line is a line that looks blank, ie. containing nothing but spaces or tabs.
- Line break:
\h{2,}$ - Blank line:
^\h*$
Headers
There are two kinds of headers: Setext, and atx.
Setext are “underlined” by equal signs (for first level headers) and dashes (for second level headers). Any number of =’s or -‘s will do.
Atx-style headers use 1-6 hash characters at the start of the line corresponding to header level 1-6. Closing hashes may be present, but are ignored.
- Setext:
^=+$ or ^-+$ - Atx:
^#+\h* and cut \h*#*$
Blockquotes
Blockquotes starts with “> “ like in emails. You may be lazy and put the “> “ at just the first line, but doing it on every line is more readable.
Two or more blockquoted consecutive blocks are placed in the same blockquote.
Blockquotes may include other markdown elements, such as headers, list, and code blocks. They may even be nested.
Testing a blockquote
consecutive
meh
Blockquote
with a blockquote
inside
Lists
List can be ordered or unordered by using numbers or using asterisks, pluses, and hyphens. The first line tells the type.
If list items are separated by blank lines, they will be wrapped in p-tags. List items may consist of multiple paragraphs, if the paragraphs are indented by 4 spaces or one tab (at least the first line of the paragraph).
List markers typically start at the left margin, but may be indented by up to three spaces. List markers must be followed by one or more spaces or a tab. To make lists look nice, you can wrap items with hanging indents.
stuff
stuff2
stuff3
stuff4 stuff5 stuff6
stuff7 stuff8
blabla
blabla
blabla
Code blocks
Code blocks are not parsed, but placed in a <pre><code>
-</code></pre>
block.
One level of indention is removed (4 spaces or one tab).
public class Test {
public static void main(String... args) {
System.out.println("Hello, world!");
}
}
Horizontal rules
You can produce a horizontal rule tag (<hr />) by placing three or more hyphens, asterisks, or underscores on a line by themselves. If you wish, you may use spaces between the hyphens or asterisks.
Each of the following lines will produce a horizontal rule:
However the following line will not produce a horizontal rule:
_ * -
Span elements
Links
Inline links
This is an example of an inline link. The square brackets mark the link text, and the parentheses mark the url and an optional title marked with quotes.
This is an example of an inline link without a title.
Reference links
Reference links use two sets of square brackets optionally separated by a single space.
The link references may be placed anywhere in the document, and must be made up by:
- Square brackets containing the link identifier (optionally indented from the left margin using up to three spaces);
- followed by a colon;
- followed by one or more spaces (or tabs);
- followed by the URL for the link;
- optionally followed by a title attribute for the link, enclosed in double or single quotes, or enclosed in parentheses.
The link references are not outputted.
The link URL may, optionally, be surrounded by angle brackets:
[id]: <http://example.com/> “Example.com”
The labels are case insensitive.
Implicit links are links where the label is omitted. The link text is used as label instead.
Emphasis
Single asterisks and single underscores wrap in <em>.
Double asterisks and double underscores wrap in <strong>.
But does is work with a double at the end of the line?
The opening and closing symbol must be the same. Emphasis may be used in the middle of a word, however if * _ ** __ __ ** _ * are surrounded by spaces, they will be treated as literals.
*Literals may be forced by escaping them.*
A list with spanning emphasis:
Normal Bold
bold italic+bold
Bold italic
italic normal
Code
Code is wrapped in backticks (`):
“Use the printf()
function.”
Double backticks may be used to include literal backticks (`)
Backtick delimitors may include spaces — one after the opening and one before the closing — This allows you to place literal backtick characters at the beginning or end of a code span:
A backtick-delimited string in a code span: `foo`
Images
Images work exactly like links. They are, however, preceeded by an exclamation mark:
Miscellaneous
Automatic Links
Backslash escapes
\ backslash
` backtick
* asterisk
_ underscore
{} curly braces
[] square brackets
() parentheses
# hash mark
+ plus sign
- minus sign (hyphen)
. dot
! exclamation mark