Skip to content

Instantly share code, notes, and snippets.

@jdkato
Last active February 7, 2017 23:18
Show Gist options
  • Save jdkato/ce10dcb18e0cf6f65d11cfddc26f010e to your computer and use it in GitHub Desktop.
Save jdkato/ce10dcb18e0cf6f65d11cfddc26f010e to your computer and use it in GitHub Desktop.
This is intended as a quick reference and showcase. For more complete info, see [John Gruber's original spec](http://daringfireball.net/projects/markdown/) and the [Github-flavored Markdown info page](http://github.github.com/github-flavored-markdown/).
^ Paragraph start
^ Block end
^ Linting paragraph
This cheatsheet is specifically *Markdown Here's* version of Github-flavored Markdown. This differs slightly in styling and syntax from what Github uses, so what you see below might vary a little from what you get in a *Markdown Here* email, but it should be pretty close.
^ Paragraph start
^ Block end
^ Linting paragraph
You can play around with Markdown on our [live demo page](http://www.markdown-here.com/livedemo.html).
^ Paragraph start
^ Block end
^ Linting paragraph
(If you're not a Markdown Here user, check out the [Markdown Cheatsheet](./Markdown-Cheatsheet) that is not specific to MDH. But, really, you should also use Markdown Here, because it's awesome. http://markdown-here.com)
^ Paragraph start
^ Block end
^ Linting paragraph
##### Table of Contents
^ Linting single line
[Headers](#headers)
^ Linting single line
[Emphasis](#emphasis)
^ Linting single line
[Lists](#lists)
^ Linting single line
[Links](#links)
^ Linting single line
[Images](#images)
^ Linting single line
[Code and Syntax Highlighting](#code)
^ Linting single line
[Tables](#tables)
^ Linting single line
[Blockquotes](#blockquotes)
^ Linting single line
[Inline HTML](#html)
^ Linting single line
[Horizontal Rule](#hr)
^ Linting single line
[Line Breaks](#lines)
^ Linting single line
[Youtube videos](#videos)
^ Linting single line
<a name="headers"/>
## Headers
^ Linting single line (heading)
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
# H1
## H2
### H3
#### H4
##### H5
###### H6
Alternatively, for H1 and H2, an underline-ish style:
Alt-H1
======
Alt-H2
------
```
^ Fenced end
# H1
^ Linting single line
## H2
^ Linting single line (heading)
### H3
^ Linting single line (heading)
#### H4
^ Linting single line (heading)
##### H5
^ Linting single line (heading)
###### H6
^ Linting single line (heading)
Alternatively, for H1 and H2, an underline-ish style:
^ Paragraph start
^ Block end
^ Linting paragraph
Alt-H1
^ Paragraph start
======
^ Not a paragraph; linting single line (heading)
Alt-H2
^ Paragraph start
------
^ Not a paragraph; linting single line (heading)
<a name="emphasis"/>
## Emphasis
^ Linting single line (heading)
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
Emphasis, aka italics, with *asterisks* or _underscores_.
Strong emphasis, aka bold, with **asterisks** or __underscores__.
Combined emphasis with **asterisks and _underscores_**.
Strikethrough uses two tildes. ~~Scratch this.~~
```
^ Fenced end
Emphasis, aka italics, with *asterisks* or _underscores_.
^ Paragraph start
^ Block end
^ Linting paragraph
Strong emphasis, aka bold, with **asterisks** or __underscores__.
^ Paragraph start
^ Block end
^ Linting paragraph
Combined emphasis with **asterisks and _underscores_**.
^ Paragraph start
^ Block end
^ Linting paragraph
Strikethrough uses two tildes. ~~Scratch this.~~
^ Paragraph start
^ Block end
^ Linting paragraph
<a name="lists"/>
## Lists
^ Linting single line (heading)
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
1. First ordered list item
2. Another item
* Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
1. Ordered sub-list
4. And another item.
Some text that should be aligned with the above item.
* Unordered list can use asterisks
- Or minuses
+ Or pluses
```
^ Fenced end
1. First ordered list item
^ Linting single line
2. Another item
^ Linting single line
* Unordered sub-list.
1. Actual numbers don't matter, just that it's a number
^ Linting single line
1. Ordered sub-list
4. And another item.
^ Linting single line
Some text that should be aligned with the above item.
* Unordered list can use asterisks
^ Linting single line
- Or minuses
^ Linting single line
+ Or pluses
^ Linting single line
<a name="links"/>
## Links
^ Linting single line (heading)
There are two ways to create links.
^ Paragraph start
^ Block end
^ Linting paragraph
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
[I'm an inline-style link](https://www.google.com)
[I'm a reference-style link][Arbitrary case-insensitive reference text]
[You can use numbers for reference-style link definitions][1]
Or leave it empty and use the [link text itself]
URLs and URLs in angle brackets will automatically get turned into links.
http://www.example.com or <http://www.example.com> and sometimes
example.com (but not on Github, for example).
Some text to show that the reference links can follow later.
[arbitrary case-insensitive reference text]: https://www.mozilla.org
[1]: http://slashdot.org
[link text itself]: http://www.reddit.com
```
^ Fenced end
[I'm an inline-style link](https://www.google.com)
^ Linting single line
[I'm a reference-style link][Arbitrary case-insensitive reference text]
^ Linting single line
[You can use numbers for reference-style link definitions][1]
^ Linting single line
Or leave it empty and use the [link text itself]
^ Paragraph start
^ Block end
^ Linting paragraph
URLs and URLs in angle brackets will automatically get turned into links.
^ Paragraph start
http://www.example.com or <http://www.example.com> and sometimes
^ Adding to paragraph
example.com (but not on Github, for example).
^ Adding to paragraph
^ Block end
^ Linting paragraph
Some text to show that the reference links can follow later.
^ Paragraph start
^ Block end
^ Linting paragraph
[arbitrary case-insensitive reference text]: https://www.mozilla.org
^ Linting single line
[1]: http://slashdot.org
^ Linting single line
[link text itself]: http://www.reddit.com
^ Linting single line
<a name="images"/>
## Images
^ Linting single line (heading)
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
Here's our logo (hover to see the title text):
Inline-style:
![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
Reference-style:
![alt text][logo]
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
```
^ Fenced end
Here's our logo (hover to see the title text):
^ Paragraph start
^ Block end
^ Linting paragraph
Inline-style:
^ Paragraph start
![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
^ Adding to paragraph
^ Block end
^ Linting paragraph
Reference-style:
^ Paragraph start
![alt text][logo]
^ Adding to paragraph
^ Block end
^ Linting paragraph
[logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
^ Linting single line
<a name="code"/>
## Code and Syntax Highlighting
^ Linting single line (heading)
Code blocks are part of the Markdown spec, but syntax highlighting isn't. However, many renderers -- like Github's and *Markdown Here* -- support syntax highlighting. *Markdown Here* supports highlighting for dozens of languages (and not-really-languages, like diffs and HTTP headers); to see the complete list, and how to write the language names, see the [highlight.js demo page](http://softwaremaniacs.org/media/soft/highlight/test.html).
^ Paragraph start
^ Block end
^ Linting paragraph
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
Inline `code` has `back-ticks around` it.
```
^ Fenced end
Inline `code` has `back-ticks around` it.
^ Paragraph start
^ Block end
^ Linting paragraph
Blocks of code are either fenced by lines with three back-ticks <code>```</code>, or are indented with four spaces. I recommend only using the fenced code blocks -- they're easier and only they support syntax highlighting.
^ Paragraph start
^ Block end
^ Linting paragraph
<pre lang="no-highlight"><code>```javascript
^ HTML start
var s = "JavaScript syntax highlighting";
alert(s);
```
```python
s = "Python syntax highlighting"
print s
```
```
No language indicated, so no syntax highlighting.
But let's throw in a &lt;b&gt;tag&lt;/b&gt;.
```
</code></pre>
^ HTML end
```javascript
^ Fenced start
^ Found syntax; trying to lint...
^ Fenced end (from lintCode)
```python
^ Fenced start
^ Found syntax; trying to lint...
^ Fenced end (from lintCode)
```
^ Fenced start
No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
But let's throw in a <b>tag</b>.
```
^ Fenced end
Again, to see what languages are available for highlighting, and how to write those language names, see the [highlight.js demo page](http://softwaremaniacs.org/media/soft/highlight/test.html).
^ Paragraph start
^ Block end
^ Linting paragraph
<a name="tables"/>
## Tables
^ Linting single line (heading)
Tables aren't part of the core Markdown spec, but they are part of GFM and *Markdown Here* supports them. They are an easy way of adding tables to your email -- a task that would otherwise require copy-pasting from another application.
^ Paragraph start
^ Block end
^ Linting paragraph
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
Colons can be used to align columns.
| Tables | Are | Cool |
| ------------- |:-------------:| -----:|
| col 3 is | right-aligned | $1600 |
| col 2 is | centered | $12 |
| zebra stripes | are neat | $1 |
The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
Markdown | Less | Pretty
--- | --- | ---
*Still* | `renders` | **nicely**
1 | 2 | 3
```
^ Fenced end
Colons can be used to align columns.
^ Paragraph start
^ Block end
^ Linting paragraph
| Tables | Are | Cool |
^ Table start
| ------------- |:-------------:| -----:|
^ Linting single line
| col 3 is | right-aligned | $1600 |
^ Linting single line
| col 2 is | centered | $12 |
^ Linting single line
| zebra stripes | are neat | $1 |
^ Linting single line
^ Table end
The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
^ Paragraph start
^ Block end
^ Linting paragraph
Markdown | Less | Pretty
^ Table start
--- | --- | ---
^ Linting single line
*Still* | `renders` | **nicely**
^ Linting single line
1 | 2 | 3
^ Linting single line
^ Table end
<a name="blockquotes"/>
## Blockquotes
^ Linting single line (heading)
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
> Blockquotes are very handy in email to emulate reply text.
> This line is part of the same quote.
Quote break.
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
```
^ Fenced end
> Blockquotes are very handy in email to emulate reply text.
^ Linting single line
> This line is part of the same quote.
^ Linting single line
Quote break.
^ Paragraph start
^ Block end
^ Linting paragraph
> This is a very long line that will still be quoted properly when it wraps. Oh boy let's keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can *put* **Markdown** into a blockquote.
^ Linting single line
<a name="html"/>
## Inline HTML
^ Linting single line (heading)
You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
^ Paragraph start
^ Block end
^ Linting paragraph
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
<dl>
<dt>Definition list</dt>
<dd>Is something people use sometimes.</dd>
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
```
^ Fenced end
<dl>
^ HTML start
<dt>Definition list</dt>
<dd>Is something people use sometimes.</dd>
<dt>Markdown in HTML</dt>
<dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
</dl>
^ HTML end
<a name="hr"/>
## Horizontal Rule
^ Linting single line (heading)
```
^ Fenced start
Three or more...
---
Hyphens
***
Asterisks
___
Underscores
```
^ Fenced end
Three or more...
^ Paragraph start
^ Block end
^ Linting paragraph
---
^ Linting single line
Hyphens
^ Paragraph start
^ Block end
^ Linting paragraph
***
^ Linting single line
Asterisks
^ Paragraph start
^ Block end
^ Linting paragraph
___
^ Paragraph start
^ Block end
^ Linting paragraph
Underscores
^ Paragraph start
^ Block end
^ Linting paragraph
<a name="lines"/>
## Line Breaks
^ Linting single line (heading)
My basic recommendation for learning how line breaks work is to experiment and discover -- hit &lt;Enter&gt; once (i.e., insert one newline), then hit it twice (i.e., insert two newlines), see what happens. You'll soon learn to get what you want. "Markdown Toggle" is your friend.
^ Paragraph start
^ Block end
^ Linting paragraph
Here are some things to try out:
^ Paragraph start
^ Block end
^ Linting paragraph
```
^ Fenced start
Here's a line for us to start with.
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
This line is also a separate paragraph, but...
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
```
^ Fenced end
Here's a line for us to start with.
^ Paragraph start
^ Block end
^ Linting paragraph
This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
^ Paragraph start
^ Block end
^ Linting paragraph
This line is also begins a separate paragraph, but...
^ Paragraph start
This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
^ Adding to paragraph
^ Block end
^ Linting paragraph
(Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
^ Paragraph start
^ Block end
^ Linting paragraph
<a name="videos"/>
## Youtube videos
^ Linting single line (heading)
They can't be added directly but you can add an image with a link to the video like this:
^ Paragraph start
^ Block end
^ Linting paragraph
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
<a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
" target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
```
^ Fenced end
Or, in pure Markdown, but losing the image sizing and border:
^ Paragraph start
^ Block end
^ Linting paragraph
```no-highlight
^ Fenced start
^ Found syntax; trying to lint...
^ Unknown syntax
[![IMAGE ALT TEXT HERE](http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg)](http://www.youtube.com/watch?v=YOUTUBE_VIDEO_ID_HERE)
```
^ Fenced end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment