-
Notifications
You must be signed in to change notification settings - Fork 2
How to use Markdown
In this brief post, we look at the essentials of Markdown, the formatting language that is used to create this wiki.
Markdown is a text-to-HTML conversion tool for web writers. Essentially, it takes in a simplified syntax and spits out HTML text without you having to bother about placing the HTML tags correctly. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid HTML.
It will be useful for creating wiki pages, write github issues, but also to document your jupyter notebooks. Please review this tutorial before you make edits to the wiki.
For more details on Markdown, visit the official Markdown documentation. Much of the content here was taken from the Markdown basics page.
- Paragraphs, Headers, Blockquotes
- Emphasis
- Lists
- Links
- Images
- Code
- Tables
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.
Markdown offers two styles of headers: Setext and atx. Setext-style headers for <h1>
and <h2>
are created by “underlining” with equal signs (=
) and hyphens (-
), respectively. To create an atx-style header, you put 1-6 hash marks (#
) at the beginning of the line — the number of hashes equals the resulting HTML header level.
Blockquotes are indicated using email-style >
angle brackets.
Markdown example:
A First Level Header
====================
A Second Level Header
---------------------
This is just a
regular paragraph.
The quick brown fox jumped over the lazy
dog's back.
### Header 3
> This is a blockquote.
>
> This is the second paragraph in the blockquote.
>
> ## This is an H2 in a blockquote
Output:
<h1>A First Level Header</h1>
<h2>A Second Level Header</h2>
<p>Now is the time for all good men to come to
the aid of their country. This is just a
regular paragraph.</p>
<p>The quick brown fox jumped over the lazy
dog's back.</p>
<h3>Header 3</h3>
<blockquote>
<p>This is a blockquote.</p>
<p>This is the second paragraph in the blockquote.</p>
<h2>This is an H2 in a blockquote</h2>
</blockquote>
Markdown uses asterisks and underscores to indicate spans of emphasis.
Markdown example:
Some of these words *are emphasized*.
Some of these words _are emphasized also_.
Use two asterisks for **strong emphasis**.
Or, if you prefer, __use two underscores instead__.
Output:
Some of these words are emphasized.
Some of these words are emphasized also.
Use two asterisks for strong emphasis.
Or, if you prefer, use two underscores instead
Unordered (bulleted) lists use asterisks, pluses, and hyphens (*, +, and -) as list markers. These three markers are interchangable; this:
Markdown example:
* Candy.
* Gum.
* Booze.
Output:
- Candy.
- Gum.
- Booze.
Ordered (numbered) lists use regular numbers, followed by periods, as list markers:
1. Red
2. Green
3. Blue
Output:
- Red
- Green
- Blue
If you put blank lines between items, you’ll get
tags for the list item text. You can create multi-paragraph list items by indenting the paragraphs by 4 spaces or 1 tab:
* A list item.
With multiple paragraphs.
* Another item in the list.
Output:
-
A list item.
With multiple paragraphs.
-
Another item in the list.
Markdown supports two styles for creating links: inline and reference. With both styles, you use square brackets to delimit the text you want to turn into a link. The title attribute is optional. Link names may contain letters, numbers and spaces, but are not case sensitive.
Inline-style links use parentheses immediately after the link text. Optionally, you may include a title attribute in the parentheses. For example: This is the [AI4ER program](https://ai4er-cdt.esc.cam.ac.uk/ "The AI4ER is awesome..").
Output:
This is the AI4ER program.
Reference-style links allow you to refer to your links by names, which you define elsewhere in your document (for example at the bottom):
Example:
I get 10 times more traffic from [Google][1] than from
[Yahoo][2] or [MSN][3].
[1]: http://google.com/ "Google"
[2]: http://search.yahoo.com/ "Yahoo Search"
[3]: http://search.msn.com/ "MSN Search"
Output:
I get 10 times more traffic from Google than from Yahoo or MSN.
Image syntax is very much like link syntax.
Here's the inline syntax (titles are optional):
![alt text](https://raw.githubusercontent.com/ai4er-cdt/resources/master/img/cambridge_sample_img.jpg "Title")
And here's the alternative reference-style syntax:
![alt text][id]
[id]: https://raw.githubusercontent.com/ai4er-cdt/resources/master/img/cambridge_sample_img.jpg "Title"
Both of the above examples produce the same output <img src=".../cambridge_sample_img.jpg" alt="alt text" title="Title" />
which is displayed below:
Note:
- If you want to resize an image to a certain display size, you can do so by using HTML directly in your Markdown. You can specifiy both the
width
andheight
of the image, or only specify thewidth
. Here's an example:
<img src=".../cambridge_sample_img.jpg" alt="alt text" title="Title" width="400"/>
. - To add your own images to the wiki, you can either upload them in the main repo under
resources/img/your_image_name.jpg
(.png
is also supported), or you could do it even more cleanly and directly clone the wiki's repo and add the images there. - GitHub also allows you a hacky way to quickly add screenshot images by dragging and dropping them directly into the markdown editor. This is not recommended for contributing to the Wiki (as other users won't be able to properly edit), but can be useful when adding e.g. a screenshot to a GitHub issue. Here is a brief explanation on how to use this feature.
In a regular paragraph, you can create code span by wrapping text in backtick ( ` ) quotes. To create a multiline codeblock, either wrap your text in three consecutive backticks or indent it by 4 spaces or 1 tab. Here's an example
Markdown example:
```
# This is a multiline codeblock
def add(a, b):
return a + b
```
Output:
# This is a multiline codeblock
def add(a, b):
return a + b
The Markdown table syntax is quite simple. There is a handy online table generator that you can use to create the code for a Markdown table.
Note that simple Markdown table syntax does not allow row or cell spanning as well as putting multi-line text in a cell. The first row is always the header followed by an extra line with dashes "-" and optional colons ":" for forcing column alignment.
Tables | Are | Cool |
---|---|---|
col 1 is | left-aligned | $1600 |
col 2 is | centered | $12 |
col 3 is | right-aligned | $1 |
The code that generates this table is
| Tables | Are | Cool |
|----------|:-------------:|------:|
| col 1 is | left-aligned | $1600 |
| col 2 is | centered | $12 |
| col 3 is | right-aligned | $1 |