Text::Markdown::Discount
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.

897 lines
27 KiB

  1. Markdown: Syntax
  2. ================
  3. <ul id="ProjectSubmenu">
  4. <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
  5. <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
  6. <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
  7. <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
  8. <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
  9. </ul>
  10. * [Overview](#overview)
  11. * [Philosophy](#philosophy)
  12. * [Inline HTML](#html)
  13. * [Automatic Escaping for Special Characters](#autoescape)
  14. * [Block Elements](#block)
  15. * [Paragraphs and Line Breaks](#p)
  16. * [Headers](#header)
  17. * [Blockquotes](#blockquote)
  18. * [Lists](#list)
  19. * [Code Blocks](#precode)
  20. * [Horizontal Rules](#hr)
  21. * [Span Elements](#span)
  22. * [Links](#link)
  23. * [Emphasis](#em)
  24. * [Code](#code)
  25. * [Images](#img)
  26. * [Miscellaneous](#misc)
  27. * [Backslash Escapes](#backslash)
  28. * [Automatic Links](#autolink)
  29. **Note:** This document is itself written using Markdown; you
  30. can [see the source for it by adding '.text' to the URL][src].
  31. [src]: /projects/markdown/syntax.text
  32. * * *
  33. <h2 id="overview">Overview</h2>
  34. <h3 id="philosophy">Philosophy</h3>
  35. Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
  36. Readability, however, is emphasized above all else. A Markdown-formatted
  37. document should be publishable as-is, as plain text, without looking
  38. like it's been marked up with tags or formatting instructions. While
  39. Markdown's syntax has been influenced by several existing text-to-HTML
  40. filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
  41. [Grutatext] [5], and [EtText] [6] -- the single biggest source of
  42. inspiration for Markdown's syntax is the format of plain text email.
  43. [1]: http://docutils.sourceforge.net/mirror/setext.html
  44. [2]: http://www.aaronsw.com/2002/atx/
  45. [3]: http://textism.com/tools/textile/
  46. [4]: http://docutils.sourceforge.net/rst.html
  47. [5]: http://www.triptico.com/software/grutatxt.html
  48. [6]: http://ettext.taint.org/doc/
  49. To this end, Markdown's syntax is comprised entirely of punctuation
  50. characters, which punctuation characters have been carefully chosen so
  51. as to look like what they mean. E.g., asterisks around a word actually
  52. look like \*emphasis\*. Markdown lists look like, well, lists. Even
  53. blockquotes look like quoted passages of text, assuming you've ever
  54. used email.
  55. <h3 id="html">Inline HTML</h3>
  56. Markdown's syntax is intended for one purpose: to be used as a
  57. format for *writing* for the web.
  58. Markdown is not a replacement for HTML, or even close to it. Its
  59. syntax is very small, corresponding only to a very small subset of
  60. HTML tags. The idea is *not* to create a syntax that makes it easier
  61. to insert HTML tags. In my opinion, HTML tags are already easy to
  62. insert. The idea for Markdown is to make it easy to read, write, and
  63. edit prose. HTML is a *publishing* format; Markdown is a *writing*
  64. format. Thus, Markdown's formatting syntax only addresses issues that
  65. can be conveyed in plain text.
  66. For any markup that is not covered by Markdown's syntax, you simply
  67. use HTML itself. There's no need to preface it or delimit it to
  68. indicate that you're switching from Markdown to HTML; you just use
  69. the tags.
  70. The only restrictions are that block-level HTML elements -- e.g. `<div>`,
  71. `<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
  72. content by blank lines, and the start and end tags of the block should
  73. not be indented with tabs or spaces. Markdown is smart enough not
  74. to add extra (unwanted) `<p>` tags around HTML block-level tags.
  75. For example, to add an HTML table to a Markdown article:
  76. This is a regular paragraph.
  77. <table>
  78. <tr>
  79. <td>Foo</td>
  80. </tr>
  81. </table>
  82. This is another regular paragraph.
  83. Note that Markdown formatting syntax is not processed within block-level
  84. HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
  85. HTML block.
  86. Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
  87. used anywhere in a Markdown paragraph, list item, or header. If you
  88. want, you can even use HTML tags instead of Markdown formatting; e.g. if
  89. you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
  90. link or image syntax, go right ahead.
  91. Unlike block-level HTML tags, Markdown syntax *is* processed within
  92. span-level tags.
  93. <h3 id="autoescape">Automatic Escaping for Special Characters</h3>
  94. In HTML, there are two characters that demand special treatment: `<`
  95. and `&`. Left angle brackets are used to start tags; ampersands are
  96. used to denote HTML entities. If you want to use them as literal
  97. characters, you must escape them as entities, e.g. `&lt;`, and
  98. `&amp;`.
  99. Ampersands in particular are bedeviling for web writers. If you want to
  100. write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
  101. escape ampersands within URLs. Thus, if you want to link to:
  102. http://images.google.com/images?num=30&q=larry+bird
  103. you need to encode the URL as:
  104. http://images.google.com/images?num=30&amp;q=larry+bird
  105. in your anchor tag `href` attribute. Needless to say, this is easy to
  106. forget, and is probably the single most common source of HTML validation
  107. errors in otherwise well-marked-up web sites.
  108. Markdown allows you to use these characters naturally, taking care of
  109. all the necessary escaping for you. If you use an ampersand as part of
  110. an HTML entity, it remains unchanged; otherwise it will be translated
  111. into `&amp;`.
  112. So, if you want to include a copyright symbol in your article, you can write:
  113. &copy;
  114. and Markdown will leave it alone. But if you write:
  115. AT&T
  116. Markdown will translate it to:
  117. AT&amp;T
  118. Similarly, because Markdown supports [inline HTML](#html), if you use
  119. angle brackets as delimiters for HTML tags, Markdown will treat them as
  120. such. But if you write:
  121. 4 < 5
  122. Markdown will translate it to:
  123. 4 &lt; 5
  124. However, inside Markdown code spans and blocks, angle brackets and
  125. ampersands are *always* encoded automatically. This makes it easy to use
  126. Markdown to write about HTML code. (As opposed to raw HTML, which is a
  127. terrible format for writing about HTML syntax, because every single `<`
  128. and `&` in your example code needs to be escaped.)
  129. * * *
  130. <h2 id="block">Block Elements</h2>
  131. <h3 id="p">Paragraphs and Line Breaks</h3>
  132. A paragraph is simply one or more consecutive lines of text, separated
  133. by one or more blank lines. (A blank line is any line that looks like a
  134. blank line -- a line containing nothing but spaces or tabs is considered
  135. blank.) Normal paragraphs should not be indented with spaces or tabs.
  136. The implication of the "one or more consecutive lines of text" rule is
  137. that Markdown supports "hard-wrapped" text paragraphs. This differs
  138. significantly from most other text-to-HTML formatters (including Movable
  139. Type's "Convert Line Breaks" option) which translate every line break
  140. character in a paragraph into a `<br />` tag.
  141. When you *do* want to insert a `<br />` break tag using Markdown, you
  142. end a line with two or more spaces, then type return.
  143. Yes, this takes a tad more effort to create a `<br />`, but a simplistic
  144. "every line break is a `<br />`" rule wouldn't work for Markdown.
  145. Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
  146. work best -- and look better -- when you format them with hard breaks.
  147. [bq]: #blockquote
  148. [l]: #list
  149. <h3 id="header">Headers</h3>
  150. Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
  151. Setext-style headers are "underlined" using equal signs (for first-level
  152. headers) and dashes (for second-level headers). For example:
  153. This is an H1
  154. =============
  155. This is an H2
  156. -------------
  157. Any number of underlining `=`'s or `-`'s will work.
  158. Atx-style headers use 1-6 hash characters at the start of the line,
  159. corresponding to header levels 1-6. For example:
  160. # This is an H1
  161. ## This is an H2
  162. ###### This is an H6
  163. Optionally, you may "close" atx-style headers. This is purely
  164. cosmetic -- you can use this if you think it looks better. The
  165. closing hashes don't even need to match the number of hashes
  166. used to open the header. (The number of opening hashes
  167. determines the header level.) :
  168. # This is an H1 #
  169. ## This is an H2 ##
  170. ### This is an H3 ######
  171. <h3 id="blockquote">Blockquotes</h3>
  172. Markdown uses email-style `>` characters for blockquoting. If you're
  173. familiar with quoting passages of text in an email message, then you
  174. know how to create a blockquote in Markdown. It looks best if you hard
  175. wrap the text and put a `>` before every line:
  176. > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
  177. > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
  178. > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
  179. >
  180. > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
  181. > id sem consectetuer libero luctus adipiscing.
  182. Markdown allows you to be lazy and only put the `>` before the first
  183. line of a hard-wrapped paragraph:
  184. > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
  185. consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
  186. Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
  187. > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
  188. id sem consectetuer libero luctus adipiscing.
  189. Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
  190. adding additional levels of `>`:
  191. > This is the first level of quoting.
  192. >
  193. > > This is nested blockquote.
  194. >
  195. > Back to the first level.
  196. Blockquotes can contain other Markdown elements, including headers, lists,
  197. and code blocks:
  198. > ## This is a header.
  199. >
  200. > 1. This is the first list item.
  201. > 2. This is the second list item.
  202. >
  203. > Here's some example code:
  204. >
  205. > return shell_exec("echo $input | $markdown_script");
  206. Any decent text editor should make email-style quoting easy. For
  207. example, with BBEdit, you can make a selection and choose Increase
  208. Quote Level from the Text menu.
  209. <h3 id="list">Lists</h3>
  210. Markdown supports ordered (numbered) and unordered (bulleted) lists.
  211. Unordered lists use asterisks, pluses, and hyphens -- interchangably
  212. -- as list markers:
  213. * Red
  214. * Green
  215. * Blue
  216. is equivalent to:
  217. + Red
  218. + Green
  219. + Blue
  220. and:
  221. - Red
  222. - Green
  223. - Blue
  224. Ordered lists use numbers followed by periods:
  225. 1. Bird
  226. 2. McHale
  227. 3. Parish
  228. It's important to note that the actual numbers you use to mark the
  229. list have no effect on the HTML output Markdown produces. The HTML
  230. Markdown produces from the above list is:
  231. <ol>
  232. <li>Bird</li>
  233. <li>McHale</li>
  234. <li>Parish</li>
  235. </ol>
  236. If you instead wrote the list in Markdown like this:
  237. 1. Bird
  238. 1. McHale
  239. 1. Parish
  240. or even:
  241. 3. Bird
  242. 1. McHale
  243. 8. Parish
  244. you'd get the exact same HTML output. The point is, if you want to,
  245. you can use ordinal numbers in your ordered Markdown lists, so that
  246. the numbers in your source match the numbers in your published HTML.
  247. But if you want to be lazy, you don't have to.
  248. If you do use lazy list numbering, however, you should still start the
  249. list with the number 1. At some point in the future, Markdown may support
  250. starting ordered lists at an arbitrary number.
  251. List markers typically start at the left margin, but may be indented by
  252. up to three spaces. List markers must be followed by one or more spaces
  253. or a tab.
  254. To make lists look nice, you can wrap items with hanging indents:
  255. * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  256. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
  257. viverra nec, fringilla in, laoreet vitae, risus.
  258. * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
  259. Suspendisse id sem consectetuer libero luctus adipiscing.
  260. But if you want to be lazy, you don't have to:
  261. * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
  262. Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
  263. viverra nec, fringilla in, laoreet vitae, risus.
  264. * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
  265. Suspendisse id sem consectetuer libero luctus adipiscing.
  266. If list items are separated by blank lines, Markdown will wrap the
  267. items in `<p>` tags in the HTML output. For example, this input:
  268. * Bird
  269. * Magic
  270. will turn into:
  271. <ul>
  272. <li>Bird</li>
  273. <li>Magic</li>
  274. </ul>
  275. But this:
  276. * Bird
  277. * Magic
  278. will turn into:
  279. <ul>
  280. <li><p>Bird</p></li>
  281. <li><p>Magic</p></li>
  282. </ul>
  283. List items may consist of multiple paragraphs. Each subsequent
  284. paragraph in a list item must be intended by either 4 spaces
  285. or one tab:
  286. 1. This is a list item with two paragraphs. Lorem ipsum dolor
  287. sit amet, consectetuer adipiscing elit. Aliquam hendrerit
  288. mi posuere lectus.
  289. Vestibulum enim wisi, viverra nec, fringilla in, laoreet
  290. vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
  291. sit amet velit.
  292. 2. Suspendisse id sem consectetuer libero luctus adipiscing.
  293. It looks nice if you indent every line of the subsequent
  294. paragraphs, but here again, Markdown will allow you to be
  295. lazy:
  296. * This is a list item with two paragraphs.
  297. This is the second paragraph in the list item. You're
  298. only required to indent the first line. Lorem ipsum dolor
  299. sit amet, consectetuer adipiscing elit.
  300. * Another item in the same list.
  301. To put a blockquote within a list item, the blockquote's `>`
  302. delimiters need to be indented:
  303. * A list item with a blockquote:
  304. > This is a blockquote
  305. > inside a list item.
  306. To put a code block within a list item, the code block needs
  307. to be indented *twice* -- 8 spaces or two tabs:
  308. * A list item with a code block:
  309. <code goes here>
  310. It's worth noting that it's possible to trigger an ordered list by
  311. accident, by writing something like this:
  312. 1986. What a great season.
  313. In other words, a *number-period-space* sequence at the beginning of a
  314. line. To avoid this, you can backslash-escape the period:
  315. 1986\. What a great season.
  316. <h3 id="precode">Code Blocks</h3>
  317. Pre-formatted code blocks are used for writing about programming or
  318. markup source code. Rather than forming normal paragraphs, the lines
  319. of a code block are interpreted literally. Markdown wraps a code block
  320. in both `<pre>` and `<code>` tags.
  321. To produce a code block in Markdown, simply indent every line of the
  322. block by at least 4 spaces or 1 tab. For example, given this input:
  323. This is a normal paragraph:
  324. This is a code block.
  325. Markdown will generate:
  326. <p>This is a normal paragraph:</p>
  327. <pre><code>This is a code block.
  328. </code></pre>
  329. One level of indentation -- 4 spaces or 1 tab -- is removed from each
  330. line of the code block. For example, this:
  331. Here is an example of AppleScript:
  332. tell application "Foo"
  333. beep
  334. end tell
  335. will turn into:
  336. <p>Here is an example of AppleScript:</p>
  337. <pre><code>tell application "Foo"
  338. beep
  339. end tell
  340. </code></pre>
  341. A code block continues until it reaches a line that is not indented
  342. (or the end of the article).
  343. Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
  344. are automatically converted into HTML entities. This makes it very
  345. easy to include example HTML source code using Markdown -- just paste
  346. it and indent it, and Markdown will handle the hassle of encoding the
  347. ampersands and angle brackets. For example, this:
  348. <div class="footer">
  349. &copy; 2004 Foo Corporation
  350. </div>
  351. will turn into:
  352. <pre><code>&lt;div class="footer"&gt;
  353. &amp;copy; 2004 Foo Corporation
  354. &lt;/div&gt;
  355. </code></pre>
  356. Regular Markdown syntax is not processed within code blocks. E.g.,
  357. asterisks are just literal asterisks within a code block. This means
  358. it's also easy to use Markdown to write about Markdown's own syntax.
  359. <h3 id="hr">Horizontal Rules</h3>
  360. You can produce a horizontal rule tag (`<hr />`) by placing three or
  361. more hyphens, asterisks, or underscores on a line by themselves. If you
  362. wish, you may use spaces between the hyphens or asterisks. Each of the
  363. following lines will produce a horizontal rule:
  364. * * *
  365. ***
  366. *****
  367. - - -
  368. ---------------------------------------
  369. * * *
  370. <h2 id="span">Span Elements</h2>
  371. <h3 id="link">Links</h3>
  372. Markdown supports two style of links: *inline* and *reference*.
  373. In both styles, the link text is delimited by [square brackets].
  374. To create an inline link, use a set of regular parentheses immediately
  375. after the link text's closing square bracket. Inside the parentheses,
  376. put the URL where you want the link to point, along with an *optional*
  377. title for the link, surrounded in quotes. For example:
  378. This is [an example](http://example.com/ "Title") inline link.
  379. [This link](http://example.net/) has no title attribute.
  380. Will produce:
  381. <p>This is <a href="http://example.com/" title="Title">
  382. an example</a> inline link.</p>
  383. <p><a href="http://example.net/">This link</a> has no
  384. title attribute.</p>
  385. If you're referring to a local resource on the same server, you can
  386. use relative paths:
  387. See my [About](/about/) page for details.
  388. Reference-style links use a second set of square brackets, inside
  389. which you place a label of your choosing to identify the link:
  390. This is [an example][id] reference-style link.
  391. You can optionally use a space to separate the sets of brackets:
  392. This is [an example] [id] reference-style link.
  393. Then, anywhere in the document, you define your link label like this,
  394. on a line by itself:
  395. [id]: http://example.com/ "Optional Title Here"
  396. That is:
  397. * Square brackets containing the link identifier (optionally
  398. indented from the left margin using up to three spaces);
  399. * followed by a colon;
  400. * followed by one or more spaces (or tabs);
  401. * followed by the URL for the link;
  402. * optionally followed by a title attribute for the link, enclosed
  403. in double or single quotes, or enclosed in parentheses.
  404. The following three link definitions are equivalent:
  405. [foo]: http://example.com/ "Optional Title Here"
  406. [foo]: http://example.com/ 'Optional Title Here'
  407. [foo]: http://example.com/ (Optional Title Here)
  408. **Note:** There is a known bug in Markdown.pl 1.0.1 which prevents
  409. single quotes from being used to delimit link titles.
  410. The link URL may, optionally, be surrounded by angle brackets:
  411. [id]: <http://example.com/> "Optional Title Here"
  412. You can put the title attribute on the next line and use extra spaces
  413. or tabs for padding, which tends to look better with longer URLs:
  414. [id]: http://example.com/longish/path/to/resource/here
  415. "Optional Title Here"
  416. Link definitions are only used for creating links during Markdown
  417. processing, and are stripped from your document in the HTML output.
  418. Link definition names may constist of letters, numbers, spaces, and
  419. punctuation -- but they are *not* case sensitive. E.g. these two
  420. links:
  421. [link text][a]
  422. [link text][A]
  423. are equivalent.
  424. The *implicit link name* shortcut allows you to omit the name of the
  425. link, in which case the link text itself is used as the name.
  426. Just use an empty set of square brackets -- e.g., to link the word
  427. "Google" to the google.com web site, you could simply write:
  428. [Google][]
  429. And then define the link:
  430. [Google]: http://google.com/
  431. Because link names may contain spaces, this shortcut even works for
  432. multiple words in the link text:
  433. Visit [Daring Fireball][] for more information.
  434. And then define the link:
  435. [Daring Fireball]: http://daringfireball.net/
  436. Link definitions can be placed anywhere in your Markdown document. I
  437. tend to put them immediately after each paragraph in which they're
  438. used, but if you want, you can put them all at the end of your
  439. document, sort of like footnotes.
  440. Here's an example of reference links in action:
  441. I get 10 times more traffic from [Google] [1] than from
  442. [Yahoo] [2] or [MSN] [3].
  443. [1]: http://google.com/ "Google"
  444. [2]: http://search.yahoo.com/ "Yahoo Search"
  445. [3]: http://search.msn.com/ "MSN Search"
  446. Using the implicit link name shortcut, you could instead write:
  447. I get 10 times more traffic from [Google][] than from
  448. [Yahoo][] or [MSN][].
  449. [google]: http://google.com/ "Google"
  450. [yahoo]: http://search.yahoo.com/ "Yahoo Search"
  451. [msn]: http://search.msn.com/ "MSN Search"
  452. Both of the above examples will produce the following HTML output:
  453. <p>I get 10 times more traffic from <a href="http://google.com/"
  454. title="Google">Google</a> than from
  455. <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
  456. or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
  457. For comparison, here is the same paragraph written using
  458. Markdown's inline link style:
  459. I get 10 times more traffic from [Google](http://google.com/ "Google")
  460. than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
  461. [MSN](http://search.msn.com/ "MSN Search").
  462. The point of reference-style links is not that they're easier to
  463. write. The point is that with reference-style links, your document
  464. source is vastly more readable. Compare the above examples: using
  465. reference-style links, the paragraph itself is only 81 characters
  466. long; with inline-style links, it's 176 characters; and as raw HTML,
  467. it's 234 characters. In the raw HTML, there's more markup than there
  468. is text.
  469. With Markdown's reference-style links, a source document much more
  470. closely resembles the final output, as rendered in a browser. By
  471. allowing you to move the markup-related metadata out of the paragraph,
  472. you can add links without interrupting the narrative flow of your
  473. prose.
  474. <h3 id="em">Emphasis</h3>
  475. Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
  476. emphasis. Text wrapped with one `*` or `_` will be wrapped with an
  477. HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
  478. `<strong>` tag. E.g., this input:
  479. *single asterisks*
  480. _single underscores_
  481. **double asterisks**
  482. __double underscores__
  483. will produce:
  484. <em>single asterisks</em>
  485. <em>single underscores</em>
  486. <strong>double asterisks</strong>
  487. <strong>double underscores</strong>
  488. You can use whichever style you prefer; the lone restriction is that
  489. the same character must be used to open and close an emphasis span.
  490. Emphasis can be used in the middle of a word:
  491. un*fucking*believable
  492. But if you surround an `*` or `_` with spaces, it'll be treated as a
  493. literal asterisk or underscore.
  494. To produce a literal asterisk or underscore at a position where it
  495. would otherwise be used as an emphasis delimiter, you can backslash
  496. escape it:
  497. \*this text is surrounded by literal asterisks\*
  498. <h3 id="code">Code</h3>
  499. To indicate a span of code, wrap it with backtick quotes (`` ` ``).
  500. Unlike a pre-formatted code block, a code span indicates code within a
  501. normal paragraph. For example:
  502. Use the `printf()` function.
  503. will produce:
  504. <p>Use the <code>printf()</code> function.</p>
  505. To include a literal backtick character within a code span, you can use
  506. multiple backticks as the opening and closing delimiters:
  507. ``There is a literal backtick (`) here.``
  508. which will produce this:
  509. <p><code>There is a literal backtick (`) here.</code></p>
  510. The backtick delimiters surrounding a code span may include spaces --
  511. one after the opening, one before the closing. This allows you to place
  512. literal backtick characters at the beginning or end of a code span:
  513. A single backtick in a code span: `` ` ``
  514. A backtick-delimited string in a code span: `` `foo` ``
  515. will produce:
  516. <p>A single backtick in a code span: <code>`</code></p>
  517. <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
  518. With a code span, ampersands and angle brackets are encoded as HTML
  519. entities automatically, which makes it easy to include example HTML
  520. tags. Markdown will turn this:
  521. Please don't use any `<blink>` tags.
  522. into:
  523. <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
  524. You can write this:
  525. `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
  526. to produce:
  527. <p><code>&amp;#8212;</code> is the decimal-encoded
  528. equivalent of <code>&amp;mdash;</code>.</p>
  529. <h3 id="img">Images</h3>
  530. Admittedly, it's fairly difficult to devise a "natural" syntax for
  531. placing images into a plain text document format.
  532. Markdown uses an image syntax that is intended to resemble the syntax
  533. for links, allowing for two styles: *inline* and *reference*.
  534. Inline image syntax looks like this:
  535. ![Alt text](/path/to/img.jpg)
  536. ![Alt text](/path/to/img.jpg "Optional title")
  537. That is:
  538. * An exclamation mark: `!`;
  539. * followed by a set of square brackets, containing the `alt`
  540. attribute text for the image;
  541. * followed by a set of parentheses, containing the URL or path to
  542. the image, and an optional `title` attribute enclosed in double
  543. or single quotes.
  544. Reference-style image syntax looks like this:
  545. ![Alt text][id]
  546. Where "id" is the name of a defined image reference. Image references
  547. are defined using syntax identical to link references:
  548. [id]: url/to/image "Optional title attribute"
  549. As of this writing, Markdown has no syntax for specifying the
  550. dimensions of an image; if this is important to you, you can simply
  551. use regular HTML `<img>` tags.
  552. * * *
  553. <h2 id="misc">Miscellaneous</h2>
  554. <h3 id="autolink">Automatic Links</h3>
  555. Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:
  556. <http://example.com/>
  557. Markdown will turn this into:
  558. <a href="http://example.com/">http://example.com/</a>
  559. Automatic links for email addresses work similarly, except that
  560. Markdown will also perform a bit of randomized decimal and hex
  561. entity-encoding to help obscure your address from address-harvesting
  562. spambots. For example, Markdown will turn this:
  563. <address@example.com>
  564. into something like this:
  565. <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
  566. &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
  567. &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
  568. &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
  569. which will render in a browser as a clickable link to "address@example.com".
  570. (This sort of entity-encoding trick will indeed fool many, if not
  571. most, address-harvesting bots, but it definitely won't fool all of
  572. them. It's better than nothing, but an address published in this way
  573. will probably eventually start receiving spam.)
  574. <h3 id="backslash">Backslash Escapes</h3>
  575. Markdown allows you to use backslash escapes to generate literal
  576. characters which would otherwise have special meaning in Markdown's
  577. formatting syntax. For example, if you wanted to surround a word with
  578. literal asterisks (instead of an HTML `<em>` tag), you can backslashes
  579. before the asterisks, like this:
  580. \*literal asterisks\*
  581. Markdown provides backslash escapes for the following characters:
  582. \ backslash
  583. ` backtick
  584. * asterisk
  585. _ underscore
  586. {} curly braces
  587. [] square brackets
  588. () parentheses
  589. # hash mark
  590. + plus sign
  591. - minus sign (hyphen)
  592. . dot
  593. ! exclamation mark