Skip to content

How to use Markdown

Simon Mathis edited this page Oct 6, 2020 · 8 revisions

Markdown Intro

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.

1. Tables

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 |

1. Paragraphs, Headers, Blockquotes

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>

2. Emphasis

3. Lists

4. Links

5. Images

Image syntax is very much like link syntax.

Here's the inline syntax (titles are optional): ![alt text](/path/to/img.jpg "Title")

And here's the alternative reference-style syntax:

![alt text][id]
[id]: /path/to/img.jpg "Title"

Both of the above examples produce the same output: alt text

6. Code

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

This makes it easy to use Markdown to write about HTML example code: