--- a/markdown-syntax.md +++ b/markdown-syntax.md @@ -1,12 +1,7 @@ -Markdown: Syntax ================ @@ -31,7 +26,6 @@ * [Automatic Links](#autolink) -**Note:** This document is itself written using Markdown; you can [see the source for it by adding '.text' to the URL][src]. [src]: /projects/markdown/syntax.text @@ -42,15 +36,11 @@

Philosophy

-Markdown is intended to be as easy-to-read and easy-to-write as is feasible. -Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions. While -Markdown's syntax has been influenced by several existing text-to-HTML filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4], [Grutatext] [5], and [EtText] [6] -- the single biggest source of -inspiration for Markdown's syntax is the format of plain text email. [1]: http://docutils.sourceforge.net/mirror/setext.html [2]: http://www.aaronsw.com/2002/atx/ @@ -59,10 +49,8 @@ [5]: http://www.triptico.com/software/grutatxt.html [6]: http://ettext.taint.org/doc/ -To this end, Markdown's syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually -look like \*emphasis\*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you've ever used email. @@ -70,30 +58,21 @@

Inline HTML

-Markdown's syntax is intended for one purpose: to be used as a format for *writing* for the web. -Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is *not* to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to -insert. The idea for Markdown is to make it easy to read, write, and -edit prose. HTML is a *publishing* format; Markdown is a *writing* -format. Thus, Markdown's formatting syntax only addresses issues that can be conveyed in plain text. -For any markup that is not covered by Markdown's syntax, you simply use HTML itself. There's no need to preface it or delimit it to -indicate that you're switching from Markdown to HTML; you just use the tags. The only restrictions are that block-level HTML elements -- e.g. `
`, ``, `
`, `

`, etc. -- must be separated from surrounding content by blank lines, and the start and end tags of the block should -not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) `

` tags around HTML block-level tags. -For example, to add an HTML table to a Markdown article: This is a regular paragraph. @@ -105,17 +84,11 @@ This is another regular paragraph. -Note that Markdown formatting syntax is not processed within block-level -HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an HTML block. Span-level HTML tags -- e.g. ``, ``, or `` -- can be -used anywhere in a Markdown paragraph, list item, or header. If you -want, you can even use HTML tags instead of Markdown formatting; e.g. if -you'd prefer to use HTML `` or `` tags instead of Markdown's link or image syntax, go right ahead. -Unlike block-level HTML tags, Markdown syntax *is* processed within span-level tags. @@ -141,7 +114,6 @@ forget, and is probably the single most common source of HTML validation errors in otherwise well-marked-up web sites. -Markdown allows you to use these characters naturally, taking care of all the necessary escaping for you. If you use an ampersand as part of an HTML entity, it remains unchanged; otherwise it will be translated into `&`. @@ -150,27 +122,20 @@ © -and Markdown will leave it alone. But if you write: AT&T -Markdown will translate it to: AT&T -Similarly, because Markdown supports [inline HTML](#html), if you use -angle brackets as delimiters for HTML tags, Markdown will treat them as such. But if you write: 4 < 5 -Markdown will translate it to: 4 < 5 -However, inside Markdown code spans and blocks, angle brackets and ampersands are *always* encoded automatically. This makes it easy to use -Markdown to write about HTML code. (As opposed to raw HTML, which is a terrible format for writing about HTML syntax, because every single `<` and `&` in your example code needs to be escaped.) @@ -189,17 +154,13 @@ blank.) Normal paragraphs should not be indented with spaces or tabs. The implication of the "one or more consecutive lines of text" rule is -that Markdown supports "hard-wrapped" text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type's "Convert Line Breaks" option) which translate every line break character in a paragraph into a `
` tag. -When you *do* want to insert a `
` break tag using Markdown, you end a line with two or more spaces, then type return. Yes, this takes a tad more effort to create a `
`, but a simplistic -"every line break is a `
`" rule wouldn't work for Markdown. -Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l] work best -- and look better -- when you format them with hard breaks. [bq]: #blockquote @@ -209,7 +170,6 @@

-Markdown supports two styles of headers, [Setext] [1] and [atx] [2]. Setext-style headers are "underlined" using equal signs (for first-level headers) and dashes (for second-level headers). For example: @@ -246,9 +206,7 @@

Blockquotes

-Markdown uses email-style `>` characters for blockquoting. If you're familiar with quoting passages of text in an email message, then you -know how to create a blockquote in Markdown. It looks best if you hard wrap the text and put a `>` before every line: > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, @@ -258,7 +216,6 @@ > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse > id sem consectetuer libero luctus adipiscing. -Markdown allows you to be lazy and only put the `>` before the first line of a hard-wrapped paragraph: > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet, @@ -277,7 +234,6 @@ > > Back to the first level. -Blockquotes can contain other Markdown elements, including headers, lists, and code blocks: > ## This is a header. @@ -296,7 +252,6 @@

Lists

-Markdown supports ordered (numbered) and unordered (bulleted) lists. Unordered lists use asterisks, pluses, and hyphens -- interchangably -- as list markers: @@ -324,8 +279,6 @@ 3. Parish It's important to note that the actual numbers you use to mark the -list have no effect on the HTML output Markdown produces. The HTML -Markdown produces from the above list is:
  1. Bird
  2. @@ -333,7 +286,6 @@
  3. Parish
-If you instead wrote the list in Markdown like this: 1. Bird 1. McHale @@ -346,12 +298,10 @@ 8. Parish you'd get the exact same HTML output. The point is, if you want to, -you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don't have to. If you do use lazy list numbering, however, you should still start the -list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number. List markers typically start at the left margin, but may be indented by @@ -374,7 +324,6 @@ * Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse id sem consectetuer libero luctus adipiscing. -If list items are separated by blank lines, Markdown will wrap the items in `

` tags in the HTML output. For example, this input: * Bird @@ -415,7 +364,6 @@ 2. Suspendisse id sem consectetuer libero luctus adipiscing. It looks nice if you indent every line of the subsequent -paragraphs, but here again, Markdown will allow you to be lazy: * This is a list item with two paragraphs. @@ -458,10 +406,8 @@ Pre-formatted code blocks are used for writing about programming or markup source code. Rather than forming normal paragraphs, the lines -of a code block are interpreted literally. Markdown wraps a code block in both `

` and `` tags.

-To produce a code block in Markdown, simply indent every line of the
 block by at least 4 spaces or 1 tab. For example, given this input:

     This is a normal paragraph:
@@ -468,7 +414,6 @@

         This is a code block.

-Markdown will generate:

     

This is a normal paragraph:

@@ -498,8 +443,6 @@ Within a code block, ampersands (`&`) and angle brackets (`<` and `>`) are automatically converted into HTML entities. This makes it very -easy to include example HTML source code using Markdown -- just paste -it and indent it, and Markdown will handle the hassle of encoding the ampersands and angle brackets. For example, this:
-Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means -it's also easy to use Markdown to write about Markdown's own syntax. @@ -543,7 +484,6 @@ -Markdown supports two style of links: *inline* and *reference*. In both styles, the link text is delimited by [square brackets]. @@ -599,7 +539,6 @@ [foo]: http://example.com/ 'Optional Title Here' [foo]: http://example.com/ (Optional Title Here) -**Note:** There is a known bug in Markdown.pl 1.0.1 which prevents single quotes from being used to delimit link titles. The link URL may, optionally, be surrounded by angle brackets: @@ -612,7 +551,6 @@ [id]: http://example.com/longish/path/to/resource/here "Optional Title Here" -Link definitions are only used for creating links during Markdown processing, and are stripped from your document in the HTML output. Link definition names may consist of letters, numbers, spaces, and @@ -644,7 +582,6 @@ [Daring Fireball]: http://daringfireball.net/ -Link definitions can be placed anywhere in your Markdown document. I tend to put them immediately after each paragraph in which they're used, but if you want, you can put them all at the end of your document, sort of like footnotes. @@ -675,7 +612,6 @@ or
MSN.

For comparison, here is the same paragraph written using -Markdown's inline link style: I get 10 times more traffic from [Google](http://google.com/ "Google") than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or @@ -689,7 +625,6 @@ it's 234 characters. In the raw HTML, there's more markup than there is text. -With Markdown's reference-style links, a source document much more closely resembles the final output, as rendered in a browser. By allowing you to move the markup-related metadata out of the paragraph, you can add links without interrupting the narrative flow of your @@ -698,7 +633,6 @@

Emphasis

-Markdown treats asterisks (`*`) and underscores (`_`) as indicators of emphasis. Text wrapped with one `*` or `_` will be wrapped with an HTML `` tag; double `*`'s or `_`'s will be wrapped with an HTML `` tag. E.g., this input: @@ -776,7 +710,6 @@ With a code span, ampersands and angle brackets are encoded as HTML entities automatically, which makes it easy to include example HTML -tags. Markdown will turn this: Please don't use any `` tags. @@ -800,7 +733,6 @@ Admittedly, it's fairly difficult to devise a "natural" syntax for placing images into a plain text document format. -Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: *inline* and *reference*. Inline image syntax looks like this: @@ -827,7 +759,6 @@ [id]: url/to/image "Optional title attribute" -As of this writing, Markdown has no syntax for specifying the dimensions of an image; if this is important to you, you can simply use regular HTML `` tags. @@ -839,18 +770,14 @@ -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: -Markdown will turn this into: http://example.com/ Automatic links for email addresses work similarly, except that -Markdown will also perform a bit of randomized decimal and hex entity-encoding to help obscure your address from address-harvesting -spambots. For example, Markdown will turn this: @@ -872,8 +799,6 @@

Backslash Escapes

-Markdown allows you to use backslash escapes to generate literal -characters which would otherwise have special meaning in Markdown's formatting syntax. For example, if you wanted to surround a word with literal asterisks (instead of an HTML `` tag), you can use backslashes before the asterisks, like this: @@ -880,7 +805,6 @@ \*literal asterisks\* -Markdown provides backslash escapes for the following characters: \ backslash ` backtick