markdown
Version:
A sensible Markdown parser for javascript
394 lines (393 loc) • 36.5 kB
JSON
["html", ["h1", "Markdown: Syntax"], "\u000a\u000a", ["ul", {
"id": "ProjectSubmenu"
},
["li", ["a", {
"href": "/projects/markdown/",
"title": "Markdown Project Page"
},
"Main"]],
["li", ["a", {
"href": "/projects/markdown/basics",
"title": "Markdown Basics"
},
"Basics"]],
["li", ["a", {
"class": "selected",
"title": "Markdown Syntax Documentation"
},
"Syntax"]],
["li", ["a", {
"href": "/projects/markdown/license",
"title": "Pricing and License Information"
},
"License"]],
["li", ["a", {
"href": "/projects/markdown/dingus",
"title": "Online Markdown Web Form"
},
"Dingus"]]],
["ul", ["li", ["a", {
"href": "#overview"
},
"Overview"], "\u000a", ["ul", ["li", ["a", {
"href": "#philosophy"
},
"Philosophy"]],
["li", ["a", {
"href": "#html"
},
"Inline HTML"]],
["li", ["a", {
"href": "#autoescape"
},
"Automatic Escaping for Special Characters"]]]],
["li", ["a", {
"href": "#block"
},
"Block Elements"], "\u000a", ["ul", ["li", ["a", {
"href": "#p"
},
"Paragraphs and Line Breaks"]],
["li", ["a", {
"href": "#header"
},
"Headers"]],
["li", ["a", {
"href": "#blockquote"
},
"Blockquotes"]],
["li", ["a", {
"href": "#list"
},
"Lists"]],
["li", ["a", {
"href": "#precode"
},
"Code Blocks"]],
["li", ["a", {
"href": "#hr"
},
"Horizontal Rules"]]]],
["li", ["a", {
"href": "#span"
},
"Span Elements"], "\u000a", ["ul", ["li", ["a", {
"href": "#link"
},
"Links"]],
["li", ["a", {
"href": "#em"
},
"Emphasis"]],
["li", ["a", {
"href": "#code"
},
"Code"]],
["li", ["a", {
"href": "#img"
},
"Images"]]]],
["li", ["a", {
"href": "#misc"
},
"Miscellaneous"], "\u000a", ["ul", ["li", ["a", {
"href": "#backslash"
},
"Backslash Escapes"]],
["li", ["a", {
"href": "#autolink"
},
"Automatic Links"]]]]],
["p", ["strong", "Note:"], " This document is itself written using Markdown; you\u000acan ", ["a", {
"href": "/projects/markdown/syntax.text"
},
"see the source for it by adding '.text' to the URL"], "."], "\u000a\u000a", ["hr"], "\u000a\u000a", ["h2", {
"id": "overview"
},
"Overview"], "\u000a\u000a", ["h3", {
"id": "philosophy"
},
"Philosophy"], "\u000a\u000a", ["p", "Markdown is intended to be as easy-to-read and easy-to-write as is feasible."],
["p", "Readability, however, is emphasized above all else. A Markdown-formatted\u000adocument should be publishable as-is, as plain text, without looking\u000alike it's been marked up with tags or formatting instructions. While\u000aMarkdown's syntax has been influenced by several existing text-to-HTML\u000afilters -- including ", ["a", {
"href": "http://docutils.sourceforge.net/mirror/setext.html"
},
"Setext"], ", ", ["a", {
"href": "http://www.aaronsw.com/2002/atx/"
},
"atx"], ", ", ["a", {
"href": "http://textism.com/tools/textile/"
},
"Textile"], ", ", ["a", {
"href": "http://docutils.sourceforge.net/rst.html"
},
"reStructuredText"], ",\u000a", ["a", {
"href": "http://www.triptico.com/software/grutatxt.html"
},
"Grutatext"], ", and ", ["a", {
"href": "http://ettext.taint.org/doc/"
},
"EtText"], " -- the single biggest source of\u000ainspiration for Markdown's syntax is the format of plain text email."],
["p", "To this end, Markdown's syntax is comprised entirely of punctuation\u000acharacters, which punctuation characters have been carefully chosen so\u000aas to look like what they mean. E.g., asterisks around a word actually\u000alook like *emphasis*. Markdown lists look like, well, lists. Even\u000ablockquotes look like quoted passages of text, assuming you've ever\u000aused email."], "\u000a\u000a", ["h3", {
"id": "html"
},
"Inline HTML"], "\u000a\u000a", ["p", "Markdown's syntax is intended for one purpose: to be used as a\u000aformat for ", ["em", "writing"], " for the web."],
["p", "Markdown is not a replacement for HTML, or even close to it. Its\u000asyntax is very small, corresponding only to a very small subset of\u000aHTML tags. The idea is ", ["em", "not"], " to create a syntax that makes it easier\u000ato insert HTML tags. In my opinion, HTML tags are already easy to\u000ainsert. The idea for Markdown is to make it easy to read, write, and\u000aedit prose. HTML is a ", ["em", "publishing"], " format; Markdown is a ", ["em", "writing"], "\u000aformat. Thus, Markdown's formatting syntax only addresses issues that\u000acan be conveyed in plain text."],
["p", "For any markup that is not covered by Markdown's syntax, you simply\u000ause HTML itself. There's no need to preface it or delimit it to\u000aindicate that you're switching from Markdown to HTML; you just use\u000athe tags."],
["p", "The only restrictions are that block-level HTML elements -- e.g. ", ["code", "<div>"], ",\u000a", ["code", "<table>"], ", ", ["code", "<pre>"], ", ", ["code", "<p>"], ", etc. -- must be separated from surrounding\u000acontent by blank lines, and the start and end tags of the block should\u000anot be indented with tabs or spaces. Markdown is smart enough not\u000ato add extra (unwanted) ", ["code", "<p>"], " tags around HTML block-level tags."],
["p", "For example, to add an HTML table to a Markdown article:"],
["pre", ["code", "This is a regular paragraph.\u000a\u000a<table>\u000a <tr>\u000a <td>Foo</td>\u000a </tr>\u000a</table>\u000a\u000aThis is another regular paragraph.\u000a"]],
["p", "Note that Markdown formatting syntax is not processed within block-level\u000aHTML tags. E.g., you can't use Markdown-style ", ["code", "*emphasis*"], " inside an\u000aHTML block."],
["p", "Span-level HTML tags -- e.g. ", ["code", "<span>"], ", ", ["code", "<cite>"], ", or ", ["code", "<del>"], " -- can be\u000aused anywhere in a Markdown paragraph, list item, or header. If you\u000awant, you can even use HTML tags instead of Markdown formatting; e.g. if\u000ayou'd prefer to use HTML ", ["code", "<a>"], " or ", ["code", "<img>"], " tags instead of Markdown's\u000alink or image syntax, go right ahead."],
["p", "Unlike block-level HTML tags, Markdown syntax ", ["em", "is"], " processed within\u000aspan-level tags."], "\u000a\u000a", ["h3", {
"id": "autoescape"
},
"Automatic Escaping for Special Characters"], "\u000a\u000a", ["p", "In HTML, there are two characters that demand special treatment: ", ["code", "<"], "\u000aand ", ["code", "&"], ". Left angle brackets are used to start tags; ampersands are\u000aused to denote HTML entities. If you want to use them as literal\u000acharacters, you must escape them as entities, e.g. ", ["code", "<"], ", and\u000a", ["code", "&"], "."],
["p", "Ampersands in particular are bedeviling for web writers. If you want to\u000awrite about 'AT&T', you need to write '", ["code", "AT&T"], "'. You even need to\u000aescape ampersands within URLs. Thus, if you want to link to:"],
["pre", ["code", "http://images.google.com/images?num=30&q=larry+bird\u000a"]],
["p", "you need to encode the URL as:"],
["pre", ["code", "http://images.google.com/images?num=30&q=larry+bird\u000a"]],
["p", "in your anchor tag ", ["code", "href"], " attribute. Needless to say, this is easy to\u000aforget, and is probably the single most common source of HTML validation\u000aerrors in otherwise well-marked-up web sites."],
["p", "Markdown allows you to use these characters naturally, taking care of\u000aall the necessary escaping for you. If you use an ampersand as part of\u000aan HTML entity, it remains unchanged; otherwise it will be translated\u000ainto ", ["code", "&"], "."],
["p", "So, if you want to include a copyright symbol in your article, you can write:"],
["pre", ["code", "©\u000a"]],
["p", "and Markdown will leave it alone. But if you write:"],
["pre", ["code", "AT&T\u000a"]],
["p", "Markdown will translate it to:"],
["pre", ["code", "AT&T\u000a"]],
["p", "Similarly, because Markdown supports ", ["a", {
"href": "#html"
},
"inline HTML"], ", if you use\u000aangle brackets as delimiters for HTML tags, Markdown will treat them as\u000asuch. But if you write:"],
["pre", ["code", "4 < 5\u000a"]],
["p", "Markdown will translate it to:"],
["pre", ["code", "4 < 5\u000a"]],
["p", "However, inside Markdown code spans and blocks, angle brackets and\u000aampersands are ", ["em", "always"], " encoded automatically. This makes it easy to use\u000aMarkdown to write about HTML code. (As opposed to raw HTML, which is a\u000aterrible format for writing about HTML syntax, because every single ", ["code", "<"], "\u000aand ", ["code", "&"], " in your example code needs to be escaped.)"], "\u000a\u000a", ["hr"], "\u000a\u000a", ["h2", {
"id": "block"
},
"Block Elements"], "\u000a\u000a", ["h3", {
"id": "p"
},
"Paragraphs and Line Breaks"], "\u000a\u000a", ["p", "A paragraph is simply one or more consecutive lines of text, separated\u000aby one or more blank lines. (A blank line is any line that looks like a\u000ablank line -- a line containing nothing but spaces or tabs is considered\u000ablank.) Normal paragraphs should not be intended with spaces or tabs."],
["p", "The implication of the \"one or more consecutive lines of text\" rule is\u000athat Markdown supports \"hard-wrapped\" text paragraphs. This differs\u000asignificantly from most other text-to-HTML formatters (including Movable\u000aType's \"Convert Line Breaks\" option) which translate every line break\u000acharacter in a paragraph into a ", ["code", "<br />"], " tag."],
["p", "When you ", ["em", "do"], " want to insert a ", ["code", "<br />"], " break tag using Markdown, you\u000aend a line with two or more spaces, then type return."],
["p", "Yes, this takes a tad more effort to create a ", ["code", "<br />"], ", but a simplistic\u000a\"every line break is a ", ["code", "<br />"], "\" rule wouldn't work for Markdown.\u000aMarkdown's email-style ", ["a", {
"href": "#blockquote"
},
"blockquoting"], " and multi-paragraph ", ["a", {
"href": "#list"
},
"list items"], "\u000awork best -- and look better -- when you format them with hard breaks."], "\u000a\u000a", ["h3", {
"id": "header"
},
"Headers"], "\u000a\u000a", ["p", "Markdown supports two styles of headers, ", ["a", {
"href": "http://docutils.sourceforge.net/mirror/setext.html"
},
"Setext"], " and ", ["a", {
"href": "http://www.aaronsw.com/2002/atx/"
},
"atx"], "."],
["p", "Setext-style headers are \"underlined\" using equal signs (for first-level\u000aheaders) and dashes (for second-level headers). For example:"],
["pre", ["code", "This is an H1\u000a=============\u000a\u000aThis is an H2\u000a-------------\u000a"]],
["p", "Any number of underlining ", ["code", "="], "'s or ", ["code", "-"], "'s will work."],
["p", "Atx-style headers use 1-6 hash characters at the start of the line,\u000acorresponding to header levels 1-6. For example:"],
["pre", ["code", "# This is an H1\u000a\u000a## This is an H2\u000a\u000a###### This is an H6\u000a"]],
["p", "Optionally, you may \"close\" atx-style headers. This is purely\u000acosmetic -- you can use this if you think it looks better. The\u000aclosing hashes don't even need to match the number of hashes\u000aused to open the header. (The number of opening hashes\u000adetermines the header level.) :"],
["pre", ["code", "# This is an H1 #\u000a\u000a## This is an H2 ##\u000a\u000a### This is an H3 ######\u000a"]], "\u000a\u000a", ["h3", {
"id": "blockquote"
},
"Blockquotes"], "\u000a\u000a", ["p", "Markdown uses email-style ", ["code", ">"], " characters for blockquoting. If you're\u000afamiliar with quoting passages of text in an email message, then you\u000aknow how to create a blockquote in Markdown. It looks best if you hard\u000awrap the text and put a ", ["code", ">"], " before every line:"],
["pre", ["code", "> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\u000a> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\u000a> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\u000a> \u000a> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\u000a> id sem consectetuer libero luctus adipiscing.\u000a"]],
["p", "Markdown allows you to be lazy and only put the ", ["code", ">"], " before the first\u000aline of a hard-wrapped paragraph:"],
["pre", ["code", "> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\u000aconsectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\u000aVestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\u000a\u000a> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\u000aid sem consectetuer libero luctus adipiscing.\u000a"]],
["p", "Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by\u000aadding additional levels of ", ["code", ">"], ":"],
["pre", ["code", "> This is the first level of quoting.\u000a>\u000a> > This is nested blockquote.\u000a>\u000a> Back to the first level.\u000a"]],
["p", "Blockquotes can contain other Markdown elements, including headers, lists,\u000aand code blocks:"],
["pre", ["code", "> ## This is a header.\u000a> \u000a> 1. This is the first list item.\u000a> 2. This is the second list item.\u000a> \u000a> Here's some example code:\u000a> \u000a> return shell_exec(\"echo $input | $markdown_script\");\u000a"]],
["p", "Any decent text editor should make email-style quoting easy. For\u000aexample, with BBEdit, you can make a selection and choose Increase\u000aQuote Level from the Text menu."], "\u000a\u000a", ["h3", {
"id": "list"
},
"Lists"], "\u000a\u000a", ["p", "Markdown supports ordered (numbered) and unordered (bulleted) lists."],
["p", "Unordered lists use asterisks, pluses, and hyphens -- interchangably\u000a-- as list markers:"],
["pre", ["code", "* Red\u000a* Green\u000a* Blue\u000a"]],
["p", "is equivalent to:"],
["pre", ["code", "+ Red\u000a+ Green\u000a+ Blue\u000a"]],
["p", "and:"],
["pre", ["code", "- Red\u000a- Green\u000a- Blue\u000a"]],
["p", "Ordered lists use numbers followed by periods:"],
["pre", ["code", "1. Bird\u000a2. McHale\u000a3. Parish\u000a"]],
["p", "It's important to note that the actual numbers you use to mark the\u000alist have no effect on the HTML output Markdown produces. The HTML\u000aMarkdown produces from the above list is:"],
["pre", ["code", "<ol>\u000a<li>Bird</li>\u000a<li>McHale</li>\u000a<li>Parish</li>\u000a</ol>\u000a"]],
["p", "If you instead wrote the list in Markdown like this:"],
["pre", ["code", "1. Bird\u000a1. McHale\u000a1. Parish\u000a"]],
["p", "or even:"],
["pre", ["code", "3. Bird\u000a1. McHale\u000a8. Parish\u000a"]],
["p", "you'd get the exact same HTML output. The point is, if you want to,\u000ayou can use ordinal numbers in your ordered Markdown lists, so that\u000athe numbers in your source match the numbers in your published HTML.\u000aBut if you want to be lazy, you don't have to."],
["p", "If you do use lazy list numbering, however, you should still start the\u000alist with the number 1. At some point in the future, Markdown may support\u000astarting ordered lists at an arbitrary number."],
["p", "List markers typically start at the left margin, but may be indented by\u000aup to three spaces. List markers must be followed by one or more spaces\u000aor a tab."],
["p", "To make lists look nice, you can wrap items with hanging indents:"],
["pre", ["code", "* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\u000a Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\u000a viverra nec, fringilla in, laoreet vitae, risus.\u000a* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\u000a Suspendisse id sem consectetuer libero luctus adipiscing.\u000a"]],
["p", "But if you want to be lazy, you don't have to:"],
["pre", ["code", "* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\u000aAliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\u000aviverra nec, fringilla in, laoreet vitae, risus.\u000a* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\u000aSuspendisse id sem consectetuer libero luctus adipiscing.\u000a"]],
["p", "If list items are separated by blank lines, Markdown will wrap the\u000aitems in ", ["code", "<p>"], " tags in the HTML output. For example, this input:"],
["pre", ["code", "* Bird\u000a* Magic\u000a"]],
["p", "will turn into:"],
["pre", ["code", "<ul>\u000a<li>Bird</li>\u000a<li>Magic</li>\u000a</ul>\u000a"]],
["p", "But this:"],
["pre", ["code", "* Bird\u000a\u000a* Magic\u000a"]],
["p", "will turn into:"],
["pre", ["code", "<ul>\u000a<li><p>Bird</p></li>\u000a<li><p>Magic</p></li>\u000a</ul>\u000a"]],
["p", "List items may consist of multiple paragraphs. Each subsequent\u000aparagraph in a list item must be intended by either 4 spaces\u000aor one tab:"],
["pre", ["code", "1. This is a list item with two paragraphs. Lorem ipsum dolor\u000a sit amet, consectetuer adipiscing elit. Aliquam hendrerit\u000a mi posuere lectus.\u000a\u000a Vestibulum enim wisi, viverra nec, fringilla in, laoreet\u000a vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\u000a sit amet velit.\u000a\u000a2. Suspendisse id sem consectetuer libero luctus adipiscing.\u000a"]],
["p", "It looks nice if you indent every line of the subsequent\u000aparagraphs, but here again, Markdown will allow you to be\u000alazy:"],
["pre", ["code", "* This is a list item with two paragraphs.\u000a\u000a This is the second paragraph in the list item. You're\u000aonly required to indent the first line. Lorem ipsum dolor\u000asit amet, consectetuer adipiscing elit.\u000a\u000a* Another item in the same list.\u000a"]],
["p", "To put a blockquote within a list item, the blockquote's ", ["code", ">"], "\u000adelimiters need to be indented:"],
["pre", ["code", "* A list item with a blockquote:\u000a\u000a > This is a blockquote\u000a > inside a list item.\u000a"]],
["p", "To put a code block within a list item, the code block needs\u000ato be indented ", ["em", "twice"], " -- 8 spaces or two tabs:"],
["pre", ["code", "* A list item with a code block:\u000a\u000a <code goes here>\u000a"]],
["p", "It's worth noting that it's possible to trigger an ordered list by\u000aaccident, by writing something like this:"],
["pre", ["code", "1986. What a great season.\u000a"]],
["p", "In other words, a ", ["em", "number-period-space"], " sequence at the beginning of a\u000aline. To avoid this, you can backslash-escape the period:"],
["pre", ["code", "1986\\. What a great season.\u000a"]], "\u000a\u000a", ["h3", {
"id": "precode"
},
"Code Blocks"], "\u000a\u000a", ["p", "Pre-formatted code blocks are used for writing about programming or\u000amarkup source code. Rather than forming normal paragraphs, the lines\u000aof a code block are interpreted literally. Markdown wraps a code block\u000ain both ", ["code", "<pre>"], " and ", ["code", "<code>"], " tags."],
["p", "To produce a code block in Markdown, simply indent every line of the\u000ablock by at least 4 spaces or 1 tab. For example, given this input:"],
["pre", ["code", "This is a normal paragraph:\u000a\u000a This is a code block.\u000a"]],
["p", "Markdown will generate:"],
["pre", ["code", "<p>This is a normal paragraph:</p>\u000a\u000a<pre><code>This is a code block.\u000a</code></pre>\u000a"]],
["p", "One level of indentation -- 4 spaces or 1 tab -- is removed from each\u000aline of the code block. For example, this:"],
["pre", ["code", "Here is an example of AppleScript:\u000a\u000a tell application \"Foo\"\u000a beep\u000a end tell\u000a"]],
["p", "will turn into:"],
["pre", ["code", "<p>Here is an example of AppleScript:</p>\u000a\u000a<pre><code>tell application \"Foo\"\u000a beep\u000aend tell\u000a</code></pre>\u000a"]],
["p", "A code block continues until it reaches a line that is not indented\u000a(or the end of the article)."],
["p", "Within a code block, ampersands (", ["code", "&"], ") and angle brackets (", ["code", "<"], " and ", ["code", ">"], ")\u000aare automatically converted into HTML entities. This makes it very\u000aeasy to include example HTML source code using Markdown -- just paste\u000ait and indent it, and Markdown will handle the hassle of encoding the\u000aampersands and angle brackets. For example, this:"],
["pre", ["code", " <div class=\"footer\">\u000a © 2004 Foo Corporation\u000a </div>\u000a"]],
["p", "will turn into:"],
["pre", ["code", "<pre><code><div class=\"footer\">\u000a &copy; 2004 Foo Corporation\u000a</div>\u000a</code></pre>\u000a"]],
["p", "Regular Markdown syntax is not processed within code blocks. E.g.,\u000aasterisks are just literal asterisks within a code block. This means\u000ait's also easy to use Markdown to write about Markdown's own syntax."], "\u000a\u000a", ["h3", {
"id": "hr"
},
"Horizontal Rules"], "\u000a\u000a", ["p", "You can produce a horizontal rule tag (", ["code", "<hr />"], ") by placing three or\u000amore hyphens, asterisks, or underscores on a line by themselves. If you\u000awish, you may use spaces between the hyphens or asterisks. Each of the\u000afollowing lines will produce a horizontal rule:"],
["pre", ["code", "* * *\u000a\u000a***\u000a\u000a*****\u000a\u000a- - -\u000a\u000a---------------------------------------\u000a\u000a_ _ _\u000a"]], "\u000a\u000a", ["hr"], "\u000a\u000a", ["h2", {
"id": "span"
},
"Span Elements"], "\u000a\u000a", ["h3", {
"id": "link"
},
"Links"], "\u000a\u000a", ["p", "Markdown supports two style of links: ", ["em", "inline"], " and ", ["em", "reference"], "."],
["p", "In both styles, the link text is delimited by [square brackets]."],
["p", "To create an inline link, use a set of regular parentheses immediately\u000aafter the link text's closing square bracket. Inside the parentheses,\u000aput the URL where you want the link to point, along with an ", ["em", "optional"], "\u000atitle for the link, surrounded in quotes. For example:"],
["pre", ["code", "This is [an example](http://example.com/ \"Title\") inline link.\u000a\u000a[This link](http://example.net/) has no title attribute.\u000a"]],
["p", "Will produce:"],
["pre", ["code", "<p>This is <a href=\"http://example.com/\" title=\"Title\">\u000aan example</a> inline link.</p>\u000a\u000a<p><a href=\"http://example.net/\">This link</a> has no\u000atitle attribute.</p>\u000a"]],
["p", "If you're referring to a local resource on the same server, you can\u000ause relative paths:"],
["pre", ["code", "See my [About](/about/) page for details.\u000a"]],
["p", "Reference-style links use a second set of square brackets, inside\u000awhich you place a label of your choosing to identify the link:"],
["pre", ["code", "This is [an example][id] reference-style link.\u000a"]],
["p", "You can optionally use a space to separate the sets of brackets:"],
["pre", ["code", "This is [an example] [id] reference-style link.\u000a"]],
["p", "Then, anywhere in the document, you define your link label like this,\u000aon a line by itself:"],
["pre", ["code", "[id]: http://example.com/ \"Optional Title Here\"\u000a"]],
["p", "That is:"],
["ul", ["li", "Square brackets containing the link identifier (optionally\u000aindented from the left margin using up to three spaces);"],
["li", "followed by a colon;"],
["li", "followed by one or more spaces (or tabs);"],
["li", "followed by the URL for the link;"],
["li", "optionally followed by a title attribute for the link, enclosed\u000ain double or single quotes."]],
["p", "The link URL may, optionally, be surrounded by angle brackets:"],
["pre", ["code", "[id]: <http://example.com/> \"Optional Title Here\"\u000a"]],
["p", "You can put the title attribute on the next line and use extra spaces\u000aor tabs for padding, which tends to look better with longer URLs:"],
["pre", ["code", "[id]: http://example.com/longish/path/to/resource/here\u000a \"Optional Title Here\"\u000a"]],
["p", "Link definitions are only used for creating links during Markdown\u000aprocessing, and are stripped from your document in the HTML output."],
["p", "Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are ", ["em", "not"], " case sensitive. E.g. these two links:"],
["pre", ["code", "[link text][a]\u000a[link text][A]\u000a"]],
["p", "are equivalent."],
["p", "The ", ["em", "implicit link name"], " shortcut allows you to omit the name of the\u000alink, in which case the link text itself is used as the name.\u000aJust use an empty set of square brackets -- e.g., to link the word\u000a\"Google\" to the google.com web site, you could simply write:"],
["pre", ["code", "[Google][]\u000a"]],
["p", "And then define the link:"],
["pre", ["code", "[Google]: http://google.com/\u000a"]],
["p", "Because link names may contain spaces, this shortcut even works for\u000amultiple words in the link text:"],
["pre", ["code", "Visit [Daring Fireball][] for more information.\u000a"]],
["p", "And then define the link:"],
["pre", ["code", "[Daring Fireball]: http://daringfireball.net/\u000a"]],
["p", "Link definitions can be placed anywhere in your Markdown document. I\u000atend to put them immediately after each paragraph in which they're\u000aused, but if you want, you can put them all at the end of your\u000adocument, sort of like footnotes."],
["p", "Here's an example of reference links in action:"],
["pre", ["code", "I get 10 times more traffic from [Google] [1] than from\u000a[Yahoo] [2] or [MSN] [3].\u000a\u000a [1]: http://google.com/ \"Google\"\u000a [2]: http://search.yahoo.com/ \"Yahoo Search\"\u000a [3]: http://search.msn.com/ \"MSN Search\"\u000a"]],
["p", "Using the implicit link name shortcut, you could instead write:"],
["pre", ["code", "I get 10 times more traffic from [Google][] than from\u000a[Yahoo][] or [MSN][].\u000a\u000a [google]: http://google.com/ \"Google\"\u000a [yahoo]: http://search.yahoo.com/ \"Yahoo Search\"\u000a [msn]: http://search.msn.com/ \"MSN Search\"\u000a"]],
["p", "Both of the above examples will produce the following HTML output:"],
["pre", ["code", "<p>I get 10 times more traffic from <a href=\"http://google.com/\"\u000atitle=\"Google\">Google</a> than from\u000a<a href=\"http://search.yahoo.com/\" title=\"Yahoo Search\">Yahoo</a>\u000aor <a href=\"http://search.msn.com/\" title=\"MSN Search\">MSN</a>.</p>\u000a"]],
["p", "For comparison, here is the same paragraph written using\u000aMarkdown's inline link style:"],
["pre", ["code", "I get 10 times more traffic from [Google](http://google.com/ \"Google\")\u000athan from [Yahoo](http://search.yahoo.com/ \"Yahoo Search\") or\u000a[MSN](http://search.msn.com/ \"MSN Search\").\u000a"]],
["p", "The point of reference-style links is not that they're easier to\u000awrite. The point is that with reference-style links, your document\u000asource is vastly more readable. Compare the above examples: using\u000areference-style links, the paragraph itself is only 81 characters\u000along; with inline-style links, it's 176 characters; and as raw HTML,\u000ait's 234 characters. In the raw HTML, there's more markup than there\u000ais text."],
["p", "With Markdown's reference-style links, a source document much more\u000aclosely resembles the final output, as rendered in a browser. By\u000aallowing you to move the markup-related metadata out of the paragraph,\u000ayou can add links without interrupting the narrative flow of your\u000aprose."], "\u000a\u000a", ["h3", {
"id": "em"
},
"Emphasis"], "\u000a\u000a", ["p", "Markdown treats asterisks (", ["code", "*"], ") and underscores (", ["code", "_"], ") as indicators of\u000aemphasis. Text wrapped with one ", ["code", "*"], " or ", ["code", "_"], " will be wrapped with an\u000aHTML ", ["code", "<em>"], " tag; double ", ["code", "*"], "'s or ", ["code", "_"], "'s will be wrapped with an HTML\u000a", ["code", "<strong>"], " tag. E.g., this input:"],
["pre", ["code", "*single asterisks*\u000a\u000a_single underscores_\u000a\u000a**double asterisks**\u000a\u000a__double underscores__\u000a"]],
["p", "will produce:"],
["pre", ["code", "<em>single asterisks</em>\u000a\u000a<em>single underscores</em>\u000a\u000a<strong>double asterisks</strong>\u000a\u000a<strong>double underscores</strong>\u000a"]],
["p", "You can use whichever style you prefer; the lone restriction is that\u000athe same character must be used to open and close an emphasis span."],
["p", "Emphasis can be used in the middle of a word:"],
["pre", ["code", "un*fucking*believable\u000a"]],
["p", "But if you surround an ", ["code", "*"], " or ", ["code", "_"], " with spaces, it'll be treated as a\u000aliteral asterisk or underscore."],
["p", "To produce a literal asterisk or underscore at a position where it\u000awould otherwise be used as an emphasis delimiter, you can backslash\u000aescape it:"],
["pre", ["code", "\\*this text is surrounded by literal asterisks\\*\u000a"]], "\u000a\u000a", ["h3", {
"id": "code"
},
"Code"], "\u000a\u000a", ["p", "To indicate a span of code, wrap it with backtick quotes (", ["code", "`"], ").\u000aUnlike a pre-formatted code block, a code span indicates code within a\u000anormal paragraph. For example:"],
["pre", ["code", "Use the `printf()` function.\u000a"]],
["p", "will produce:"],
["pre", ["code", "<p>Use the <code>printf()</code> function.</p>\u000a"]],
["p", "To include a literal backtick character within a code span, you can use\u000amultiple backticks as the opening and closing delimiters:"],
["pre", ["code", "``There is a literal backtick (`) here.``\u000a"]],
["p", "which will produce this:"],
["pre", ["code", "<p><code>There is a literal backtick (`) here.</code></p>\u000a"]],
["p", "The backtick delimiters surrounding a code span may include spaces --\u000aone after the opening, one before the closing. This allows you to place\u000aliteral backtick characters at the beginning or end of a code span:"],
["pre", ["code", "A single backtick in a code span: `` ` ``\u000a\u000aA backtick-delimited string in a code span: `` `foo` ``\u000a"]],
["p", "will produce:"],
["pre", ["code", "<p>A single backtick in a code span: <code>`</code></p>\u000a\u000a<p>A backtick-delimited string in a code span: <code>`foo`</code></p>\u000a"]],
["p", "With a code span, ampersands and angle brackets are encoded as HTML\u000aentities automatically, which makes it easy to include example HTML\u000atags. Markdown will turn this:"],
["pre", ["code", "Please don't use any `<blink>` tags.\u000a"]],
["p", "into:"],
["pre", ["code", "<p>Please don't use any <code><blink></code> tags.</p>\u000a"]],
["p", "You can write this:"],
["pre", ["code", "`—` is the decimal-encoded equivalent of `—`.\u000a"]],
["p", "to produce:"],
["pre", ["code", "<p><code>&#8212;</code> is the decimal-encoded\u000aequivalent of <code>&mdash;</code>.</p>\u000a"]], "\u000a\u000a", ["h3", {
"id": "img"
},
"Images"], "\u000a\u000a", ["p", "Admittedly, it's fairly difficult to devise a \"natural\" syntax for\u000aplacing images into a plain text document format."],
["p", "Markdown uses an image syntax that is intended to resemble the syntax\u000afor links, allowing for two styles: ", ["em", "inline"], " and ", ["em", "reference"], "."],
["p", "Inline image syntax looks like this:"],
["pre", ["code", "\u000a\u000a\u000a"]],
["p", "That is:"],
["ul", ["li", "An exclamation mark: ", ["code", "!"], ";"],
["li", "followed by a set of square brackets, containing the ", ["code", "alt"], "\u000aattribute text for the image;"],
["li", "followed by a set of parentheses, containing the URL or path to\u000athe image, and an optional ", ["code", "title"], " attribute enclosed in double\u000aor single quotes."]],
["p", "Reference-style image syntax looks like this:"],
["pre", ["code", "![Alt text][id]\u000a"]],
["p", "Where \"id\" is the name of a defined image reference. Image references\u000aare defined using syntax identical to link references:"],
["pre", ["code", "[id]: url/to/image \"Optional title attribute\"\u000a"]],
["p", "As of this writing, Markdown has no syntax for specifying the\u000adimensions of an image; if this is important to you, you can simply\u000ause regular HTML ", ["code", "<img>"], " tags."], "\u000a\u000a", ["hr"], "\u000a\u000a", ["h2", {
"id": "misc"
},
"Miscellaneous"], "\u000a\u000a", ["h3", {
"id": "autolink"
},
"Automatic Links"], "\u000a\u000a", ["p", "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:"],
["pre", ["code", "<http://example.com/>\u000a"]],
["p", "Markdown will turn this into:"],
["pre", ["code", "<a href=\"http://example.com/\">http://example.com/</a>\u000a"]],
["p", "Automatic links for email addresses work similarly, except that\u000aMarkdown will also perform a bit of randomized decimal and hex\u000aentity-encoding to help obscure your address from address-harvesting\u000aspambots. For example, Markdown will turn this:"],
["pre", ["code", "<address@example.com>\u000a"]],
["p", "into something like this:"],
["pre", ["code", "<a href=\"mailto:addre\u000ass@example.co\u000am\">address@exa\u000ample.com</a>\u000a"]],
["p", "which will render in a browser as a clickable link to \"address@example.com\"."],
["p", "(This sort of entity-encoding trick will indeed fool many, if not\u000amost, address-harvesting bots, but it definitely won't fool all of\u000athem. It's better than nothing, but an address published in this way\u000awill probably eventually start receiving spam.)"], "\u000a\u000a", ["h3", {
"id": "backslash"
},
"Backslash Escapes"], "\u000a\u000a", ["p", "Markdown allows you to use backslash escapes to generate literal\u000acharacters which would otherwise have special meaning in Markdown's\u000aformatting syntax. For example, if you wanted to surround a word with\u000aliteral asterisks (instead of an HTML ", ["code", "<em>"], " tag), you can backslashes\u000abefore the asterisks, like this:"],
["pre", ["code", "\\*literal asterisks\\*\u000a"]],
["p", "Markdown provides backslash escapes for the following characters:"],
["pre", ["code", "\\ backslash\u000a` backtick\u000a* asterisk\u000a_ underscore\u000a{} curly braces\u000a[] square brackets\u000a() parentheses\u000a# hash mark\u000a+ plus sign\u000a- minus sign (hyphen)\u000a. dot\u000a! exclamation mark\u000a"]]]