-
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, 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.
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>
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:
- Since the image is rather wide, I have explicitly constrained its width. You can do so by using HTML directly in your Markdown like so:
<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 |