Markdown basics

Acknowledgements: This page is adapted from health-data-science-OR/jupyterlab-introduction.

1 What is markdown?

Markdown is a way of writing documents using plain text plus a few extra characters to show structure and formatting. Instead of a hidden file format (like a .docx), everything is visible as text: your words and the little symbols (e.g., #, *, -) that control how they look.

When you view or render a Markdown file (for example, by opening it in a preview window or creating a final document), a tool reads your text and these symbols and turns them into a nicely formatted document (for example, HTML or PDF).

A normal Markdown file usually ends in .md. In this workshop we mostly used Quarto Markdown, which is the same idea but with extra features for things like interactivity, code and citations, and those files end in .qmd.

On this page you will practice Markdown features that you can use in your Quarto documents.

2 Headings and subheadings

In Markdown, a heading is formatted with the character #.

The number of # characters represents the level of the heading. For example:

# Heading level 1

## Heading level 2

### Heading level 3

#### Heading level 4

Task: Open markdown.qmd and create three headings:

Render the page and check that the heading sizes look different.

3 Adding a horizontal line between sections

To add a horizontal line between sections, use three dashes or asterisk on a line by themselves - either:

---
***

Task: In markdown.qmd:

Re-render the page to check it has worked.

4 Bold and italic text

To create bold text, you need to surround a word or phrase with **. For example:

The final word of this sentence will be **bold**.

To create italic text, you need to surround a word or phrase with *.

*This whole sentence will be in italics.*

You can also combine both if you need stronger emphasis.

Task: In markdown.qmd:

Re-render the page to see the effect.

5 Bullet points and numbered lists

To create a bullet list, use * or - or + followed by a space and then your text:

* Bullet point 1
* Bullet point 2
* Bullet point 3

Can give more space by having blank lines between items

* Bullet point 1

* Bullet point 2

* Bullet point 3

You can indent with spaces (or tab) to create sub-bullets:

* Bullet point 1
    * Bullet point level 2
        * Bullet point level 3
* Back to level 1

A numbered list is created in a similar way using numbers, letters or Roman numerals, or can use #, will just give deciminal numbers from 1:

1. Numbered point 1
    a. Numbered point level 2 
    b. Numbered point level 2 again
2. Back to level 1

To create a checklist, add [ ] between the bullet and text. You can then click on the boxes to cross them out, or have them already shown as crossed out using [x].

* [ ] First task
* [x] Finished task

Task: In markdown.qmd:

6 Block quotes

To indent text as a block quote, use > at the start of the line:

> This is indented

You can use this for quotes, highlights, or short notes.

Task: In markdown.qmd:

8 Inline code and code blocks

You can show short bits of code or filenames using single backticks. This is good for things like file names, commands, and short code fragments.

Example:

Run `python script.py` in your terminal.

Open `analysis.qmd` and edit the first section.

Run python script.py in your terminal.

Open analysis.qmd and edit the first section.

For longer code, use a code block fenced with three backticks:

```bash
python script.py --help
echo "Hello, world"
```
python script.py --help
echo "Hello, world"

Task: In markdown.qmd:

9 Tables

You can create simple tables using pipes | and dashes -:

| Letter | Number |
| - | - |
| A | 1 |
| B | 2 |
| C | 3 |
Letter Number
A 1
B 2
C 3

Task: In markdown.qmd: