Markdown cheat sheet

As demanded in another thread, I’ll start here a short Markdown “cheat sheet” with some shortcuts you can use in your posts. Feel free to add stuff. :slight_smile:

0. Introduction

Discourse changes some chars into formats. For example it turns the * at the beginning of a new line/paragraph into a bullet list. If you would like to prevent Discourse from this, just put a backslash \ before the char, in the example: \* This leads to: *. If you would like to print the backlash \, use two of them: \\

1. Fonts

This code:

Text attributes _italic_, *italic*, __bold__, **bold**, 
`monospace/preformatted text`, ~~strikethrough~~

(note that there are two _ before and after bold))

produces this:

Text attributes italic, italic, bold, bold,
monospace/preformatted text, strikethrough


2. Paragraphs:

Two spaces at the end of a line (like in this one) leave a
line break.

The lines of quotes are starting with >. So this:

> This is a quote

produces this output:

This is a quote


3. Lists

This code:

Bullet list:
* Franklin
* Ransome
* Delores

Numbered list:
1. Franklin
2. Ransome
3. Delores

produces this:

Bullet list:

  • Franklin
  • Ransome
  • Delores

Numbered list:

  1. Franklin
  2. Ransome
  3. Delores

Notes:
For bullet lists you can use + or - instead of *.
For numbered lists you can use parentheses instead of the dots:

Numbered list:
1) Franklin
2) Ransome
3) Delores

4. Links

This code:

[Wikipedia article](https://en.wikipedia.org/wiki/Markdown)

produces this:

Wikipedia article


5. Lines

You can produce a line with and empty paragraph following three -. So this:

---

produces this:


6. Headings:

This code:

# Heading
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut

## Sub-heading
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut

### Sub-sub-heading
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut

leads to this:

Heading

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut

Sub-heading

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut

Sub-sub-heading

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut

Note: You can use the following code as an alternative:

A heading
---

Another heading
===

7. Tables

This code:

| Country        | Percent | Remark |
| -------------- |:-------:| ------:|
| United States  | 30.3%   | First  |
| Germany        | 20.1%   | Second |
| United Kingdom | 11.5%   | Third  |

produces this result:

Country Percent Remark
United States 30.3% First
Germany 20.1% Second
United Kingdom 11.5% Third

Note: In the second row:
|: --- :| means: center the cell content
--- :| means: align the cell content right

You can insert as much - and spaces as you like. This would be also valid:

| Country | Percent | Remark |
| --- |:---:| ---:|
| United States | 30.3% | First |
| Germany | 20.1% | Second |
| United Kingdom | 11.5% | Third |

8. Code blocks

This code with backticks:

```
var hello = "hello world";
print(hello);
```

produces this output:

var hello = "hello world";
print(hello);

Note: Discourse tries to recognize the programming language.


9. Shortcuts

If you enter an interrogation mark, several keyboard shortcuts are shown:

6 Likes

That doesn’t look numbered to me :stuck_out_tongue:

So I am not the only one.
Putting on your magical nose glasses fixes this.
8o)

Really? :stuck_out_tongue_winking_eye:

(Copy and paste is evil…)

1 Like

Numbered lists work also with parentheses :slight_smile:

1) cacca
2) culo

gives

  1. cacca
  2. culo
1 Like

Thanks, I’ve added that!

Maybe @eviltrout can change the first post into a wiki post so that we all can add and change the cheat sheet?

Just beware you have an empty line above the three -, otherwise you end up with a heading

@Someone : thanks for creating the thread. :slight_smile:

Would it be OK for you to change a bit the order of the contents so that at the top of the post we provide the syntax for the most used features in this forum (bold/italic, lists, other popular things usually obtained using the buttons in the toolbar of the writing window)?

In this way we would have a quick&easy top section useful to everybody and a more detailed section for those who want to discover the less used and technical features of MarkDown.

Also, would it be OK for you to mention a few useful keyboard shortcuts (without giving the full list of Discourse shortcuts)? When I create links, the CTRL-K shortcuts really makes the task super-fast for me.

You can do that yourself.

Ah, yes. :slight_smile: I did that, so …

… feel free to edit it. :slight_smile: Is it possible in Discourse to create a table of content at the beginning?

Should we start a new thread with some shortcuts and/or the BBcode? I wasn’t sure if I should add some BBcode-tags like [details="..."]

If you enter an interrogation mark, several keyboard shortcuts are shown:

2 Likes

Which keys on keyboard do you use to display these:
~~

?

Depends on your keyboad layout. On a German keyboard I have to press [Alt gr]+[+]
([Alt gr] is the right Alt key)

:expressionless: Yeah, thanks, [Alt gr] is the same on italian layout, but the combination doesn’t work and still I don’t see any symbol like that… Maybe you know its name? Or if there are other ways to obtain the same result? Every time I want to do that I need to copy those wave-like characters from here.

The character is called “Tilde” and it seems that it is not available on a standard Italian layout. Maybe these pages are helping:

1 Like

It’s tilde. To get it on every keyboard, press and hold the ALT key, then type 126 on the numeric keypad (not on the first row of the main keyboard). Then release the ALT key and you will see your tilde character.

1 Like

Apart from those that don’t have a numeric keypad :stuck_out_tongue:

1 Like

We have a word for those.

Losers. :smiling_imp:

6 Likes