|
| 1 | +<https://github.com/mxstbr/markdown-test-file> |
| 2 | + |
| 3 | +--------------------------------------------------------------------- |
| 4 | + |
| 5 | +# Markdown: Syntax |
| 6 | + |
| 7 | +* [Overview](#overview) |
| 8 | + * [Philosophy](#philosophy) |
| 9 | + * [Inline HTML](#html) |
| 10 | + * [Automatic Escaping for Special Characters](#autoescape) |
| 11 | +* [Block Elements](#block) |
| 12 | + * [Paragraphs and Line Breaks](#p) |
| 13 | + * [Headers](#header) |
| 14 | + * [Blockquotes](#blockquote) |
| 15 | + * [Lists](#list) |
| 16 | + * [Code Blocks](#precode) |
| 17 | + * [Horizontal Rules](#hr) |
| 18 | +* [Span Elements](#span) |
| 19 | + * [Links](#link) |
| 20 | + * [Emphasis](#em) |
| 21 | + * [Code](#code) |
| 22 | + * [Images](#img) |
| 23 | +* [Miscellaneous](#misc) |
| 24 | + * [Backslash Escapes](#backslash) |
| 25 | + * [Automatic Links](#autolink) |
| 26 | + |
| 27 | + |
| 28 | +**Note:** This document is itself written using Markdown; you |
| 29 | +can [see the source for it by adding '.text' to the URL](/projects/markdown/syntax.text). |
| 30 | + |
| 31 | +---- |
| 32 | + |
| 33 | +## Overview |
| 34 | + |
| 35 | +### Philosophy |
| 36 | + |
| 37 | +Markdown is intended to be as easy-to-read and easy-to-write as is feasible. |
| 38 | + |
| 39 | +Readability, however, is emphasized above all else. A Markdown-formatted |
| 40 | +document should be publishable as-is, as plain text, without looking |
| 41 | +like it's been marked up with tags or formatting instructions. While |
| 42 | +Markdown's syntax has been influenced by several existing text-to-HTML |
| 43 | +filters -- including [Setext](http://docutils.sourceforge.net/mirror/setext.html), [atx](http://www.aaronsw.com/2002/atx/), [Textile](http://textism.com/tools/textile/), [reStructuredText](http://docutils.sourceforge.net/rst.html), |
| 44 | +[Grutatext](http://www.triptico.com/software/grutatxt.html), and [EtText](http://ettext.taint.org/doc/) -- the single biggest source of |
| 45 | +inspiration for Markdown's syntax is the format of plain text email. |
| 46 | + |
| 47 | +## Block Elements |
| 48 | + |
| 49 | +### Paragraphs and Line Breaks |
| 50 | + |
| 51 | +A paragraph is simply one or more consecutive lines of text, separated |
| 52 | +by one or more blank lines. (A blank line is any line that looks like a |
| 53 | +blank line -- a line containing nothing but spaces or tabs is considered |
| 54 | +blank.) Normal paragraphs should not be indented with spaces or tabs. |
| 55 | + |
| 56 | +The implication of the "one or more consecutive lines of text" rule is |
| 57 | +that Markdown supports "hard-wrapped" text paragraphs. This differs |
| 58 | +significantly from most other text-to-HTML formatters (including Movable |
| 59 | +Type's "Convert Line Breaks" option) which translate every line break |
| 60 | +character in a paragraph into a `<br />` tag. |
| 61 | + |
| 62 | +When you *do* want to insert a `<br />` break tag using Markdown, you |
| 63 | +end a line with two or more spaces, then type return. |
| 64 | + |
| 65 | +### Headers |
| 66 | + |
| 67 | +Markdown supports two styles of headers, [Setext] [1] and [atx] [2]. |
| 68 | + |
| 69 | +Optionally, you may "close" atx-style headers. This is purely |
| 70 | +cosmetic -- you can use this if you think it looks better. The |
| 71 | +closing hashes don't even need to match the number of hashes |
| 72 | +used to open the header. (The number of opening hashes |
| 73 | +determines the header level.) |
| 74 | + |
| 75 | + |
| 76 | +### Blockquotes |
| 77 | + |
| 78 | +Markdown uses email-style `>` characters for blockquoting. If you're |
| 79 | +familiar with quoting passages of text in an email message, then you |
| 80 | +know how to create a blockquote in Markdown. It looks best if you hard |
| 81 | +wrap the text and put a `>` before every line: |
| 82 | + |
| 83 | +> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, |
| 84 | +> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. |
| 85 | +> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. |
| 86 | +> |
| 87 | +> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse |
| 88 | +> id sem consectetuer libero luctus adipiscing. |
| 89 | +Markdown allows you to be lazy and only put the `>` before the first |
| 90 | +line of a hard-wrapped paragraph: |
| 91 | + |
| 92 | +> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, |
| 93 | +consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus. |
| 94 | +Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus. |
| 95 | +> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse |
| 96 | +id sem consectetuer libero luctus adipiscing. |
| 97 | +Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by |
| 98 | +adding additional levels of `>`: |
| 99 | + |
| 100 | +> This is the first level of quoting. |
| 101 | +> |
| 102 | +> > This is nested blockquote. |
| 103 | +> |
| 104 | +> Back to the first level. |
| 105 | +Blockquotes can contain other Markdown elements, including headers, lists, |
| 106 | +and code blocks: |
| 107 | + |
| 108 | +> ## This is a header. |
| 109 | +> |
| 110 | +> 1. This is the first list item. |
| 111 | +> 2. This is the second list item. |
| 112 | +> |
| 113 | +> Here's some example code: |
| 114 | +> |
| 115 | +> return shell_exec("echo $input | $markdown_script"); |
| 116 | +Any decent text editor should make email-style quoting easy. For |
| 117 | +example, with BBEdit, you can make a selection and choose Increase |
| 118 | +Quote Level from the Text menu. |
| 119 | + |
| 120 | + |
| 121 | +### Lists |
| 122 | + |
| 123 | +Markdown supports ordered (numbered) and unordered (bulleted) lists. |
| 124 | + |
| 125 | +Unordered lists use asterisks, pluses, and hyphens -- interchangably |
| 126 | +-- as list markers: |
| 127 | + |
| 128 | +* Red |
| 129 | +* Green |
| 130 | +* Blue |
| 131 | + |
| 132 | +is equivalent to: |
| 133 | + |
| 134 | ++ Red |
| 135 | ++ Green |
| 136 | ++ Blue |
| 137 | + |
| 138 | +and: |
| 139 | + |
| 140 | +- Red |
| 141 | +- Green |
| 142 | +- Blue |
| 143 | + |
| 144 | +Ordered lists use numbers followed by periods: |
| 145 | + |
| 146 | +1. Bird |
| 147 | +2. McHale |
| 148 | +3. Parish |
| 149 | + |
| 150 | +It's important to note that the actual numbers you use to mark the |
| 151 | +list have no effect on the HTML output Markdown produces. The HTML |
| 152 | +Markdown produces from the above list is: |
| 153 | + |
| 154 | +If you instead wrote the list in Markdown like this: |
| 155 | + |
| 156 | +1. Bird |
| 157 | +1. McHale |
| 158 | +1. Parish |
| 159 | + |
| 160 | +or even: |
| 161 | + |
| 162 | +3. Bird |
| 163 | +1. McHale |
| 164 | +8. Parish |
| 165 | + |
| 166 | +you'd get the exact same HTML output. The point is, if you want to, |
| 167 | +you can use ordinal numbers in your ordered Markdown lists, so that |
| 168 | +the numbers in your source match the numbers in your published HTML. |
| 169 | +But if you want to be lazy, you don't have to. |
| 170 | + |
| 171 | +To make lists look nice, you can wrap items with hanging indents: |
| 172 | + |
| 173 | +* Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 174 | + Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, |
| 175 | + viverra nec, fringilla in, laoreet vitae, risus. |
| 176 | +* Donec sit amet nisl. Aliquam semper ipsum sit amet velit. |
| 177 | + Suspendisse id sem consectetuer libero luctus adipiscing. |
| 178 | + |
| 179 | +But if you want to be lazy, you don't have to: |
| 180 | + |
| 181 | +* Lorem ipsum dolor sit amet, consectetuer adipiscing elit. |
| 182 | +Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi, |
| 183 | +viverra nec, fringilla in, laoreet vitae, risus. |
| 184 | +* Donec sit amet nisl. Aliquam semper ipsum sit amet velit. |
| 185 | +Suspendisse id sem consectetuer libero luctus adipiscing. |
| 186 | + |
| 187 | +List items may consist of multiple paragraphs. Each subsequent |
| 188 | +paragraph in a list item must be indented by either 4 spaces |
| 189 | +or one tab: |
| 190 | + |
| 191 | +1. This is a list item with two paragraphs. Lorem ipsum dolor |
| 192 | + sit amet, consectetuer adipiscing elit. Aliquam hendrerit |
| 193 | + mi posuere lectus. |
| 194 | + |
| 195 | + Vestibulum enim wisi, viverra nec, fringilla in, laoreet |
| 196 | + vitae, risus. Donec sit amet nisl. Aliquam semper ipsum |
| 197 | + sit amet velit. |
| 198 | + |
| 199 | +2. Suspendisse id sem consectetuer libero luctus adipiscing. |
| 200 | + |
| 201 | +It looks nice if you indent every line of the subsequent |
| 202 | +paragraphs, but here again, Markdown will allow you to be |
| 203 | +lazy: |
| 204 | + |
| 205 | +* This is a list item with two paragraphs. |
| 206 | + |
| 207 | + This is the second paragraph in the list item. You're |
| 208 | +only required to indent the first line. Lorem ipsum dolor |
| 209 | +sit amet, consectetuer adipiscing elit. |
| 210 | + |
| 211 | +* Another item in the same list. |
| 212 | + |
| 213 | +To put a blockquote within a list item, the blockquote's `>` |
| 214 | +delimiters need to be indented: |
| 215 | + |
| 216 | +* A list item with a blockquote: |
| 217 | + |
| 218 | + > This is a blockquote |
| 219 | + > inside a list item. |
| 220 | +To put a code block within a list item, the code block needs |
| 221 | +to be indented *twice* -- 8 spaces or two tabs: |
| 222 | + |
| 223 | +* A list item with a code block: |
| 224 | + |
| 225 | + <code goes here> |
| 226 | + |
| 227 | +### Code Blocks |
| 228 | + |
| 229 | +Pre-formatted code blocks are used for writing about programming or |
| 230 | +markup source code. Rather than forming normal paragraphs, the lines |
| 231 | +of a code block are interpreted literally. Markdown wraps a code block |
| 232 | +in both `<pre>` and `<code>` tags. |
| 233 | + |
| 234 | +To produce a code block in Markdown, simply indent every line of the |
| 235 | +block by at least 4 spaces or 1 tab. |
| 236 | + |
| 237 | +This is a normal paragraph: |
| 238 | + |
| 239 | + This is a code block. |
| 240 | + |
| 241 | +Here is an example of AppleScript: |
| 242 | + |
| 243 | + tell application "Foo" |
| 244 | + beep |
| 245 | + end tell |
| 246 | + |
| 247 | +A code block continues until it reaches a line that is not indented |
| 248 | +(or the end of the article). |
| 249 | + |
| 250 | +Within a code block, ampersands (`&`) and angle brackets (`<` and `>`) |
| 251 | +are automatically converted into HTML entities. This makes it very |
| 252 | +easy to include example HTML source code using Markdown -- just paste |
| 253 | +it and indent it, and Markdown will handle the hassle of encoding the |
| 254 | +ampersands and angle brackets. For example, this: |
| 255 | + |
| 256 | + <div class="footer"> |
| 257 | + © 2004 Foo Corporation |
| 258 | + </div> |
| 259 | + |
| 260 | +Regular Markdown syntax is not processed within code blocks. E.g., |
| 261 | +asterisks are just literal asterisks within a code block. This means |
| 262 | +it's also easy to use Markdown to write about Markdown's own syntax. |
| 263 | + |
| 264 | +``` |
| 265 | +tell application "Foo" |
| 266 | + beep |
| 267 | +end tell |
| 268 | +``` |
| 269 | + |
| 270 | +## Span Elements |
| 271 | + |
| 272 | +### Links |
| 273 | + |
| 274 | +Markdown supports two style of links: *inline* and *reference*. |
| 275 | + |
| 276 | +In both styles, the link text is delimited by [square brackets]. |
| 277 | + |
| 278 | +To create an inline link, use a set of regular parentheses immediately |
| 279 | +after the link text's closing square bracket. Inside the parentheses, |
| 280 | +put the URL where you want the link to point, along with an *optional* |
| 281 | +title for the link, surrounded in quotes. For example: |
| 282 | + |
| 283 | +This is [an example](http://example.com/) inline link. |
| 284 | + |
| 285 | +[This link](http://example.net/) has no title attribute. |
| 286 | + |
| 287 | +### Emphasis |
| 288 | + |
| 289 | +Markdown treats asterisks (`*`) and underscores (`_`) as indicators of |
| 290 | +emphasis. Text wrapped with one `*` or `_` will be wrapped with an |
| 291 | +HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML |
| 292 | +`<strong>` tag. E.g., this input: |
| 293 | + |
| 294 | +*single asterisks* |
| 295 | + |
| 296 | +_single underscores_ |
| 297 | + |
| 298 | +**double asterisks** |
| 299 | + |
| 300 | +__double underscores__ |
| 301 | + |
| 302 | +### Code |
| 303 | + |
| 304 | +To indicate a span of code, wrap it with backtick quotes (`` ` ``). |
| 305 | +Unlike a pre-formatted code block, a code span indicates code within a |
| 306 | +normal paragraph. For example: |
| 307 | + |
| 308 | +Use the `printf()` function. |
| 309 | + |
| 310 | +--------------------------------------------------------------------- |
| 311 | + |
| 312 | +MIT License |
| 313 | + |
| 314 | +Copyright (c) 2017 Max Stoiber |
| 315 | + |
| 316 | +Permission is hereby granted, free of charge, to any person obtaining a copy |
| 317 | +of this software and associated documentation files (the "Software"), to deal |
| 318 | +in the Software without restriction, including without limitation the rights |
| 319 | +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 320 | +copies of the Software, and to permit persons to whom the Software is |
| 321 | +furnished to do so, subject to the following conditions: |
| 322 | + |
| 323 | +The above copyright notice and this permission notice shall be included in all |
| 324 | +copies or substantial portions of the Software. |
| 325 | + |
| 326 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 327 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 328 | +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 329 | +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 330 | +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 331 | +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 332 | +SOFTWARE. |
0 commit comments