A quick guide to GitHub markdown for my own purposes. I'll eventually get around to making a better cheat sheet.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

363 lines
9.1 KiB

  1. # The Cheat Sheet
  2. ## Table of Contents
  3. [Headers](#headers)
  4. [Emphasis](#emphasis)
  5. [Lists](#lists)
  6. [Links](#links)
  7. [Images](#images)
  8. [Code and Syntax Highlighting](#code)
  9. [Tables](#tables)
  10. [Blockquotes](#blockquotes)
  11. [Inline HTML](#html)
  12. [Horizontal Rule](#hr)
  13. [Line Breaks](#lines)
  14. [Youtube videos](#videos)
  15. ### Headers
  16. ```no-highlight
  17. # H1
  18. ## H2
  19. ### H3
  20. #### H4
  21. ##### H5
  22. ###### H6
  23. Alternatively, for H1 and H2, an underline-ish style:
  24. Alt-H1
  25. ======
  26. Alt-H2
  27. ------
  28. ```
  29. # H1
  30. ## H2
  31. ### H3
  32. #### H4
  33. ##### H5
  34. ###### H6
  35. Alternatively, for H1 and H2, an underline-ish style:
  36. Alt-H1
  37. ======
  38. Alt-H2
  39. ------
  40. ### Emphasis
  41. ```no-highlight
  42. Emphasis, aka italics, with *asterisks* or _underscores_.
  43. Strong emphasis, aka bold, with **asterisks** or __underscores__.
  44. Combined emphasis with **asterisks and _underscores_**.
  45. Strikethrough uses two tildes. ~~Scratch this.~~
  46. ```
  47. Emphasis, aka italics, with *asterisks* or _underscores_.
  48. Strong emphasis, aka bold, with **asterisks** or __underscores__.
  49. Combined emphasis with **asterisks and _underscores_**.
  50. Strikethrough uses two tildes. ~~Scratch this.~~
  51. ### Lists
  52. ```no-highlight
  53. 1. First ordered list item
  54. 2. Another item
  55. * Unordered sub-list.
  56. 1. Actual numbers don't matter, just that it's a number
  57. 1. Ordered sub-list
  58. 4. And another item.
  59. Some text that should be aligned with the above item.
  60. * Unordered list can use asterisks
  61. - Or minuses
  62. + Or pluses
  63. ```
  64. 1. First ordered list item
  65. 2. Another item
  66. * Unordered sub-list.
  67. 1. Actual numbers don't matter, just that it's a number
  68. 1. Ordered sub-list
  69. 4. And another item.
  70. Some text that should be aligned with the above item.
  71. * Unordered list can use asterisks
  72. - Or minuses
  73. + Or pluses
  74. ### Links
  75. There are two ways to create links.
  76. ```no-highlight
  77. [I'm an inline-style link](https://www.google.com)
  78. [I'm a reference-style link][Arbitrary case-insensitive reference text]
  79. [You can use numbers for reference-style link definitions][1]
  80. Or leave it empty and use the [link text itself][]
  81. Some text to show that the reference links can follow later.
  82. [arbitrary case-insensitive reference text]: https://www.mozilla.org
  83. [1]: http://slashdot.org
  84. [link text itself]: http://www.reddit.com
  85. ```
  86. [I'm an inline-style link](https://www.google.com)
  87. [I'm a reference-style link][Arbitrary case-insensitive reference text]
  88. [You can use numbers for reference-style link definitions][1]
  89. Or leave it empty and use the [link text itself][]
  90. Some text to show that the reference links can follow later.
  91. [arbitrary case-insensitive reference text]: https://www.mozilla.org
  92. [1]: http://slashdot.org
  93. [link text itself]: http://www.reddit.com
  94. ### Images
  95. ```no-highlight
  96. Here's our logo (hover to see the title text):
  97. Inline-style:
  98. ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
  99. Reference-style:
  100. ![alt text][logo]
  101. [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
  102. ```
  103. Here's our logo (hover to see the title text):
  104. Inline-style:
  105. ![alt text](https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 1")
  106. Reference-style:
  107. ![alt text][logo]
  108. [logo]: https://github.com/adam-p/markdown-here/raw/master/src/common/images/icon48.png "Logo Title Text 2"
  109. ### Code and Syntax Highlighting
  110. 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).
  111. ```no-highlight
  112. Inline `code` has `back-ticks around` it.
  113. ```
  114. Inline `code` has `back-ticks around` it.
  115. 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.
  116. ```no-highlight
  117. ```javascript
  118. var s = "JavaScript syntax highlighting";
  119. alert(s);
  120. ```
  121. ```python
  122. s = "Python syntax highlighting"
  123. print s
  124. ```
  125. ```
  126. No language indicated, so no syntax highlighting.
  127. But let's throw in a <b>tag</b>.
  128. ```
  129. ```
  130. ```javascript
  131. var s = "JavaScript syntax highlighting";
  132. alert(s);
  133. ```
  134. ```python
  135. s = "Python syntax highlighting"
  136. print s
  137. ```
  138. ```
  139. No language indicated, so no syntax highlighting in Markdown Here (varies on Github).
  140. But let's throw in a <b>tag</b>.
  141. ```
  142. (Github Wiki pages don't seem to support syntax highlighting, so the above won't be colourful (the strings are not red, for example). Try it out in a *Markdown Here* email or a Github Markdown README or Github Issue -- you can preview a new Issue without submitting it.)
  143. 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).
  144. ### Tables
  145. 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.
  146. ```no-highlight
  147. Colons can be used to align columns.
  148. | Tables | Are | Cool |
  149. | ------------- |:-------------:| -----:|
  150. | col 3 is | right-aligned | $1600 |
  151. | col 2 is | centered | $12 |
  152. | zebra stripes | are neat | $1 |
  153. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
  154. Markdown | Less | Pretty
  155. --- | --- | ---
  156. *Still* | `renders` | **nicely**
  157. 1 | 2 | 3
  158. ```
  159. Colons can be used to align columns.
  160. | Tables | Are | Cool |
  161. | ------------- |:-------------:| -----:|
  162. | col 3 is | right-aligned | $1600 |
  163. | col 2 is | centered | $12 |
  164. | zebra stripes | are neat | $1 |
  165. The outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.
  166. Markdown | Less | Pretty
  167. --- | --- | ---
  168. *Still* | `renders` | **nicely**
  169. 1 | 2 | 3
  170. ### Blockquotes
  171. ```no-highlight
  172. > Blockquotes are very handy in email to emulate reply text.
  173. > This line is part of the same quote.
  174. Quote break.
  175. > 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.
  176. ```
  177. > Blockquotes are very handy in email to emulate reply text.
  178. > This line is part of the same quote.
  179. Quote break.
  180. > 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.
  181. ### Inline HTML
  182. You can also use raw HTML in your Markdown, and it'll mostly work pretty well.
  183. ```no-highlight
  184. <dl>
  185. <dt>Definition list</dt>
  186. <dd>Is something people use sometimes.</dd>
  187. <dt>Markdown in HTML</dt>
  188. <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
  189. </dl>
  190. ```
  191. <dl>
  192. <dt>Definition list</dt>
  193. <dd>Is something people use sometimes.</dd>
  194. <dt>Markdown in HTML</dt>
  195. <dd>Does *not* work **very** well. Use HTML <em>tags</em>.</dd>
  196. </dl>
  197. ### Horizontal Rule
  198. ```
  199. Three or more...
  200. ---
  201. Hyphens
  202. ***
  203. Asterisks
  204. ___
  205. Underscores
  206. ```
  207. Three or more...
  208. ---
  209. Hyphens
  210. ***
  211. Asterisks
  212. ___
  213. Underscores
  214. ### Line Breaks
  215. 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.
  216. Here are some things to try out:
  217. ```
  218. Here's a line for us to start with.
  219. This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
  220. This line is also a separate paragraph, but...
  221. This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
  222. ```
  223. Here's a line for us to start with.
  224. This line is separated from the one above by two newlines, so it will be a *separate paragraph*.
  225. This line is also begins a separate paragraph, but...
  226. This line is only separated by a single newline, so it's a separate line in the *same paragraph*.
  227. (Technical note: *Markdown Here* uses GFM line breaks, so there's no need to use MD's two-space line breaks.)
  228. ### Youtube videos
  229. They can't be added directly but you can add an image with a link to the video like this:
  230. ```no-highlight
  231. <a href="http://www.youtube.com/watch?feature=player_embedded&v=YOUTUBE_VIDEO_ID_HERE
  232. " target="_blank"><img src="http://img.youtube.com/vi/YOUTUBE_VIDEO_ID_HERE/0.jpg"
  233. alt="IMAGE ALT TEXT HERE" width="240" height="180" border="10" /></a>
  234. ```
  235. Or, in pure Markdown, but losing the image sizing and border:
  236. ```no-highlight
  237. [![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)
  238. ```