Skip to content

Instantly share code, notes, and snippets.

@raghubetina
Last active March 11, 2024 06:21
Show Gist options
  • Save raghubetina/a1b6e89e24a8c3acae6f0b63a1fd3323 to your computer and use it in GitHub Desktop.
Save raghubetina/a1b6e89e24a8c3acae6f0b63a1fd3323 to your computer and use it in GitHub Desktop.
Markdown Essentials

Markdown Essentials

Here are the parts of markdown that I use most often.

For each example, the markdown code is shown first, and the rendered result is shown below.

Strong/bold

Surround with **two asterisks for strong/bold**.

Surround with two asterisks for strong/bold.

Emphasis/italic

Surround with _underscores for emphasis/italic_.

Surround with underscores for emphasis/italic.

Links

[Put link titles in square brackets](https://gist.github.com/raghubetina/a1b6e89e24a8c3acae6f0b63a1fd3323#links) and link targets in parentheses following the closing square bracket.

Put link titles in square brackets and link targets in parentheses following the closing square bracket.

Bulleted lists

For bulleted lists — one space, followed by a dash, followed by a space, and then the item:

- First bullet
- Second bullet
- etc

For bulleted lists — a dash, followed by a space, and then the item:

  • First bullet
  • Second bullet
  • etc

Ordered lists

For numbered lists — any number, followed by a dot, followed by a space, and then the item:

1. First point
1. Second point
1. etc

For numbered lists — any number, followed by a dot, followed by a space, and then the item:

  1. First point
  2. Second point
  3. etc

Multiple blocks within list items

To nest something within the same list item, go to the next line and then indent by 4 spaces:

- I am a list item that has multiple paragraphs.

    This is the second paragraph of the first list item.
    
    You can have as many paragraphs as you want.
- This is the second list item.
- etc

To nest something within the same list item, go to the next line and then indent by 4 spaces:

  • I am a list item that has multiple paragraphs.

    This is the second paragraph of the first list item.

    You can have as many paragraphs as you want.

  • This is the second list item.

  • etc


Technically, you can use any number of spaces, not just 4; as long as it's more than what you indented the first level by. I use 4 to make nesting more visually clear than just using 2.

Nesting lists within lists

You can nest other lists within lists by indenting 8 spaces, 12 spaces, etc:

- Top level
    - Second level
        1. 3a
        2. 3b
        
            Another paragraph in 3b.        
        3. 3c
    - Back out to second level.
    
    Some explanatory text still in the very first bullet.
- Second top level bullet.
- etc
  • Top level

    • Second level
      1. 3a

      2. 3b

        Another paragraph in 3b.

      3. 3c

    • Back out to second level.

    Some explanatory text still in the very first bullet.

  • Second top level bullet.

  • etc

Headings

# Heading level 1

## Heading level 2

### Heading level 3

#### Heading level 4

##### Heading level 5

###### Heading level 6

Heading level 1

Heading level 2

Heading level 3

Heading level 4

Heading level 5
Heading level 6

Horizontal rules

---

Use three dashes to...

---

... create separation with horizontal rules.

---

Use three dashes to...


... create separation with horizontal rules.


Inline code

Highlight `variable` names, etc, in the middle of a line by `surrounding` it with backticks.

Highlight variable names, etc, in the middle of a line by surrounding it with backticks.

Code blocks

Start a code block with a line comprised of three backticks, followed optionally by the language (if you want syntax highlighting). End the code block with another line comprised of three backticks:

```ruby
class Person
  attr_accessor :first_name
  attr_accessor :last_name

  def full_name
    return self.first_name + " " + self.last_name
  end
end
```
class Person
  attr_accessor :first_name
  attr_accessor :last_name

  def full_name
    return self.first_name + " " + self.last_name
  end
end

Blockquotes

> The person who chases two rabbits, catches neither.
>
> — Confucius

The person who chases two rabbits, catches neither.

— Confucius


You can use any other markdown within blockquotes:

> 1. First point
> 2. Second point
> 3. etc
>
> ```ruby
> class Person
>   attr_accessor :first_name
>   attr_accessor :last_name
> 
>   def full_name
>     return self.first_name + " " + self.last_name
>   end
> end
> ```
  1. First point
  2. Second point
  3. etc
class Person
  attr_accessor :first_name
  attr_accessor :last_name

  def full_name
    return self.first_name + " " + self.last_name
  end
end

Tables

I don't bother trying to write markdown tables by hand; instead, I generate them:

Strikethrough

~~Strike something out~~ and replace it by surrounding it with two tildes.

Strike something out and replace it by surrounding it with two tildes.

Task lists (GitHub-only)

On GitHub, you can make interactive task lists, which e.g. add handy counters to Issues and Pull Requests indicating your progress towards completing them:

- [x] Finish my changes
- [ ] Push my commits to GitHub
- [ ] Open a pull request
  • Finish my changes
  • Push my commits to GitHub
  • Open a pull request

Task lists are not respected by most other Markdown parsers, other than GitHub's.

Converting Rich Text to Markdown

Sometimes it's useful to convert Rich Text (i.e. from Word, or copy-pasted from anywhere else really) into Markdown. Try this site for that.

Use Markdown anywhere

Markdown Here is an incredibly useful browser extension that allows you to use Markdown in any text field — for example, within Gmail. (I use this extension a hundred times a day.)

@silviar11
Copy link

I cannot wait to learn more about coding.

@ArawakChief
Copy link

I am having trouble with the hello world assignment. I'm quite sure I did it wrong.

@buyanzayatserenbanzad
Copy link

Hello.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment