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.

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