Post

GitHub Markdown Syntax Summary

Learn what Markdown is and summarize the main Markdown syntax based on GitHub Flavored Markdown for GitHub Pages blog hosting.

To utilize GitHub Pages, it’s necessary to understand markdown syntax. This summary is based on GitHub’s official documents Mastering Markdown and Basic writing and formatting syntax.

1. What is Markdown

Markdown is a lightweight markup language based on plain text. It is used to write formatted documents in plain text and is characterized by its easy and simple syntax compared to general markup languages. It is widely used in README files distributed with application software or online posts because it can be easily converted to formatted documents such as HTML and Rich Text Format (RTF).

John Gruber created the Markdown language in 2004, with significant collaboration from Aaron Swartz on the syntax, with the goal of enabling people to “write using an easy-to-read and easy-to-write plain text format, optionally convert it to structurally valid XHTML (or HTML)”.

-Wikipedia, Markdown

2. Markdown Syntax

Since Markdown doesn’t have a set standard, detailed syntax may vary slightly depending on where it’s used. The Markdown syntax summarized here is based on GitHub Flavored Markdown.

2.1. Line Breaks, Paragraph Separation

In Markdown, a single press of the enter key is not recognized as a line break.

1
2
3
First sentence.
Second sentence.
Third sentence.

First sentence. Second sentence. Third sentence.

A line break is applied when two or more consecutive spaces are entered.

1
2
3
First sentence.  
Second sentence.  
Third sentence.

First sentence.
Second sentence.
Third sentence.

Paragraphs are separated by a blank line (pressing enter twice).

1
2
3
One paragraph.

Another paragraph.

One paragraph.

Another paragraph.

2.2. Headers

There are six levels in total.

1
2
3
4
5
6
# This is an H1
## This is an H2
### This is an H3
#### This is an H4
##### This is an H5
###### This is an H6

This is an H1

This is an H2

This is an H3

This is an H4

This is an H5
This is an H6

2.3. Emphasis

1
2
3
4
5
6
7
8
9
10
11
*This text is italicized*
_This is italicized too_

**This is bold text**
__This is bold text too__

~~This was mistaken text~~

_You **can** combine them_

***All this text is important***

This text is italicized
This is italicized too

This is bold text
This is bold text too

This was mistaken text

You can combine them

All this text is important

2.4. Text Quoting

Use >.

1
2
3
> This is a first blockquote.
>> This is a second blockquote.
>>> This is a third blockquote.

This is a first blockquote.

This is a second blockquote.

This is a third blockquote.

2.5. Code Quoting

Use ``` or ~~~.

1
2
3
4
5
```
git status
git add
git commit
```
1
2
3
git status
git add
git commit

You can also activate syntax highlighting by specifying the programming language.

1
2
3
4
5
```ruby
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
```
1
2
3
require 'redcarpet'
markdown = Redcarpet.new("Hello World!")
puts markdown.to_html
1
2
[GitHub Pages](https://pages.github.com/)
<https://pages.github.com/>

GitHub Pages
https://pages.github.com/

You can also use relative path links pointing to other files within the repository. The usage is the same as in the terminal.

1
[README](../README.md)

2.7. Unordered Lists

Use - or *.

1
2
3
- George Washington
- John Adams
- Thomas Jefferson
  • George Washington
  • John Adams
  • Thomas Jefferson

2.8. Ordered Lists

Use numbers.

1
2
3
1. James Madison
2. James Monroe
3. John Quincy Adams
  1. James Madison
  2. James Monroe
  3. John Quincy Adams

2.9. Nested Lists

1
2
3
1. First list item
   - First nested list item
     - Second nested list item
  1. First list item
    • First nested list item
      • Second nested list item

2.10. Task Lists

To create a task list, add [ ] before each item. To mark a task as complete, use [x].

1
2
3
- [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

2.11. Image Attachment

1
2
3
4
Method: ![(Optional)Image description](url){(Optional)Additional options}
![GitHub Logo](/images/logo.png)
![GitHub Logo](/images/logo.png){: .align-center}
![GitHub Logo](/images/logo.png){: width="50%" height="50%"}

2.12. Table Creation

You can create tables using | and -. Leave a blank line before the table for it to display correctly. Use at least three - for it to be recognized properly.

1
2
3
4
5
| Left-aligned | Center-aligned | Right-aligned |
| :---         |     :---:      |          ---: |
| git status   | git status     | git status    |
| git diff     | git diff       | git diff      |
Left-alignedCenter-alignedRight-aligned
git statusgit statusgit status
git diffgit diffgit diff
This post is licensed under CC BY-NC 4.0 by the author.

Comments powered by Disqus.