From 965dfbd28c7688023a759e4bf02613425dd9db57 Mon Sep 17 00:00:00 2001 From: Gordon Guthrie Date: Thu, 11 Mar 2010 14:20:29 +0000 Subject: [PATCH] production bug fixed 1.1.8 --- README | 23 ++++ README.html | 22 ++++ src/markdown.erl | 79 +++++++----- src/markdown_tests.erl | 95 -------------- src/markdown_tests.hrl | 286 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 377 insertions(+), 128 deletions(-) delete mode 100644 src/markdown_tests.erl create mode 100644 src/markdown_tests.hrl diff --git a/README b/README index 4f905bc..bf0253a 100644 --- a/README +++ b/README @@ -1,6 +1,29 @@ +DEVELOPER NOTES +=============== + +Erlmarkdown uses generated tests. There are 2 levels of generation: +`./tests/index.html` uses `generate_tests.js` to take a set of input test cases +and output an EUnit test file for Erlang. + +Some of the tests in `generate_tests.js` are hand written and some have been generated from the MarkdownSharp test suites. + +The MarkdownSharp test suites were originally downloaded from: +`http://code.google.com/p/markdownsharp/` + +They can be found in `./tests/markdowndownsharp/` + +The code that generates tests from them in in the escript file: +`./priv/make_tests` + + Release Notes ============= +Version 1.1.8 Production Bug Fix +-------------------------------- + +Some blocktag/html errrors fixed + Version 1.1.7 Production Bug Fix -------------------------------- diff --git a/README.html b/README.html index e4c08a5..c2677f7 100644 --- a/README.html +++ b/README.html @@ -1,6 +1,28 @@ +

DEVELOPER NOTES

+ + +

Erlmarkdown uses generated tests. There are 2 levels of generation: +./tests/index.html uses generate_tests.js to take a set of input test cases +and output an EUnit test file for Erlang.

+ +

Some of the tests in generate_tests.js are hand written and some have been generated from the MarkdownSharp test suites.

+ +

The MarkdownSharp test suites were originally downloaded from: +http://code.google.com/p/markdownsharp/

+ +

They can be found in ./tests/markdowndownsharp/

+ +

The code that generates tests from them in in the escript file: +./priv/make_tests

+

Release Notes

+

Version 1.1.8 Production Bug Fix

+ + +

Some blocktag/html errrors fixed

+

Version 1.1.7 Production Bug Fix

diff --git a/src/markdown.erl b/src/markdown.erl index adde4f3..215ea0f 100644 --- a/src/markdown.erl +++ b/src/markdown.erl @@ -1,7 +1,7 @@ %%%------------------------------------------------------------------- %%% @author Gordon Guthrie %%% @copyright (C) 2009, Gordon Guthrie -%%% @docws, +%%% @doc, %%% %%% @end %%% Created : 10 Sep 2009 by gordonguthrie@backawinner.gg @@ -13,8 +13,6 @@ conv_utf8/1, conv_file/2]). --export([debug/0]). - -import(lists, [flatten/1, reverse/1]). -include_lib("eunit/include/eunit.hrl"). @@ -24,13 +22,9 @@ -define(LF, 10). -define(CR, 13). -define(NBSP, 160). +-define(AMP, $&, $a, $m, $p, $;). +-define(COPY, $&, $c, $o, $p, $y, $;). -debug() -> - Input = "Paragraph and no space:\r* ciao\r\rParagraph and 1 space:\r * ciao\r\rParagraph and 3 spaces:\r * ciao\r\rParagraph and 4 spaces:\r * ciao\r\rParagraph before header:\r#Header\r\rParagraph before blockquote:\r>Some quote.\r", - ShouldBe = "

Paragraph and no space:\n* ciao

\n\n

Paragraph and 1 space:\n * ciao

\n\n

Paragraph and 3 spaces:\n * ciao

\n\n

Paragraph and 4 spaces:\n * ciao

\n\n

Paragraph before header:

\n\n

Header

\n\n

Paragraph before blockquote:

\n\n
\n

Some quote.

\n
", - Ret = conv(Input), - io:format("Input is ~p~nRet is ~n~p~nShouldBe is ~n~p~n", [Input, Ret, ShouldBe]). - %%% the lexer first lexes the input %%% make_lines does 2 passes: %%% * it chops the lexed strings into lines which it represents as a @@ -55,7 +49,7 @@ conv(String) -> Lex = lex(String), % io:format("UntypedLines are ~p~n", [UntypedLines]), {TypedLines, Refs} = type_lines(UntypedLines), % io:format("TypedLines are ~p~nRefs is ~p~n", - % [TypedLines, Refs]), + % [TypedLines, Refs]), parse(TypedLines, Refs). -spec conv_utf8(list()) -> list(). @@ -109,13 +103,20 @@ p1([], _R, _I, Acc) -> flatten(reverse(Acc)); %% Tags have the highest precedence... p1([{tag, Tag} | T], R, I, Acc) -> case T of + [] -> p1([], R, I, + [make_tag_str(Tag) | Acc]); [{blank, _} | T2] -> p1(T2, R, I, [make_tag_str(Tag) | Acc]); _Other -> p1(T, R, I, - [pad(I) ++ "

" ++ make_tag_str(Tag) ++ - "

" | Acc]) + [pad(I) ++ make_tag_str(Tag) | Acc]) end; +p1([{blocktag, [{{{tag, open}, Type}, Tg}] = _Tag} | T], R, I, Acc) -> + {Block, Rest} = grab_for_blockhtml(T, Type, []), + %% add the line end back in for testing + Str = lists:flatten([Tg , "\n" | Block]), + p1(Rest, R, I, [Str | Acc]); + %% blank lines/linefeeds are gobbled down p1([{Type, _} | T], R, I, Acc) when Type == blank orelse Type == linefeed -> @@ -238,6 +239,20 @@ p1([{h2_or_hr, _} | T], R, I, Acc) -> p1([{inlineref, _P} | T], R, I, Acc) -> p1(T, R, I, Acc). +grab_for_blockhtml([], Type, Acc) -> + {lists:reverse(["" | Acc]), []}; +grab_for_blockhtml([{blocktag, [{{{tag, close}, Type}, Tg}]} + | T], Type, Acc) -> + {lists:reverse([Tg | Acc]), T}; +grab_for_blockhtml([{tag, {{{tag, self_closing}, _Ty}, Tg}} + | T], Type, Acc) -> + %% add the line end back in for testing + grab_for_blockhtml(T, Type, [Tg | Acc]); +grab_for_blockhtml([H | T], Type, Acc) -> + {_Type, Content} = H, + Str = make_plain_str(Content), + grab_for_blockhtml(T, Type, [Str | Acc]). + grab_empties([{linefeed, _} | T]) -> grab_empties(T); grab_empties([{blank, _} | T]) -> grab_empties(T); grab_empties(List) -> List. @@ -504,12 +519,12 @@ t_l1([[{{md, star}, _} | _T1] = H | T], A1, A2) -> %% Block level tags - these are look ahead they must be %% on a single line (ie directly followed by a lf and nothing else -t_l1([[{{{tag, _Type}, Tag}, _} = H | T1] = List | T], A1, A2) -> +t_l1([[{{{tag, _Type}, Tag}, _ } = H | T1] = List | T], A1, A2) -> case is_blank(T1) of false -> t_l1(T, A1, [{normal , List} | A2]); true -> case is_block_tag(Tag) of - true -> t_l1(T, A1, [{tag , H} | A2]); - false -> t_l1(T, A1, [{normal , List} | A2]) + true -> t_l1(T, A1, [{blocktag , [H]} | A2]); + false -> t_l1(T, A1, [{tag, H} | A2]) end end; @@ -671,8 +686,6 @@ type_atx(List) -> {h5, A}; ((Sz == 6) andalso (R == [{{lf, lf}, "\n"}])) -> {h5, A}; - ((Sz == 6) andalso (R == [{{lf, cr}, "\n"}])) -> - {h5, A}; ((Sz == 6) andalso (R == [{{lf, crlf}, "\r\n"}])) -> {h5, A}; ((Sz == 6) andalso (R =/= [])) -> @@ -768,12 +781,7 @@ gt(String, Len) -> end. %% make a tag into a string -make_tag_str({{{tag, Type}, Tag}, _}) -> - case Type of - open -> "<" ++ Tag ++ ">"; - close -> ""; - self_closing -> "<" ++ Tag ++ " />;" - end. +make_tag_str({{{tag, _Type}, _Tag}, B}) -> B. esc_tag(String) -> esc_t1(String, []). @@ -940,7 +948,7 @@ l1([?TAB | T], A1, A2) -> l1(T, [], [{{ws, tab}, "\t"}, l2(A1) | A2]); l1([?NBSP | T], A1, A2) -> l1(T, [], [{{ws, sp}, " "}, l2(A1) | A2]); l1([?CR, ?LF | T], A1, A2) -> l1(T, [], [{{lf, crlf}, [?CR , ?LF]}, l2(A1) | A2]); l1([?LF | T], A1, A2) -> l1(T, [], [{{lf, lf}, [?LF]}, l2(A1) | A2]); -l1([?CR | T], A1, A2) -> l1(T, [], [{{lf, cr}, [?CR]}, l2(A1) | A2]); +%% l1([?CR | T], A1, A2) -> l1(T, [], [{{lf, cr}, [?CR]}, l2(A1) | A2]); %% this final clause accumulates line fragments l1([H|T], A1, A2) -> l1(T, [H |A1] , A2). @@ -960,13 +968,15 @@ openingdiv(String) -> % dumps out a list if it is not an opening div openingdiv1([], Acc) -> {flatten([{{punc, bra}, "<"} - | lex(reverse(Acc))]), []}; + | lex(reverse(Acc))]), []}; openingdiv1([$/,$>| T], Acc) -> Acc2 = flatten(reverse(Acc)), - Tag = string:to_lower(Acc2), - {{{{{tag, self_closing}, Tag}, "<" - ++ Acc2 ++ ">"}, Acc2}, T}; + Acc3 = string:to_lower(Acc2), + [Tag | _T] = string:tokens(Acc3, " "), + {{{{tag, self_closing}, Tag}, "<" + ++ Acc2 ++ "/>"}, T}; openingdiv1([$>| T], Acc) -> Acc2 = flatten(reverse(Acc)), - Tag = string:to_lower(Acc2), + Acc3 = string:to_lower(Acc2), + [Tag | _T] = string:tokens(Acc3, " "), {{{{tag, open}, Tag}, "<" ++ Acc2 ++ ">"}, T}; openingdiv1([H|T], Acc) -> openingdiv1(T, [H | Acc]). @@ -976,8 +986,9 @@ closingdiv([], Acc) -> {flatten([{{punc, bra}, "<"}, {{punc, fslash}, "/"} | lex(reverse(Acc))]), []}; closingdiv([$>| T], Acc) -> Acc2 = flatten(reverse(Acc)), - Tag = string:to_lower(Acc2), - {{{{tag, close}, Tag}, "<" + Acc3 = string:to_lower(Acc2), + [Tag | _T] = string:tokens(Acc3, " "), + {{{{tag, close}, Tag}, ""}, T}; closingdiv([H|T], Acc) -> closingdiv(T, [H | Acc]). @@ -1153,7 +1164,7 @@ htmlchars1([], Acc) -> flatten(reverse(Acc)); %% tags are just wheeched out unescaped htmlchars1([{tags, Tag} | T], Acc) -> htmlchars1(T, [Tag | Acc]); %% line ends are pushed to a space.. -htmlchars1([?CR, ?LF | T], Acc) -> htmlchars1(T, ["\r\n" | Acc]); +htmlchars1([?CR, ?LF | T], Acc) -> htmlchars1(T, ["\n" | Acc]); htmlchars1([?LF | T], Acc) -> htmlchars1(T, ["\n" | Acc]); htmlchars1([?CR | T], Acc) -> htmlchars1(T, ["\r" | Acc]); %% emphasis is a bit strange - must be preceeded by or followed by @@ -1192,6 +1203,8 @@ htmlchars1([$`, $` | T], A) -> {T2, NewA} = dblcode(T), htmlchars1(T2, [NewA | A]); htmlchars1([$` | T], A) -> {T2, NewA} = code(T), htmlchars1(T2, [NewA | A]); +htmlchars1([?COPY | T], A) -> htmlchars1(T, ["©" | A]); +htmlchars1([?AMP | T], A) -> htmlchars1(T, ["&" | A]); htmlchars1([$& | T], A) -> htmlchars1(T, ["&" | A]); htmlchars1([$< | T], A) -> htmlchars1(T, ["<" | A]); htmlchars1([?NBSP | T], A) -> htmlchars1(T, [" " | A]); @@ -1257,4 +1270,4 @@ make_img_tag(Url, Acc, Title) -> %%% %%%------------------------------------------------------------------- --include("markdown_tests.erl"). +-include("markdown_tests.hrl"). diff --git a/src/markdown_tests.erl b/src/markdown_tests.erl deleted file mode 100644 index a6e5976..0000000 --- a/src/markdown_tests.erl +++ /dev/null @@ -1,95 +0,0 @@ -unit_test_() -> - [ -%% ?_assert(conv("AT&T has an ampersand in their name.\n\nAT&T is another way to write it.\n\nThis & that.\n\n4 < 5.\n\n6 > 5.\n\nHere's a [link] [1] with an ampersand in the URL.\n\nHere's a link with an amersand in the link text: [AT&T] [2].\n\nHere's an inline [link](/script?foo=1&bar=2).\n\nHere's an inline [link]().\n\n\n[1]: http://example.com/?foo=1&bar=2\n[2]: http://att.com/ \"AT&T\"") == "

AT&T has an ampersand in their name.

\n\n

AT&T is another way to write it.

\n\n

This & that.

\n\n

4 < 5.

\n\n

6 > 5.

\n\n

Here's a link with an ampersand in the URL.

\n\n

Here's a link with an amersand in the link text: AT&T.

\n\n

Here's an inline link.

\n\n

Here's an inline link.

"), -%% ?_assert(conv("Link: .\n\nWith an ampersand: \n\n* In a list?\n* \n* It should.\n\n> Blockquoted: \n\nAuto-links should not occur here: ``\n\n\tor here: ") == "

Link: http://example.com/.

\n\n

With an ampersand: http://example.com/?foo=1&bar=2

\n\n\n\n
\n

Blockquoted: http://example.com/

\n
\n\n

Auto-links should not occur here: <http://example.com/>

\n\n
or here: <http://example.com/>\n
"), -%% ?_assert(conv("These should all get escaped:\n\nBackslash: \\\\\n\nBacktick: \\`\n\nAsterisk: \\*\n\nUnderscore: \\_\n\nLeft brace: \\{\n\nRight brace: \\}\n\nLeft bracket: \\[\n\nRight bracket: \\]\n\nLeft paren: \\(\n\nRight paren: \\)\n\nGreater-than: \\>\n\nHash: \\#\n\nPeriod: \\.\n\nBang: \\!\n\nPlus: \\+\n\nMinus: \\-\n\n\n\nThese should not, because they occur within a code block:\n\n\tBackslash: \\\\\n\n\tBacktick: \\`\n\n\tAsterisk: \\*\n\n\tUnderscore: \\_\n\n\tLeft brace: \\{\n\n\tRight brace: \\}\n\n\tLeft bracket: \\[\n\n\tRight bracket: \\]\n\n\tLeft paren: \\(\n\n\tRight paren: \\)\n\n\tGreater-than: \\>\n\n\tHash: \\#\n\n\tPeriod: \\.\n\n\tBang: \\!\n\n\tPlus: \\+\n\n\tMinus: \\-\n\n\nNor should these, which occur in code spans:\n\nBackslash: `\\\\`\n\nBacktick: `` \\` ``\n\nAsterisk: `\\*`\n\nUnderscore: `\\_`\n\nLeft brace: `\\{`\n\nRight brace: `\\}`\n\nLeft bracket: `\\[`\n\nRight bracket: `\\]`\n\nLeft paren: `\\(`\n\nRight paren: `\\)`\n\nGreater-than: `\\>`\n\nHash: `\\#`\n\nPeriod: `\\.`\n\nBang: `\\!`\n\nPlus: `\\+`\n\nMinus: `\\-`\n\n\nThese should get escaped, even though they're matching pairs for\nother Markdown constructs:\n\n\\*asterisks\\*\n\n\\_underscores\\_\n\n\\`backticks\\`\n\nThis is a code span with a literal backslash-backtick sequence: `` \\` ``\n\nThis is a tag with unescaped backticks bar.\n\nThis is a tag with backslashes bar.\n") == "

These should all get escaped:

\n\n

Backslash: \\

\n\n

Backtick: `

\n\n

Asterisk: *

\n\n

Underscore: _

\n\n

Left brace: {

\n\n

Right brace: }

\n\n

Left bracket: [

\n\n

Right bracket: ]

\n\n

Left paren: (

\n\n

Right paren: )

\n\n

Greater-than: >

\n\n

Hash: #

\n\n

Period: .

\n\n

Bang: !

\n\n

Plus: +

\n\n

Minus: -

\n\n

These should not, because they occur within a code block:

\n\n
Backslash: \\\\\n\nBacktick: \\`\n\nAsterisk: \\*\n\nUnderscore: \\_\n\nLeft brace: \\{\n\nRight brace: \\}\n\nLeft bracket: \\[\n\nRight bracket: \\]\n\nLeft paren: \\(\n\nRight paren: \\)\n\nGreater-than: \\>\n\nHash: \\#\n\nPeriod: \\.\n\nBang: \\!\n\nPlus: \\+\n\nMinus: \\-\n
\n\n

Nor should these, which occur in code spans:

\n\n

Backslash: \\\\

\n\n

Backtick: \\`

\n\n

Asterisk: \\*

\n\n

Underscore: \\_

\n\n

Left brace: \\{

\n\n

Right brace: \\}

\n\n

Left bracket: \\[

\n\n

Right bracket: \\]

\n\n

Left paren: \\(

\n\n

Right paren: \\)

\n\n

Greater-than: \\>

\n\n

Hash: \\#

\n\n

Period: \\.

\n\n

Bang: \\!

\n\n

Plus: \\+

\n\n

Minus: \\-

\n\n

These should get escaped, even though they're matching pairs for\nother Markdown constructs:

\n\n

*asterisks*

\n\n

_underscores_

\n\n

`backticks`

\n\n

This is a code span with a literal backslash-backtick sequence: \\`

\n\n

This is a tag with unescaped backticks bar.

\n\n

This is a tag with backslashes bar.

"), -%% ?_assert(conv("> Example:\n> \n> sub status {\n> print \"working\";\n> }\n> \n> Or:\n> \n> sub status {\n> return \"working\";\n> }\n") == "
\n

Example:

\n\n
sub status {\n    print \"working\";\n}\n
\n \n

Or:

\n\n
sub status {\n    return \"working\";\n}\n
\n
"), -%% ?_assert(conv("\tcode block on the first line\n\t\nRegular text.\n\n code block indented by spaces\n\nRegular text.\n\n\tthe lines in this block \n\tall contain trailing spaces \n\nRegular Text.\n\n\tcode block on the last line") == "
code block on the first line\n
\n\n

Regular text.

\n\n
code block indented by spaces\n
\n\n

Regular text.

\n\n
the lines in this block  \nall contain trailing spaces  \n
\n\n

Regular Text.

\n\n
code block on the last line\n
"), -%% ?_assert(conv("``\n\nFix for backticks within HTML tag: like this\n\nHere's how you put `` `backticks` `` in a code span.") == "

<test a=\" content of attribute \">

\n\n

Fix for backticks within HTML tag: like this

\n\n

Here's how you put `backticks` in a code span.

"), -%% ?_assert(conv("In Markdown 1.0.0 and earlier. Version\n8. This line turns into a list item.\nBecause a hard-wrapped line in the\nmiddle of a paragraph looked like a\nlist item.\n\nHere's one with a bullet.\n* criminey.\n") == "

In Markdown 1.0.0 and earlier. Version\n8. This line turns into a list item.\nBecause a hard-wrapped line in the\nmiddle of a paragraph looked like a\nlist item.

\n\n

Here's one with a bullet.\n* criminey.

"), -%% ?_assert(conv("Dashes:\n\n---\n\n ---\n \n ---\n\n ---\n\n\t---\n\n- - -\n\n - - -\n \n - - -\n\n - - -\n\n\t- - -\n\n\nAsterisks:\n\n***\n\n ***\n \n ***\n\n ***\n\n\t***\n\n* * *\n\n * * *\n \n * * *\n\n * * *\n\n\t* * *\n\n\nUnderscores:\n\n___\n\n ___\n \n ___\n\n ___\n\n ___\n\n_ _ _\n\n _ _ _\n \n _ _ _\n\n _ _ _\n\n _ _ _\n") == "

Dashes:

\n\n
\n\n
\n\n
\n\n
\n\n
---\n
\n\n
\n\n
\n\n
\n\n
\n\n
- - -\n
\n\n

Asterisks:

\n\n
\n\n
\n\n
\n\n
\n\n
***\n
\n\n
\n\n
\n\n
\n\n
\n\n
* * *\n
\n\n

Underscores:

\n\n
\n\n
\n\n
\n\n
\n\n
___\n
\n\n
\n\n
\n\n
\n\n
\n\n
_ _ _\n
"), -%% ?_assert(conv("![Alt text](/path/to/img.jpg)\n\n![Alt text](/path/to/img.jpg \"Optional title\")\n\nInline within a paragraph: [alt text](/url/).\n\n![alt text](/url/ \"title preceded by two spaces\")\n\n![alt text](/url/ \"title has spaces afterward\" )\n\n![alt text]()\n\n![alt text]( \"with a title\").\n\n![Empty]()\n\n![this is a stupid URL](http://example.com/(parens).jpg)\n\n\n![alt text][foo]\n\n [foo]: /url/\n\n![alt text][bar]\n\n [bar]: /url/ \"Title here\"") == "

\"Alt

\n\n

\"Alt

\n\n

Inline within a paragraph: alt text.

\n\n

\"alt

\n\n

\"alt

\n\n

\"alt

\n\n

\"alt.

\n\n

!Empty

\n\n

\"this.jpg)

\n\n

\"alt

\n\n

\"alt

"), -%% ?_assert(conv("Simple block on one line:\n\n
foo
\n\nAnd nested without indentation:\n\n
\n
\n
\nfoo\n
\n
\"/>\n
\n
bar
\n
\n\nAnd with attributes:\n\n
\n\t
\n\t
\n
\n\nThis was broken in 1.0.2b7:\n\n
\n
\nfoo\n
\n
\n") == "

Simple block on one line:

\n\n
foo
\n\nAnd nested without indentation:\n\n
\n
\n
\nfoo\n
\n\n
\"/>\n
\n\n
bar
\n
\n\n

And with attributes:

\n\n
\n
\n
\n
\n\n

This was broken in 1.0.2b7:

\n\n
\n
\nfoo\n
\n\n

"), -%% ?_assert(conv("Here's a simple block:\n\n
\n\tfoo\n
\n\nThis should be a code block, though:\n\n\t
\n\t\tfoo\n\t
\n\nAs should this:\n\n\t
foo
\n\nNow, nested:\n\n
\n\t
\n\t\t
\n\t\t\tfoo\n\t\t
\n\t
\n
\n\nThis should just be an HTML comment:\n\n\n\nMultiline:\n\n\n\nCode block:\n\n\t\n\nJust plain comment, with trailing spaces on the line:\n\n \n\nCode:\n\n\t
\n\t\nHr's:\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n") == "

Here's a simple block:

\n\n
\n foo\n
\n\n

This should be a code block, though:

\n\n
<div>\n    foo\n</div>\n
\n\n

As should this:

\n\n
<div>foo</div>\n
\n\n

Now, nested:

\n\n
\n
\n
\n foo\n
\n
\n
\n\n

This should just be an HTML comment:

\n\n\n\n

Multiline:

\n\n\n\n

Code block:

\n\n
<!-- Comment -->\n
\n\n

Just plain comment, with trailing spaces on the line:

\n\n \n\n

Code:

\n\n
<hr />\n
\n\n

Hr's:

\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
"), -%% ?_assert(conv("Paragraph one.\n\n\n\n\n\nParagraph two.\n\n\n\nThe end.\n") == "

Paragraph one.

\n\n\n\n\n\n

Paragraph two.

\n\n\n\n

The end.

"), -%% ?_assert(conv("Just a [URL](/url/).\n\n[URL and title](/url/ \"title\").\n\n[URL and title](/url/ \"title preceded by two spaces\").\n\n[URL and title](/url/\t\"title preceded by a tab\").\n\n[URL and title](/url/ \"title has spaces afterward\" ).\n\n[URL wrapped in angle brackets]().\n\n[URL w/ angle brackets + title]( \"Here's the title\").\n\n[Empty]().\n\n[With parens in the URL](http://en.wikipedia.org/wiki/WIMP_(computing))\n\n(With outer parens and [parens in url](/foo(bar)))\n\n\n[With parens in the URL](/foo(bar) \"and a title\")\n\n(With outer parens and [parens in url](/foo(bar) \"and a title\"))\n") == "

Just a URL.

\n\n

URL and title.

\n\n

URL and title.

\n\n

URL and title.

\n\n

URL and title.

\n\n

URL wrapped in angle brackets.

\n\n

URL w/ angle brackets + title.

\n\n

Empty.

\n\n

With parens in the URL)

\n\n

(With outer parens and parens in url))

\n\n

With parens in the URL \"and a title\")

\n\n

(With outer parens and parens in url \"and a title\"))

"), -%% ?_assert(conv("Foo [bar] [1].\n\nFoo [bar][1].\n\nFoo [bar]\n[1].\n\n[1]: /url/ \"Title\"\n\n\nWith [embedded [brackets]] [b].\n\n\nIndented [once][].\n\nIndented [twice][].\n\nIndented [thrice][].\n\nIndented [four][] times.\n\n [once]: /url\n\n [twice]: /url\n\n [thrice]: /url\n\n [four]: /url\n\n\n[b]: /url/\n\n* * *\n\n[this] [this] should work\n\nSo should [this][this].\n\nAnd [this] [].\n\nAnd [this][].\n\nAnd [this].\n\nBut not [that] [].\n\nNor [that][].\n\nNor [that].\n\n[Something in brackets like [this][] should work]\n\n[Same with [this].]\n\nIn this case, [this](/somethingelse/) points to something else.\n\nBackslashing should suppress \\[this] and [this\\].\n\n[this]: foo\n\n\n* * *\n\nHere's one where the [link\nbreaks] across lines.\n\nHere's another where the [link \nbreaks] across lines, but with a line-ending space.\n\n\n[link breaks]: /url/\n") == "

Foo bar.

\n\n

Foo bar.

\n\n

Foo bar.

\n\n

With embedded [brackets].

\n\n

Indented once.

\n\n

Indented twice.

\n\n

Indented thrice.

\n\n

Indented [four][] times.

\n\n
[four]: /url\n
\n\n
\n\n

this should work

\n\n

So should this.

\n\n

And this.

\n\n

And this.

\n\n

And this.

\n\n

But not [that] [].

\n\n

Nor [that][].

\n\n

Nor [that].

\n\n

[Something in brackets like this should work]

\n\n

[Same with this.]

\n\n

In this case, this points to something else.

\n\n

Backslashing should suppress [this] and [this].

\n\n
\n\n

Here's one where the link\nbreaks across lines.

\n\n

Here's another where the link \nbreaks across lines, but with a line-ending space.

"), -%% ?_assert(conv("This is the [simple case].\n\n[simple case]: /simple\n\n\n\nThis one has a [line\nbreak].\n\nThis one has a [line \nbreak] with a line-ending space.\n\n[line break]: /foo\n\n\n[this] [that] and the [other]\n\n[this]: /this\n[that]: /that\n[other]: /other\n") == "

This is the simple case.

\n\n

This one has a line\nbreak.

\n\n

This one has a line \nbreak with a line-ending space.

\n\n

this and the other

"), -%% ?_assert(conv("Foo [bar][].\n\nFoo [bar](/url/ \"Title with \"quotes\" inside\").\n\n\n [bar]: /url/ \"Title with \"quotes\" inside\"\n\n") == "

Foo bar.

\n\n

Foo bar.

"), -%% ?_assert(conv("Markdown: Basics\n================\n\n\n\n\nGetting the Gist of Markdown's Formatting Syntax\n------------------------------------------------\n\nThis page offers a brief overview of what it's like to use Markdown.\nThe [syntax page] [s] provides complete, detailed documentation for\nevery feature, but Markdown should be very easy to pick up simply by\nlooking at a few examples of it in action. The examples on this page\nare written in a before/after style, showing example syntax and the\nHTML output produced by Markdown.\n\nIt's also helpful to simply try Markdown out; the [Dingus] [d] is a\nweb application that allows you type your own Markdown-formatted text\nand translate it to XHTML.\n\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL] [src].\n\n [s]: /projects/markdown/syntax \"Markdown Syntax\"\n [d]: /projects/markdown/dingus \"Markdown Dingus\"\n [src]: /projects/markdown/basics.text\n\n\n## Paragraphs, Headers, Blockquotes ##\n\nA paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.\n\nMarkdown offers two styles of headers: *Setext* and *atx*.\nSetext-style headers for `

` and `

` are created by\n\"underlining\" with equal signs (`=`) and hyphens (`-`), respectively.\nTo create an atx-style header, you put 1-6 hash marks (`#`) at the\nbeginning of the line -- the number of hashes equals the resulting\nHTML header level.\n\nBlockquotes are indicated using email-style '`>`' angle brackets.\n\nMarkdown:\n\n A First Level Header\n ====================\n \n A Second Level Header\n ---------------------\n\n Now is the time for all good men to come to\n the aid of their country. This is just a\n regular paragraph.\n\n The quick brown fox jumped over the lazy\n dog's back.\n \n ### Header 3\n\n > This is a blockquote.\n > \n > This is the second paragraph in the blockquote.\n >\n > ## This is an H2 in a blockquote\n\n\nOutput:\n\n

A First Level Header

\n \n

A Second Level Header

\n \n

Now is the time for all good men to come to\n the aid of their country. This is just a\n regular paragraph.

\n \n

The quick brown fox jumped over the lazy\n dog's back.

\n \n

Header 3

\n \n
\n

This is a blockquote.

\n \n

This is the second paragraph in the blockquote.

\n \n

This is an H2 in a blockquote

\n
\n\n\n\n### Phrase Emphasis ###\n\nMarkdown uses asterisks and underscores to indicate spans of emphasis.\n\nMarkdown:\n\n Some of these words *are emphasized*.\n Some of these words _are emphasized also_.\n \n Use two asterisks for **strong emphasis**.\n Or, if you prefer, __use two underscores instead__.\n\nOutput:\n\n

Some of these words are emphasized.\n Some of these words are emphasized also.

\n \n

Use two asterisks for strong emphasis.\n Or, if you prefer, use two underscores instead.

\n \n\n\n## Lists ##\n\nUnordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,\n`+`, and `-`) as list markers. These three markers are\ninterchangable; this:\n\n * Candy.\n * Gum.\n * Booze.\n\nthis:\n\n + Candy.\n + Gum.\n + Booze.\n\nand this:\n\n - Candy.\n - Gum.\n - Booze.\n\nall produce the same output:\n\n
    \n
  • Candy.
  • \n
  • Gum.
  • \n
  • Booze.
  • \n
\n\nOrdered (numbered) lists use regular numbers, followed by periods, as\nlist markers:\n\n 1. Red\n 2. Green\n 3. Blue\n\nOutput:\n\n
    \n
  1. Red
  2. \n
  3. Green
  4. \n
  5. Blue
  6. \n
\n\nIf you put blank lines between items, you'll get `

` tags for the\nlist item text. You can create multi-paragraph list items by indenting\nthe paragraphs by 4 spaces or 1 tab:\n\n * A list item.\n \n With multiple paragraphs.\n\n * Another item in the list.\n\nOutput:\n\n

    \n
  • A list item.

    \n

    With multiple paragraphs.

  • \n
  • Another item in the list.

  • \n
\n \n\n\n### Links ###\n\nMarkdown supports two styles for creating links: *inline* and\n*reference*. With both styles, you use square brackets to delimit the\ntext you want to turn into a link.\n\nInline-style links use parentheses immediately after the link text.\nFor example:\n\n This is an [example link](http://example.com/).\n\nOutput:\n\n

This is an \n example link.

\n\nOptionally, you may include a title attribute in the parentheses:\n\n This is an [example link](http://example.com/ \"With a Title\").\n\nOutput:\n\n

This is an \n example link.

\n\nReference-style links allow you to refer to your links by names, which\nyou define elsewhere in your document:\n\n I get 10 times more traffic from [Google][1] than from\n [Yahoo][2] or [MSN][3].\n\n [1]: http://google.com/ \"Google\"\n [2]: http://search.yahoo.com/ \"Yahoo Search\"\n [3]: http://search.msn.com/ \"MSN Search\"\n\nOutput:\n\n

I get 10 times more traffic from Google than from Yahoo or MSN.

\n\nThe title attribute is optional. Link names may contain letters,\nnumbers and spaces, but are *not* case sensitive:\n\n I start my morning with a cup of coffee and\n [The New York Times][NY Times].\n\n [ny times]: http://www.nytimes.com/\n\nOutput:\n\n

I start my morning with a cup of coffee and\n The New York Times.

\n\n\n### Images ###\n\nImage syntax is very much like link syntax.\n\nInline (titles are optional):\n\n ![alt text](/path/to/img.jpg \"Title\")\n\nReference-style:\n\n ![alt text][id]\n\n [id]: /path/to/img.jpg \"Title\"\n\nBoth of the above examples produce the same output:\n\n \"alt\n\n\n\n### Code ###\n\nIn a regular paragraph, you can create code span by wrapping text in\nbacktick quotes. Any ampersands (`&`) and angle brackets (`<` or\n`>`) will automatically be translated into HTML entities. This makes\nit easy to use Markdown to write about HTML example code:\n\n I strongly recommend against using any `` tags.\n\n I wish SmartyPants used named entities like `—`\n instead of decimal-encoded entites like `—`.\n\nOutput:\n\n

I strongly recommend against using any\n <blink> tags.

\n \n

I wish SmartyPants used named entities like\n &mdash; instead of decimal-encoded\n entites like &#8212;.

\n\n\nTo specify an entire block of pre-formatted code, indent every line of\nthe block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,\nand `>` characters will be escaped automatically.\n\nMarkdown:\n\n If you want your page to validate under XHTML 1.0 Strict,\n you've got to put paragraph tags in your blockquotes:\n\n
\n

For example.

\n
\n\nOutput:\n\n

If you want your page to validate under XHTML 1.0 Strict,\n you've got to put paragraph tags in your blockquotes:

\n \n
<blockquote>\n        <p>For example.</p>\n    </blockquote>\n    
\n") == "

Markdown: Basics

\n\n\n\n

Getting the Gist of Markdown's Formatting Syntax

\n\n

This page offers a brief overview of what it's like to use Markdown.\nThe syntax page provides complete, detailed documentation for\nevery feature, but Markdown should be very easy to pick up simply by\nlooking at a few examples of it in action. The examples on this page\nare written in a before/after style, showing example syntax and the\nHTML output produced by Markdown.

\n\n

It's also helpful to simply try Markdown out; the Dingus is a\nweb application that allows you type your own Markdown-formatted text\nand translate it to XHTML.

\n\n

Note: This document is itself written using Markdown; you\ncan see the source for it by adding '.text' to the URL.

\n\n

Paragraphs, Headers, Blockquotes

\n\n

A paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.

\n\n

Markdown offers two styles of headers: Setext and atx.\nSetext-style headers for <h1> and <h2> are created by\n\"underlining\" with equal signs (=) and hyphens (-), respectively.\nTo create an atx-style header, you put 1-6 hash marks (#) at the\nbeginning of the line -- the number of hashes equals the resulting\nHTML header level.

\n\n

Blockquotes are indicated using email-style '>' angle brackets.

\n\n

Markdown:

\n\n
A First Level Header\n====================\n\nA Second Level Header\n---------------------\n\nNow is the time for all good men to come to\nthe aid of their country. This is just a\nregular paragraph.\n\nThe quick brown fox jumped over the lazy\ndog's back.\n\n### Header 3\n\n> This is a blockquote.\n> \n> This is the second paragraph in the blockquote.\n>\n> ## This is an H2 in a blockquote\n
\n\n

Output:

\n\n
<h1>A First Level Header</h1>\n\n<h2>A Second Level Header</h2>\n\n<p>Now is the time for all good men to come to\nthe aid of their country. This is just a\nregular paragraph.</p>\n\n<p>The quick brown fox jumped over the lazy\ndog's back.</p>\n\n<h3>Header 3</h3>\n\n<blockquote>\n    <p>This is a blockquote.</p>\n\n    <p>This is the second paragraph in the blockquote.</p>\n\n    <h2>This is an H2 in a blockquote</h2>\n</blockquote>\n
\n\n

Phrase Emphasis

\n\n

Markdown uses asterisks and underscores to indicate spans of emphasis.

\n\n

Markdown:

\n\n
Some of these words *are emphasized*.\nSome of these words _are emphasized also_.\n\nUse two asterisks for **strong emphasis**.\nOr, if you prefer, __use two underscores instead__.\n
\n\n

Output:

\n\n
<p>Some of these words <em>are emphasized</em>.\nSome of these words <em>are emphasized also</em>.</p>\n\n<p>Use two asterisks for <strong>strong emphasis</strong>.\nOr, if you prefer, <strong>use two underscores instead</strong>.</p>\n
\n\n

Lists

\n\n

Unordered (bulleted) lists use asterisks, pluses, and hyphens (*,\n+, and -) as list markers. These three markers are\ninterchangable; this:

\n\n
*   Candy.\n*   Gum.\n*   Booze.\n
\n\n

this:

\n\n
+   Candy.\n+   Gum.\n+   Booze.\n
\n\n

and this:

\n\n
-   Candy.\n-   Gum.\n-   Booze.\n
\n\n

all produce the same output:

\n\n
<ul>\n<li>Candy.</li>\n<li>Gum.</li>\n<li>Booze.</li>\n</ul>\n
\n\n

Ordered (numbered) lists use regular numbers, followed by periods, as\nlist markers:

\n\n
1.  Red\n2.  Green\n3.  Blue\n
\n\n

Output:

\n\n
<ol>\n<li>Red</li>\n<li>Green</li>\n<li>Blue</li>\n</ol>\n
\n\n

If you put blank lines between items, you'll get <p> tags for the\nlist item text. You can create multi-paragraph list items by indenting\nthe paragraphs by 4 spaces or 1 tab:

\n\n
*   A list item.\n\n    With multiple paragraphs.\n\n*   Another item in the list.\n
\n\n

Output:

\n\n
<ul>\n<li><p>A list item.</p>\n<p>With multiple paragraphs.</p></li>\n<li><p>Another item in the list.</p></li>\n</ul>\n
\n\n

Links

\n\n

Markdown supports two styles for creating links: inline and\nreference. With both styles, you use square brackets to delimit the\ntext you want to turn into a link.

\n\n

Inline-style links use parentheses immediately after the link text.\nFor example:

\n\n
This is an [example link](http://example.com/).\n
\n\n

Output:

\n\n
<p>This is an <a href=\"http://example.com/\">\nexample link</a>.</p>\n
\n\n

Optionally, you may include a title attribute in the parentheses:

\n\n
This is an [example link](http://example.com/ \"With a Title\").\n
\n\n

Output:

\n\n
<p>This is an <a href=\"http://example.com/\" title=\"With a Title\">\nexample link</a>.</p>\n
\n\n

Reference-style links allow you to refer to your links by names, which\nyou define elsewhere in your document:

\n\n
I get 10 times more traffic from [Google][1] than from\n[Yahoo][2] or [MSN][3].\n\n[1]: http://google.com/        \"Google\"\n[2]: http://search.yahoo.com/  \"Yahoo Search\"\n[3]: http://search.msn.com/    \"MSN Search\"\n
\n\n

Output:

\n\n
<p>I get 10 times more traffic from <a href=\"http://google.com/\"\ntitle=\"Google\">Google</a> than from <a href=\"http://search.yahoo.com/\"\ntitle=\"Yahoo Search\">Yahoo</a> or <a href=\"http://search.msn.com/\"\ntitle=\"MSN Search\">MSN</a>.</p>\n
\n\n

The title attribute is optional. Link names may contain letters,\nnumbers and spaces, but are not case sensitive:

\n\n
I start my morning with a cup of coffee and\n[The New York Times][NY Times].\n\n[ny times]: http://www.nytimes.com/\n
\n\n

Output:

\n\n
<p>I start my morning with a cup of coffee and\n<a href=\"http://www.nytimes.com/\">The New York Times</a>.</p>\n
\n\n

Images

\n\n

Image syntax is very much like link syntax.

\n\n

Inline (titles are optional):

\n\n
![alt text](/path/to/img.jpg \"Title\")\n
\n\n

Reference-style:

\n\n
![alt text][id]\n\n[id]: /path/to/img.jpg \"Title\"\n
\n\n

Both of the above examples produce the same output:

\n\n
<img src=\"/path/to/img.jpg\" alt=\"alt text\" title=\"Title\" />\n
\n\n

Code

\n\n

In a regular paragraph, you can create code span by wrapping text in\nbacktick quotes. Any ampersands (&) and angle brackets (< or\n>) will automatically be translated into HTML entities. This makes\nit easy to use Markdown to write about HTML example code:

\n\n
I strongly recommend against using any `<blink>` tags.\n\nI wish SmartyPants used named entities like `&mdash;`\ninstead of decimal-encoded entites like `&#8212;`.\n
\n\n

Output:

\n\n
<p>I strongly recommend against using any\n<code>&lt;blink&gt;</code> tags.</p>\n\n<p>I wish SmartyPants used named entities like\n<code>&amp;mdash;</code> instead of decimal-encoded\nentites like <code>&amp;#8212;</code>.</p>\n
\n\n

To specify an entire block of pre-formatted code, indent every line of\nthe block by 4 spaces or 1 tab. Just like with code spans, &, <,\nand > characters will be escaped automatically.

\n\n

Markdown:

\n\n
If you want your page to validate under XHTML 1.0 Strict,\nyou've got to put paragraph tags in your blockquotes:\n\n    <blockquote>\n        <p>For example.</p>\n    </blockquote>\n
\n\n

Output:

\n\n
<p>If you want your page to validate under XHTML 1.0 Strict,\nyou've got to put paragraph tags in your blockquotes:</p>\n\n<pre><code>&lt;blockquote&gt;\n    &lt;p&gt;For example.&lt;/p&gt;\n&lt;/blockquote&gt;\n</code></pre>\n
"), -%% ?_assert(conv("Markdown: Syntax\n================\n\n\n\n\n* [Overview](#overview)\n * [Philosophy](#philosophy)\n * [Inline HTML](#html)\n * [Automatic Escaping for Special Characters](#autoescape)\n* [Block Elements](#block)\n * [Paragraphs and Line Breaks](#p)\n * [Headers](#header)\n * [Blockquotes](#blockquote)\n * [Lists](#list)\n * [Code Blocks](#precode)\n * [Horizontal Rules](#hr)\n* [Span Elements](#span)\n * [Links](#link)\n * [Emphasis](#em)\n * [Code](#code)\n * [Images](#img)\n* [Miscellaneous](#misc)\n * [Backslash Escapes](#backslash)\n * [Automatic Links](#autolink)\n\n\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL][src].\n\n [src]: /projects/markdown/syntax.text\n\n* * *\n\n

Overview

\n\n

Philosophy

\n\nMarkdown is intended to be as easy-to-read and easy-to-write as is feasible.\n\nReadability, however, is emphasized above all else. A Markdown-formatted\ndocument should be publishable as-is, as plain text, without looking\nlike it's been marked up with tags or formatting instructions. While\nMarkdown's syntax has been influenced by several existing text-to-HTML\nfilters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],\n[Grutatext] [5], and [EtText] [6] -- the single biggest source of\ninspiration for Markdown's syntax is the format of plain text email.\n\n [1]: http://docutils.sourceforge.net/mirror/setext.html\n [2]: http://www.aaronsw.com/2002/atx/\n [3]: http://textism.com/tools/textile/\n [4]: http://docutils.sourceforge.net/rst.html\n [5]: http://www.triptico.com/software/grutatxt.html\n [6]: http://ettext.taint.org/doc/\n\nTo this end, Markdown's syntax is comprised entirely of punctuation\ncharacters, which punctuation characters have been carefully chosen so\nas to look like what they mean. E.g., asterisks around a word actually\nlook like \\*emphasis\\*. Markdown lists look like, well, lists. Even\nblockquotes look like quoted passages of text, assuming you've ever\nused email.\n\n\n\n

Inline HTML

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

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

` tags around HTML block-level tags.\n\nFor example, to add an HTML table to a Markdown article:\n\n This is a regular paragraph.\n\n

\n \n \n \n
Foo
\n\n This is another regular paragraph.\n\nNote that Markdown formatting syntax is not processed within block-level\nHTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an\nHTML block.\n\nSpan-level HTML tags -- e.g. ``, ``, or `` -- can be\nused anywhere in a Markdown paragraph, list item, or header. If you\nwant, you can even use HTML tags instead of Markdown formatting; e.g. if\nyou'd prefer to use HTML `` or `` tags instead of Markdown's\nlink or image syntax, go right ahead.\n\nUnlike block-level HTML tags, Markdown syntax *is* processed within\nspan-level tags.\n\n\n

Automatic Escaping for Special Characters

\n\nIn HTML, there are two characters that demand special treatment: `<`\nand `&`. Left angle brackets are used to start tags; ampersands are\nused to denote HTML entities. If you want to use them as literal\ncharacters, you must escape them as entities, e.g. `<`, and\n`&`.\n\nAmpersands in particular are bedeviling for web writers. If you want to\nwrite about 'AT&T', you need to write '`AT&T`'. You even need to\nescape ampersands within URLs. Thus, if you want to link to:\n\n http://images.google.com/images?num=30&q=larry+bird\n\nyou need to encode the URL as:\n\n http://images.google.com/images?num=30&q=larry+bird\n\nin your anchor tag `href` attribute. Needless to say, this is easy to\nforget, and is probably the single most common source of HTML validation\nerrors in otherwise well-marked-up web sites.\n\nMarkdown allows you to use these characters naturally, taking care of\nall the necessary escaping for you. If you use an ampersand as part of\nan HTML entity, it remains unchanged; otherwise it will be translated\ninto `&`.\n\nSo, if you want to include a copyright symbol in your article, you can write:\n\n ©\n\nand Markdown will leave it alone. But if you write:\n\n AT&T\n\nMarkdown will translate it to:\n\n AT&T\n\nSimilarly, because Markdown supports [inline HTML](#html), if you use\nangle brackets as delimiters for HTML tags, Markdown will treat them as\nsuch. But if you write:\n\n 4 < 5\n\nMarkdown will translate it to:\n\n 4 < 5\n\nHowever, inside Markdown code spans and blocks, angle brackets and\nampersands are *always* encoded automatically. This makes it easy to use\nMarkdown to write about HTML code. (As opposed to raw HTML, which is a\nterrible format for writing about HTML syntax, because every single `<`\nand `&` in your example code needs to be escaped.)\n\n\n* * *\n\n\n

Block Elements

\n\n\n

Paragraphs and Line Breaks

\n\nA paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing but spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.\n\nThe implication of the \"one or more consecutive lines of text\" rule is\nthat Markdown supports \"hard-wrapped\" text paragraphs. This differs\nsignificantly from most other text-to-HTML formatters (including Movable\nType's \"Convert Line Breaks\" option) which translate every line break\ncharacter in a paragraph into a `
` tag.\n\nWhen you *do* want to insert a `
` break tag using Markdown, you\nend a line with two or more spaces, then type return.\n\nYes, this takes a tad more effort to create a `
`, but a simplistic\n\"every line break is a `
`\" rule wouldn't work for Markdown.\nMarkdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]\nwork best -- and look better -- when you format them with hard breaks.\n\n [bq]: #blockquote\n [l]: #list\n\n\n\n

Headers

\n\nMarkdown supports two styles of headers, [Setext] [1] and [atx] [2].\n\nSetext-style headers are \"underlined\" using equal signs (for first-level\nheaders) and dashes (for second-level headers). For example:\n\n This is an H1\n =============\n\n This is an H2\n -------------\n\nAny number of underlining `=`'s or `-`'s will work.\n\nAtx-style headers use 1-6 hash characters at the start of the line,\ncorresponding to header levels 1-6. For example:\n\n # This is an H1\n\n ## This is an H2\n\n ###### This is an H6\n\nOptionally, you may \"close\" atx-style headers. This is purely\ncosmetic -- you can use this if you think it looks better. The\nclosing hashes don't even need to match the number of hashes\nused to open the header. (The number of opening hashes\ndetermines the header level.) :\n\n # This is an H1 #\n\n ## This is an H2 ##\n\n ### This is an H3 ######\n\n\n

Blockquotes

\n\nMarkdown uses email-style `>` characters for blockquoting. If you're\nfamiliar with quoting passages of text in an email message, then you\nknow how to create a blockquote in Markdown. It looks best if you hard\nwrap the text and put a `>` before every line:\n\n > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n > \n > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n > id sem consectetuer libero luctus adipiscing.\n\nMarkdown allows you to be lazy and only put the `>` before the first\nline of a hard-wrapped paragraph:\n\n > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n\n > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n id sem consectetuer libero luctus adipiscing.\n\nBlockquotes can be nested (i.e. a blockquote-in-a-blockquote) by\nadding additional levels of `>`:\n\n > This is the first level of quoting.\n >\n > > This is nested blockquote.\n >\n > Back to the first level.\n\nBlockquotes can contain other Markdown elements, including headers, lists,\nand code blocks:\n\n\t> ## This is a header.\n\t> \n\t> 1. This is the first list item.\n\t> 2. This is the second list item.\n\t> \n\t> Here's some example code:\n\t> \n\t> return shell_exec(\"echo $input | $markdown_script\");\n\nAny decent text editor should make email-style quoting easy. For\nexample, with BBEdit, you can make a selection and choose Increase\nQuote Level from the Text menu.\n\n\n

Lists

\n\nMarkdown supports ordered (numbered) and unordered (bulleted) lists.\n\nUnordered lists use asterisks, pluses, and hyphens -- interchangably\n-- as list markers:\n\n * Red\n * Green\n * Blue\n\nis equivalent to:\n\n + Red\n + Green\n + Blue\n\nand:\n\n - Red\n - Green\n - Blue\n\nOrdered lists use numbers followed by periods:\n\n 1. Bird\n 2. McHale\n 3. Parish\n\nIt's important to note that the actual numbers you use to mark the\nlist have no effect on the HTML output Markdown produces. The HTML\nMarkdown produces from the above list is:\n\n
    \n
  1. Bird
  2. \n
  3. McHale
  4. \n
  5. Parish
  6. \n
\n\nIf you instead wrote the list in Markdown like this:\n\n 1. Bird\n 1. McHale\n 1. Parish\n\nor even:\n\n 3. Bird\n 1. McHale\n 8. Parish\n\nyou'd get the exact same HTML output. The point is, if you want to,\nyou can use ordinal numbers in your ordered Markdown lists, so that\nthe numbers in your source match the numbers in your published HTML.\nBut if you want to be lazy, you don't have to.\n\nIf you do use lazy list numbering, however, you should still start the\nlist with the number 1. At some point in the future, Markdown may support\nstarting ordered lists at an arbitrary number.\n\nList markers typically start at the left margin, but may be indented by\nup to three spaces. List markers must be followed by one or more spaces\nor a tab.\n\nTo make lists look nice, you can wrap items with hanging indents:\n\n * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nBut if you want to be lazy, you don't have to:\n\n * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIf list items are separated by blank lines, Markdown will wrap the\nitems in `

` tags in the HTML output. For example, this input:\n\n * Bird\n * Magic\n\nwill turn into:\n\n

    \n
  • Bird
  • \n
  • Magic
  • \n
\n\nBut this:\n\n * Bird\n\n * Magic\n\nwill turn into:\n\n
    \n
  • Bird

  • \n
  • Magic

  • \n
\n\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be intended by either 4 spaces\nor one tab:\n\n 1. This is a list item with two paragraphs. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n mi posuere lectus.\n\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n sit amet velit.\n\n 2. Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIt looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:\n\n * This is a list item with two paragraphs.\n\n This is the second paragraph in the list item. You're\n only required to indent the first line. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit.\n\n * Another item in the same list.\n\nTo put a blockquote within a list item, the blockquote's `>`\ndelimiters need to be indented:\n\n * A list item with a blockquote:\n\n > This is a blockquote\n > inside a list item.\n\nTo put a code block within a list item, the code block needs\nto be indented *twice* -- 8 spaces or two tabs:\n\n * A list item with a code block:\n\n \n\n\nIt's worth noting that it's possible to trigger an ordered list by\naccident, by writing something like this:\n\n 1986. What a great season.\n\nIn other words, a *number-period-space* sequence at the beginning of a\nline. To avoid this, you can backslash-escape the period:\n\n 1986\\. What a great season.\n\n\n\n

Code Blocks

\n\nPre-formatted code blocks are used for writing about programming or\nmarkup source code. Rather than forming normal paragraphs, the lines\nof a code block are interpreted literally. Markdown wraps a code block\nin both `
` and `` tags.\n\nTo produce a code block in Markdown, simply indent every line of the\nblock by at least 4 spaces or 1 tab. For example, given this input:\n\n    This is a normal paragraph:\n\n        This is a code block.\n\nMarkdown will generate:\n\n    

This is a normal paragraph:

\n\n
This is a code block.\n    
\n\nOne level of indentation -- 4 spaces or 1 tab -- is removed from each\nline of the code block. For example, this:\n\n Here is an example of AppleScript:\n\n tell application \"Foo\"\n beep\n end tell\n\nwill turn into:\n\n

Here is an example of AppleScript:

\n\n
tell application \"Foo\"\n        beep\n    end tell\n    
\n\nA code block continues until it reaches a line that is not indented\n(or the end of the article).\n\nWithin a code block, ampersands (`&`) and angle brackets (`<` and `>`)\nare automatically converted into HTML entities. This makes it very\neasy to include example HTML source code using Markdown -- just paste\nit and indent it, and Markdown will handle the hassle of encoding the\nampersands and angle brackets. For example, this:\n\n
\n © 2004 Foo Corporation\n
\n\nwill turn into:\n\n
<div class=\"footer\">\n        &copy; 2004 Foo Corporation\n    </div>\n    
\n\nRegular Markdown syntax is not processed within code blocks. E.g.,\nasterisks are just literal asterisks within a code block. This means\nit's also easy to use Markdown to write about Markdown's own syntax.\n\n\n\n

Horizontal Rules

\n\nYou can produce a horizontal rule tag (`
`) by placing three or\nmore hyphens, asterisks, or underscores on a line by themselves. If you\nwish, you may use spaces between the hyphens or asterisks. Each of the\nfollowing lines will produce a horizontal rule:\n\n * * *\n\n ***\n\n *****\n\t\n - - -\n\n ---------------------------------------\n\n\t_ _ _\n\n\n* * *\n\n

Span Elements

\n\n

Links

\n\nMarkdown supports two style of links: *inline* and *reference*.\n\nIn both styles, the link text is delimited by [square brackets].\n\nTo create an inline link, use a set of regular parentheses immediately\nafter the link text's closing square bracket. Inside the parentheses,\nput the URL where you want the link to point, along with an *optional*\ntitle for the link, surrounded in quotes. For example:\n\n This is [an example](http://example.com/ \"Title\") inline link.\n\n [This link](http://example.net/) has no title attribute.\n\nWill produce:\n\n

This is \n an example inline link.

\n\n

This link has no\n title attribute.

\n\nIf you're referring to a local resource on the same server, you can\nuse relative paths:\n\n See my [About](/about/) page for details.\n\nReference-style links use a second set of square brackets, inside\nwhich you place a label of your choosing to identify the link:\n\n This is [an example][id] reference-style link.\n\nYou can optionally use a space to separate the sets of brackets:\n\n This is [an example] [id] reference-style link.\n\nThen, anywhere in the document, you define your link label like this,\non a line by itself:\n\n [id]: http://example.com/ \"Optional Title Here\"\n\nThat is:\n\n* Square brackets containing the link identifier (optionally\n indented from the left margin using up to three spaces);\n* followed by a colon;\n* followed by one or more spaces (or tabs);\n* followed by the URL for the link;\n* optionally followed by a title attribute for the link, enclosed\n in double or single quotes.\n\nThe link URL may, optionally, be surrounded by angle brackets:\n\n [id]: \"Optional Title Here\"\n\nYou can put the title attribute on the next line and use extra spaces\nor tabs for padding, which tends to look better with longer URLs:\n\n [id]: http://example.com/longish/path/to/resource/here\n \"Optional Title Here\"\n\nLink definitions are only used for creating links during Markdown\nprocessing, and are stripped from your document in the HTML output.\n\nLink definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:\n\n\t[link text][a]\n\t[link text][A]\n\nare equivalent.\n\nThe *implicit link name* shortcut allows you to omit the name of the\nlink, in which case the link text itself is used as the name.\nJust use an empty set of square brackets -- e.g., to link the word\n\"Google\" to the google.com web site, you could simply write:\n\n\t[Google][]\n\nAnd then define the link:\n\n\t[Google]: http://google.com/\n\nBecause link names may contain spaces, this shortcut even works for\nmultiple words in the link text:\n\n\tVisit [Daring Fireball][] for more information.\n\nAnd then define the link:\n\t\n\t[Daring Fireball]: http://daringfireball.net/\n\nLink definitions can be placed anywhere in your Markdown document. I\ntend to put them immediately after each paragraph in which they're\nused, but if you want, you can put them all at the end of your\ndocument, sort of like footnotes.\n\nHere's an example of reference links in action:\n\n I get 10 times more traffic from [Google] [1] than from\n [Yahoo] [2] or [MSN] [3].\n\n [1]: http://google.com/ \"Google\"\n [2]: http://search.yahoo.com/ \"Yahoo Search\"\n [3]: http://search.msn.com/ \"MSN Search\"\n\nUsing the implicit link name shortcut, you could instead write:\n\n I get 10 times more traffic from [Google][] than from\n [Yahoo][] or [MSN][].\n\n [google]: http://google.com/ \"Google\"\n [yahoo]: http://search.yahoo.com/ \"Yahoo Search\"\n [msn]: http://search.msn.com/ \"MSN Search\"\n\nBoth of the above examples will produce the following HTML output:\n\n

I get 10 times more traffic from Google than from\n Yahoo\n or MSN.

\n\nFor comparison, here is the same paragraph written using\nMarkdown's inline link style:\n\n I get 10 times more traffic from [Google](http://google.com/ \"Google\")\n than from [Yahoo](http://search.yahoo.com/ \"Yahoo Search\") or\n [MSN](http://search.msn.com/ \"MSN Search\").\n\nThe point of reference-style links is not that they're easier to\nwrite. The point is that with reference-style links, your document\nsource is vastly more readable. Compare the above examples: using\nreference-style links, the paragraph itself is only 81 characters\nlong; with inline-style links, it's 176 characters; and as raw HTML,\nit's 234 characters. In the raw HTML, there's more markup than there\nis text.\n\nWith Markdown's reference-style links, a source document much more\nclosely resembles the final output, as rendered in a browser. By\nallowing you to move the markup-related metadata out of the paragraph,\nyou can add links without interrupting the narrative flow of your\nprose.\n\n\n

Emphasis

\n\nMarkdown treats asterisks (`*`) and underscores (`_`) as indicators of\nemphasis. Text wrapped with one `*` or `_` will be wrapped with an\nHTML `` tag; double `*`'s or `_`'s will be wrapped with an HTML\n`` tag. E.g., this input:\n\n *single asterisks*\n\n _single underscores_\n\n **double asterisks**\n\n __double underscores__\n\nwill produce:\n\n single asterisks\n\n single underscores\n\n double asterisks\n\n double underscores\n\nYou can use whichever style you prefer; the lone restriction is that\nthe same character must be used to open and close an emphasis span.\n\nEmphasis can be used in the middle of a word:\n\n un*fucking*believable\n\nBut if you surround an `*` or `_` with spaces, it'll be treated as a\nliteral asterisk or underscore.\n\nTo produce a literal asterisk or underscore at a position where it\nwould otherwise be used as an emphasis delimiter, you can backslash\nescape it:\n\n \\*this text is surrounded by literal asterisks\\*\n\n\n\n

Code

\n\nTo indicate a span of code, wrap it with backtick quotes (`` ` ``).\nUnlike a pre-formatted code block, a code span indicates code within a\nnormal paragraph. For example:\n\n Use the `printf()` function.\n\nwill produce:\n\n

Use the printf() function.

\n\nTo include a literal backtick character within a code span, you can use\nmultiple backticks as the opening and closing delimiters:\n\n ``There is a literal backtick (`) here.``\n\nwhich will produce this:\n\n

There is a literal backtick (`) here.

\n\nThe backtick delimiters surrounding a code span may include spaces --\none after the opening, one before the closing. This allows you to place\nliteral backtick characters at the beginning or end of a code span:\n\n\tA single backtick in a code span: `` ` ``\n\t\n\tA backtick-delimited string in a code span: `` `foo` ``\n\nwill produce:\n\n\t

A single backtick in a code span: `

\n\t\n\t

A backtick-delimited string in a code span: `foo`

\n\nWith a code span, ampersands and angle brackets are encoded as HTML\nentities automatically, which makes it easy to include example HTML\ntags. Markdown will turn this:\n\n Please don't use any `` tags.\n\ninto:\n\n

Please don't use any <blink> tags.

\n\nYou can write this:\n\n `—` is the decimal-encoded equivalent of `—`.\n\nto produce:\n\n

&#8212; is the decimal-encoded\n equivalent of &mdash;.

\n\n\n\n

Images

\n\nAdmittedly, it's fairly difficult to devise a \"natural\" syntax for\nplacing images into a plain text document format.\n\nMarkdown uses an image syntax that is intended to resemble the syntax\nfor links, allowing for two styles: *inline* and *reference*.\n\nInline image syntax looks like this:\n\n ![Alt text](/path/to/img.jpg)\n\n ![Alt text](/path/to/img.jpg \"Optional title\")\n\nThat is:\n\n* An exclamation mark: `!`;\n* followed by a set of square brackets, containing the `alt`\n attribute text for the image;\n* followed by a set of parentheses, containing the URL or path to\n the image, and an optional `title` attribute enclosed in double\n or single quotes.\n\nReference-style image syntax looks like this:\n\n ![Alt text][id]\n\nWhere \"id\" is the name of a defined image reference. Image references\nare defined using syntax identical to link references:\n\n [id]: url/to/image \"Optional title attribute\"\n\nAs of this writing, Markdown has no syntax for specifying the\ndimensions of an image; if this is important to you, you can simply\nuse regular HTML `` tags.\n\n\n* * *\n\n\n

Miscellaneous

\n\n

Automatic Links

\n\nMarkdown 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:\n\n \n \nMarkdown will turn this into:\n\n http://example.com/\n\nAutomatic links for email addresses work similarly, except that\nMarkdown will also perform a bit of randomized decimal and hex\nentity-encoding to help obscure your address from address-harvesting\nspambots. For example, Markdown will turn this:\n\n \n\ninto something like this:\n\n address@exa\n mple.com\n\nwhich will render in a browser as a clickable link to \"address@example.com\".\n\n(This sort of entity-encoding trick will indeed fool many, if not\nmost, address-harvesting bots, but it definitely won't fool all of\nthem. It's better than nothing, but an address published in this way\nwill probably eventually start receiving spam.)\n\n\n\n

Backslash Escapes

\n\nMarkdown allows you to use backslash escapes to generate literal\ncharacters which would otherwise have special meaning in Markdown's\nformatting syntax. For example, if you wanted to surround a word with\nliteral asterisks (instead of an HTML `` tag), you can backslashes\nbefore the asterisks, like this:\n\n \\*literal asterisks\\*\n\nMarkdown provides backslash escapes for the following characters:\n\n \\ backslash\n ` backtick\n * asterisk\n _ underscore\n {} curly braces\n [] square brackets\n () parentheses\n # hash mark\n\t+\tplus sign\n\t-\tminus sign (hyphen)\n . dot\n ! exclamation mark\n\n") == "

Markdown: Syntax

\n\n\n\n\n\n

Note: This document is itself written using Markdown; you\ncan see the source for it by adding '.text' to the URL.

\n\n
\n\n

Overview

\n\n

Philosophy

\n\n

Markdown is intended to be as easy-to-read and easy-to-write as is feasible.

\n\n

Readability, however, is emphasized above all else. A Markdown-formatted\ndocument should be publishable as-is, as plain text, without looking\nlike it's been marked up with tags or formatting instructions. While\nMarkdown's syntax has been influenced by several existing text-to-HTML\nfilters -- including Setext, atx, Textile, reStructuredText,\nGrutatext, and EtText -- the single biggest source of\ninspiration for Markdown's syntax is the format of plain text email.

\n\n

To this end, Markdown's syntax is comprised entirely of punctuation\ncharacters, which punctuation characters have been carefully chosen so\nas to look like what they mean. E.g., asterisks around a word actually\nlook like *emphasis*. Markdown lists look like, well, lists. Even\nblockquotes look like quoted passages of text, assuming you've ever\nused email.

\n\n

Inline HTML

\n\n

Markdown's syntax is intended for one purpose: to be used as a\nformat for writing for the web.

\n\n

Markdown is not a replacement for HTML, or even close to it. Its\nsyntax is very small, corresponding only to a very small subset of\nHTML tags. The idea is not to create a syntax that makes it easier\nto insert HTML tags. In my opinion, HTML tags are already easy to\ninsert. The idea for Markdown is to make it easy to read, write, and\nedit prose. HTML is a publishing format; Markdown is a writing\nformat. Thus, Markdown's formatting syntax only addresses issues that\ncan be conveyed in plain text.

\n\n

For any markup that is not covered by Markdown's syntax, you simply\nuse HTML itself. There's no need to preface it or delimit it to\nindicate that you're switching from Markdown to HTML; you just use\nthe tags.

\n\n

The only restrictions are that block-level HTML elements -- e.g. <div>,\n<table>, <pre>, <p>, etc. -- must be separated from surrounding\ncontent by blank lines, and the start and end tags of the block should\nnot be indented with tabs or spaces. Markdown is smart enough not\nto add extra (unwanted) <p> tags around HTML block-level tags.

\n\n

For example, to add an HTML table to a Markdown article:

\n\n
This is a regular paragraph.\n\n<table>\n    <tr>\n        <td>Foo</td>\n    </tr>\n</table>\n\nThis is another regular paragraph.\n
\n\n

Note that Markdown formatting syntax is not processed within block-level\nHTML tags. E.g., you can't use Markdown-style *emphasis* inside an\nHTML block.

\n\n

Span-level HTML tags -- e.g. <span>, <cite>, or <del> -- can be\nused anywhere in a Markdown paragraph, list item, or header. If you\nwant, you can even use HTML tags instead of Markdown formatting; e.g. if\nyou'd prefer to use HTML <a> or <img> tags instead of Markdown's\nlink or image syntax, go right ahead.

\n\n

Unlike block-level HTML tags, Markdown syntax is processed within\nspan-level tags.

\n\n

Automatic Escaping for Special Characters

\n\n

In HTML, there are two characters that demand special treatment: <\nand &. Left angle brackets are used to start tags; ampersands are\nused to denote HTML entities. If you want to use them as literal\ncharacters, you must escape them as entities, e.g. &lt;, and\n&amp;.

\n\n

Ampersands in particular are bedeviling for web writers. If you want to\nwrite about 'AT&T', you need to write 'AT&amp;T'. You even need to\nescape ampersands within URLs. Thus, if you want to link to:

\n\n
http://images.google.com/images?num=30&q=larry+bird\n
\n\n

you need to encode the URL as:

\n\n
http://images.google.com/images?num=30&amp;q=larry+bird\n
\n\n

in your anchor tag href attribute. Needless to say, this is easy to\nforget, and is probably the single most common source of HTML validation\nerrors in otherwise well-marked-up web sites.

\n\n

Markdown allows you to use these characters naturally, taking care of\nall the necessary escaping for you. If you use an ampersand as part of\nan HTML entity, it remains unchanged; otherwise it will be translated\ninto &amp;.

\n\n

So, if you want to include a copyright symbol in your article, you can write:

\n\n
&copy;\n
\n\n

and Markdown will leave it alone. But if you write:

\n\n
AT&T\n
\n\n

Markdown will translate it to:

\n\n
AT&amp;T\n
\n\n

Similarly, because Markdown supports inline HTML, if you use\nangle brackets as delimiters for HTML tags, Markdown will treat them as\nsuch. But if you write:

\n\n
4 < 5\n
\n\n

Markdown will translate it to:

\n\n
4 &lt; 5\n
\n\n

However, inside Markdown code spans and blocks, angle brackets and\nampersands are always encoded automatically. This makes it easy to use\nMarkdown to write about HTML code. (As opposed to raw HTML, which is a\nterrible format for writing about HTML syntax, because every single <\nand & in your example code needs to be escaped.)

\n\n
\n\n

Block Elements

\n\n

Paragraphs and Line Breaks

\n\n

A paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing but spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.

\n\n

The implication of the \"one or more consecutive lines of text\" rule is\nthat Markdown supports \"hard-wrapped\" text paragraphs. This differs\nsignificantly from most other text-to-HTML formatters (including Movable\nType's \"Convert Line Breaks\" option) which translate every line break\ncharacter in a paragraph into a <br /> tag.

\n\n

When you do want to insert a <br /> break tag using Markdown, you\nend a line with two or more spaces, then type return.

\n\n

Yes, this takes a tad more effort to create a <br />, but a simplistic\n\"every line break is a <br />\" rule wouldn't work for Markdown.\nMarkdown's email-style blockquoting and multi-paragraph list items\nwork best -- and look better -- when you format them with hard breaks.

\n\n

Headers

\n\n

Markdown supports two styles of headers, Setext and atx.

\n\n

Setext-style headers are \"underlined\" using equal signs (for first-level\nheaders) and dashes (for second-level headers). For example:

\n\n
This is an H1\n=============\n\nThis is an H2\n-------------\n
\n\n

Any number of underlining ='s or -'s will work.

\n\n

Atx-style headers use 1-6 hash characters at the start of the line,\ncorresponding to header levels 1-6. For example:

\n\n
# This is an H1\n\n## This is an H2\n\n###### This is an H6\n
\n\n

Optionally, you may \"close\" atx-style headers. This is purely\ncosmetic -- you can use this if you think it looks better. The\nclosing hashes don't even need to match the number of hashes\nused to open the header. (The number of opening hashes\ndetermines the header level.) :

\n\n
# This is an H1 #\n\n## This is an H2 ##\n\n### This is an H3 ######\n
\n\n

Blockquotes

\n\n

Markdown uses email-style > characters for blockquoting. If you're\nfamiliar with quoting passages of text in an email message, then you\nknow how to create a blockquote in Markdown. It looks best if you hard\nwrap the text and put a > before every line:

\n\n
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n> \n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n> id sem consectetuer libero luctus adipiscing.\n
\n\n

Markdown allows you to be lazy and only put the > before the first\nline of a hard-wrapped paragraph:

\n\n
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\nconsectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\nVestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n\n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\nid sem consectetuer libero luctus adipiscing.\n
\n\n

Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by\nadding additional levels of >:

\n\n
> This is the first level of quoting.\n>\n> > This is nested blockquote.\n>\n> Back to the first level.\n
\n\n

Blockquotes can contain other Markdown elements, including headers, lists,\nand code blocks:

\n\n
> ## This is a header.\n> \n> 1.   This is the first list item.\n> 2.   This is the second list item.\n> \n> Here's some example code:\n> \n>     return shell_exec(\"echo $input | $markdown_script\");\n
\n\n

Any decent text editor should make email-style quoting easy. For\nexample, with BBEdit, you can make a selection and choose Increase\nQuote Level from the Text menu.

\n\n

Lists

\n\n

Markdown supports ordered (numbered) and unordered (bulleted) lists.

\n\n

Unordered lists use asterisks, pluses, and hyphens -- interchangably\n-- as list markers:

\n\n
*   Red\n*   Green\n*   Blue\n
\n\n

is equivalent to:

\n\n
+   Red\n+   Green\n+   Blue\n
\n\n

and:

\n\n
-   Red\n-   Green\n-   Blue\n
\n\n

Ordered lists use numbers followed by periods:

\n\n
1.  Bird\n2.  McHale\n3.  Parish\n
\n\n

It's important to note that the actual numbers you use to mark the\nlist have no effect on the HTML output Markdown produces. The HTML\nMarkdown produces from the above list is:

\n\n
<ol>\n<li>Bird</li>\n<li>McHale</li>\n<li>Parish</li>\n</ol>\n
\n\n

If you instead wrote the list in Markdown like this:

\n\n
1.  Bird\n1.  McHale\n1.  Parish\n
\n\n

or even:

\n\n
3. Bird\n1. McHale\n8. Parish\n
\n\n

you'd get the exact same HTML output. The point is, if you want to,\nyou can use ordinal numbers in your ordered Markdown lists, so that\nthe numbers in your source match the numbers in your published HTML.\nBut if you want to be lazy, you don't have to.

\n\n

If you do use lazy list numbering, however, you should still start the\nlist with the number 1. At some point in the future, Markdown may support\nstarting ordered lists at an arbitrary number.

\n\n

List markers typically start at the left margin, but may be indented by\nup to three spaces. List markers must be followed by one or more spaces\nor a tab.

\n\n

To make lists look nice, you can wrap items with hanging indents:

\n\n
*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n    Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n    viverra nec, fringilla in, laoreet vitae, risus.\n*   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n    Suspendisse id sem consectetuer libero luctus adipiscing.\n
\n\n

But if you want to be lazy, you don't have to:

\n\n
*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\nAliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\nviverra nec, fringilla in, laoreet vitae, risus.\n*   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\nSuspendisse id sem consectetuer libero luctus adipiscing.\n
\n\n

If list items are separated by blank lines, Markdown will wrap the\nitems in <p> tags in the HTML output. For example, this input:

\n\n
*   Bird\n*   Magic\n
\n\n

will turn into:

\n\n
<ul>\n<li>Bird</li>\n<li>Magic</li>\n</ul>\n
\n\n

But this:

\n\n
*   Bird\n\n*   Magic\n
\n\n

will turn into:

\n\n
<ul>\n<li><p>Bird</p></li>\n<li><p>Magic</p></li>\n</ul>\n
\n\n

List items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be intended by either 4 spaces\nor one tab:

\n\n
1.  This is a list item with two paragraphs. Lorem ipsum dolor\n    sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n    mi posuere lectus.\n\n    Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n    sit amet velit.\n\n2.  Suspendisse id sem consectetuer libero luctus adipiscing.\n
\n\n

It looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:

\n\n
*   This is a list item with two paragraphs.\n\n    This is the second paragraph in the list item. You're\nonly required to indent the first line. Lorem ipsum dolor\nsit amet, consectetuer adipiscing elit.\n\n*   Another item in the same list.\n
\n\n

To put a blockquote within a list item, the blockquote's >\ndelimiters need to be indented:

\n\n
*   A list item with a blockquote:\n\n    > This is a blockquote\n    > inside a list item.\n
\n\n

To put a code block within a list item, the code block needs\nto be indented twice -- 8 spaces or two tabs:

\n\n
*   A list item with a code block:\n\n        <code goes here>\n
\n\n

It's worth noting that it's possible to trigger an ordered list by\naccident, by writing something like this:

\n\n
1986. What a great season.\n
\n\n

In other words, a number-period-space sequence at the beginning of a\nline. To avoid this, you can backslash-escape the period:

\n\n
1986\\. What a great season.\n
\n\n

Code Blocks

\n\n

Pre-formatted code blocks are used for writing about programming or\nmarkup source code. Rather than forming normal paragraphs, the lines\nof a code block are interpreted literally. Markdown wraps a code block\nin both <pre> and <code> tags.

\n\n

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

\n\n
This is a normal paragraph:\n\n    This is a code block.\n
\n\n

Markdown will generate:

\n\n
<p>This is a normal paragraph:</p>\n\n<pre><code>This is a code block.\n</code></pre>\n
\n\n

One level of indentation -- 4 spaces or 1 tab -- is removed from each\nline of the code block. For example, this:

\n\n
Here is an example of AppleScript:\n\n    tell application \"Foo\"\n        beep\n    end tell\n
\n\n

will turn into:

\n\n
<p>Here is an example of AppleScript:</p>\n\n<pre><code>tell application \"Foo\"\n    beep\nend tell\n</code></pre>\n
\n\n

A code block continues until it reaches a line that is not indented\n(or the end of the article).

\n\n

Within a code block, ampersands (&) and angle brackets (< and >)\nare automatically converted into HTML entities. This makes it very\neasy to include example HTML source code using Markdown -- just paste\nit and indent it, and Markdown will handle the hassle of encoding the\nampersands and angle brackets. For example, this:

\n\n
    <div class=\"footer\">\n        &copy; 2004 Foo Corporation\n    </div>\n
\n\n

will turn into:

\n\n
<pre><code>&lt;div class=\"footer\"&gt;\n    &amp;copy; 2004 Foo Corporation\n&lt;/div&gt;\n</code></pre>\n
\n\n

Regular Markdown syntax is not processed within code blocks. E.g.,\nasterisks are just literal asterisks within a code block. This means\nit's also easy to use Markdown to write about Markdown's own syntax.

\n\n

Horizontal Rules

\n\n

You can produce a horizontal rule tag (<hr />) by placing three or\nmore hyphens, asterisks, or underscores on a line by themselves. If you\nwish, you may use spaces between the hyphens or asterisks. Each of the\nfollowing lines will produce a horizontal rule:

\n\n
* * *\n\n***\n\n*****\n\n- - -\n\n---------------------------------------\n\n_ _ _\n
\n\n
\n\n

Span Elements

\n\n

Links

\n\n

Markdown supports two style of links: inline and reference.

\n\n

In both styles, the link text is delimited by [square brackets].

\n\n

To create an inline link, use a set of regular parentheses immediately\nafter the link text's closing square bracket. Inside the parentheses,\nput the URL where you want the link to point, along with an optional\ntitle for the link, surrounded in quotes. For example:

\n\n
This is [an example](http://example.com/ \"Title\") inline link.\n\n[This link](http://example.net/) has no title attribute.\n
\n\n

Will produce:

\n\n
<p>This is <a href=\"http://example.com/\" title=\"Title\">\nan example</a> inline link.</p>\n\n<p><a href=\"http://example.net/\">This link</a> has no\ntitle attribute.</p>\n
\n\n

If you're referring to a local resource on the same server, you can\nuse relative paths:

\n\n
See my [About](/about/) page for details.\n
\n\n

Reference-style links use a second set of square brackets, inside\nwhich you place a label of your choosing to identify the link:

\n\n
This is [an example][id] reference-style link.\n
\n\n

You can optionally use a space to separate the sets of brackets:

\n\n
This is [an example] [id] reference-style link.\n
\n\n

Then, anywhere in the document, you define your link label like this,\non a line by itself:

\n\n
[id]: http://example.com/  \"Optional Title Here\"\n
\n\n

That is:

\n\n
    \n
  • Square brackets containing the link identifier (optionally\nindented from the left margin using up to three spaces);
  • \n
  • followed by a colon;
  • \n
  • followed by one or more spaces (or tabs);
  • \n
  • followed by the URL for the link;
  • \n
  • optionally followed by a title attribute for the link, enclosed\nin double or single quotes.
  • \n
\n\n

The link URL may, optionally, be surrounded by angle brackets:

\n\n
[id]: <http://example.com/>  \"Optional Title Here\"\n
\n\n

You can put the title attribute on the next line and use extra spaces\nor tabs for padding, which tends to look better with longer URLs:

\n\n
[id]: http://example.com/longish/path/to/resource/here\n    \"Optional Title Here\"\n
\n\n

Link definitions are only used for creating links during Markdown\nprocessing, and are stripped from your document in the HTML output.

\n\n

Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are not case sensitive. E.g. these two links:

\n\n
[link text][a]\n[link text][A]\n
\n\n

are equivalent.

\n\n

The implicit link name shortcut allows you to omit the name of the\nlink, in which case the link text itself is used as the name.\nJust use an empty set of square brackets -- e.g., to link the word\n\"Google\" to the google.com web site, you could simply write:

\n\n
[Google][]\n
\n\n

And then define the link:

\n\n
[Google]: http://google.com/\n
\n\n

Because link names may contain spaces, this shortcut even works for\nmultiple words in the link text:

\n\n
Visit [Daring Fireball][] for more information.\n
\n\n

And then define the link:

\n\n
[Daring Fireball]: http://daringfireball.net/\n
\n\n

Link definitions can be placed anywhere in your Markdown document. I\ntend to put them immediately after each paragraph in which they're\nused, but if you want, you can put them all at the end of your\ndocument, sort of like footnotes.

\n\n

Here's an example of reference links in action:

\n\n
I get 10 times more traffic from [Google] [1] than from\n[Yahoo] [2] or [MSN] [3].\n\n  [1]: http://google.com/        \"Google\"\n  [2]: http://search.yahoo.com/  \"Yahoo Search\"\n  [3]: http://search.msn.com/    \"MSN Search\"\n
\n\n

Using the implicit link name shortcut, you could instead write:

\n\n
I get 10 times more traffic from [Google][] than from\n[Yahoo][] or [MSN][].\n\n  [google]: http://google.com/        \"Google\"\n  [yahoo]:  http://search.yahoo.com/  \"Yahoo Search\"\n  [msn]:    http://search.msn.com/    \"MSN Search\"\n
\n\n

Both of the above examples will produce the following HTML output:

\n\n
<p>I get 10 times more traffic from <a href=\"http://google.com/\"\ntitle=\"Google\">Google</a> than from\n<a href=\"http://search.yahoo.com/\" title=\"Yahoo Search\">Yahoo</a>\nor <a href=\"http://search.msn.com/\" title=\"MSN Search\">MSN</a>.</p>\n
\n\n

For comparison, here is the same paragraph written using\nMarkdown's inline link style:

\n\n
I get 10 times more traffic from [Google](http://google.com/ \"Google\")\nthan from [Yahoo](http://search.yahoo.com/ \"Yahoo Search\") or\n[MSN](http://search.msn.com/ \"MSN Search\").\n
\n\n

The point of reference-style links is not that they're easier to\nwrite. The point is that with reference-style links, your document\nsource is vastly more readable. Compare the above examples: using\nreference-style links, the paragraph itself is only 81 characters\nlong; with inline-style links, it's 176 characters; and as raw HTML,\nit's 234 characters. In the raw HTML, there's more markup than there\nis text.

\n\n

With Markdown's reference-style links, a source document much more\nclosely resembles the final output, as rendered in a browser. By\nallowing you to move the markup-related metadata out of the paragraph,\nyou can add links without interrupting the narrative flow of your\nprose.

\n\n

Emphasis

\n\n

Markdown treats asterisks (*) and underscores (_) as indicators of\nemphasis. Text wrapped with one * or _ will be wrapped with an\nHTML <em> tag; double *'s or _'s will be wrapped with an HTML\n<strong> tag. E.g., this input:

\n\n
*single asterisks*\n\n_single underscores_\n\n**double asterisks**\n\n__double underscores__\n
\n\n

will produce:

\n\n
<em>single asterisks</em>\n\n<em>single underscores</em>\n\n<strong>double asterisks</strong>\n\n<strong>double underscores</strong>\n
\n\n

You can use whichever style you prefer; the lone restriction is that\nthe same character must be used to open and close an emphasis span.

\n\n

Emphasis can be used in the middle of a word:

\n\n
un*fucking*believable\n
\n\n

But if you surround an * or _ with spaces, it'll be treated as a\nliteral asterisk or underscore.

\n\n

To produce a literal asterisk or underscore at a position where it\nwould otherwise be used as an emphasis delimiter, you can backslash\nescape it:

\n\n
\\*this text is surrounded by literal asterisks\\*\n
\n\n

Code

\n\n

To indicate a span of code, wrap it with backtick quotes (`).\nUnlike a pre-formatted code block, a code span indicates code within a\nnormal paragraph. For example:

\n\n
Use the `printf()` function.\n
\n\n

will produce:

\n\n
<p>Use the <code>printf()</code> function.</p>\n
\n\n

To include a literal backtick character within a code span, you can use\nmultiple backticks as the opening and closing delimiters:

\n\n
``There is a literal backtick (`) here.``\n
\n\n

which will produce this:

\n\n
<p><code>There is a literal backtick (`) here.</code></p>\n
\n\n

The backtick delimiters surrounding a code span may include spaces --\none after the opening, one before the closing. This allows you to place\nliteral backtick characters at the beginning or end of a code span:

\n\n
A single backtick in a code span: `` ` ``\n\nA backtick-delimited string in a code span: `` `foo` ``\n
\n\n

will produce:

\n\n
<p>A single backtick in a code span: <code>`</code></p>\n\n<p>A backtick-delimited string in a code span: <code>`foo`</code></p>\n
\n\n

With a code span, ampersands and angle brackets are encoded as HTML\nentities automatically, which makes it easy to include example HTML\ntags. Markdown will turn this:

\n\n
Please don't use any `<blink>` tags.\n
\n\n

into:

\n\n
<p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>\n
\n\n

You can write this:

\n\n
`&#8212;` is the decimal-encoded equivalent of `&mdash;`.\n
\n\n

to produce:

\n\n
<p><code>&amp;#8212;</code> is the decimal-encoded\nequivalent of <code>&amp;mdash;</code>.</p>\n
\n\n

Images

\n\n

Admittedly, it's fairly difficult to devise a \"natural\" syntax for\nplacing images into a plain text document format.

\n\n

Markdown uses an image syntax that is intended to resemble the syntax\nfor links, allowing for two styles: inline and reference.

\n\n

Inline image syntax looks like this:

\n\n
![Alt text](/path/to/img.jpg)\n\n![Alt text](/path/to/img.jpg \"Optional title\")\n
\n\n

That is:

\n\n
    \n
  • An exclamation mark: !;
  • \n
  • followed by a set of square brackets, containing the alt\nattribute text for the image;
  • \n
  • followed by a set of parentheses, containing the URL or path to\nthe image, and an optional title attribute enclosed in double\nor single quotes.
  • \n
\n\n

Reference-style image syntax looks like this:

\n\n
![Alt text][id]\n
\n\n

Where \"id\" is the name of a defined image reference. Image references\nare defined using syntax identical to link references:

\n\n
[id]: url/to/image  \"Optional title attribute\"\n
\n\n

As of this writing, Markdown has no syntax for specifying the\ndimensions of an image; if this is important to you, you can simply\nuse regular HTML <img> tags.

\n\n
\n\n

Miscellaneous

\n\n

Automatic Links

\n\n

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:

\n\n
<http://example.com/>\n
\n\n

Markdown will turn this into:

\n\n
<a href=\"http://example.com/\">http://example.com/</a>\n
\n\n

Automatic links for email addresses work similarly, except that\nMarkdown will also perform a bit of randomized decimal and hex\nentity-encoding to help obscure your address from address-harvesting\nspambots. For example, Markdown will turn this:

\n\n
<address@example.com>\n
\n\n

into something like this:

\n\n
<a href=\"&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;\n&#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;\n&#109;\">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;\n&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>\n
\n\n

which will render in a browser as a clickable link to \"address@example.com\".

\n\n

(This sort of entity-encoding trick will indeed fool many, if not\nmost, address-harvesting bots, but it definitely won't fool all of\nthem. It's better than nothing, but an address published in this way\nwill probably eventually start receiving spam.)

\n\n

Backslash Escapes

\n\n

Markdown allows you to use backslash escapes to generate literal\ncharacters which would otherwise have special meaning in Markdown's\nformatting syntax. For example, if you wanted to surround a word with\nliteral asterisks (instead of an HTML <em> tag), you can backslashes\nbefore the asterisks, like this:

\n\n
\\*literal asterisks\\*\n
\n\n

Markdown provides backslash escapes for the following characters:

\n\n
\\   backslash\n`   backtick\n*   asterisk\n_   underscore\n{}  curly braces\n[]  square brackets\n()  parentheses\n#   hash mark\n+   plus sign\n-   minus sign (hyphen)\n.   dot\n!   exclamation mark\n
"), -%% ?_assert(conv("> foo\n>\n> > bar\n>\n> foo\n") == "
\n

foo

\n \n
\n

bar

\n
\n \n

foo

\n
"), -%% ?_assert(conv("## Unordered\n\nAsterisks tight:\n\n*\tasterisk 1\n*\tasterisk 2\n*\tasterisk 3\n\n\nAsterisks loose:\n\n*\tasterisk 1\n\n*\tasterisk 2\n\n*\tasterisk 3\n\n* * *\n\nPluses tight:\n\n+\tPlus 1\n+\tPlus 2\n+\tPlus 3\n\n\nPluses loose:\n\n+\tPlus 1\n\n+\tPlus 2\n\n+\tPlus 3\n\n* * *\n\n\nMinuses tight:\n\n-\tMinus 1\n-\tMinus 2\n-\tMinus 3\n\n\nMinuses loose:\n\n-\tMinus 1\n\n-\tMinus 2\n\n-\tMinus 3\n\n\n## Ordered\n\nTight:\n\n1.\tFirst\n2.\tSecond\n3.\tThird\n\nand:\n\n1. One\n2. Two\n3. Three\n\n\nLoose using tabs:\n\n1.\tFirst\n\n2.\tSecond\n\n3.\tThird\n\nand using spaces:\n\n1. One\n\n2. Two\n\n3. Three\n\nMultiple paragraphs:\n\n1.\tItem 1, graf one.\n\n\tItem 2. graf two. The quick brown fox jumped over the lazy dog's\n\tback.\n\t\n2.\tItem 2.\n\n3.\tItem 3.\n\n\n\n## Nested\n\n*\tTab\n\t*\tTab\n\t\t*\tTab\n\nHere's another:\n\n1. First\n2. Second:\n\t* Fee\n\t* Fie\n\t* Foe\n3. Third\n\nSame thing but with paragraphs:\n\n1. First\n\n2. Second:\n\t* Fee\n\t* Fie\n\t* Foe\n\n3. Third\n\n\nThis was an error in Markdown 1.0.1:\n\n*\tthis\n\n\t*\tsub\n\n\tthat\n") == "

Unordered

\n\n

Asterisks tight:

\n\n
    \n
  • asterisk 1
  • \n
  • asterisk 2
  • \n
  • asterisk 3
  • \n
\n\n

Asterisks loose:

\n\n
    \n
  • asterisk 1

  • \n
  • asterisk 2

  • \n
  • asterisk 3

  • \n
\n\n
\n\n

Pluses tight:

\n\n
    \n
  • Plus 1
  • \n
  • Plus 2
  • \n
  • Plus 3
  • \n
\n\n

Pluses loose:

\n\n
    \n
  • Plus 1

  • \n
  • Plus 2

  • \n
  • Plus 3

  • \n
\n\n
\n\n

Minuses tight:

\n\n
    \n
  • Minus 1
  • \n
  • Minus 2
  • \n
  • Minus 3
  • \n
\n\n

Minuses loose:

\n\n
    \n
  • Minus 1

  • \n
  • Minus 2

  • \n
  • Minus 3

  • \n
\n\n

Ordered

\n\n

Tight:

\n\n
    \n
  1. First
  2. \n
  3. Second
  4. \n
  5. Third
  6. \n
\n\n

and:

\n\n
    \n
  1. One
  2. \n
  3. Two
  4. \n
  5. Three
  6. \n
\n\n

Loose using tabs:

\n\n
    \n
  1. First

  2. \n
  3. Second

  4. \n
  5. Third

  6. \n
\n\n

and using spaces:

\n\n
    \n
  1. One

  2. \n
  3. Two

  4. \n
  5. Three

  6. \n
\n\n

Multiple paragraphs:

\n\n
    \n
  1. Item 1, graf one.

    \n\n

    Item 2. graf two. The quick brown fox jumped over the lazy dog's\nback.

  2. \n
  3. Item 2.

  4. \n
  5. Item 3.

  6. \n
\n\n

Nested

\n\n
    \n
  • Tab\n
    • Tab\n
      • Tab
  • \n
\n\n

Here's another:

\n\n
    \n
  1. First
  2. \n
  3. Second:\n
    • Fee
    • \n
    • Fie
    • \n
    • Foe
  4. \n
  5. Third
  6. \n
\n\n

Same thing but with paragraphs:

\n\n
    \n
  1. First

  2. \n
  3. Second:

    \n\n
    • Fee
    • \n
    • Fie
    • \n
    • Foe
  4. \n
  5. Third

  6. \n
\n\n

This was an error in Markdown 1.0.1:

\n\n
    \n
  • this

    \n\n
    • sub
    \n\n

    that

  • \n
"), -%% ?_assert(conv("***This is strong and em.***\n\nSo is ***this*** word.\n\n___This is strong and em.___\n\nSo is ___this___ word.\n") == "

This is strong and em.

\n\n

So is this word.

\n\n

This is strong and em.

\n\n

So is this word.

"), -%% ?_assert(conv("+\tthis is a list item\n\tindented with tabs\n\n+ this is a list item\n indented with spaces\n\nCode:\n\n\tthis code block is indented by one tab\n\nAnd:\n\n\t\tthis code block is indented by two tabs\n\nAnd:\n\n\t+\tthis is an example list item\n\t\tindented with tabs\n\t\n\t+ this is an example list item\n\t indented with spaces\n") == "
    \n
  • this is a list item\nindented with tabs

  • \n
  • this is a list item\nindented with spaces

  • \n
\n\n

Code:

\n\n
this code block is indented by one tab\n
\n\n

And:

\n\n
    this code block is indented by two tabs\n
\n\n

And:

\n\n
+   this is an example list item\n    indented with tabs\n\n+   this is an example list item\n    indented with spaces\n
"), -%% ?_assert(conv("> A list within a blockquote:\n> \n> *\tasterisk 1\n> *\tasterisk 2\n> *\tasterisk 3\n") == "
\n

A list within a blockquote:

\n \n
    \n
  • asterisk 1
  • \n
  • asterisk 2
  • \n
  • asterisk 3
  • \n
\n
"), -%% ?_assert(conv("1. one\r\n\r\n code\r\n indented 8 spaces\r\n\r\n2. two\r\n\r\n code\r\n idented-12-spaces\r\n\r\n3. three\r\n\r\n code\r\n\r\n indented-12-spaces") == "

1. one

\n\n
    code<t>\n    indented 8 spaces<t>\n
\n\n
    \n
  1. two

    \n\n
    code<t>\n    idented-12-spaces<t>\n
  2. \n
  3. three

    \n\n
    code<t>\n\n\n
    indented-12-spaces&lt;t&gt;\n
    \n\n
  4. \n
"), -%% ?_assert(conv("##Header##\r\r----------\r\rSome **bold** Some *italic* and [a link][1] \r\rA little code sample\r\r \r Web Page Title\r \r\rA picture\r\r![alt text][2]\r\rA list\r\r- apples\r- oranges\r- eggs\r\rA numbered list\r\r1. a\r2. b\r3. c\r\rA little quote\r\r> It is now time for all good men to come to the aid of their country. \r\rA final paragraph.\r\r [1]: http://www.google.com\r [2]: http://www.google.com/intl/en_ALL/images/logo.gif") == "

Header

\n\n
\n\n

Some bold Some italic and a link

\n\n

A little code sample

\n\n
</head>\n<title>Web Page Title</title>\n</head>\n
\n\n

A picture

\n\n

\"alt

\n\n

A list

\n\n
    \n
  • apples
  • \n
  • oranges
  • \n
  • eggs
  • \n
\n\n

A numbered list

\n\n
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n\n

A little quote

\n\n
\n

It is now time for all good men to come to the aid of their country.

\n
\n\n

A final paragraph.

"), -%% ?_assert(conv("##Header##\r\n\r\n----------\r\n\r\nSome **bold** Some *italic* and [a link][1] \r\n\r\nA little code sample\r\n\r\n \r\n Web Page Title\r\n \r\n\r\nA picture\r\n\r\n![alt text][2]\r\n\r\nA list\r\n\r\n- apples\r\n- oranges\r\n- eggs\r\n\r\nA numbered list\r\n\r\n1. a\r\n2. b\r\n3. c\r\n\r\nA little quote\r\n\r\n> It is now time for all good men to come to the aid of their country. \r\n\r\nA final paragraph.\r\n\r\n [1]: http://www.google.com\r\n [2]: http://www.google.com/intl/en_ALL/images/logo.gif") == "

Header

\n\n
\n\n

Some bold Some italic and a link

\n\n

A little code sample

\n\n
</head>\n<title>Web Page Title</title>\n</head>\n
\n\n

A picture

\n\n

\"alt

\n\n

A list

\n\n
    \n
  • apples
  • \n
  • oranges
  • \n
  • eggs
  • \n
\n\n

A numbered list

\n\n
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n\n

A little quote

\n\n
\n

It is now time for all good men to come to the aid of their country.

\n
\n\n

A final paragraph.

"), -%% ?_assert(conv("##Header##\n\n----------\n\nSome **bold** Some *italic* and [a link][1] \n\nA little code sample\n\n \n Web Page Title\n \n\nA picture\n\n![alt text][2]\n\nA list\n\n- apples\n- oranges\n- eggs\n\nA numbered list\n\n1. a\n2. b\n3. c\n\nA little quote\n\n> It is now time for all good men to come to the aid of their country. \n\nA final paragraph.\n\n [1]: http://www.google.com\n [2]: http://www.google.com/intl/en_ALL/images/logo.gif") == "

Header

\n\n
\n\n

Some bold Some italic and a link

\n\n

A little code sample

\n\n
</head>\n<title>Web Page Title</title>\n</head>\n
\n\n

A picture

\n\n

\"alt

\n\n

A list

\n\n
    \n
  • apples
  • \n
  • oranges
  • \n
  • eggs
  • \n
\n\n

A numbered list

\n\n
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n\n

A little quote

\n\n
\n

It is now time for all good men to come to the aid of their country.

\n
\n\n

A final paragraph.

"), -%% ?_assert(conv("Markdown\n========\n\nVersion 1.0.1 - Tue 14 Dec 2004\n\nby John Gruber \n\n\n\nIntroduction\n------------\n\nMarkdown is a text-to-HTML conversion tool for web writers. Markdown\nallows you to write using an easy-to-read, easy-to-write plain text\nformat, then convert it to structurally valid XHTML (or HTML).\n\nThus, \"Markdown\" is two things: a plain text markup syntax, and a\nsoftware tool, written in Perl, that converts the plain text markup \nto HTML.\n\nMarkdown works both as a Movable Type plug-in and as a standalone Perl\nscript -- which means it can also be used as a text filter in BBEdit\n(or any other application that supporst filters written in Perl).\n\nFull documentation of Markdown's syntax and configuration options is\navailable on the web: .\n(Note: this readme file is formatted in Markdown.)\n\n\n\nInstallation and Requirements\n-----------------------------\n\nMarkdown requires Perl 5.6.0 or later. Welcome to the 21st Century.\nMarkdown also requires the standard Perl library module `Digest::MD5`. \n\n\n### Movable Type ###\n\nMarkdown works with Movable Type version 2.6 or later (including \nMT 3.0 or later).\n\n1. Copy the \"Markdown.pl\" file into your Movable Type \"plugins\"\n directory. The \"plugins\" directory should be in the same directory\n as \"mt.cgi\"; if the \"plugins\" directory doesn't already exist, use\n your FTP program to create it. Your installation should look like\n this:\n\n (mt home)/plugins/Markdown.pl\n\n2. Once installed, Markdown will appear as an option in Movable Type's\n Text Formatting pop-up menu. This is selectable on a per-post basis.\n Markdown translates your posts to HTML when you publish; the posts\n themselves are stored in your MT database in Markdown format.\n\n3. If you also install SmartyPants 1.5 (or later), Markdown will offer\n a second text formatting option: \"Markdown with SmartyPants\". This\n option is the same as the regular \"Markdown\" formatter, except that\n automatically uses SmartyPants to create typographically correct\n curly quotes, em-dashes, and ellipses. See the SmartyPants web page\n for more information: \n\n4. To make Markdown (or \"Markdown with SmartyPants\") your default\n text formatting option for new posts, go to Weblog Config ->\n Preferences.\n\nNote that by default, Markdown produces XHTML output. To configure\nMarkdown to produce HTML 4 output, see \"Configuration\", below.\n\n\n### Blosxom ###\n\nMarkdown works with Blosxom version 2.x.\n\n1. Rename the \"Markdown.pl\" plug-in to \"Markdown\" (case is\n important). Movable Type requires plug-ins to have a \".pl\"\n extension; Blosxom forbids it.\n\n2. Copy the \"Markdown\" plug-in file to your Blosxom plug-ins folder.\n If you're not sure where your Blosxom plug-ins folder is, see the\n Blosxom documentation for information.\n\n3. That's it. The entries in your weblog will now automatically be\n processed by Markdown.\n\n4. If you'd like to apply Markdown formatting only to certain posts,\n rather than all of them, see Jason Clark's instructions for using\n Markdown in conjunction with Blosxom's Meta plugin:\n \n \n\n\n### BBEdit ###\n\nMarkdown works with BBEdit 6.1 or later on Mac OS X. (It also works\nwith BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.)\n\n1. Copy the \"Markdown.pl\" file to appropriate filters folder in your\n \"BBEdit Support\" folder. On Mac OS X, this should be:\n\n BBEdit Support/Unix Support/Unix Filters/\n\n See the BBEdit documentation for more details on the location of\n these folders.\n\n You can rename \"Markdown.pl\" to whatever you wish.\n\n2. That's it. To use Markdown, select some text in a BBEdit document,\n then choose Markdown from the Filters sub-menu in the \"#!\" menu, or\n the Filters floating palette\n\n\n\nConfiguration\n-------------\n\nBy default, Markdown produces XHTML output for tags with empty elements.\nE.g.:\n\n
\n\nMarkdown can be configured to produce HTML-style tags; e.g.:\n\n
\n\n\n### Movable Type ###\n\nYou need to use a special `MTMarkdownOptions` container tag in each\nMovable Type template where you want HTML 4-style output:\n\n \n ... put your entry content here ...\n \n\nThe easiest way to use MTMarkdownOptions is probably to put the\nopening tag right after your `` tag, and the closing tag right\nbefore ``.\n\nTo suppress Markdown processing in a particular template, i.e. to\npublish the raw Markdown-formatted text without translation into\n(X)HTML, set the `output` attribute to 'raw':\n\n \n ... put your entry content here ...\n \n\n\n### Command-Line ###\n\nUse the `--html4tags` command-line switch to produce HTML output from a\nUnix-style command line. E.g.:\n\n % perl Markdown.pl --html4tags foo.text\n\nType `perldoc Markdown.pl`, or read the POD documentation within the\nMarkdown.pl source code for more information.\n\n\n\nBugs\n----\n\nTo file bug reports or feature requests please send email to:\nmarkdown@daringfireball.net.\n\n\n\nVersion History\n---------------\n\n1.0.1 (14 Dec 2004):\n\n+\tChanged the syntax rules for code blocks and spans. Previously,\n\tbackslash escapes for special Markdown characters were processed\n\teverywhere other than within inline HTML tags. Now, the contents\n\tof code blocks and spans are no longer processed for backslash\n\tescapes. This means that code blocks and spans are now treated\n\tliterally, with no special rules to worry about regarding\n\tbackslashes.\n\n\t**NOTE**: This changes the syntax from all previous versions of\n\tMarkdown. Code blocks and spans involving backslash characters\n\twill now generate different output than before.\n\n+\tTweaked the rules for link definitions so that they must occur\n\twithin three spaces of the left margin. Thus if you indent a link\n\tdefinition by four spaces or a tab, it will now be a code block.\n\t\n\t\t [a]: /url/ \"Indented 3 spaces, this is a link def\"\n\n\t\t [b]: /url/ \"Indented 4 spaces, this is a code block\"\n\t\n\t**IMPORTANT**: This may affect existing Markdown content if it\n\tcontains link definitions indented by 4 or more spaces.\n\n+\tAdded `>`, `+`, and `-` to the list of backslash-escapable\n\tcharacters. These should have been done when these characters\n\twere added as unordered list item markers.\n\n+\tTrailing spaces and tabs following HTML comments and `
` tags\n\tare now ignored.\n\n+\tInline links using `<` and `>` URL delimiters weren't working:\n\n\t\tlike [this]()\n\n+\tAdded a bit of tolerance for trailing spaces and tabs after\n\tMarkdown hr's.\n\n+\tFixed bug where auto-links were being processed within code spans:\n\n\t\tlike this: ``\n\n+\tSort-of fixed a bug where lines in the middle of hard-wrapped\n\tparagraphs, which lines look like the start of a list item,\n\twould accidentally trigger the creation of a list. E.g. a\n\tparagraph that looked like this:\n\n\t\tI recommend upgrading to version\n\t\t8. Oops, now this line is treated\n\t\tas a sub-list.\n\n\tThis is fixed for top-level lists, but it can still happen for\n\tsub-lists. E.g., the following list item will not be parsed\n\tproperly:\n\n\t\t+\tI recommend upgrading to version\n\t\t\t8. Oops, now this line is treated\n\t\t\tas a sub-list.\n\n\tGiven Markdown's list-creation rules, I'm not sure this can\n\tbe fixed.\n\n+\tStandalone HTML comments are now handled; previously, they'd get\n\twrapped in a spurious `

` tag.\n\n+\tFix for horizontal rules preceded by 2 or 3 spaces.\n\n+\t`


` HTML tags in must occur within three spaces of left\n\tmargin. (With 4 spaces or a tab, they should be code blocks, but\n\tweren't before this fix.)\n\n+\tCapitalized \"With\" in \"Markdown With SmartyPants\" for\n\tconsistency with the same string label in SmartyPants.pl.\n\t(This fix is specific to the MT plug-in interface.)\n\n+\tAuto-linked email address can now optionally contain\n\ta 'mailto:' protocol. I.e. these are equivalent:\n\n\t\t\n\t\t\n\n+\tFixed annoying bug where nested lists would wind up with\n\tspurious (and invalid) `

` tags.\n\n+\tYou can now write empty links:\n\n\t\t[like this]()\n\n\tand they'll be turned into anchor tags with empty href attributes.\n\tThis should have worked before, but didn't.\n\n+\t`***this***` and `___this___` are now turned into\n\n\t\tthis\n\n\tInstead of\n\n\t\tthis\n\n\twhich isn't valid. (Thanks to Michel Fortin for the fix.)\n\n+\tAdded a new substitution in `_EncodeCode()`: s/\\$/$/g; This\n\tis only for the benefit of Blosxom users, because Blosxom\n\t(sometimes?) interpolates Perl scalars in your article bodies.\n\n+\tFixed problem for links defined with urls that include parens, e.g.:\n\n\t\t[1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky)\n\n\t\"Chomsky\" was being erroneously treated as the URL's title.\n\n+\tAt some point during 1.0's beta cycle, I changed every sub's\n\targument fetching from this idiom:\n\n\t\tmy $text = shift;\n\n\tto:\n\n\t\tmy $text = shift || return '';\n\n\tThe idea was to keep Markdown from doing any work in a sub\n\tif the input was empty. This introduced a bug, though:\n\tif the input to any function was the single-character string\n\t\"0\", it would also evaluate as false and return immediately.\n\tHow silly. Now fixed.\n\n\n\nDonations\n---------\n\nDonations to support Markdown's development are happily accepted. See:\n for details.\n\n\n\nCopyright and License\n---------------------\n\nCopyright (c) 2003-2004 John Gruber \n \nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n* Neither the name \"Markdown\" nor the names of its contributors may\n be used to endorse or promote products derived from this software\n without specific prior written permission.\n\nThis software is provided by the copyright holders and contributors \"as\nis\" and any express or implied warranties, including, but not limited\nto, the implied warranties of merchantability and fitness for a\nparticular purpose are disclaimed. In no event shall the copyright owner\nor contributors be liable for any direct, indirect, incidental, special,\nexemplary, or consequential damages (including, but not limited to,\nprocurement of substitute goods or services; loss of use, data, or\nprofits; or business interruption) however caused and on any theory of\nliability, whether in contract, strict liability, or tort (including\nnegligence or otherwise) arising in any way out of the use of this\nsoftware, even if advised of the possibility of such damage.\n") == "

Markdown

\n\n

Version 1.0.1 - Tue 14 Dec 2004

\n\n

by John Gruber
\nhttp://daringfireball.net/

\n\n

Introduction

\n\n

Markdown is a text-to-HTML conversion tool for web writers. Markdown\nallows you to write using an easy-to-read, easy-to-write plain text\nformat, then convert it to structurally valid XHTML (or HTML).

\n\n

Thus, \"Markdown\" is two things: a plain text markup syntax, and a\nsoftware tool, written in Perl, that converts the plain text markup \nto HTML.

\n\n

Markdown works both as a Movable Type plug-in and as a standalone Perl\nscript -- which means it can also be used as a text filter in BBEdit\n(or any other application that supporst filters written in Perl).

\n\n

Full documentation of Markdown's syntax and configuration options is\navailable on the web: http://daringfireball.net/projects/markdown/.\n(Note: this readme file is formatted in Markdown.)

\n\n

Installation and Requirements

\n\n

Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century.\nMarkdown also requires the standard Perl library module Digest::MD5.

\n\n

Movable Type

\n\n

Markdown works with Movable Type version 2.6 or later (including \nMT 3.0 or later).

\n\n
    \n
  1. Copy the \"Markdown.pl\" file into your Movable Type \"plugins\"\ndirectory. The \"plugins\" directory should be in the same directory\nas \"mt.cgi\"; if the \"plugins\" directory doesn't already exist, use\nyour FTP program to create it. Your installation should look like\nthis:

    \n\n
    (mt home)/plugins/Markdown.pl\n
  2. \n
  3. Once installed, Markdown will appear as an option in Movable Type's\nText Formatting pop-up menu. This is selectable on a per-post basis.\nMarkdown translates your posts to HTML when you publish; the posts\nthemselves are stored in your MT database in Markdown format.

  4. \n
  5. If you also install SmartyPants 1.5 (or later), Markdown will offer\na second text formatting option: \"Markdown with SmartyPants\". This\noption is the same as the regular \"Markdown\" formatter, except that\nautomatically uses SmartyPants to create typographically correct\ncurly quotes, em-dashes, and ellipses. See the SmartyPants web page\nfor more information: http://daringfireball.net/projects/smartypants/

  6. \n
  7. To make Markdown (or \"Markdown with SmartyPants\") your default\ntext formatting option for new posts, go to Weblog Config ->\nPreferences.

  8. \n
\n\n

Note that by default, Markdown produces XHTML output. To configure\nMarkdown to produce HTML 4 output, see \"Configuration\", below.

\n\n

Blosxom

\n\n

Markdown works with Blosxom version 2.x.

\n\n
    \n
  1. Rename the \"Markdown.pl\" plug-in to \"Markdown\" (case is\nimportant). Movable Type requires plug-ins to have a \".pl\"\nextension; Blosxom forbids it.

  2. \n
  3. Copy the \"Markdown\" plug-in file to your Blosxom plug-ins folder.\nIf you're not sure where your Blosxom plug-ins folder is, see the\nBlosxom documentation for information.

  4. \n
  5. That's it. The entries in your weblog will now automatically be\nprocessed by Markdown.

  6. \n
  7. If you'd like to apply Markdown formatting only to certain posts,\nrather than all of them, see Jason Clark's instructions for using\nMarkdown in conjunction with Blosxom's Meta plugin:

    \n\n

    http://jclark.org/weblog/WebDev/Blosxom/Markdown.html

  8. \n
\n\n

BBEdit

\n\n

Markdown works with BBEdit 6.1 or later on Mac OS X. (It also works\nwith BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.)

\n\n
    \n
  1. Copy the \"Markdown.pl\" file to appropriate filters folder in your\n\"BBEdit Support\" folder. On Mac OS X, this should be:

    \n\n
    BBEdit Support/Unix Support/Unix Filters/\n
    \n\n

    See the BBEdit documentation for more details on the location of\nthese folders.

    \n\n

    You can rename \"Markdown.pl\" to whatever you wish.

  2. \n
  3. That's it. To use Markdown, select some text in a BBEdit document,\nthen choose Markdown from the Filters sub-menu in the \"#!\" menu, or\nthe Filters floating palette

  4. \n
\n\n

Configuration

\n\n

By default, Markdown produces XHTML output for tags with empty elements.\nE.g.:

\n\n
<br />\n
\n\n

Markdown can be configured to produce HTML-style tags; e.g.:

\n\n
<br>\n
\n\n

Movable Type

\n\n

You need to use a special MTMarkdownOptions container tag in each\nMovable Type template where you want HTML 4-style output:

\n\n
<MTMarkdownOptions output='html4'>\n    ... put your entry content here ...\n</MTMarkdownOptions>\n
\n\n

The easiest way to use MTMarkdownOptions is probably to put the\nopening tag right after your <body> tag, and the closing tag right\nbefore </body>.

\n\n

To suppress Markdown processing in a particular template, i.e. to\npublish the raw Markdown-formatted text without translation into\n(X)HTML, set the output attribute to 'raw':

\n\n
<MTMarkdownOptions output='raw'>\n    ... put your entry content here ...\n</MTMarkdownOptions>\n
\n\n

Command-Line

\n\n

Use the --html4tags command-line switch to produce HTML output from a\nUnix-style command line. E.g.:

\n\n
% perl Markdown.pl --html4tags foo.text\n
\n\n

Type perldoc Markdown.pl, or read the POD documentation within the\nMarkdown.pl source code for more information.

\n\n

Bugs

\n\n

To file bug reports or feature requests please send email to:\nmarkdown@daringfireball.net.

\n\n

Version History

\n\n

1.0.1 (14 Dec 2004):

\n\n
    \n
  • Changed the syntax rules for code blocks and spans. Previously,\nbackslash escapes for special Markdown characters were processed\neverywhere other than within inline HTML tags. Now, the contents\nof code blocks and spans are no longer processed for backslash\nescapes. This means that code blocks and spans are now treated\nliterally, with no special rules to worry about regarding\nbackslashes.

    \n\n

    NOTE: This changes the syntax from all previous versions of\nMarkdown. Code blocks and spans involving backslash characters\nwill now generate different output than before.

  • \n
  • Tweaked the rules for link definitions so that they must occur\nwithin three spaces of the left margin. Thus if you indent a link\ndefinition by four spaces or a tab, it will now be a code block.

    \n\n
       [a]: /url/  \"Indented 3 spaces, this is a link def\"\n\n\n
    [b]: /url/  \"Indented 4 spaces, this is a code block\"\n
    \n\n
    \n\n

    IMPORTANT: This may affect existing Markdown content if it\ncontains link definitions indented by 4 or more spaces.

  • \n
  • Added >, +, and - to the list of backslash-escapable\ncharacters. These should have been done when these characters\nwere added as unordered list item markers.

  • \n
  • Trailing spaces and tabs following HTML comments and <hr/> tags\nare now ignored.

  • \n
  • Inline links using < and > URL delimiters weren't working:

    \n\n
    like [this](<http://example.com/>)\n
  • \n
  • Added a bit of tolerance for trailing spaces and tabs after\nMarkdown hr's.

  • \n
  • Fixed bug where auto-links were being processed within code spans:

    \n\n
    like this: `<http://example.com/>`\n
  • \n
  • Sort-of fixed a bug where lines in the middle of hard-wrapped\nparagraphs, which lines look like the start of a list item,\nwould accidentally trigger the creation of a list. E.g. a\nparagraph that looked like this:

    \n\n
    I recommend upgrading to version\n8. Oops, now this line is treated\nas a sub-list.\n
    \n\n

    This is fixed for top-level lists, but it can still happen for\nsub-lists. E.g., the following list item will not be parsed\nproperly:

    \n\n
    +   I recommend upgrading to version\n    8. Oops, now this line is treated\n    as a sub-list.\n
    \n\n

    Given Markdown's list-creation rules, I'm not sure this can\nbe fixed.

  • \n
  • Standalone HTML comments are now handled; previously, they'd get\nwrapped in a spurious <p> tag.

  • \n
  • Fix for horizontal rules preceded by 2 or 3 spaces.

  • \n
  • <hr> HTML tags in must occur within three spaces of left\nmargin. (With 4 spaces or a tab, they should be code blocks, but\nweren't before this fix.)

  • \n
  • Capitalized \"With\" in \"Markdown With SmartyPants\" for\nconsistency with the same string label in SmartyPants.pl.\n(This fix is specific to the MT plug-in interface.)

  • \n
  • Auto-linked email address can now optionally contain\na 'mailto:' protocol. I.e. these are equivalent:

    \n\n
    <mailto:user@example.com>\n<user@example.com>\n
  • \n
  • Fixed annoying bug where nested lists would wind up with\nspurious (and invalid) <p> tags.

  • \n
  • You can now write empty links:

    \n\n
    [like this]()\n
    \n\n

    and they'll be turned into anchor tags with empty href attributes.\nThis should have worked before, but didn't.

  • \n
  • ***this*** and ___this___ are now turned into

    \n\n
    <strong><em>this</em></strong>\n
    \n\n

    Instead of

    \n\n
    <strong><em>this</strong></em>\n
    \n\n

    which isn't valid. (Thanks to Michel Fortin for the fix.)

  • \n
  • Added a new substitution in _EncodeCode(): s/\\$/$/g; This\nis only for the benefit of Blosxom users, because Blosxom\n(sometimes?) interpolates Perl scalars in your article bodies.

  • \n
  • Fixed problem for links defined with urls that include parens, e.g.:

    \n\n
    [1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky)\n
    \n\n

    \"Chomsky\" was being erroneously treated as the URL's title.

  • \n
  • At some point during 1.0's beta cycle, I changed every sub's\nargument fetching from this idiom:

    \n\n
    my $text = shift;\n
    \n\n

    to:

    \n\n
    my $text = shift || return '';\n
    \n\n

    The idea was to keep Markdown from doing any work in a sub\nif the input was empty. This introduced a bug, though:\nif the input to any function was the single-character string\n\"0\", it would also evaluate as false and return immediately.\nHow silly. Now fixed.

  • \n
\n\n

Donations

\n\n

Donations to support Markdown's development are happily accepted. See:\nhttp://daringfireball.net/projects/markdown/ for details.

\n\n

Copyright and License

\n\n

Copyright (c) 2003-2004 John Gruber
\nhttp://daringfireball.net/
\nAll rights reserved.

\n\n

Redistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:

\n\n
    \n
  • Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.

  • \n
  • Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.

  • \n
  • Neither the name \"Markdown\" nor the names of its contributors may\nbe used to endorse or promote products derived from this software\nwithout specific prior written permission.

  • \n
\n\n

This software is provided by the copyright holders and contributors \"as\nis\" and any express or implied warranties, including, but not limited\nto, the implied warranties of merchantability and fitness for a\nparticular purpose are disclaimed. In no event shall the copyright owner\nor contributors be liable for any direct, indirect, incidental, special,\nexemplary, or consequential damages (including, but not limited to,\nprocurement of substitute goods or services; loss of use, data, or\nprofits; or business interruption) however caused and on any theory of\nliability, whether in contract, strict liability, or tort (including\nnegligence or otherwise) arising in any way out of the use of this\nsoftware, even if advised of the possibility of such damage.

"), -%% ?_assert(conv("Tricky combinaisons:\r\rbackslash with \\\\-- two dashes\r\rbackslash with \\\\> greater than\r\r\\\\\\[test](not a link)\r\r\\\\\\*no emphasis*") == "

Tricky combinaisons:

\n\n

backslash with \\-- two dashes

\n\n

backslash with \\> greater than

\n\n

\\[test](not a link)

\n\n

\\*no emphasis*

"), -%% ?_assert(conv("From ``\non two lines.\n\nFrom ``\non three lines.\n") == "

From <!-- to -->\non two lines.

\n\n

From <!--\nto -->\non three lines.

"), -%% ?_assert(conv("\n*\tList Item:\n\n\t\tcode block\n\n\t\twith a blank line\n\n\twithin a list item.") == "
    \n
  • List Item:

    \n\n
    code block\n\n\nwith a blank line\n
    \n\n

    within a list item.

  • \n
"), -%% ?_assert(conv("Combined emphasis:\n\n1. ***test test***\n2. ___test test___\n3. *test **test***\n4. **test *test***\n5. ***test* test**\n6. ***test** test*\n7. ***test* test**\n8. **test *test***\n9. *test **test***\n10. _test __test___\n11. __test _test___\n12. ___test_ test__\n13. ___test__ test_\n14. ___test_ test__\n15. __test _test___\n16. _test __test___\n\n\nIncorrect nesting:\n\n1. *test **test* test**\n2. _test __test_ test__\n3. **test *test** test*\n4. __test _test__ test_\n5. *test *test* test*\n6. _test _test_ test_\n7. **test **test** test**\n8. __test __test__ test__\n\n\n\nNo emphasis:\n\n1. test* test *test\n2. test** test **test\n3. test_ test _test\n4. test__ test __test\n\n\n\nMiddle-word emphasis (asterisks):\n\n1. *a*b\n2. a*b*\n3. a*b*c\n4. **a**b\n5. a**b**\n6. a**b**c\n\n\nMiddle-word emphasis (underscore):\n\n1. _a_b\n2. a_b_\n3. a_b_c\n4. __a__b\n5. a__b__\n6. a__b__c\n\nmy_precious_file.txt\n\n\n## Tricky Cases\n\nE**. **Test** TestTestTest\n\nE**. **Test** Test Test Test\n") == "

Combined emphasis:

\n\n
    \n
  1. test test
  2. \n
  3. test test
  4. \n
  5. test test
  6. \n
  7. test test
  8. \n
  9. test test
  10. \n
  11. test test
  12. \n
  13. test test
  14. \n
  15. test test
  16. \n
  17. test test
  18. \n
  19. test test
  20. \n
  21. test test
  22. \n
  23. test test
  24. \n
  25. test test
  26. \n
  27. test test
  28. \n
  29. test test
  30. \n
  31. test test
  32. \n
\n\n

Incorrect nesting:

\n\n
    \n
  1. test test test
  2. \n
  3. test test test
  4. \n
  5. test test test
  6. \n
  7. test test test
  8. \n
  9. test *test test*
  10. \n
  11. test _test test_
  12. \n
  13. test *test test*
  14. \n
  15. test _test test_
  16. \n
\n\n

No emphasis:

\n\n
    \n
  1. test* test *test
  2. \n
  3. test* test *test
  4. \n
  5. test_ test _test
  6. \n
  7. test_ test _test
  8. \n
\n\n

Middle-word emphasis (asterisks):

\n\n
    \n
  1. ab
  2. \n
  3. ab
  4. \n
  5. abc
  6. \n
  7. ab
  8. \n
  9. ab
  10. \n
  11. abc
  12. \n
\n\n

Middle-word emphasis (underscore):

\n\n
    \n
  1. ab
  2. \n
  3. ab
  4. \n
  5. abc
  6. \n
  7. ab
  8. \n
  9. ab
  10. \n
  11. abc
  12. \n
\n\n

mypreciousfile.txt

\n\n

Tricky Cases

\n\n

E. **Test TestTestTest

\n\n

E. **Test Test Test Test

"), -%% ?_assert(conv("Header\r======\r\rHeader\r------\r\r### Header\n\n - - -\n\nHeader\r======\rParagraph\r\rHeader\r------\rParagraph\r\r### Header\rParagraph\n\n - - -\n\nParagraph\rHeader\r======\rParagraph\r\rParagraph\rHeader\r------\rParagraph\r\rParagraph\r### Header\rParagraph") == "

Header

\n\n

Header

\n\n

Header

\n\n
\n\n

Header

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n
\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

"), -%% ?_assert(conv("Horizontal rules:\n\n- - -\n \n* * *\n \n***\n \n---\n \n___\n\nNot horizontal rules (testing for a bug in 1.0.1j):\n\n+++\n\n,,,\n\n===\n\n???\n\nAAA\n\njjj\n\nj j j\n\nn n n\n") == "

Horizontal rules:

\n\n
\n\n
\n\n
\n\n
\n\n
\n\n

Not horizontal rules (testing for a bug in 1.0.1j):

\n\n

+++

\n\n

,,,

\n\n

===

\n\n

???

\n\n

AAA

\n\n

jjj

\n\n

j j j

\n\n

n n n

"), -%% ?_assert(conv("With some attributes:\n\n
\n\tfoo\n
\n\n
\n\tfoo\n
\n\t\nHr's:\n\n
\n") == "

With some attributes:

\n\n
\n foo\n
\n\n
\n foo\n
\n\n

Hr's:

\n\n
"), -%% ?_assert(conv("ACINACS\n\nSB \nSB") == "

ACINACS

\n\n

SB

"), -%% ?_assert(conv("Paragraph one.\n\n\n\nParagraph two.\n\n\n\nThe end.\n") == "

Paragraph one.

\n\n\n\n

Paragraph two.

\n\n\n\n

The end.

"), -%% ?_assert(conv("Here is a block tag ins:\n\n\n

Some text

\n
\n\nAnd here it is inside a paragraph.\n\nAnd here it is in the middle of a paragraph.\n\n\n

Some text

\n
\n\nAnd here is ins as a paragraph.\n\nAnd here it is in the middle of a paragraph.\n") == "

Here is a block tag ins:

\n\n\n

Some text

\n
\n\n

And here it is inside a paragraph.

\n\n

And here it is in the middle of a paragraph.

\n\n\n

Some text

\n
\n\n

And here is ins as a paragraph.

\n\n

And here it is in the middle of a paragraph.

"), -%% ?_assert(conv("[silly URL w/ angle brackets]().\n") == "

silly URL w/ angle brackets>).

"), -%% ?_assert(conv("# Character Escapes\n\nThe MD5 value for `+` is \"26b17225b626fb9238849fd60eabdf60\".\n\n# HTML Blocks\n\n

test

\n\nThe MD5 value for `

test

` is:\n\n6205333b793f34273d75379350b36826") == "

Character Escapes

\n\n

The MD5 value for + is \"26b17225b626fb9238849fd60eabdf60\".

\n\n

HTML Blocks

\n\n

test

\n\n

The MD5 value for <p>test</p> is:

\n\n

6205333b793f34273d75379350b36826

"), -%% ?_assert(conv("Valid nesting:\n\n**[Link](url)**\n\n[**Link**](url)\n\n**[**Link**](url)**\n\nInvalid nesting:\n\n[[Link](url)](url)") == "

Valid nesting:

\n\n

Link

\n\n

Link

\n\n

Link

\n\n

Invalid nesting:

\n\n

[Link](url)

"), -%% ?_assert(conv("This tests for a bug where quotes escaped by PHP when using \n`preg_replace` with the `/e` modifier must be correctly unescaped\n(hence the `_UnslashQuotes` function found only in PHP Markdown).\n\n\n\nHeaders below should appear exactly as they are typed (no backslash\nadded or removed).\n\nHeader \"quoted\\\" again \\\\\"\"\n===========================\n\nHeader \"quoted\\\" again \\\\\"\"\n---------------------------\n\n### Header \"quoted\\\" again \\\\\"\" ###\n\n\n\nTest with tabs for `_Detab`:\n\n\tCode\t'block'\twith\tsome\t\"tabs\"\tand\t\"quotes\"\n") == "

This tests for a bug where quotes escaped by PHP when using \npreg_replace with the /e modifier must be correctly unescaped\n(hence the _UnslashQuotes function found only in PHP Markdown).

\n\n

Headers below should appear exactly as they are typed (no backslash\nadded or removed).

\n\n

Header \"quoted\\\" again \\\"\"

\n\n

Header \"quoted\\\" again \\\"\"

\n\n

Header \"quoted\\\" again \\\"\"

\n\n

Test with tabs for _Detab:

\n\n
Code    'block' with    some    \"tabs\"  and \"quotes\"\n
"), -%% ?_assert(conv("[Inline link 1 with parens](/url\\(test\\) \"title\").\n\n[Inline link 2 with parens]( \"title\").\n\n[Inline link 3 with non-escaped parens](/url(test) \"title\").\n\n[Inline link 4 with non-escaped parens]( \"title\").\n\n[Reference link 1 with parens][1].\n\n[Reference link 2 with parens][2].\n\n [1]: /url(test) \"title\"\n [2]: \"title\"\n") == "

Inline link 1 with parens.

\n\n

Inline link 2 with parens> \"title\").

\n\n

Inline link 3 with non-escaped parens \"title\").

\n\n

Inline link 4 with non-escaped parens> \"title\").

\n\n

Reference link 1 with parens.

\n\n

"title\">Reference link 2 with parens.

"), -%% ?_assert(conv("Paragraph and no space:\r* ciao\r\rParagraph and 1 space:\r * ciao\r\rParagraph and 3 spaces:\r * ciao\r\rParagraph and 4 spaces:\r * ciao\r\rParagraph before header:\r#Header\r\rParagraph before blockquote:\r>Some quote.\r") == "

Paragraph and no space:\n* ciao

\n\n

Paragraph and 1 space:\n * ciao

\n\n

Paragraph and 3 spaces:\n * ciao

\n\n

Paragraph and 4 spaces:\n * ciao

\n\n

Paragraph before header:

\n\n

Header

\n\n

Paragraph before blockquote:

\n\n
\n

Some quote.

\n
"), -%% ?_assert(conv("AT&T has an ampersand in their name.\n\nAT&T is another way to write it.\n\nThis & that.\n\n4 < 5.\n\n6 > 5.\n\nHere's a [link] [1] with an ampersand in the URL.\n\nHere's a link with an amersand in the link text: [AT&T] [2].\n\nHere's an inline [link](/script?foo=1&bar=2).\n\nHere's an inline [link]().\n\n\n[1]: http://example.com/?foo=1&bar=2\n[2]: http://att.com/ \"AT&T\"") == "

AT&T has an ampersand in their name.

\n\n

AT&T is another way to write it.

\n\n

This & that.

\n\n

4 < 5.

\n\n

6 > 5.

\n\n

Here's a link with an ampersand in the URL.

\n\n

Here's a link with an amersand in the link text: AT&T.

\n\n

Here's an inline link.

\n\n

Here's an inline link.

"), -%% ?_assert(conv("Link: .\n\nWith an ampersand: \n\n* In a list?\n* \n* It should.\n\n> Blockquoted: \n\nAuto-links should not occur here: ``\n\n\tor here: ") == "

Link: http://example.com/.

\n\n

With an ampersand: http://example.com/?foo=1&bar=2

\n\n\n\n
\n

Blockquoted: http://example.com/

\n
\n\n

Auto-links should not occur here: <http://example.com/>

\n\n
or here: <http://example.com/>\n
"), -%% ?_assert(conv("These should all get escaped:\n\nBackslash: \\\\\n\nBacktick: \\`\n\nAsterisk: \\*\n\nUnderscore: \\_\n\nLeft brace: \\{\n\nRight brace: \\}\n\nLeft bracket: \\[\n\nRight bracket: \\]\n\nLeft paren: \\(\n\nRight paren: \\)\n\nGreater-than: \\>\n\nHash: \\#\n\nPeriod: \\.\n\nBang: \\!\n\nPlus: \\+\n\nMinus: \\-\n\n\n\nThese should not, because they occur within a code block:\n\n\tBackslash: \\\\\n\n\tBacktick: \\`\n\n\tAsterisk: \\*\n\n\tUnderscore: \\_\n\n\tLeft brace: \\{\n\n\tRight brace: \\}\n\n\tLeft bracket: \\[\n\n\tRight bracket: \\]\n\n\tLeft paren: \\(\n\n\tRight paren: \\)\n\n\tGreater-than: \\>\n\n\tHash: \\#\n\n\tPeriod: \\.\n\n\tBang: \\!\n\n\tPlus: \\+\n\n\tMinus: \\-\n\n\nNor should these, which occur in code spans:\n\nBackslash: `\\\\`\n\nBacktick: `` \\` ``\n\nAsterisk: `\\*`\n\nUnderscore: `\\_`\n\nLeft brace: `\\{`\n\nRight brace: `\\}`\n\nLeft bracket: `\\[`\n\nRight bracket: `\\]`\n\nLeft paren: `\\(`\n\nRight paren: `\\)`\n\nGreater-than: `\\>`\n\nHash: `\\#`\n\nPeriod: `\\.`\n\nBang: `\\!`\n\nPlus: `\\+`\n\nMinus: `\\-`\n\n\nThese should get escaped, even though they're matching pairs for\nother Markdown constructs:\n\n\\*asterisks\\*\n\n\\_underscores\\_\n\n\\`backticks\\`\n\nThis is a code span with a literal backslash-backtick sequence: `` \\` ``\n\nThis is a tag with unescaped backticks bar.\n\nThis is a tag with backslashes bar.\n") == "

These should all get escaped:

\n\n

Backslash: \\

\n\n

Backtick: `

\n\n

Asterisk: *

\n\n

Underscore: _

\n\n

Left brace: {

\n\n

Right brace: }

\n\n

Left bracket: [

\n\n

Right bracket: ]

\n\n

Left paren: (

\n\n

Right paren: )

\n\n

Greater-than: >

\n\n

Hash: #

\n\n

Period: .

\n\n

Bang: !

\n\n

Plus: +

\n\n

Minus: -

\n\n

These should not, because they occur within a code block:

\n\n
Backslash: \\\\\n\nBacktick: \\`\n\nAsterisk: \\*\n\nUnderscore: \\_\n\nLeft brace: \\{\n\nRight brace: \\}\n\nLeft bracket: \\[\n\nRight bracket: \\]\n\nLeft paren: \\(\n\nRight paren: \\)\n\nGreater-than: \\>\n\nHash: \\#\n\nPeriod: \\.\n\nBang: \\!\n\nPlus: \\+\n\nMinus: \\-\n
\n\n

Nor should these, which occur in code spans:

\n\n

Backslash: \\\\

\n\n

Backtick: \\`

\n\n

Asterisk: \\*

\n\n

Underscore: \\_

\n\n

Left brace: \\{

\n\n

Right brace: \\}

\n\n

Left bracket: \\[

\n\n

Right bracket: \\]

\n\n

Left paren: \\(

\n\n

Right paren: \\)

\n\n

Greater-than: \\>

\n\n

Hash: \\#

\n\n

Period: \\.

\n\n

Bang: \\!

\n\n

Plus: \\+

\n\n

Minus: \\-

\n\n

These should get escaped, even though they're matching pairs for\nother Markdown constructs:

\n\n

*asterisks*

\n\n

_underscores_

\n\n

`backticks`

\n\n

This is a code span with a literal backslash-backtick sequence: \\`

\n\n

This is a tag with unescaped backticks bar.

\n\n

This is a tag with backslashes bar.

"), -%% ?_assert(conv("> Example:\n> \n> sub status {\n> print \"working\";\n> }\n> \n> Or:\n> \n> sub status {\n> return \"working\";\n> }\n") == "
\n

Example:

\n\n
sub status {\n    print \"working\";\n}\n
\n \n

Or:

\n\n
sub status {\n    return \"working\";\n}\n
\n
"), -%% ?_assert(conv("\tcode block on the first line\n\t\nRegular text.\n\n code block indented by spaces\n\nRegular text.\n\n\tthe lines in this block \n\tall contain trailing spaces \n\nRegular Text.\n\n\tcode block on the last line") == "
code block on the first line\n
\n\n

Regular text.

\n\n
code block indented by spaces\n
\n\n

Regular text.

\n\n
the lines in this block  \nall contain trailing spaces  \n
\n\n

Regular Text.

\n\n
code block on the last line\n
"), -%% ?_assert(conv("``\n\nFix for backticks within HTML tag: like this\n\nHere's how you put `` `backticks` `` in a code span.") == "

<test a=\" content of attribute \">

\n\n

Fix for backticks within HTML tag: like this

\n\n

Here's how you put `backticks` in a code span.

"), -%% ?_assert(conv("In Markdown 1.0.0 and earlier. Version\n8. This line turns into a list item.\nBecause a hard-wrapped line in the\nmiddle of a paragraph looked like a\nlist item.\n\nHere's one with a bullet.\n* criminey.\n") == "

In Markdown 1.0.0 and earlier. Version\n8. This line turns into a list item.\nBecause a hard-wrapped line in the\nmiddle of a paragraph looked like a\nlist item.

\n\n

Here's one with a bullet.\n* criminey.

"), -%% ?_assert(conv("Dashes:\n\n---\n\n ---\n \n ---\n\n ---\n\n\t---\n\n- - -\n\n - - -\n \n - - -\n\n - - -\n\n\t- - -\n\n\nAsterisks:\n\n***\n\n ***\n \n ***\n\n ***\n\n\t***\n\n* * *\n\n * * *\n \n * * *\n\n * * *\n\n\t* * *\n\n\nUnderscores:\n\n___\n\n ___\n \n ___\n\n ___\n\n ___\n\n_ _ _\n\n _ _ _\n \n _ _ _\n\n _ _ _\n\n _ _ _\n") == "

Dashes:

\n\n
\n\n
\n\n
\n\n
\n\n
---\n
\n\n
\n\n
\n\n
\n\n
\n\n
- - -\n
\n\n

Asterisks:

\n\n
\n\n
\n\n
\n\n
\n\n
***\n
\n\n
\n\n
\n\n
\n\n
\n\n
* * *\n
\n\n

Underscores:

\n\n
\n\n
\n\n
\n\n
\n\n
___\n
\n\n
\n\n
\n\n
\n\n
\n\n
_ _ _\n
"), -%% ?_assert(conv("![Alt text](/path/to/img.jpg)\n\n![Alt text](/path/to/img.jpg \"Optional title\")\n\nInline within a paragraph: [alt text](/url/).\n\n![alt text](/url/ \"title preceded by two spaces\")\n\n![alt text](/url/ \"title has spaces afterward\" )\n\n![alt text]()\n\n![alt text]( \"with a title\").\n\n![Empty]()\n\n![this is a stupid URL](http://example.com/(parens).jpg)\n\n\n![alt text][foo]\n\n [foo]: /url/\n\n![alt text][bar]\n\n [bar]: /url/ \"Title here\"") == "

\"Alt

\n\n

\"Alt

\n\n

Inline within a paragraph: alt text.

\n\n

\"alt

\n\n

\"alt

\n\n

\"alt

\n\n

\"alt.

\n\n

!Empty

\n\n

\"this.jpg)

\n\n

\"alt

\n\n

\"alt

"), -%% ?_assert(conv("Simple block on one line:\n\n
foo
\n\nAnd nested without indentation:\n\n
\n
\n
\nfoo\n
\n
\"/>\n
\n
bar
\n
\n\nAnd with attributes:\n\n
\n\t
\n\t
\n
\n\nThis was broken in 1.0.2b7:\n\n
\n
\nfoo\n
\n
\n") == "

Simple block on one line:

\n\n
foo
\n\nAnd nested without indentation:\n\n
\n
\n
\nfoo\n
\n\n
\"/>\n
\n\n
bar
\n
\n\n

And with attributes:

\n\n
\n
\n
\n
\n\n

This was broken in 1.0.2b7:

\n\n
\n
\nfoo\n
\n\n

"), -%% ?_assert(conv("Here's a simple block:\n\n
\n\tfoo\n
\n\nThis should be a code block, though:\n\n\t
\n\t\tfoo\n\t
\n\nAs should this:\n\n\t
foo
\n\nNow, nested:\n\n
\n\t
\n\t\t
\n\t\t\tfoo\n\t\t
\n\t
\n
\n\nThis should just be an HTML comment:\n\n\n\nMultiline:\n\n\n\nCode block:\n\n\t\n\nJust plain comment, with trailing spaces on the line:\n\n \n\nCode:\n\n\t
\n\t\nHr's:\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n") == "

Here's a simple block:

\n\n
\n foo\n
\n\n

This should be a code block, though:

\n\n
<div>\n    foo\n</div>\n
\n\n

As should this:

\n\n
<div>foo</div>\n
\n\n

Now, nested:

\n\n
\n
\n
\n foo\n
\n
\n
\n\n

This should just be an HTML comment:

\n\n\n\n

Multiline:

\n\n\n\n

Code block:

\n\n
<!-- Comment -->\n
\n\n

Just plain comment, with trailing spaces on the line:

\n\n \n\n

Code:

\n\n
<hr />\n
\n\n

Hr's:

\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
"), -%% ?_assert(conv("Paragraph one.\n\n\n\n\n\nParagraph two.\n\n\n\nThe end.\n") == "

Paragraph one.

\n\n\n\n\n\n

Paragraph two.

\n\n\n\n

The end.

"), -%% ?_assert(conv("Just a [URL](/url/).\n\n[URL and title](/url/ \"title\").\n\n[URL and title](/url/ \"title preceded by two spaces\").\n\n[URL and title](/url/\t\"title preceded by a tab\").\n\n[URL and title](/url/ \"title has spaces afterward\" ).\n\n[URL wrapped in angle brackets]().\n\n[URL w/ angle brackets + title]( \"Here's the title\").\n\n[Empty]().\n\n[With parens in the URL](http://en.wikipedia.org/wiki/WIMP_(computing))\n\n(With outer parens and [parens in url](/foo(bar)))\n\n\n[With parens in the URL](/foo(bar) \"and a title\")\n\n(With outer parens and [parens in url](/foo(bar) \"and a title\"))\n") == "

Just a URL.

\n\n

URL and title.

\n\n

URL and title.

\n\n

URL and title.

\n\n

URL and title.

\n\n

URL wrapped in angle brackets.

\n\n

URL w/ angle brackets + title.

\n\n

Empty.

\n\n

With parens in the URL)

\n\n

(With outer parens and parens in url))

\n\n

With parens in the URL \"and a title\")

\n\n

(With outer parens and parens in url \"and a title\"))

"), -%% ?_assert(conv("Foo [bar] [1].\n\nFoo [bar][1].\n\nFoo [bar]\n[1].\n\n[1]: /url/ \"Title\"\n\n\nWith [embedded [brackets]] [b].\n\n\nIndented [once][].\n\nIndented [twice][].\n\nIndented [thrice][].\n\nIndented [four][] times.\n\n [once]: /url\n\n [twice]: /url\n\n [thrice]: /url\n\n [four]: /url\n\n\n[b]: /url/\n\n* * *\n\n[this] [this] should work\n\nSo should [this][this].\n\nAnd [this] [].\n\nAnd [this][].\n\nAnd [this].\n\nBut not [that] [].\n\nNor [that][].\n\nNor [that].\n\n[Something in brackets like [this][] should work]\n\n[Same with [this].]\n\nIn this case, [this](/somethingelse/) points to something else.\n\nBackslashing should suppress \\[this] and [this\\].\n\n[this]: foo\n\n\n* * *\n\nHere's one where the [link\nbreaks] across lines.\n\nHere's another where the [link \nbreaks] across lines, but with a line-ending space.\n\n\n[link breaks]: /url/\n") == "

Foo bar.

\n\n

Foo bar.

\n\n

Foo bar.

\n\n

With embedded [brackets].

\n\n

Indented once.

\n\n

Indented twice.

\n\n

Indented thrice.

\n\n

Indented [four][] times.

\n\n
[four]: /url\n
\n\n
\n\n

this should work

\n\n

So should this.

\n\n

And this.

\n\n

And this.

\n\n

And this.

\n\n

But not [that] [].

\n\n

Nor [that][].

\n\n

Nor [that].

\n\n

[Something in brackets like this should work]

\n\n

[Same with this.]

\n\n

In this case, this points to something else.

\n\n

Backslashing should suppress [this] and [this].

\n\n
\n\n

Here's one where the link\nbreaks across lines.

\n\n

Here's another where the link \nbreaks across lines, but with a line-ending space.

"), -%% ?_assert(conv("This is the [simple case].\n\n[simple case]: /simple\n\n\n\nThis one has a [line\nbreak].\n\nThis one has a [line \nbreak] with a line-ending space.\n\n[line break]: /foo\n\n\n[this] [that] and the [other]\n\n[this]: /this\n[that]: /that\n[other]: /other\n") == "

This is the simple case.

\n\n

This one has a line\nbreak.

\n\n

This one has a line \nbreak with a line-ending space.

\n\n

this and the other

"), -%% ?_assert(conv("Foo [bar][].\n\nFoo [bar](/url/ \"Title with \"quotes\" inside\").\n\n\n [bar]: /url/ \"Title with \"quotes\" inside\"\n\n") == "

Foo bar.

\n\n

Foo bar.

"), -%% ?_assert(conv("Markdown: Basics\n================\n\n\n\n\nGetting the Gist of Markdown's Formatting Syntax\n------------------------------------------------\n\nThis page offers a brief overview of what it's like to use Markdown.\nThe [syntax page] [s] provides complete, detailed documentation for\nevery feature, but Markdown should be very easy to pick up simply by\nlooking at a few examples of it in action. The examples on this page\nare written in a before/after style, showing example syntax and the\nHTML output produced by Markdown.\n\nIt's also helpful to simply try Markdown out; the [Dingus] [d] is a\nweb application that allows you type your own Markdown-formatted text\nand translate it to XHTML.\n\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL] [src].\n\n [s]: /projects/markdown/syntax \"Markdown Syntax\"\n [d]: /projects/markdown/dingus \"Markdown Dingus\"\n [src]: /projects/markdown/basics.text\n\n\n## Paragraphs, Headers, Blockquotes ##\n\nA paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.\n\nMarkdown offers two styles of headers: *Setext* and *atx*.\nSetext-style headers for `

` and `

` are created by\n\"underlining\" with equal signs (`=`) and hyphens (`-`), respectively.\nTo create an atx-style header, you put 1-6 hash marks (`#`) at the\nbeginning of the line -- the number of hashes equals the resulting\nHTML header level.\n\nBlockquotes are indicated using email-style '`>`' angle brackets.\n\nMarkdown:\n\n A First Level Header\n ====================\n \n A Second Level Header\n ---------------------\n\n Now is the time for all good men to come to\n the aid of their country. This is just a\n regular paragraph.\n\n The quick brown fox jumped over the lazy\n dog's back.\n \n ### Header 3\n\n > This is a blockquote.\n > \n > This is the second paragraph in the blockquote.\n >\n > ## This is an H2 in a blockquote\n\n\nOutput:\n\n

A First Level Header

\n \n

A Second Level Header

\n \n

Now is the time for all good men to come to\n the aid of their country. This is just a\n regular paragraph.

\n \n

The quick brown fox jumped over the lazy\n dog's back.

\n \n

Header 3

\n \n
\n

This is a blockquote.

\n \n

This is the second paragraph in the blockquote.

\n \n

This is an H2 in a blockquote

\n
\n\n\n\n### Phrase Emphasis ###\n\nMarkdown uses asterisks and underscores to indicate spans of emphasis.\n\nMarkdown:\n\n Some of these words *are emphasized*.\n Some of these words _are emphasized also_.\n \n Use two asterisks for **strong emphasis**.\n Or, if you prefer, __use two underscores instead__.\n\nOutput:\n\n

Some of these words are emphasized.\n Some of these words are emphasized also.

\n \n

Use two asterisks for strong emphasis.\n Or, if you prefer, use two underscores instead.

\n \n\n\n## Lists ##\n\nUnordered (bulleted) lists use asterisks, pluses, and hyphens (`*`,\n`+`, and `-`) as list markers. These three markers are\ninterchangable; this:\n\n * Candy.\n * Gum.\n * Booze.\n\nthis:\n\n + Candy.\n + Gum.\n + Booze.\n\nand this:\n\n - Candy.\n - Gum.\n - Booze.\n\nall produce the same output:\n\n
    \n
  • Candy.
  • \n
  • Gum.
  • \n
  • Booze.
  • \n
\n\nOrdered (numbered) lists use regular numbers, followed by periods, as\nlist markers:\n\n 1. Red\n 2. Green\n 3. Blue\n\nOutput:\n\n
    \n
  1. Red
  2. \n
  3. Green
  4. \n
  5. Blue
  6. \n
\n\nIf you put blank lines between items, you'll get `

` tags for the\nlist item text. You can create multi-paragraph list items by indenting\nthe paragraphs by 4 spaces or 1 tab:\n\n * A list item.\n \n With multiple paragraphs.\n\n * Another item in the list.\n\nOutput:\n\n

    \n
  • A list item.

    \n

    With multiple paragraphs.

  • \n
  • Another item in the list.

  • \n
\n \n\n\n### Links ###\n\nMarkdown supports two styles for creating links: *inline* and\n*reference*. With both styles, you use square brackets to delimit the\ntext you want to turn into a link.\n\nInline-style links use parentheses immediately after the link text.\nFor example:\n\n This is an [example link](http://example.com/).\n\nOutput:\n\n

This is an \n example link.

\n\nOptionally, you may include a title attribute in the parentheses:\n\n This is an [example link](http://example.com/ \"With a Title\").\n\nOutput:\n\n

This is an \n example link.

\n\nReference-style links allow you to refer to your links by names, which\nyou define elsewhere in your document:\n\n I get 10 times more traffic from [Google][1] than from\n [Yahoo][2] or [MSN][3].\n\n [1]: http://google.com/ \"Google\"\n [2]: http://search.yahoo.com/ \"Yahoo Search\"\n [3]: http://search.msn.com/ \"MSN Search\"\n\nOutput:\n\n

I get 10 times more traffic from Google than from Yahoo or MSN.

\n\nThe title attribute is optional. Link names may contain letters,\nnumbers and spaces, but are *not* case sensitive:\n\n I start my morning with a cup of coffee and\n [The New York Times][NY Times].\n\n [ny times]: http://www.nytimes.com/\n\nOutput:\n\n

I start my morning with a cup of coffee and\n The New York Times.

\n\n\n### Images ###\n\nImage syntax is very much like link syntax.\n\nInline (titles are optional):\n\n ![alt text](/path/to/img.jpg \"Title\")\n\nReference-style:\n\n ![alt text][id]\n\n [id]: /path/to/img.jpg \"Title\"\n\nBoth of the above examples produce the same output:\n\n \"alt\n\n\n\n### Code ###\n\nIn a regular paragraph, you can create code span by wrapping text in\nbacktick quotes. Any ampersands (`&`) and angle brackets (`<` or\n`>`) will automatically be translated into HTML entities. This makes\nit easy to use Markdown to write about HTML example code:\n\n I strongly recommend against using any `` tags.\n\n I wish SmartyPants used named entities like `—`\n instead of decimal-encoded entites like `—`.\n\nOutput:\n\n

I strongly recommend against using any\n <blink> tags.

\n \n

I wish SmartyPants used named entities like\n &mdash; instead of decimal-encoded\n entites like &#8212;.

\n\n\nTo specify an entire block of pre-formatted code, indent every line of\nthe block by 4 spaces or 1 tab. Just like with code spans, `&`, `<`,\nand `>` characters will be escaped automatically.\n\nMarkdown:\n\n If you want your page to validate under XHTML 1.0 Strict,\n you've got to put paragraph tags in your blockquotes:\n\n
\n

For example.

\n
\n\nOutput:\n\n

If you want your page to validate under XHTML 1.0 Strict,\n you've got to put paragraph tags in your blockquotes:

\n \n
<blockquote>\n        <p>For example.</p>\n    </blockquote>\n    
\n") == "

Markdown: Basics

\n\n\n\n

Getting the Gist of Markdown's Formatting Syntax

\n\n

This page offers a brief overview of what it's like to use Markdown.\nThe syntax page provides complete, detailed documentation for\nevery feature, but Markdown should be very easy to pick up simply by\nlooking at a few examples of it in action. The examples on this page\nare written in a before/after style, showing example syntax and the\nHTML output produced by Markdown.

\n\n

It's also helpful to simply try Markdown out; the Dingus is a\nweb application that allows you type your own Markdown-formatted text\nand translate it to XHTML.

\n\n

Note: This document is itself written using Markdown; you\ncan see the source for it by adding '.text' to the URL.

\n\n

Paragraphs, Headers, Blockquotes

\n\n

A paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.

\n\n

Markdown offers two styles of headers: Setext and atx.\nSetext-style headers for <h1> and <h2> are created by\n\"underlining\" with equal signs (=) and hyphens (-), respectively.\nTo create an atx-style header, you put 1-6 hash marks (#) at the\nbeginning of the line -- the number of hashes equals the resulting\nHTML header level.

\n\n

Blockquotes are indicated using email-style '>' angle brackets.

\n\n

Markdown:

\n\n
A First Level Header\n====================\n\nA Second Level Header\n---------------------\n\nNow is the time for all good men to come to\nthe aid of their country. This is just a\nregular paragraph.\n\nThe quick brown fox jumped over the lazy\ndog's back.\n\n### Header 3\n\n> This is a blockquote.\n> \n> This is the second paragraph in the blockquote.\n>\n> ## This is an H2 in a blockquote\n
\n\n

Output:

\n\n
<h1>A First Level Header</h1>\n\n<h2>A Second Level Header</h2>\n\n<p>Now is the time for all good men to come to\nthe aid of their country. This is just a\nregular paragraph.</p>\n\n<p>The quick brown fox jumped over the lazy\ndog's back.</p>\n\n<h3>Header 3</h3>\n\n<blockquote>\n    <p>This is a blockquote.</p>\n\n    <p>This is the second paragraph in the blockquote.</p>\n\n    <h2>This is an H2 in a blockquote</h2>\n</blockquote>\n
\n\n

Phrase Emphasis

\n\n

Markdown uses asterisks and underscores to indicate spans of emphasis.

\n\n

Markdown:

\n\n
Some of these words *are emphasized*.\nSome of these words _are emphasized also_.\n\nUse two asterisks for **strong emphasis**.\nOr, if you prefer, __use two underscores instead__.\n
\n\n

Output:

\n\n
<p>Some of these words <em>are emphasized</em>.\nSome of these words <em>are emphasized also</em>.</p>\n\n<p>Use two asterisks for <strong>strong emphasis</strong>.\nOr, if you prefer, <strong>use two underscores instead</strong>.</p>\n
\n\n

Lists

\n\n

Unordered (bulleted) lists use asterisks, pluses, and hyphens (*,\n+, and -) as list markers. These three markers are\ninterchangable; this:

\n\n
*   Candy.\n*   Gum.\n*   Booze.\n
\n\n

this:

\n\n
+   Candy.\n+   Gum.\n+   Booze.\n
\n\n

and this:

\n\n
-   Candy.\n-   Gum.\n-   Booze.\n
\n\n

all produce the same output:

\n\n
<ul>\n<li>Candy.</li>\n<li>Gum.</li>\n<li>Booze.</li>\n</ul>\n
\n\n

Ordered (numbered) lists use regular numbers, followed by periods, as\nlist markers:

\n\n
1.  Red\n2.  Green\n3.  Blue\n
\n\n

Output:

\n\n
<ol>\n<li>Red</li>\n<li>Green</li>\n<li>Blue</li>\n</ol>\n
\n\n

If you put blank lines between items, you'll get <p> tags for the\nlist item text. You can create multi-paragraph list items by indenting\nthe paragraphs by 4 spaces or 1 tab:

\n\n
*   A list item.\n\n    With multiple paragraphs.\n\n*   Another item in the list.\n
\n\n

Output:

\n\n
<ul>\n<li><p>A list item.</p>\n<p>With multiple paragraphs.</p></li>\n<li><p>Another item in the list.</p></li>\n</ul>\n
\n\n

Links

\n\n

Markdown supports two styles for creating links: inline and\nreference. With both styles, you use square brackets to delimit the\ntext you want to turn into a link.

\n\n

Inline-style links use parentheses immediately after the link text.\nFor example:

\n\n
This is an [example link](http://example.com/).\n
\n\n

Output:

\n\n
<p>This is an <a href=\"http://example.com/\">\nexample link</a>.</p>\n
\n\n

Optionally, you may include a title attribute in the parentheses:

\n\n
This is an [example link](http://example.com/ \"With a Title\").\n
\n\n

Output:

\n\n
<p>This is an <a href=\"http://example.com/\" title=\"With a Title\">\nexample link</a>.</p>\n
\n\n

Reference-style links allow you to refer to your links by names, which\nyou define elsewhere in your document:

\n\n
I get 10 times more traffic from [Google][1] than from\n[Yahoo][2] or [MSN][3].\n\n[1]: http://google.com/        \"Google\"\n[2]: http://search.yahoo.com/  \"Yahoo Search\"\n[3]: http://search.msn.com/    \"MSN Search\"\n
\n\n

Output:

\n\n
<p>I get 10 times more traffic from <a href=\"http://google.com/\"\ntitle=\"Google\">Google</a> than from <a href=\"http://search.yahoo.com/\"\ntitle=\"Yahoo Search\">Yahoo</a> or <a href=\"http://search.msn.com/\"\ntitle=\"MSN Search\">MSN</a>.</p>\n
\n\n

The title attribute is optional. Link names may contain letters,\nnumbers and spaces, but are not case sensitive:

\n\n
I start my morning with a cup of coffee and\n[The New York Times][NY Times].\n\n[ny times]: http://www.nytimes.com/\n
\n\n

Output:

\n\n
<p>I start my morning with a cup of coffee and\n<a href=\"http://www.nytimes.com/\">The New York Times</a>.</p>\n
\n\n

Images

\n\n

Image syntax is very much like link syntax.

\n\n

Inline (titles are optional):

\n\n
![alt text](/path/to/img.jpg \"Title\")\n
\n\n

Reference-style:

\n\n
![alt text][id]\n\n[id]: /path/to/img.jpg \"Title\"\n
\n\n

Both of the above examples produce the same output:

\n\n
<img src=\"/path/to/img.jpg\" alt=\"alt text\" title=\"Title\" />\n
\n\n

Code

\n\n

In a regular paragraph, you can create code span by wrapping text in\nbacktick quotes. Any ampersands (&) and angle brackets (< or\n>) will automatically be translated into HTML entities. This makes\nit easy to use Markdown to write about HTML example code:

\n\n
I strongly recommend against using any `<blink>` tags.\n\nI wish SmartyPants used named entities like `&mdash;`\ninstead of decimal-encoded entites like `&#8212;`.\n
\n\n

Output:

\n\n
<p>I strongly recommend against using any\n<code>&lt;blink&gt;</code> tags.</p>\n\n<p>I wish SmartyPants used named entities like\n<code>&amp;mdash;</code> instead of decimal-encoded\nentites like <code>&amp;#8212;</code>.</p>\n
\n\n

To specify an entire block of pre-formatted code, indent every line of\nthe block by 4 spaces or 1 tab. Just like with code spans, &, <,\nand > characters will be escaped automatically.

\n\n

Markdown:

\n\n
If you want your page to validate under XHTML 1.0 Strict,\nyou've got to put paragraph tags in your blockquotes:\n\n    <blockquote>\n        <p>For example.</p>\n    </blockquote>\n
\n\n

Output:

\n\n
<p>If you want your page to validate under XHTML 1.0 Strict,\nyou've got to put paragraph tags in your blockquotes:</p>\n\n<pre><code>&lt;blockquote&gt;\n    &lt;p&gt;For example.&lt;/p&gt;\n&lt;/blockquote&gt;\n</code></pre>\n
"), -%% ?_assert(conv("Markdown: Syntax\n================\n\n\n\n\n* [Overview](#overview)\n * [Philosophy](#philosophy)\n * [Inline HTML](#html)\n * [Automatic Escaping for Special Characters](#autoescape)\n* [Block Elements](#block)\n * [Paragraphs and Line Breaks](#p)\n * [Headers](#header)\n * [Blockquotes](#blockquote)\n * [Lists](#list)\n * [Code Blocks](#precode)\n * [Horizontal Rules](#hr)\n* [Span Elements](#span)\n * [Links](#link)\n * [Emphasis](#em)\n * [Code](#code)\n * [Images](#img)\n* [Miscellaneous](#misc)\n * [Backslash Escapes](#backslash)\n * [Automatic Links](#autolink)\n\n\n**Note:** This document is itself written using Markdown; you\ncan [see the source for it by adding '.text' to the URL][src].\n\n [src]: /projects/markdown/syntax.text\n\n* * *\n\n

Overview

\n\n

Philosophy

\n\nMarkdown is intended to be as easy-to-read and easy-to-write as is feasible.\n\nReadability, however, is emphasized above all else. A Markdown-formatted\ndocument should be publishable as-is, as plain text, without looking\nlike it's been marked up with tags or formatting instructions. While\nMarkdown's syntax has been influenced by several existing text-to-HTML\nfilters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],\n[Grutatext] [5], and [EtText] [6] -- the single biggest source of\ninspiration for Markdown's syntax is the format of plain text email.\n\n [1]: http://docutils.sourceforge.net/mirror/setext.html\n [2]: http://www.aaronsw.com/2002/atx/\n [3]: http://textism.com/tools/textile/\n [4]: http://docutils.sourceforge.net/rst.html\n [5]: http://www.triptico.com/software/grutatxt.html\n [6]: http://ettext.taint.org/doc/\n\nTo this end, Markdown's syntax is comprised entirely of punctuation\ncharacters, which punctuation characters have been carefully chosen so\nas to look like what they mean. E.g., asterisks around a word actually\nlook like \\*emphasis\\*. Markdown lists look like, well, lists. Even\nblockquotes look like quoted passages of text, assuming you've ever\nused email.\n\n\n\n

Inline HTML

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

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

` tags around HTML block-level tags.\n\nFor example, to add an HTML table to a Markdown article:\n\n This is a regular paragraph.\n\n

\n \n \n \n
Foo
\n\n This is another regular paragraph.\n\nNote that Markdown formatting syntax is not processed within block-level\nHTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an\nHTML block.\n\nSpan-level HTML tags -- e.g. ``, ``, or `` -- can be\nused anywhere in a Markdown paragraph, list item, or header. If you\nwant, you can even use HTML tags instead of Markdown formatting; e.g. if\nyou'd prefer to use HTML `` or `` tags instead of Markdown's\nlink or image syntax, go right ahead.\n\nUnlike block-level HTML tags, Markdown syntax *is* processed within\nspan-level tags.\n\n\n

Automatic Escaping for Special Characters

\n\nIn HTML, there are two characters that demand special treatment: `<`\nand `&`. Left angle brackets are used to start tags; ampersands are\nused to denote HTML entities. If you want to use them as literal\ncharacters, you must escape them as entities, e.g. `<`, and\n`&`.\n\nAmpersands in particular are bedeviling for web writers. If you want to\nwrite about 'AT&T', you need to write '`AT&T`'. You even need to\nescape ampersands within URLs. Thus, if you want to link to:\n\n http://images.google.com/images?num=30&q=larry+bird\n\nyou need to encode the URL as:\n\n http://images.google.com/images?num=30&q=larry+bird\n\nin your anchor tag `href` attribute. Needless to say, this is easy to\nforget, and is probably the single most common source of HTML validation\nerrors in otherwise well-marked-up web sites.\n\nMarkdown allows you to use these characters naturally, taking care of\nall the necessary escaping for you. If you use an ampersand as part of\nan HTML entity, it remains unchanged; otherwise it will be translated\ninto `&`.\n\nSo, if you want to include a copyright symbol in your article, you can write:\n\n ©\n\nand Markdown will leave it alone. But if you write:\n\n AT&T\n\nMarkdown will translate it to:\n\n AT&T\n\nSimilarly, because Markdown supports [inline HTML](#html), if you use\nangle brackets as delimiters for HTML tags, Markdown will treat them as\nsuch. But if you write:\n\n 4 < 5\n\nMarkdown will translate it to:\n\n 4 < 5\n\nHowever, inside Markdown code spans and blocks, angle brackets and\nampersands are *always* encoded automatically. This makes it easy to use\nMarkdown to write about HTML code. (As opposed to raw HTML, which is a\nterrible format for writing about HTML syntax, because every single `<`\nand `&` in your example code needs to be escaped.)\n\n\n* * *\n\n\n

Block Elements

\n\n\n

Paragraphs and Line Breaks

\n\nA paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing but spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.\n\nThe implication of the \"one or more consecutive lines of text\" rule is\nthat Markdown supports \"hard-wrapped\" text paragraphs. This differs\nsignificantly from most other text-to-HTML formatters (including Movable\nType's \"Convert Line Breaks\" option) which translate every line break\ncharacter in a paragraph into a `
` tag.\n\nWhen you *do* want to insert a `
` break tag using Markdown, you\nend a line with two or more spaces, then type return.\n\nYes, this takes a tad more effort to create a `
`, but a simplistic\n\"every line break is a `
`\" rule wouldn't work for Markdown.\nMarkdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]\nwork best -- and look better -- when you format them with hard breaks.\n\n [bq]: #blockquote\n [l]: #list\n\n\n\n

Headers

\n\nMarkdown supports two styles of headers, [Setext] [1] and [atx] [2].\n\nSetext-style headers are \"underlined\" using equal signs (for first-level\nheaders) and dashes (for second-level headers). For example:\n\n This is an H1\n =============\n\n This is an H2\n -------------\n\nAny number of underlining `=`'s or `-`'s will work.\n\nAtx-style headers use 1-6 hash characters at the start of the line,\ncorresponding to header levels 1-6. For example:\n\n # This is an H1\n\n ## This is an H2\n\n ###### This is an H6\n\nOptionally, you may \"close\" atx-style headers. This is purely\ncosmetic -- you can use this if you think it looks better. The\nclosing hashes don't even need to match the number of hashes\nused to open the header. (The number of opening hashes\ndetermines the header level.) :\n\n # This is an H1 #\n\n ## This is an H2 ##\n\n ### This is an H3 ######\n\n\n

Blockquotes

\n\nMarkdown uses email-style `>` characters for blockquoting. If you're\nfamiliar with quoting passages of text in an email message, then you\nknow how to create a blockquote in Markdown. It looks best if you hard\nwrap the text and put a `>` before every line:\n\n > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n > \n > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n > id sem consectetuer libero luctus adipiscing.\n\nMarkdown allows you to be lazy and only put the `>` before the first\nline of a hard-wrapped paragraph:\n\n > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n\n > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n id sem consectetuer libero luctus adipiscing.\n\nBlockquotes can be nested (i.e. a blockquote-in-a-blockquote) by\nadding additional levels of `>`:\n\n > This is the first level of quoting.\n >\n > > This is nested blockquote.\n >\n > Back to the first level.\n\nBlockquotes can contain other Markdown elements, including headers, lists,\nand code blocks:\n\n\t> ## This is a header.\n\t> \n\t> 1. This is the first list item.\n\t> 2. This is the second list item.\n\t> \n\t> Here's some example code:\n\t> \n\t> return shell_exec(\"echo $input | $markdown_script\");\n\nAny decent text editor should make email-style quoting easy. For\nexample, with BBEdit, you can make a selection and choose Increase\nQuote Level from the Text menu.\n\n\n

Lists

\n\nMarkdown supports ordered (numbered) and unordered (bulleted) lists.\n\nUnordered lists use asterisks, pluses, and hyphens -- interchangably\n-- as list markers:\n\n * Red\n * Green\n * Blue\n\nis equivalent to:\n\n + Red\n + Green\n + Blue\n\nand:\n\n - Red\n - Green\n - Blue\n\nOrdered lists use numbers followed by periods:\n\n 1. Bird\n 2. McHale\n 3. Parish\n\nIt's important to note that the actual numbers you use to mark the\nlist have no effect on the HTML output Markdown produces. The HTML\nMarkdown produces from the above list is:\n\n
    \n
  1. Bird
  2. \n
  3. McHale
  4. \n
  5. Parish
  6. \n
\n\nIf you instead wrote the list in Markdown like this:\n\n 1. Bird\n 1. McHale\n 1. Parish\n\nor even:\n\n 3. Bird\n 1. McHale\n 8. Parish\n\nyou'd get the exact same HTML output. The point is, if you want to,\nyou can use ordinal numbers in your ordered Markdown lists, so that\nthe numbers in your source match the numbers in your published HTML.\nBut if you want to be lazy, you don't have to.\n\nIf you do use lazy list numbering, however, you should still start the\nlist with the number 1. At some point in the future, Markdown may support\nstarting ordered lists at an arbitrary number.\n\nList markers typically start at the left margin, but may be indented by\nup to three spaces. List markers must be followed by one or more spaces\nor a tab.\n\nTo make lists look nice, you can wrap items with hanging indents:\n\n * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nBut if you want to be lazy, you don't have to:\n\n * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n viverra nec, fringilla in, laoreet vitae, risus.\n * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIf list items are separated by blank lines, Markdown will wrap the\nitems in `

` tags in the HTML output. For example, this input:\n\n * Bird\n * Magic\n\nwill turn into:\n\n

    \n
  • Bird
  • \n
  • Magic
  • \n
\n\nBut this:\n\n * Bird\n\n * Magic\n\nwill turn into:\n\n
    \n
  • Bird

  • \n
  • Magic

  • \n
\n\nList items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be intended by either 4 spaces\nor one tab:\n\n 1. This is a list item with two paragraphs. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n mi posuere lectus.\n\n Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n sit amet velit.\n\n 2. Suspendisse id sem consectetuer libero luctus adipiscing.\n\nIt looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:\n\n * This is a list item with two paragraphs.\n\n This is the second paragraph in the list item. You're\n only required to indent the first line. Lorem ipsum dolor\n sit amet, consectetuer adipiscing elit.\n\n * Another item in the same list.\n\nTo put a blockquote within a list item, the blockquote's `>`\ndelimiters need to be indented:\n\n * A list item with a blockquote:\n\n > This is a blockquote\n > inside a list item.\n\nTo put a code block within a list item, the code block needs\nto be indented *twice* -- 8 spaces or two tabs:\n\n * A list item with a code block:\n\n \n\n\nIt's worth noting that it's possible to trigger an ordered list by\naccident, by writing something like this:\n\n 1986. What a great season.\n\nIn other words, a *number-period-space* sequence at the beginning of a\nline. To avoid this, you can backslash-escape the period:\n\n 1986\\. What a great season.\n\n\n\n

Code Blocks

\n\nPre-formatted code blocks are used for writing about programming or\nmarkup source code. Rather than forming normal paragraphs, the lines\nof a code block are interpreted literally. Markdown wraps a code block\nin both `
` and `` tags.\n\nTo produce a code block in Markdown, simply indent every line of the\nblock by at least 4 spaces or 1 tab. For example, given this input:\n\n    This is a normal paragraph:\n\n        This is a code block.\n\nMarkdown will generate:\n\n    

This is a normal paragraph:

\n\n
This is a code block.\n    
\n\nOne level of indentation -- 4 spaces or 1 tab -- is removed from each\nline of the code block. For example, this:\n\n Here is an example of AppleScript:\n\n tell application \"Foo\"\n beep\n end tell\n\nwill turn into:\n\n

Here is an example of AppleScript:

\n\n
tell application \"Foo\"\n        beep\n    end tell\n    
\n\nA code block continues until it reaches a line that is not indented\n(or the end of the article).\n\nWithin a code block, ampersands (`&`) and angle brackets (`<` and `>`)\nare automatically converted into HTML entities. This makes it very\neasy to include example HTML source code using Markdown -- just paste\nit and indent it, and Markdown will handle the hassle of encoding the\nampersands and angle brackets. For example, this:\n\n
\n © 2004 Foo Corporation\n
\n\nwill turn into:\n\n
<div class=\"footer\">\n        &copy; 2004 Foo Corporation\n    </div>\n    
\n\nRegular Markdown syntax is not processed within code blocks. E.g.,\nasterisks are just literal asterisks within a code block. This means\nit's also easy to use Markdown to write about Markdown's own syntax.\n\n\n\n

Horizontal Rules

\n\nYou can produce a horizontal rule tag (`
`) by placing three or\nmore hyphens, asterisks, or underscores on a line by themselves. If you\nwish, you may use spaces between the hyphens or asterisks. Each of the\nfollowing lines will produce a horizontal rule:\n\n * * *\n\n ***\n\n *****\n\t\n - - -\n\n ---------------------------------------\n\n\t_ _ _\n\n\n* * *\n\n

Span Elements

\n\n

Links

\n\nMarkdown supports two style of links: *inline* and *reference*.\n\nIn both styles, the link text is delimited by [square brackets].\n\nTo create an inline link, use a set of regular parentheses immediately\nafter the link text's closing square bracket. Inside the parentheses,\nput the URL where you want the link to point, along with an *optional*\ntitle for the link, surrounded in quotes. For example:\n\n This is [an example](http://example.com/ \"Title\") inline link.\n\n [This link](http://example.net/) has no title attribute.\n\nWill produce:\n\n

This is \n an example inline link.

\n\n

This link has no\n title attribute.

\n\nIf you're referring to a local resource on the same server, you can\nuse relative paths:\n\n See my [About](/about/) page for details.\n\nReference-style links use a second set of square brackets, inside\nwhich you place a label of your choosing to identify the link:\n\n This is [an example][id] reference-style link.\n\nYou can optionally use a space to separate the sets of brackets:\n\n This is [an example] [id] reference-style link.\n\nThen, anywhere in the document, you define your link label like this,\non a line by itself:\n\n [id]: http://example.com/ \"Optional Title Here\"\n\nThat is:\n\n* Square brackets containing the link identifier (optionally\n indented from the left margin using up to three spaces);\n* followed by a colon;\n* followed by one or more spaces (or tabs);\n* followed by the URL for the link;\n* optionally followed by a title attribute for the link, enclosed\n in double or single quotes.\n\nThe link URL may, optionally, be surrounded by angle brackets:\n\n [id]: \"Optional Title Here\"\n\nYou can put the title attribute on the next line and use extra spaces\nor tabs for padding, which tends to look better with longer URLs:\n\n [id]: http://example.com/longish/path/to/resource/here\n \"Optional Title Here\"\n\nLink definitions are only used for creating links during Markdown\nprocessing, and are stripped from your document in the HTML output.\n\nLink definition names may constist of letters, numbers, spaces, and punctuation -- but they are *not* case sensitive. E.g. these two links:\n\n\t[link text][a]\n\t[link text][A]\n\nare equivalent.\n\nThe *implicit link name* shortcut allows you to omit the name of the\nlink, in which case the link text itself is used as the name.\nJust use an empty set of square brackets -- e.g., to link the word\n\"Google\" to the google.com web site, you could simply write:\n\n\t[Google][]\n\nAnd then define the link:\n\n\t[Google]: http://google.com/\n\nBecause link names may contain spaces, this shortcut even works for\nmultiple words in the link text:\n\n\tVisit [Daring Fireball][] for more information.\n\nAnd then define the link:\n\t\n\t[Daring Fireball]: http://daringfireball.net/\n\nLink definitions can be placed anywhere in your Markdown document. I\ntend to put them immediately after each paragraph in which they're\nused, but if you want, you can put them all at the end of your\ndocument, sort of like footnotes.\n\nHere's an example of reference links in action:\n\n I get 10 times more traffic from [Google] [1] than from\n [Yahoo] [2] or [MSN] [3].\n\n [1]: http://google.com/ \"Google\"\n [2]: http://search.yahoo.com/ \"Yahoo Search\"\n [3]: http://search.msn.com/ \"MSN Search\"\n\nUsing the implicit link name shortcut, you could instead write:\n\n I get 10 times more traffic from [Google][] than from\n [Yahoo][] or [MSN][].\n\n [google]: http://google.com/ \"Google\"\n [yahoo]: http://search.yahoo.com/ \"Yahoo Search\"\n [msn]: http://search.msn.com/ \"MSN Search\"\n\nBoth of the above examples will produce the following HTML output:\n\n

I get 10 times more traffic from Google than from\n Yahoo\n or MSN.

\n\nFor comparison, here is the same paragraph written using\nMarkdown's inline link style:\n\n I get 10 times more traffic from [Google](http://google.com/ \"Google\")\n than from [Yahoo](http://search.yahoo.com/ \"Yahoo Search\") or\n [MSN](http://search.msn.com/ \"MSN Search\").\n\nThe point of reference-style links is not that they're easier to\nwrite. The point is that with reference-style links, your document\nsource is vastly more readable. Compare the above examples: using\nreference-style links, the paragraph itself is only 81 characters\nlong; with inline-style links, it's 176 characters; and as raw HTML,\nit's 234 characters. In the raw HTML, there's more markup than there\nis text.\n\nWith Markdown's reference-style links, a source document much more\nclosely resembles the final output, as rendered in a browser. By\nallowing you to move the markup-related metadata out of the paragraph,\nyou can add links without interrupting the narrative flow of your\nprose.\n\n\n

Emphasis

\n\nMarkdown treats asterisks (`*`) and underscores (`_`) as indicators of\nemphasis. Text wrapped with one `*` or `_` will be wrapped with an\nHTML `` tag; double `*`'s or `_`'s will be wrapped with an HTML\n`` tag. E.g., this input:\n\n *single asterisks*\n\n _single underscores_\n\n **double asterisks**\n\n __double underscores__\n\nwill produce:\n\n single asterisks\n\n single underscores\n\n double asterisks\n\n double underscores\n\nYou can use whichever style you prefer; the lone restriction is that\nthe same character must be used to open and close an emphasis span.\n\nEmphasis can be used in the middle of a word:\n\n un*fucking*believable\n\nBut if you surround an `*` or `_` with spaces, it'll be treated as a\nliteral asterisk or underscore.\n\nTo produce a literal asterisk or underscore at a position where it\nwould otherwise be used as an emphasis delimiter, you can backslash\nescape it:\n\n \\*this text is surrounded by literal asterisks\\*\n\n\n\n

Code

\n\nTo indicate a span of code, wrap it with backtick quotes (`` ` ``).\nUnlike a pre-formatted code block, a code span indicates code within a\nnormal paragraph. For example:\n\n Use the `printf()` function.\n\nwill produce:\n\n

Use the printf() function.

\n\nTo include a literal backtick character within a code span, you can use\nmultiple backticks as the opening and closing delimiters:\n\n ``There is a literal backtick (`) here.``\n\nwhich will produce this:\n\n

There is a literal backtick (`) here.

\n\nThe backtick delimiters surrounding a code span may include spaces --\none after the opening, one before the closing. This allows you to place\nliteral backtick characters at the beginning or end of a code span:\n\n\tA single backtick in a code span: `` ` ``\n\t\n\tA backtick-delimited string in a code span: `` `foo` ``\n\nwill produce:\n\n\t

A single backtick in a code span: `

\n\t\n\t

A backtick-delimited string in a code span: `foo`

\n\nWith a code span, ampersands and angle brackets are encoded as HTML\nentities automatically, which makes it easy to include example HTML\ntags. Markdown will turn this:\n\n Please don't use any `` tags.\n\ninto:\n\n

Please don't use any <blink> tags.

\n\nYou can write this:\n\n `—` is the decimal-encoded equivalent of `—`.\n\nto produce:\n\n

&#8212; is the decimal-encoded\n equivalent of &mdash;.

\n\n\n\n

Images

\n\nAdmittedly, it's fairly difficult to devise a \"natural\" syntax for\nplacing images into a plain text document format.\n\nMarkdown uses an image syntax that is intended to resemble the syntax\nfor links, allowing for two styles: *inline* and *reference*.\n\nInline image syntax looks like this:\n\n ![Alt text](/path/to/img.jpg)\n\n ![Alt text](/path/to/img.jpg \"Optional title\")\n\nThat is:\n\n* An exclamation mark: `!`;\n* followed by a set of square brackets, containing the `alt`\n attribute text for the image;\n* followed by a set of parentheses, containing the URL or path to\n the image, and an optional `title` attribute enclosed in double\n or single quotes.\n\nReference-style image syntax looks like this:\n\n ![Alt text][id]\n\nWhere \"id\" is the name of a defined image reference. Image references\nare defined using syntax identical to link references:\n\n [id]: url/to/image \"Optional title attribute\"\n\nAs of this writing, Markdown has no syntax for specifying the\ndimensions of an image; if this is important to you, you can simply\nuse regular HTML `` tags.\n\n\n* * *\n\n\n

Miscellaneous

\n\n

Automatic Links

\n\nMarkdown 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:\n\n \n \nMarkdown will turn this into:\n\n http://example.com/\n\nAutomatic links for email addresses work similarly, except that\nMarkdown will also perform a bit of randomized decimal and hex\nentity-encoding to help obscure your address from address-harvesting\nspambots. For example, Markdown will turn this:\n\n \n\ninto something like this:\n\n address@exa\n mple.com\n\nwhich will render in a browser as a clickable link to \"address@example.com\".\n\n(This sort of entity-encoding trick will indeed fool many, if not\nmost, address-harvesting bots, but it definitely won't fool all of\nthem. It's better than nothing, but an address published in this way\nwill probably eventually start receiving spam.)\n\n\n\n

Backslash Escapes

\n\nMarkdown allows you to use backslash escapes to generate literal\ncharacters which would otherwise have special meaning in Markdown's\nformatting syntax. For example, if you wanted to surround a word with\nliteral asterisks (instead of an HTML `` tag), you can backslashes\nbefore the asterisks, like this:\n\n \\*literal asterisks\\*\n\nMarkdown provides backslash escapes for the following characters:\n\n \\ backslash\n ` backtick\n * asterisk\n _ underscore\n {} curly braces\n [] square brackets\n () parentheses\n # hash mark\n\t+\tplus sign\n\t-\tminus sign (hyphen)\n . dot\n ! exclamation mark\n\n") == "

Markdown: Syntax

\n\n\n\n\n\n

Note: This document is itself written using Markdown; you\ncan see the source for it by adding '.text' to the URL.

\n\n
\n\n

Overview

\n\n

Philosophy

\n\n

Markdown is intended to be as easy-to-read and easy-to-write as is feasible.

\n\n

Readability, however, is emphasized above all else. A Markdown-formatted\ndocument should be publishable as-is, as plain text, without looking\nlike it's been marked up with tags or formatting instructions. While\nMarkdown's syntax has been influenced by several existing text-to-HTML\nfilters -- including Setext, atx, Textile, reStructuredText,\nGrutatext, and EtText -- the single biggest source of\ninspiration for Markdown's syntax is the format of plain text email.

\n\n

To this end, Markdown's syntax is comprised entirely of punctuation\ncharacters, which punctuation characters have been carefully chosen so\nas to look like what they mean. E.g., asterisks around a word actually\nlook like *emphasis*. Markdown lists look like, well, lists. Even\nblockquotes look like quoted passages of text, assuming you've ever\nused email.

\n\n

Inline HTML

\n\n

Markdown's syntax is intended for one purpose: to be used as a\nformat for writing for the web.

\n\n

Markdown is not a replacement for HTML, or even close to it. Its\nsyntax is very small, corresponding only to a very small subset of\nHTML tags. The idea is not to create a syntax that makes it easier\nto insert HTML tags. In my opinion, HTML tags are already easy to\ninsert. The idea for Markdown is to make it easy to read, write, and\nedit prose. HTML is a publishing format; Markdown is a writing\nformat. Thus, Markdown's formatting syntax only addresses issues that\ncan be conveyed in plain text.

\n\n

For any markup that is not covered by Markdown's syntax, you simply\nuse HTML itself. There's no need to preface it or delimit it to\nindicate that you're switching from Markdown to HTML; you just use\nthe tags.

\n\n

The only restrictions are that block-level HTML elements -- e.g. <div>,\n<table>, <pre>, <p>, etc. -- must be separated from surrounding\ncontent by blank lines, and the start and end tags of the block should\nnot be indented with tabs or spaces. Markdown is smart enough not\nto add extra (unwanted) <p> tags around HTML block-level tags.

\n\n

For example, to add an HTML table to a Markdown article:

\n\n
This is a regular paragraph.\n\n<table>\n    <tr>\n        <td>Foo</td>\n    </tr>\n</table>\n\nThis is another regular paragraph.\n
\n\n

Note that Markdown formatting syntax is not processed within block-level\nHTML tags. E.g., you can't use Markdown-style *emphasis* inside an\nHTML block.

\n\n

Span-level HTML tags -- e.g. <span>, <cite>, or <del> -- can be\nused anywhere in a Markdown paragraph, list item, or header. If you\nwant, you can even use HTML tags instead of Markdown formatting; e.g. if\nyou'd prefer to use HTML <a> or <img> tags instead of Markdown's\nlink or image syntax, go right ahead.

\n\n

Unlike block-level HTML tags, Markdown syntax is processed within\nspan-level tags.

\n\n

Automatic Escaping for Special Characters

\n\n

In HTML, there are two characters that demand special treatment: <\nand &. Left angle brackets are used to start tags; ampersands are\nused to denote HTML entities. If you want to use them as literal\ncharacters, you must escape them as entities, e.g. &lt;, and\n&amp;.

\n\n

Ampersands in particular are bedeviling for web writers. If you want to\nwrite about 'AT&T', you need to write 'AT&amp;T'. You even need to\nescape ampersands within URLs. Thus, if you want to link to:

\n\n
http://images.google.com/images?num=30&q=larry+bird\n
\n\n

you need to encode the URL as:

\n\n
http://images.google.com/images?num=30&amp;q=larry+bird\n
\n\n

in your anchor tag href attribute. Needless to say, this is easy to\nforget, and is probably the single most common source of HTML validation\nerrors in otherwise well-marked-up web sites.

\n\n

Markdown allows you to use these characters naturally, taking care of\nall the necessary escaping for you. If you use an ampersand as part of\nan HTML entity, it remains unchanged; otherwise it will be translated\ninto &amp;.

\n\n

So, if you want to include a copyright symbol in your article, you can write:

\n\n
&copy;\n
\n\n

and Markdown will leave it alone. But if you write:

\n\n
AT&T\n
\n\n

Markdown will translate it to:

\n\n
AT&amp;T\n
\n\n

Similarly, because Markdown supports inline HTML, if you use\nangle brackets as delimiters for HTML tags, Markdown will treat them as\nsuch. But if you write:

\n\n
4 < 5\n
\n\n

Markdown will translate it to:

\n\n
4 &lt; 5\n
\n\n

However, inside Markdown code spans and blocks, angle brackets and\nampersands are always encoded automatically. This makes it easy to use\nMarkdown to write about HTML code. (As opposed to raw HTML, which is a\nterrible format for writing about HTML syntax, because every single <\nand & in your example code needs to be escaped.)

\n\n
\n\n

Block Elements

\n\n

Paragraphs and Line Breaks

\n\n

A paragraph is simply one or more consecutive lines of text, separated\nby one or more blank lines. (A blank line is any line that looks like a\nblank line -- a line containing nothing but spaces or tabs is considered\nblank.) Normal paragraphs should not be intended with spaces or tabs.

\n\n

The implication of the \"one or more consecutive lines of text\" rule is\nthat Markdown supports \"hard-wrapped\" text paragraphs. This differs\nsignificantly from most other text-to-HTML formatters (including Movable\nType's \"Convert Line Breaks\" option) which translate every line break\ncharacter in a paragraph into a <br /> tag.

\n\n

When you do want to insert a <br /> break tag using Markdown, you\nend a line with two or more spaces, then type return.

\n\n

Yes, this takes a tad more effort to create a <br />, but a simplistic\n\"every line break is a <br />\" rule wouldn't work for Markdown.\nMarkdown's email-style blockquoting and multi-paragraph list items\nwork best -- and look better -- when you format them with hard breaks.

\n\n

Headers

\n\n

Markdown supports two styles of headers, Setext and atx.

\n\n

Setext-style headers are \"underlined\" using equal signs (for first-level\nheaders) and dashes (for second-level headers). For example:

\n\n
This is an H1\n=============\n\nThis is an H2\n-------------\n
\n\n

Any number of underlining ='s or -'s will work.

\n\n

Atx-style headers use 1-6 hash characters at the start of the line,\ncorresponding to header levels 1-6. For example:

\n\n
# This is an H1\n\n## This is an H2\n\n###### This is an H6\n
\n\n

Optionally, you may \"close\" atx-style headers. This is purely\ncosmetic -- you can use this if you think it looks better. The\nclosing hashes don't even need to match the number of hashes\nused to open the header. (The number of opening hashes\ndetermines the header level.) :

\n\n
# This is an H1 #\n\n## This is an H2 ##\n\n### This is an H3 ######\n
\n\n

Blockquotes

\n\n

Markdown uses email-style > characters for blockquoting. If you're\nfamiliar with quoting passages of text in an email message, then you\nknow how to create a blockquote in Markdown. It looks best if you hard\nwrap the text and put a > before every line:

\n\n
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\n> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\n> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n> \n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\n> id sem consectetuer libero luctus adipiscing.\n
\n\n

Markdown allows you to be lazy and only put the > before the first\nline of a hard-wrapped paragraph:

\n\n
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,\nconsectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.\nVestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.\n\n> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse\nid sem consectetuer libero luctus adipiscing.\n
\n\n

Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by\nadding additional levels of >:

\n\n
> This is the first level of quoting.\n>\n> > This is nested blockquote.\n>\n> Back to the first level.\n
\n\n

Blockquotes can contain other Markdown elements, including headers, lists,\nand code blocks:

\n\n
> ## This is a header.\n> \n> 1.   This is the first list item.\n> 2.   This is the second list item.\n> \n> Here's some example code:\n> \n>     return shell_exec(\"echo $input | $markdown_script\");\n
\n\n

Any decent text editor should make email-style quoting easy. For\nexample, with BBEdit, you can make a selection and choose Increase\nQuote Level from the Text menu.

\n\n

Lists

\n\n

Markdown supports ordered (numbered) and unordered (bulleted) lists.

\n\n

Unordered lists use asterisks, pluses, and hyphens -- interchangably\n-- as list markers:

\n\n
*   Red\n*   Green\n*   Blue\n
\n\n

is equivalent to:

\n\n
+   Red\n+   Green\n+   Blue\n
\n\n

and:

\n\n
-   Red\n-   Green\n-   Blue\n
\n\n

Ordered lists use numbers followed by periods:

\n\n
1.  Bird\n2.  McHale\n3.  Parish\n
\n\n

It's important to note that the actual numbers you use to mark the\nlist have no effect on the HTML output Markdown produces. The HTML\nMarkdown produces from the above list is:

\n\n
<ol>\n<li>Bird</li>\n<li>McHale</li>\n<li>Parish</li>\n</ol>\n
\n\n

If you instead wrote the list in Markdown like this:

\n\n
1.  Bird\n1.  McHale\n1.  Parish\n
\n\n

or even:

\n\n
3. Bird\n1. McHale\n8. Parish\n
\n\n

you'd get the exact same HTML output. The point is, if you want to,\nyou can use ordinal numbers in your ordered Markdown lists, so that\nthe numbers in your source match the numbers in your published HTML.\nBut if you want to be lazy, you don't have to.

\n\n

If you do use lazy list numbering, however, you should still start the\nlist with the number 1. At some point in the future, Markdown may support\nstarting ordered lists at an arbitrary number.

\n\n

List markers typically start at the left margin, but may be indented by\nup to three spaces. List markers must be followed by one or more spaces\nor a tab.

\n\n

To make lists look nice, you can wrap items with hanging indents:

\n\n
*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\n    Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\n    viverra nec, fringilla in, laoreet vitae, risus.\n*   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\n    Suspendisse id sem consectetuer libero luctus adipiscing.\n
\n\n

But if you want to be lazy, you don't have to:

\n\n
*   Lorem ipsum dolor sit amet, consectetuer adipiscing elit.\nAliquam hendrerit mi posuere lectus. Vestibulum enim wisi,\nviverra nec, fringilla in, laoreet vitae, risus.\n*   Donec sit amet nisl. Aliquam semper ipsum sit amet velit.\nSuspendisse id sem consectetuer libero luctus adipiscing.\n
\n\n

If list items are separated by blank lines, Markdown will wrap the\nitems in <p> tags in the HTML output. For example, this input:

\n\n
*   Bird\n*   Magic\n
\n\n

will turn into:

\n\n
<ul>\n<li>Bird</li>\n<li>Magic</li>\n</ul>\n
\n\n

But this:

\n\n
*   Bird\n\n*   Magic\n
\n\n

will turn into:

\n\n
<ul>\n<li><p>Bird</p></li>\n<li><p>Magic</p></li>\n</ul>\n
\n\n

List items may consist of multiple paragraphs. Each subsequent\nparagraph in a list item must be intended by either 4 spaces\nor one tab:

\n\n
1.  This is a list item with two paragraphs. Lorem ipsum dolor\n    sit amet, consectetuer adipiscing elit. Aliquam hendrerit\n    mi posuere lectus.\n\n    Vestibulum enim wisi, viverra nec, fringilla in, laoreet\n    vitae, risus. Donec sit amet nisl. Aliquam semper ipsum\n    sit amet velit.\n\n2.  Suspendisse id sem consectetuer libero luctus adipiscing.\n
\n\n

It looks nice if you indent every line of the subsequent\nparagraphs, but here again, Markdown will allow you to be\nlazy:

\n\n
*   This is a list item with two paragraphs.\n\n    This is the second paragraph in the list item. You're\nonly required to indent the first line. Lorem ipsum dolor\nsit amet, consectetuer adipiscing elit.\n\n*   Another item in the same list.\n
\n\n

To put a blockquote within a list item, the blockquote's >\ndelimiters need to be indented:

\n\n
*   A list item with a blockquote:\n\n    > This is a blockquote\n    > inside a list item.\n
\n\n

To put a code block within a list item, the code block needs\nto be indented twice -- 8 spaces or two tabs:

\n\n
*   A list item with a code block:\n\n        <code goes here>\n
\n\n

It's worth noting that it's possible to trigger an ordered list by\naccident, by writing something like this:

\n\n
1986. What a great season.\n
\n\n

In other words, a number-period-space sequence at the beginning of a\nline. To avoid this, you can backslash-escape the period:

\n\n
1986\\. What a great season.\n
\n\n

Code Blocks

\n\n

Pre-formatted code blocks are used for writing about programming or\nmarkup source code. Rather than forming normal paragraphs, the lines\nof a code block are interpreted literally. Markdown wraps a code block\nin both <pre> and <code> tags.

\n\n

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

\n\n
This is a normal paragraph:\n\n    This is a code block.\n
\n\n

Markdown will generate:

\n\n
<p>This is a normal paragraph:</p>\n\n<pre><code>This is a code block.\n</code></pre>\n
\n\n

One level of indentation -- 4 spaces or 1 tab -- is removed from each\nline of the code block. For example, this:

\n\n
Here is an example of AppleScript:\n\n    tell application \"Foo\"\n        beep\n    end tell\n
\n\n

will turn into:

\n\n
<p>Here is an example of AppleScript:</p>\n\n<pre><code>tell application \"Foo\"\n    beep\nend tell\n</code></pre>\n
\n\n

A code block continues until it reaches a line that is not indented\n(or the end of the article).

\n\n

Within a code block, ampersands (&) and angle brackets (< and >)\nare automatically converted into HTML entities. This makes it very\neasy to include example HTML source code using Markdown -- just paste\nit and indent it, and Markdown will handle the hassle of encoding the\nampersands and angle brackets. For example, this:

\n\n
    <div class=\"footer\">\n        &copy; 2004 Foo Corporation\n    </div>\n
\n\n

will turn into:

\n\n
<pre><code>&lt;div class=\"footer\"&gt;\n    &amp;copy; 2004 Foo Corporation\n&lt;/div&gt;\n</code></pre>\n
\n\n

Regular Markdown syntax is not processed within code blocks. E.g.,\nasterisks are just literal asterisks within a code block. This means\nit's also easy to use Markdown to write about Markdown's own syntax.

\n\n

Horizontal Rules

\n\n

You can produce a horizontal rule tag (<hr />) by placing three or\nmore hyphens, asterisks, or underscores on a line by themselves. If you\nwish, you may use spaces between the hyphens or asterisks. Each of the\nfollowing lines will produce a horizontal rule:

\n\n
* * *\n\n***\n\n*****\n\n- - -\n\n---------------------------------------\n\n_ _ _\n
\n\n
\n\n

Span Elements

\n\n

Links

\n\n

Markdown supports two style of links: inline and reference.

\n\n

In both styles, the link text is delimited by [square brackets].

\n\n

To create an inline link, use a set of regular parentheses immediately\nafter the link text's closing square bracket. Inside the parentheses,\nput the URL where you want the link to point, along with an optional\ntitle for the link, surrounded in quotes. For example:

\n\n
This is [an example](http://example.com/ \"Title\") inline link.\n\n[This link](http://example.net/) has no title attribute.\n
\n\n

Will produce:

\n\n
<p>This is <a href=\"http://example.com/\" title=\"Title\">\nan example</a> inline link.</p>\n\n<p><a href=\"http://example.net/\">This link</a> has no\ntitle attribute.</p>\n
\n\n

If you're referring to a local resource on the same server, you can\nuse relative paths:

\n\n
See my [About](/about/) page for details.\n
\n\n

Reference-style links use a second set of square brackets, inside\nwhich you place a label of your choosing to identify the link:

\n\n
This is [an example][id] reference-style link.\n
\n\n

You can optionally use a space to separate the sets of brackets:

\n\n
This is [an example] [id] reference-style link.\n
\n\n

Then, anywhere in the document, you define your link label like this,\non a line by itself:

\n\n
[id]: http://example.com/  \"Optional Title Here\"\n
\n\n

That is:

\n\n
    \n
  • Square brackets containing the link identifier (optionally\nindented from the left margin using up to three spaces);
  • \n
  • followed by a colon;
  • \n
  • followed by one or more spaces (or tabs);
  • \n
  • followed by the URL for the link;
  • \n
  • optionally followed by a title attribute for the link, enclosed\nin double or single quotes.
  • \n
\n\n

The link URL may, optionally, be surrounded by angle brackets:

\n\n
[id]: <http://example.com/>  \"Optional Title Here\"\n
\n\n

You can put the title attribute on the next line and use extra spaces\nor tabs for padding, which tends to look better with longer URLs:

\n\n
[id]: http://example.com/longish/path/to/resource/here\n    \"Optional Title Here\"\n
\n\n

Link definitions are only used for creating links during Markdown\nprocessing, and are stripped from your document in the HTML output.

\n\n

Link definition names may constist of letters, numbers, spaces, and punctuation -- but they are not case sensitive. E.g. these two links:

\n\n
[link text][a]\n[link text][A]\n
\n\n

are equivalent.

\n\n

The implicit link name shortcut allows you to omit the name of the\nlink, in which case the link text itself is used as the name.\nJust use an empty set of square brackets -- e.g., to link the word\n\"Google\" to the google.com web site, you could simply write:

\n\n
[Google][]\n
\n\n

And then define the link:

\n\n
[Google]: http://google.com/\n
\n\n

Because link names may contain spaces, this shortcut even works for\nmultiple words in the link text:

\n\n
Visit [Daring Fireball][] for more information.\n
\n\n

And then define the link:

\n\n
[Daring Fireball]: http://daringfireball.net/\n
\n\n

Link definitions can be placed anywhere in your Markdown document. I\ntend to put them immediately after each paragraph in which they're\nused, but if you want, you can put them all at the end of your\ndocument, sort of like footnotes.

\n\n

Here's an example of reference links in action:

\n\n
I get 10 times more traffic from [Google] [1] than from\n[Yahoo] [2] or [MSN] [3].\n\n  [1]: http://google.com/        \"Google\"\n  [2]: http://search.yahoo.com/  \"Yahoo Search\"\n  [3]: http://search.msn.com/    \"MSN Search\"\n
\n\n

Using the implicit link name shortcut, you could instead write:

\n\n
I get 10 times more traffic from [Google][] than from\n[Yahoo][] or [MSN][].\n\n  [google]: http://google.com/        \"Google\"\n  [yahoo]:  http://search.yahoo.com/  \"Yahoo Search\"\n  [msn]:    http://search.msn.com/    \"MSN Search\"\n
\n\n

Both of the above examples will produce the following HTML output:

\n\n
<p>I get 10 times more traffic from <a href=\"http://google.com/\"\ntitle=\"Google\">Google</a> than from\n<a href=\"http://search.yahoo.com/\" title=\"Yahoo Search\">Yahoo</a>\nor <a href=\"http://search.msn.com/\" title=\"MSN Search\">MSN</a>.</p>\n
\n\n

For comparison, here is the same paragraph written using\nMarkdown's inline link style:

\n\n
I get 10 times more traffic from [Google](http://google.com/ \"Google\")\nthan from [Yahoo](http://search.yahoo.com/ \"Yahoo Search\") or\n[MSN](http://search.msn.com/ \"MSN Search\").\n
\n\n

The point of reference-style links is not that they're easier to\nwrite. The point is that with reference-style links, your document\nsource is vastly more readable. Compare the above examples: using\nreference-style links, the paragraph itself is only 81 characters\nlong; with inline-style links, it's 176 characters; and as raw HTML,\nit's 234 characters. In the raw HTML, there's more markup than there\nis text.

\n\n

With Markdown's reference-style links, a source document much more\nclosely resembles the final output, as rendered in a browser. By\nallowing you to move the markup-related metadata out of the paragraph,\nyou can add links without interrupting the narrative flow of your\nprose.

\n\n

Emphasis

\n\n

Markdown treats asterisks (*) and underscores (_) as indicators of\nemphasis. Text wrapped with one * or _ will be wrapped with an\nHTML <em> tag; double *'s or _'s will be wrapped with an HTML\n<strong> tag. E.g., this input:

\n\n
*single asterisks*\n\n_single underscores_\n\n**double asterisks**\n\n__double underscores__\n
\n\n

will produce:

\n\n
<em>single asterisks</em>\n\n<em>single underscores</em>\n\n<strong>double asterisks</strong>\n\n<strong>double underscores</strong>\n
\n\n

You can use whichever style you prefer; the lone restriction is that\nthe same character must be used to open and close an emphasis span.

\n\n

Emphasis can be used in the middle of a word:

\n\n
un*fucking*believable\n
\n\n

But if you surround an * or _ with spaces, it'll be treated as a\nliteral asterisk or underscore.

\n\n

To produce a literal asterisk or underscore at a position where it\nwould otherwise be used as an emphasis delimiter, you can backslash\nescape it:

\n\n
\\*this text is surrounded by literal asterisks\\*\n
\n\n

Code

\n\n

To indicate a span of code, wrap it with backtick quotes (`).\nUnlike a pre-formatted code block, a code span indicates code within a\nnormal paragraph. For example:

\n\n
Use the `printf()` function.\n
\n\n

will produce:

\n\n
<p>Use the <code>printf()</code> function.</p>\n
\n\n

To include a literal backtick character within a code span, you can use\nmultiple backticks as the opening and closing delimiters:

\n\n
``There is a literal backtick (`) here.``\n
\n\n

which will produce this:

\n\n
<p><code>There is a literal backtick (`) here.</code></p>\n
\n\n

The backtick delimiters surrounding a code span may include spaces --\none after the opening, one before the closing. This allows you to place\nliteral backtick characters at the beginning or end of a code span:

\n\n
A single backtick in a code span: `` ` ``\n\nA backtick-delimited string in a code span: `` `foo` ``\n
\n\n

will produce:

\n\n
<p>A single backtick in a code span: <code>`</code></p>\n\n<p>A backtick-delimited string in a code span: <code>`foo`</code></p>\n
\n\n

With a code span, ampersands and angle brackets are encoded as HTML\nentities automatically, which makes it easy to include example HTML\ntags. Markdown will turn this:

\n\n
Please don't use any `<blink>` tags.\n
\n\n

into:

\n\n
<p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>\n
\n\n

You can write this:

\n\n
`&#8212;` is the decimal-encoded equivalent of `&mdash;`.\n
\n\n

to produce:

\n\n
<p><code>&amp;#8212;</code> is the decimal-encoded\nequivalent of <code>&amp;mdash;</code>.</p>\n
\n\n

Images

\n\n

Admittedly, it's fairly difficult to devise a \"natural\" syntax for\nplacing images into a plain text document format.

\n\n

Markdown uses an image syntax that is intended to resemble the syntax\nfor links, allowing for two styles: inline and reference.

\n\n

Inline image syntax looks like this:

\n\n
![Alt text](/path/to/img.jpg)\n\n![Alt text](/path/to/img.jpg \"Optional title\")\n
\n\n

That is:

\n\n
    \n
  • An exclamation mark: !;
  • \n
  • followed by a set of square brackets, containing the alt\nattribute text for the image;
  • \n
  • followed by a set of parentheses, containing the URL or path to\nthe image, and an optional title attribute enclosed in double\nor single quotes.
  • \n
\n\n

Reference-style image syntax looks like this:

\n\n
![Alt text][id]\n
\n\n

Where \"id\" is the name of a defined image reference. Image references\nare defined using syntax identical to link references:

\n\n
[id]: url/to/image  \"Optional title attribute\"\n
\n\n

As of this writing, Markdown has no syntax for specifying the\ndimensions of an image; if this is important to you, you can simply\nuse regular HTML <img> tags.

\n\n
\n\n

Miscellaneous

\n\n

Automatic Links

\n\n

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:

\n\n
<http://example.com/>\n
\n\n

Markdown will turn this into:

\n\n
<a href=\"http://example.com/\">http://example.com/</a>\n
\n\n

Automatic links for email addresses work similarly, except that\nMarkdown will also perform a bit of randomized decimal and hex\nentity-encoding to help obscure your address from address-harvesting\nspambots. For example, Markdown will turn this:

\n\n
<address@example.com>\n
\n\n

into something like this:

\n\n
<a href=\"&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;\n&#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;\n&#109;\">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;\n&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>\n
\n\n

which will render in a browser as a clickable link to \"address@example.com\".

\n\n

(This sort of entity-encoding trick will indeed fool many, if not\nmost, address-harvesting bots, but it definitely won't fool all of\nthem. It's better than nothing, but an address published in this way\nwill probably eventually start receiving spam.)

\n\n

Backslash Escapes

\n\n

Markdown allows you to use backslash escapes to generate literal\ncharacters which would otherwise have special meaning in Markdown's\nformatting syntax. For example, if you wanted to surround a word with\nliteral asterisks (instead of an HTML <em> tag), you can backslashes\nbefore the asterisks, like this:

\n\n
\\*literal asterisks\\*\n
\n\n

Markdown provides backslash escapes for the following characters:

\n\n
\\   backslash\n`   backtick\n*   asterisk\n_   underscore\n{}  curly braces\n[]  square brackets\n()  parentheses\n#   hash mark\n+   plus sign\n-   minus sign (hyphen)\n.   dot\n!   exclamation mark\n
"), -%% ?_assert(conv("> foo\n>\n> > bar\n>\n> foo\n") == "
\n

foo

\n \n
\n

bar

\n
\n \n

foo

\n
"), -%% ?_assert(conv("## Unordered\n\nAsterisks tight:\n\n*\tasterisk 1\n*\tasterisk 2\n*\tasterisk 3\n\n\nAsterisks loose:\n\n*\tasterisk 1\n\n*\tasterisk 2\n\n*\tasterisk 3\n\n* * *\n\nPluses tight:\n\n+\tPlus 1\n+\tPlus 2\n+\tPlus 3\n\n\nPluses loose:\n\n+\tPlus 1\n\n+\tPlus 2\n\n+\tPlus 3\n\n* * *\n\n\nMinuses tight:\n\n-\tMinus 1\n-\tMinus 2\n-\tMinus 3\n\n\nMinuses loose:\n\n-\tMinus 1\n\n-\tMinus 2\n\n-\tMinus 3\n\n\n## Ordered\n\nTight:\n\n1.\tFirst\n2.\tSecond\n3.\tThird\n\nand:\n\n1. One\n2. Two\n3. Three\n\n\nLoose using tabs:\n\n1.\tFirst\n\n2.\tSecond\n\n3.\tThird\n\nand using spaces:\n\n1. One\n\n2. Two\n\n3. Three\n\nMultiple paragraphs:\n\n1.\tItem 1, graf one.\n\n\tItem 2. graf two. The quick brown fox jumped over the lazy dog's\n\tback.\n\t\n2.\tItem 2.\n\n3.\tItem 3.\n\n\n\n## Nested\n\n*\tTab\n\t*\tTab\n\t\t*\tTab\n\nHere's another:\n\n1. First\n2. Second:\n\t* Fee\n\t* Fie\n\t* Foe\n3. Third\n\nSame thing but with paragraphs:\n\n1. First\n\n2. Second:\n\t* Fee\n\t* Fie\n\t* Foe\n\n3. Third\n\n\nThis was an error in Markdown 1.0.1:\n\n*\tthis\n\n\t*\tsub\n\n\tthat\n") == "

Unordered

\n\n

Asterisks tight:

\n\n
    \n
  • asterisk 1
  • \n
  • asterisk 2
  • \n
  • asterisk 3
  • \n
\n\n

Asterisks loose:

\n\n
    \n
  • asterisk 1

  • \n
  • asterisk 2

  • \n
  • asterisk 3

  • \n
\n\n
\n\n

Pluses tight:

\n\n
    \n
  • Plus 1
  • \n
  • Plus 2
  • \n
  • Plus 3
  • \n
\n\n

Pluses loose:

\n\n
    \n
  • Plus 1

  • \n
  • Plus 2

  • \n
  • Plus 3

  • \n
\n\n
\n\n

Minuses tight:

\n\n
    \n
  • Minus 1
  • \n
  • Minus 2
  • \n
  • Minus 3
  • \n
\n\n

Minuses loose:

\n\n
    \n
  • Minus 1

  • \n
  • Minus 2

  • \n
  • Minus 3

  • \n
\n\n

Ordered

\n\n

Tight:

\n\n
    \n
  1. First
  2. \n
  3. Second
  4. \n
  5. Third
  6. \n
\n\n

and:

\n\n
    \n
  1. One
  2. \n
  3. Two
  4. \n
  5. Three
  6. \n
\n\n

Loose using tabs:

\n\n
    \n
  1. First

  2. \n
  3. Second

  4. \n
  5. Third

  6. \n
\n\n

and using spaces:

\n\n
    \n
  1. One

  2. \n
  3. Two

  4. \n
  5. Three

  6. \n
\n\n

Multiple paragraphs:

\n\n
    \n
  1. Item 1, graf one.

    \n\n

    Item 2. graf two. The quick brown fox jumped over the lazy dog's\nback.

  2. \n
  3. Item 2.

  4. \n
  5. Item 3.

  6. \n
\n\n

Nested

\n\n
    \n
  • Tab\n
    • Tab\n
      • Tab
  • \n
\n\n

Here's another:

\n\n
    \n
  1. First
  2. \n
  3. Second:\n
    • Fee
    • \n
    • Fie
    • \n
    • Foe
  4. \n
  5. Third
  6. \n
\n\n

Same thing but with paragraphs:

\n\n
    \n
  1. First

  2. \n
  3. Second:

    \n\n
    • Fee
    • \n
    • Fie
    • \n
    • Foe
  4. \n
  5. Third

  6. \n
\n\n

This was an error in Markdown 1.0.1:

\n\n
    \n
  • this

    \n\n
    • sub
    \n\n

    that

  • \n
"), -%% ?_assert(conv("***This is strong and em.***\n\nSo is ***this*** word.\n\n___This is strong and em.___\n\nSo is ___this___ word.\n") == "

This is strong and em.

\n\n

So is this word.

\n\n

This is strong and em.

\n\n

So is this word.

"), -%% ?_assert(conv("+\tthis is a list item\n\tindented with tabs\n\n+ this is a list item\n indented with spaces\n\nCode:\n\n\tthis code block is indented by one tab\n\nAnd:\n\n\t\tthis code block is indented by two tabs\n\nAnd:\n\n\t+\tthis is an example list item\n\t\tindented with tabs\n\t\n\t+ this is an example list item\n\t indented with spaces\n") == "
    \n
  • this is a list item\nindented with tabs

  • \n
  • this is a list item\nindented with spaces

  • \n
\n\n

Code:

\n\n
this code block is indented by one tab\n
\n\n

And:

\n\n
    this code block is indented by two tabs\n
\n\n

And:

\n\n
+   this is an example list item\n    indented with tabs\n\n+   this is an example list item\n    indented with spaces\n
"), -%% ?_assert(conv("> A list within a blockquote:\n> \n> *\tasterisk 1\n> *\tasterisk 2\n> *\tasterisk 3\n") == "
\n

A list within a blockquote:

\n \n
    \n
  • asterisk 1
  • \n
  • asterisk 2
  • \n
  • asterisk 3
  • \n
\n
"), -%% ?_assert(conv("1. one\r\n\r\n code\r\n indented 8 spaces\r\n\r\n2. two\r\n\r\n code\r\n idented-12-spaces\r\n\r\n3. three\r\n\r\n code\r\n\r\n indented-12-spaces") == "

1. one

\n\n
    code<t>\n    indented 8 spaces<t>\n
\n\n
    \n
  1. two

    \n\n
    code<t>\n    idented-12-spaces<t>\n
  2. \n
  3. three

    \n\n
    code<t>\n\n\n
    indented-12-spaces&lt;t&gt;\n
    \n\n
  4. \n
"), -%% ?_assert(conv("##Header##\r\r----------\r\rSome **bold** Some *italic* and [a link][1] \r\rA little code sample\r\r \r Web Page Title\r \r\rA picture\r\r![alt text][2]\r\rA list\r\r- apples\r- oranges\r- eggs\r\rA numbered list\r\r1. a\r2. b\r3. c\r\rA little quote\r\r> It is now time for all good men to come to the aid of their country. \r\rA final paragraph.\r\r [1]: http://www.google.com\r [2]: http://www.google.com/intl/en_ALL/images/logo.gif") == "

Header

\n\n
\n\n

Some bold Some italic and a link

\n\n

A little code sample

\n\n
</head>\n<title>Web Page Title</title>\n</head>\n
\n\n

A picture

\n\n

\"alt

\n\n

A list

\n\n
    \n
  • apples
  • \n
  • oranges
  • \n
  • eggs
  • \n
\n\n

A numbered list

\n\n
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n\n

A little quote

\n\n
\n

It is now time for all good men to come to the aid of their country.

\n
\n\n

A final paragraph.

"), -%% ?_assert(conv("##Header##\r\n\r\n----------\r\n\r\nSome **bold** Some *italic* and [a link][1] \r\n\r\nA little code sample\r\n\r\n \r\n Web Page Title\r\n \r\n\r\nA picture\r\n\r\n![alt text][2]\r\n\r\nA list\r\n\r\n- apples\r\n- oranges\r\n- eggs\r\n\r\nA numbered list\r\n\r\n1. a\r\n2. b\r\n3. c\r\n\r\nA little quote\r\n\r\n> It is now time for all good men to come to the aid of their country. \r\n\r\nA final paragraph.\r\n\r\n [1]: http://www.google.com\r\n [2]: http://www.google.com/intl/en_ALL/images/logo.gif") == "

Header

\n\n
\n\n

Some bold Some italic and a link

\n\n

A little code sample

\n\n
</head>\n<title>Web Page Title</title>\n</head>\n
\n\n

A picture

\n\n

\"alt

\n\n

A list

\n\n
    \n
  • apples
  • \n
  • oranges
  • \n
  • eggs
  • \n
\n\n

A numbered list

\n\n
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n\n

A little quote

\n\n
\n

It is now time for all good men to come to the aid of their country.

\n
\n\n

A final paragraph.

"), -%% ?_assert(conv("##Header##\n\n----------\n\nSome **bold** Some *italic* and [a link][1] \n\nA little code sample\n\n \n Web Page Title\n \n\nA picture\n\n![alt text][2]\n\nA list\n\n- apples\n- oranges\n- eggs\n\nA numbered list\n\n1. a\n2. b\n3. c\n\nA little quote\n\n> It is now time for all good men to come to the aid of their country. \n\nA final paragraph.\n\n [1]: http://www.google.com\n [2]: http://www.google.com/intl/en_ALL/images/logo.gif") == "

Header

\n\n
\n\n

Some bold Some italic and a link

\n\n

A little code sample

\n\n
</head>\n<title>Web Page Title</title>\n</head>\n
\n\n

A picture

\n\n

\"alt

\n\n

A list

\n\n
    \n
  • apples
  • \n
  • oranges
  • \n
  • eggs
  • \n
\n\n

A numbered list

\n\n
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
\n\n

A little quote

\n\n
\n

It is now time for all good men to come to the aid of their country.

\n
\n\n

A final paragraph.

"), -%% ?_assert(conv("Markdown\n========\n\nVersion 1.0.1 - Tue 14 Dec 2004\n\nby John Gruber \n\n\n\nIntroduction\n------------\n\nMarkdown is a text-to-HTML conversion tool for web writers. Markdown\nallows you to write using an easy-to-read, easy-to-write plain text\nformat, then convert it to structurally valid XHTML (or HTML).\n\nThus, \"Markdown\" is two things: a plain text markup syntax, and a\nsoftware tool, written in Perl, that converts the plain text markup \nto HTML.\n\nMarkdown works both as a Movable Type plug-in and as a standalone Perl\nscript -- which means it can also be used as a text filter in BBEdit\n(or any other application that supporst filters written in Perl).\n\nFull documentation of Markdown's syntax and configuration options is\navailable on the web: .\n(Note: this readme file is formatted in Markdown.)\n\n\n\nInstallation and Requirements\n-----------------------------\n\nMarkdown requires Perl 5.6.0 or later. Welcome to the 21st Century.\nMarkdown also requires the standard Perl library module `Digest::MD5`. \n\n\n### Movable Type ###\n\nMarkdown works with Movable Type version 2.6 or later (including \nMT 3.0 or later).\n\n1. Copy the \"Markdown.pl\" file into your Movable Type \"plugins\"\n directory. The \"plugins\" directory should be in the same directory\n as \"mt.cgi\"; if the \"plugins\" directory doesn't already exist, use\n your FTP program to create it. Your installation should look like\n this:\n\n (mt home)/plugins/Markdown.pl\n\n2. Once installed, Markdown will appear as an option in Movable Type's\n Text Formatting pop-up menu. This is selectable on a per-post basis.\n Markdown translates your posts to HTML when you publish; the posts\n themselves are stored in your MT database in Markdown format.\n\n3. If you also install SmartyPants 1.5 (or later), Markdown will offer\n a second text formatting option: \"Markdown with SmartyPants\". This\n option is the same as the regular \"Markdown\" formatter, except that\n automatically uses SmartyPants to create typographically correct\n curly quotes, em-dashes, and ellipses. See the SmartyPants web page\n for more information: \n\n4. To make Markdown (or \"Markdown with SmartyPants\") your default\n text formatting option for new posts, go to Weblog Config ->\n Preferences.\n\nNote that by default, Markdown produces XHTML output. To configure\nMarkdown to produce HTML 4 output, see \"Configuration\", below.\n\n\n### Blosxom ###\n\nMarkdown works with Blosxom version 2.x.\n\n1. Rename the \"Markdown.pl\" plug-in to \"Markdown\" (case is\n important). Movable Type requires plug-ins to have a \".pl\"\n extension; Blosxom forbids it.\n\n2. Copy the \"Markdown\" plug-in file to your Blosxom plug-ins folder.\n If you're not sure where your Blosxom plug-ins folder is, see the\n Blosxom documentation for information.\n\n3. That's it. The entries in your weblog will now automatically be\n processed by Markdown.\n\n4. If you'd like to apply Markdown formatting only to certain posts,\n rather than all of them, see Jason Clark's instructions for using\n Markdown in conjunction with Blosxom's Meta plugin:\n \n \n\n\n### BBEdit ###\n\nMarkdown works with BBEdit 6.1 or later on Mac OS X. (It also works\nwith BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.)\n\n1. Copy the \"Markdown.pl\" file to appropriate filters folder in your\n \"BBEdit Support\" folder. On Mac OS X, this should be:\n\n BBEdit Support/Unix Support/Unix Filters/\n\n See the BBEdit documentation for more details on the location of\n these folders.\n\n You can rename \"Markdown.pl\" to whatever you wish.\n\n2. That's it. To use Markdown, select some text in a BBEdit document,\n then choose Markdown from the Filters sub-menu in the \"#!\" menu, or\n the Filters floating palette\n\n\n\nConfiguration\n-------------\n\nBy default, Markdown produces XHTML output for tags with empty elements.\nE.g.:\n\n
\n\nMarkdown can be configured to produce HTML-style tags; e.g.:\n\n
\n\n\n### Movable Type ###\n\nYou need to use a special `MTMarkdownOptions` container tag in each\nMovable Type template where you want HTML 4-style output:\n\n \n ... put your entry content here ...\n \n\nThe easiest way to use MTMarkdownOptions is probably to put the\nopening tag right after your `` tag, and the closing tag right\nbefore ``.\n\nTo suppress Markdown processing in a particular template, i.e. to\npublish the raw Markdown-formatted text without translation into\n(X)HTML, set the `output` attribute to 'raw':\n\n \n ... put your entry content here ...\n \n\n\n### Command-Line ###\n\nUse the `--html4tags` command-line switch to produce HTML output from a\nUnix-style command line. E.g.:\n\n % perl Markdown.pl --html4tags foo.text\n\nType `perldoc Markdown.pl`, or read the POD documentation within the\nMarkdown.pl source code for more information.\n\n\n\nBugs\n----\n\nTo file bug reports or feature requests please send email to:\nmarkdown@daringfireball.net.\n\n\n\nVersion History\n---------------\n\n1.0.1 (14 Dec 2004):\n\n+\tChanged the syntax rules for code blocks and spans. Previously,\n\tbackslash escapes for special Markdown characters were processed\n\teverywhere other than within inline HTML tags. Now, the contents\n\tof code blocks and spans are no longer processed for backslash\n\tescapes. This means that code blocks and spans are now treated\n\tliterally, with no special rules to worry about regarding\n\tbackslashes.\n\n\t**NOTE**: This changes the syntax from all previous versions of\n\tMarkdown. Code blocks and spans involving backslash characters\n\twill now generate different output than before.\n\n+\tTweaked the rules for link definitions so that they must occur\n\twithin three spaces of the left margin. Thus if you indent a link\n\tdefinition by four spaces or a tab, it will now be a code block.\n\t\n\t\t [a]: /url/ \"Indented 3 spaces, this is a link def\"\n\n\t\t [b]: /url/ \"Indented 4 spaces, this is a code block\"\n\t\n\t**IMPORTANT**: This may affect existing Markdown content if it\n\tcontains link definitions indented by 4 or more spaces.\n\n+\tAdded `>`, `+`, and `-` to the list of backslash-escapable\n\tcharacters. These should have been done when these characters\n\twere added as unordered list item markers.\n\n+\tTrailing spaces and tabs following HTML comments and `
` tags\n\tare now ignored.\n\n+\tInline links using `<` and `>` URL delimiters weren't working:\n\n\t\tlike [this]()\n\n+\tAdded a bit of tolerance for trailing spaces and tabs after\n\tMarkdown hr's.\n\n+\tFixed bug where auto-links were being processed within code spans:\n\n\t\tlike this: ``\n\n+\tSort-of fixed a bug where lines in the middle of hard-wrapped\n\tparagraphs, which lines look like the start of a list item,\n\twould accidentally trigger the creation of a list. E.g. a\n\tparagraph that looked like this:\n\n\t\tI recommend upgrading to version\n\t\t8. Oops, now this line is treated\n\t\tas a sub-list.\n\n\tThis is fixed for top-level lists, but it can still happen for\n\tsub-lists. E.g., the following list item will not be parsed\n\tproperly:\n\n\t\t+\tI recommend upgrading to version\n\t\t\t8. Oops, now this line is treated\n\t\t\tas a sub-list.\n\n\tGiven Markdown's list-creation rules, I'm not sure this can\n\tbe fixed.\n\n+\tStandalone HTML comments are now handled; previously, they'd get\n\twrapped in a spurious `

` tag.\n\n+\tFix for horizontal rules preceded by 2 or 3 spaces.\n\n+\t`


` HTML tags in must occur within three spaces of left\n\tmargin. (With 4 spaces or a tab, they should be code blocks, but\n\tweren't before this fix.)\n\n+\tCapitalized \"With\" in \"Markdown With SmartyPants\" for\n\tconsistency with the same string label in SmartyPants.pl.\n\t(This fix is specific to the MT plug-in interface.)\n\n+\tAuto-linked email address can now optionally contain\n\ta 'mailto:' protocol. I.e. these are equivalent:\n\n\t\t\n\t\t\n\n+\tFixed annoying bug where nested lists would wind up with\n\tspurious (and invalid) `

` tags.\n\n+\tYou can now write empty links:\n\n\t\t[like this]()\n\n\tand they'll be turned into anchor tags with empty href attributes.\n\tThis should have worked before, but didn't.\n\n+\t`***this***` and `___this___` are now turned into\n\n\t\tthis\n\n\tInstead of\n\n\t\tthis\n\n\twhich isn't valid. (Thanks to Michel Fortin for the fix.)\n\n+\tAdded a new substitution in `_EncodeCode()`: s/\\$/$/g; This\n\tis only for the benefit of Blosxom users, because Blosxom\n\t(sometimes?) interpolates Perl scalars in your article bodies.\n\n+\tFixed problem for links defined with urls that include parens, e.g.:\n\n\t\t[1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky)\n\n\t\"Chomsky\" was being erroneously treated as the URL's title.\n\n+\tAt some point during 1.0's beta cycle, I changed every sub's\n\targument fetching from this idiom:\n\n\t\tmy $text = shift;\n\n\tto:\n\n\t\tmy $text = shift || return '';\n\n\tThe idea was to keep Markdown from doing any work in a sub\n\tif the input was empty. This introduced a bug, though:\n\tif the input to any function was the single-character string\n\t\"0\", it would also evaluate as false and return immediately.\n\tHow silly. Now fixed.\n\n\n\nDonations\n---------\n\nDonations to support Markdown's development are happily accepted. See:\n for details.\n\n\n\nCopyright and License\n---------------------\n\nCopyright (c) 2003-2004 John Gruber \n \nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\n* Redistributions of source code must retain the above copyright notice,\n this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright\n notice, this list of conditions and the following disclaimer in the\n documentation and/or other materials provided with the distribution.\n\n* Neither the name \"Markdown\" nor the names of its contributors may\n be used to endorse or promote products derived from this software\n without specific prior written permission.\n\nThis software is provided by the copyright holders and contributors \"as\nis\" and any express or implied warranties, including, but not limited\nto, the implied warranties of merchantability and fitness for a\nparticular purpose are disclaimed. In no event shall the copyright owner\nor contributors be liable for any direct, indirect, incidental, special,\nexemplary, or consequential damages (including, but not limited to,\nprocurement of substitute goods or services; loss of use, data, or\nprofits; or business interruption) however caused and on any theory of\nliability, whether in contract, strict liability, or tort (including\nnegligence or otherwise) arising in any way out of the use of this\nsoftware, even if advised of the possibility of such damage.\n") == "

Markdown

\n\n

Version 1.0.1 - Tue 14 Dec 2004

\n\n

by John Gruber
\nhttp://daringfireball.net/

\n\n

Introduction

\n\n

Markdown is a text-to-HTML conversion tool for web writers. Markdown\nallows you to write using an easy-to-read, easy-to-write plain text\nformat, then convert it to structurally valid XHTML (or HTML).

\n\n

Thus, \"Markdown\" is two things: a plain text markup syntax, and a\nsoftware tool, written in Perl, that converts the plain text markup \nto HTML.

\n\n

Markdown works both as a Movable Type plug-in and as a standalone Perl\nscript -- which means it can also be used as a text filter in BBEdit\n(or any other application that supporst filters written in Perl).

\n\n

Full documentation of Markdown's syntax and configuration options is\navailable on the web: http://daringfireball.net/projects/markdown/.\n(Note: this readme file is formatted in Markdown.)

\n\n

Installation and Requirements

\n\n

Markdown requires Perl 5.6.0 or later. Welcome to the 21st Century.\nMarkdown also requires the standard Perl library module Digest::MD5.

\n\n

Movable Type

\n\n

Markdown works with Movable Type version 2.6 or later (including \nMT 3.0 or later).

\n\n
    \n
  1. Copy the \"Markdown.pl\" file into your Movable Type \"plugins\"\ndirectory. The \"plugins\" directory should be in the same directory\nas \"mt.cgi\"; if the \"plugins\" directory doesn't already exist, use\nyour FTP program to create it. Your installation should look like\nthis:

    \n\n
    (mt home)/plugins/Markdown.pl\n
  2. \n
  3. Once installed, Markdown will appear as an option in Movable Type's\nText Formatting pop-up menu. This is selectable on a per-post basis.\nMarkdown translates your posts to HTML when you publish; the posts\nthemselves are stored in your MT database in Markdown format.

  4. \n
  5. If you also install SmartyPants 1.5 (or later), Markdown will offer\na second text formatting option: \"Markdown with SmartyPants\". This\noption is the same as the regular \"Markdown\" formatter, except that\nautomatically uses SmartyPants to create typographically correct\ncurly quotes, em-dashes, and ellipses. See the SmartyPants web page\nfor more information: http://daringfireball.net/projects/smartypants/

  6. \n
  7. To make Markdown (or \"Markdown with SmartyPants\") your default\ntext formatting option for new posts, go to Weblog Config ->\nPreferences.

  8. \n
\n\n

Note that by default, Markdown produces XHTML output. To configure\nMarkdown to produce HTML 4 output, see \"Configuration\", below.

\n\n

Blosxom

\n\n

Markdown works with Blosxom version 2.x.

\n\n
    \n
  1. Rename the \"Markdown.pl\" plug-in to \"Markdown\" (case is\nimportant). Movable Type requires plug-ins to have a \".pl\"\nextension; Blosxom forbids it.

  2. \n
  3. Copy the \"Markdown\" plug-in file to your Blosxom plug-ins folder.\nIf you're not sure where your Blosxom plug-ins folder is, see the\nBlosxom documentation for information.

  4. \n
  5. That's it. The entries in your weblog will now automatically be\nprocessed by Markdown.

  6. \n
  7. If you'd like to apply Markdown formatting only to certain posts,\nrather than all of them, see Jason Clark's instructions for using\nMarkdown in conjunction with Blosxom's Meta plugin:

    \n\n

    http://jclark.org/weblog/WebDev/Blosxom/Markdown.html

  8. \n
\n\n

BBEdit

\n\n

Markdown works with BBEdit 6.1 or later on Mac OS X. (It also works\nwith BBEdit 5.1 or later and MacPerl 5.6.1 on Mac OS 8.6 or later.)

\n\n
    \n
  1. Copy the \"Markdown.pl\" file to appropriate filters folder in your\n\"BBEdit Support\" folder. On Mac OS X, this should be:

    \n\n
    BBEdit Support/Unix Support/Unix Filters/\n
    \n\n

    See the BBEdit documentation for more details on the location of\nthese folders.

    \n\n

    You can rename \"Markdown.pl\" to whatever you wish.

  2. \n
  3. That's it. To use Markdown, select some text in a BBEdit document,\nthen choose Markdown from the Filters sub-menu in the \"#!\" menu, or\nthe Filters floating palette

  4. \n
\n\n

Configuration

\n\n

By default, Markdown produces XHTML output for tags with empty elements.\nE.g.:

\n\n
<br />\n
\n\n

Markdown can be configured to produce HTML-style tags; e.g.:

\n\n
<br>\n
\n\n

Movable Type

\n\n

You need to use a special MTMarkdownOptions container tag in each\nMovable Type template where you want HTML 4-style output:

\n\n
<MTMarkdownOptions output='html4'>\n    ... put your entry content here ...\n</MTMarkdownOptions>\n
\n\n

The easiest way to use MTMarkdownOptions is probably to put the\nopening tag right after your <body> tag, and the closing tag right\nbefore </body>.

\n\n

To suppress Markdown processing in a particular template, i.e. to\npublish the raw Markdown-formatted text without translation into\n(X)HTML, set the output attribute to 'raw':

\n\n
<MTMarkdownOptions output='raw'>\n    ... put your entry content here ...\n</MTMarkdownOptions>\n
\n\n

Command-Line

\n\n

Use the --html4tags command-line switch to produce HTML output from a\nUnix-style command line. E.g.:

\n\n
% perl Markdown.pl --html4tags foo.text\n
\n\n

Type perldoc Markdown.pl, or read the POD documentation within the\nMarkdown.pl source code for more information.

\n\n

Bugs

\n\n

To file bug reports or feature requests please send email to:\nmarkdown@daringfireball.net.

\n\n

Version History

\n\n

1.0.1 (14 Dec 2004):

\n\n
    \n
  • Changed the syntax rules for code blocks and spans. Previously,\nbackslash escapes for special Markdown characters were processed\neverywhere other than within inline HTML tags. Now, the contents\nof code blocks and spans are no longer processed for backslash\nescapes. This means that code blocks and spans are now treated\nliterally, with no special rules to worry about regarding\nbackslashes.

    \n\n

    NOTE: This changes the syntax from all previous versions of\nMarkdown. Code blocks and spans involving backslash characters\nwill now generate different output than before.

  • \n
  • Tweaked the rules for link definitions so that they must occur\nwithin three spaces of the left margin. Thus if you indent a link\ndefinition by four spaces or a tab, it will now be a code block.

    \n\n
       [a]: /url/  \"Indented 3 spaces, this is a link def\"\n\n\n
    [b]: /url/  \"Indented 4 spaces, this is a code block\"\n
    \n\n
    \n\n

    IMPORTANT: This may affect existing Markdown content if it\ncontains link definitions indented by 4 or more spaces.

  • \n
  • Added >, +, and - to the list of backslash-escapable\ncharacters. These should have been done when these characters\nwere added as unordered list item markers.

  • \n
  • Trailing spaces and tabs following HTML comments and <hr/> tags\nare now ignored.

  • \n
  • Inline links using < and > URL delimiters weren't working:

    \n\n
    like [this](<http://example.com/>)\n
  • \n
  • Added a bit of tolerance for trailing spaces and tabs after\nMarkdown hr's.

  • \n
  • Fixed bug where auto-links were being processed within code spans:

    \n\n
    like this: `<http://example.com/>`\n
  • \n
  • Sort-of fixed a bug where lines in the middle of hard-wrapped\nparagraphs, which lines look like the start of a list item,\nwould accidentally trigger the creation of a list. E.g. a\nparagraph that looked like this:

    \n\n
    I recommend upgrading to version\n8. Oops, now this line is treated\nas a sub-list.\n
    \n\n

    This is fixed for top-level lists, but it can still happen for\nsub-lists. E.g., the following list item will not be parsed\nproperly:

    \n\n
    +   I recommend upgrading to version\n    8. Oops, now this line is treated\n    as a sub-list.\n
    \n\n

    Given Markdown's list-creation rules, I'm not sure this can\nbe fixed.

  • \n
  • Standalone HTML comments are now handled; previously, they'd get\nwrapped in a spurious <p> tag.

  • \n
  • Fix for horizontal rules preceded by 2 or 3 spaces.

  • \n
  • <hr> HTML tags in must occur within three spaces of left\nmargin. (With 4 spaces or a tab, they should be code blocks, but\nweren't before this fix.)

  • \n
  • Capitalized \"With\" in \"Markdown With SmartyPants\" for\nconsistency with the same string label in SmartyPants.pl.\n(This fix is specific to the MT plug-in interface.)

  • \n
  • Auto-linked email address can now optionally contain\na 'mailto:' protocol. I.e. these are equivalent:

    \n\n
    <mailto:user@example.com>\n<user@example.com>\n
  • \n
  • Fixed annoying bug where nested lists would wind up with\nspurious (and invalid) <p> tags.

  • \n
  • You can now write empty links:

    \n\n
    [like this]()\n
    \n\n

    and they'll be turned into anchor tags with empty href attributes.\nThis should have worked before, but didn't.

  • \n
  • ***this*** and ___this___ are now turned into

    \n\n
    <strong><em>this</em></strong>\n
    \n\n

    Instead of

    \n\n
    <strong><em>this</strong></em>\n
    \n\n

    which isn't valid. (Thanks to Michel Fortin for the fix.)

  • \n
  • Added a new substitution in _EncodeCode(): s/\\$/$/g; This\nis only for the benefit of Blosxom users, because Blosxom\n(sometimes?) interpolates Perl scalars in your article bodies.

  • \n
  • Fixed problem for links defined with urls that include parens, e.g.:

    \n\n
    [1]: http://sources.wikipedia.org/wiki/Middle_East_Policy_(Chomsky)\n
    \n\n

    \"Chomsky\" was being erroneously treated as the URL's title.

  • \n
  • At some point during 1.0's beta cycle, I changed every sub's\nargument fetching from this idiom:

    \n\n
    my $text = shift;\n
    \n\n

    to:

    \n\n
    my $text = shift || return '';\n
    \n\n

    The idea was to keep Markdown from doing any work in a sub\nif the input was empty. This introduced a bug, though:\nif the input to any function was the single-character string\n\"0\", it would also evaluate as false and return immediately.\nHow silly. Now fixed.

  • \n
\n\n

Donations

\n\n

Donations to support Markdown's development are happily accepted. See:\nhttp://daringfireball.net/projects/markdown/ for details.

\n\n

Copyright and License

\n\n

Copyright (c) 2003-2004 John Gruber
\nhttp://daringfireball.net/
\nAll rights reserved.

\n\n

Redistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:

\n\n
    \n
  • Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.

  • \n
  • Redistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.

  • \n
  • Neither the name \"Markdown\" nor the names of its contributors may\nbe used to endorse or promote products derived from this software\nwithout specific prior written permission.

  • \n
\n\n

This software is provided by the copyright holders and contributors \"as\nis\" and any express or implied warranties, including, but not limited\nto, the implied warranties of merchantability and fitness for a\nparticular purpose are disclaimed. In no event shall the copyright owner\nor contributors be liable for any direct, indirect, incidental, special,\nexemplary, or consequential damages (including, but not limited to,\nprocurement of substitute goods or services; loss of use, data, or\nprofits; or business interruption) however caused and on any theory of\nliability, whether in contract, strict liability, or tort (including\nnegligence or otherwise) arising in any way out of the use of this\nsoftware, even if advised of the possibility of such damage.

"), -%% ?_assert(conv("Tricky combinaisons:\r\rbackslash with \\\\-- two dashes\r\rbackslash with \\\\> greater than\r\r\\\\\\[test](not a link)\r\r\\\\\\*no emphasis*") == "

Tricky combinaisons:

\n\n

backslash with \\-- two dashes

\n\n

backslash with \\> greater than

\n\n

\\[test](not a link)

\n\n

\\*no emphasis*

"), -%% ?_assert(conv("From ``\non two lines.\n\nFrom ``\non three lines.\n") == "

From <!-- to -->\non two lines.

\n\n

From <!--\nto -->\non three lines.

"), -%% ?_assert(conv("\n*\tList Item:\n\n\t\tcode block\n\n\t\twith a blank line\n\n\twithin a list item.") == "
    \n
  • List Item:

    \n\n
    code block\n\n\nwith a blank line\n
    \n\n

    within a list item.

  • \n
"), -% ?_assert(conv("Combined emphasis:\n\n1. ***test test***\n2. ___test test___\n3. *test **test***\n4. **test *test***\n5. ***test* test**\n6. ***test** test*\n7. ***test* test**\n8. **test *test***\n9. *test **test***\n10. _test __test___\n11. __test _test___\n12. ___test_ test__\n13. ___test__ test_\n14. ___test_ test__\n15. __test _test___\n16. _test __test___\n\n\nIncorrect nesting:\n\n1. *test **test* test**\n2. _test __test_ test__\n3. **test *test** test*\n4. __test _test__ test_\n5. *test *test* test*\n6. _test _test_ test_\n7. **test **test** test**\n8. __test __test__ test__\n\n\n\nNo emphasis:\n\n1. test* test *test\n2. test** test **test\n3. test_ test _test\n4. test__ test __test\n\n\n\nMiddle-word emphasis (asterisks):\n\n1. *a*b\n2. a*b*\n3. a*b*c\n4. **a**b\n5. a**b**\n6. a**b**c\n\n\nMiddle-word emphasis (underscore):\n\n1. _a_b\n2. a_b_\n3. a_b_c\n4. __a__b\n5. a__b__\n6. a__b__c\n\nmy_precious_file.txt\n\n\n## Tricky Cases\n\nE**. **Test** TestTestTest\n\nE**. **Test** Test Test Test\n") == "

Combined emphasis:

\n\n
    \n
  1. test test
  2. \n
  3. test test
  4. \n
  5. test test
  6. \n
  7. test test
  8. \n
  9. test test
  10. \n
  11. test test
  12. \n
  13. test test
  14. \n
  15. test test
  16. \n
  17. test test
  18. \n
  19. test test
  20. \n
  21. test test
  22. \n
  23. test test
  24. \n
  25. test test
  26. \n
  27. test test
  28. \n
  29. test test
  30. \n
  31. test test
  32. \n
\n\n

Incorrect nesting:

\n\n
    \n
  1. test test test
  2. \n
  3. test test test
  4. \n
  5. test test test
  6. \n
  7. test test test
  8. \n
  9. test *test test*
  10. \n
  11. test _test test_
  12. \n
  13. test *test test*
  14. \n
  15. test _test test_
  16. \n
\n\n

No emphasis:

\n\n
    \n
  1. test* test *test
  2. \n
  3. test* test *test
  4. \n
  5. test_ test _test
  6. \n
  7. test_ test _test
  8. \n
\n\n

Middle-word emphasis (asterisks):

\n\n
    \n
  1. ab
  2. \n
  3. ab
  4. \n
  5. abc
  6. \n
  7. ab
  8. \n
  9. ab
  10. \n
  11. abc
  12. \n
\n\n

Middle-word emphasis (underscore):

\n\n
    \n
  1. ab
  2. \n
  3. ab
  4. \n
  5. abc
  6. \n
  7. ab
  8. \n
  9. ab
  10. \n
  11. abc
  12. \n
\n\n

mypreciousfile.txt

\n\n

Tricky Cases

\n\n

E. **Test TestTestTest

\n\n

E. **Test Test Test Test

"), -%% ?_assert(conv("Header\r======\r\rHeader\r------\r\r### Header\n\n - - -\n\nHeader\r======\rParagraph\r\rHeader\r------\rParagraph\r\r### Header\rParagraph\n\n - - -\n\nParagraph\rHeader\r======\rParagraph\r\rParagraph\rHeader\r------\rParagraph\r\rParagraph\r### Header\rParagraph") == "

Header

\n\n

Header

\n\n

Header

\n\n
\n\n

Header

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n
\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

\n\n

Paragraph

\n\n

Header

\n\n

Paragraph

"), -%% ?_assert(conv("Horizontal rules:\n\n- - -\n \n* * *\n \n***\n \n---\n \n___\n\nNot horizontal rules (testing for a bug in 1.0.1j):\n\n+++\n\n,,,\n\n===\n\n???\n\nAAA\n\njjj\n\nj j j\n\nn n n\n") == "

Horizontal rules:

\n\n
\n\n
\n\n
\n\n
\n\n
\n\n

Not horizontal rules (testing for a bug in 1.0.1j):

\n\n

+++

\n\n

,,,

\n\n

===

\n\n

???

\n\n

AAA

\n\n

jjj

\n\n

j j j

\n\n

n n n

"), -%% ?_assert(conv("With some attributes:\n\n
\n\tfoo\n
\n\n
\n\tfoo\n
\n\t\nHr's:\n\n
\n") == "

With some attributes:

\n\n
\n foo\n
\n\n
\n foo\n
\n\n

Hr's:

\n\n
"), -%% ?_assert(conv("ACINACS\n\nSB \nSB") == "

ACINACS

\n\n

SB

"), -%% ?_assert(conv("Paragraph one.\n\n\n\nParagraph two.\n\n\n\nThe end.\n") == "

Paragraph one.

\n\n\n\n

Paragraph two.

\n\n\n\n

The end.

"), -%% ?_assert(conv("Here is a block tag ins:\n\n\n

Some text

\n
\n\nAnd here it is inside a paragraph.\n\nAnd here it is in the middle of a paragraph.\n\n\n

Some text

\n
\n\nAnd here is ins as a paragraph.\n\nAnd here it is in the middle of a paragraph.\n") == "

Here is a block tag ins:

\n\n\n

Some text

\n
\n\n

And here it is inside a paragraph.

\n\n

And here it is in the middle of a paragraph.

\n\n\n

Some text

\n
\n\n

And here is ins as a paragraph.

\n\n

And here it is in the middle of a paragraph.

"), -%% ?_assert(conv("[silly URL w/ angle brackets]().\n") == "

silly URL w/ angle brackets>).

"), -%% ?_assert(conv("# Character Escapes\n\nThe MD5 value for `+` is \"26b17225b626fb9238849fd60eabdf60\".\n\n# HTML Blocks\n\n

test

\n\nThe MD5 value for `

test

` is:\n\n6205333b793f34273d75379350b36826") == "

Character Escapes

\n\n

The MD5 value for + is \"26b17225b626fb9238849fd60eabdf60\".

\n\n

HTML Blocks

\n\n

test

\n\n

The MD5 value for <p>test</p> is:

\n\n

6205333b793f34273d75379350b36826

"), -%% ?_assert(conv("Valid nesting:\n\n**[Link](url)**\n\n[**Link**](url)\n\n**[**Link**](url)**\n\nInvalid nesting:\n\n[[Link](url)](url)") == "

Valid nesting:

\n\n

Link

\n\n

Link

\n\n

Link

\n\n

Invalid nesting:

\n\n

[Link](url)

"), -%% ?_assert(conv("This tests for a bug where quotes escaped by PHP when using \n`preg_replace` with the `/e` modifier must be correctly unescaped\n(hence the `_UnslashQuotes` function found only in PHP Markdown).\n\n\n\nHeaders below should appear exactly as they are typed (no backslash\nadded or removed).\n\nHeader \"quoted\\\" again \\\\\"\"\n===========================\n\nHeader \"quoted\\\" again \\\\\"\"\n---------------------------\n\n### Header \"quoted\\\" again \\\\\"\" ###\n\n\n\nTest with tabs for `_Detab`:\n\n\tCode\t'block'\twith\tsome\t\"tabs\"\tand\t\"quotes\"\n") == "

This tests for a bug where quotes escaped by PHP when using \npreg_replace with the /e modifier must be correctly unescaped\n(hence the _UnslashQuotes function found only in PHP Markdown).

\n\n

Headers below should appear exactly as they are typed (no backslash\nadded or removed).

\n\n

Header \"quoted\\\" again \\\"\"

\n\n

Header \"quoted\\\" again \\\"\"

\n\n

Header \"quoted\\\" again \\\"\"

\n\n

Test with tabs for _Detab:

\n\n
Code    'block' with    some    \"tabs\"  and \"quotes\"\n
"), -%% ?_assert(conv("[Inline link 1 with parens](/url\\(test\\) \"title\").\n\n[Inline link 2 with parens]( \"title\").\n\n[Inline link 3 with non-escaped parens](/url(test) \"title\").\n\n[Inline link 4 with non-escaped parens]( \"title\").\n\n[Reference link 1 with parens][1].\n\n[Reference link 2 with parens][2].\n\n [1]: /url(test) \"title\"\n [2]: \"title\"\n") == "

Inline link 1 with parens.

\n\n

Inline link 2 with parens> \"title\").

\n\n

Inline link 3 with non-escaped parens \"title\").

\n\n

Inline link 4 with non-escaped parens> \"title\").

\n\n

Reference link 1 with parens.

\n\n

"title\">Reference link 2 with parens.

"), - ?_assert(conv("Paragraph and no space:\r* ciao\r\rParagraph and 1 space:\r * ciao\r\rParagraph and 3 spaces:\r * ciao\r\rParagraph and 4 spaces:\r * ciao\r\rParagraph before header:\r#Header\r\rParagraph before blockquote:\r>Some quote.\r") == "

Paragraph and no space:\n* ciao

\n\n

Paragraph and 1 space:\n * ciao

\n\n

Paragraph and 3 spaces:\n * ciao

\n\n

Paragraph and 4 spaces:\n * ciao

\n\n

Paragraph before header:

\n\n

Header

\n\n

Paragraph before blockquote:

\n\n
\n

Some quote.

\n
") - ]. - -utf8_test() -> - [?_assertEqual("

", conv_utf8("†"))]. - diff --git a/src/markdown_tests.hrl b/src/markdown_tests.hrl new file mode 100644 index 0000000..53f54e1 --- /dev/null +++ b/src/markdown_tests.hrl @@ -0,0 +1,286 @@ +%% Do not edit this file - it is generated with ../tests/index.html +unit_test_() -> + [ + ?_assertEqual("
\n\n\n\n\n\n\n
", conv("
\n\n\n\n\n\n\n
\n")), + ?_assertEqual("

\nLets let html through\n

", conv("

\nLets let html through\n

")), + ?_assertEqual("

©

", conv("©")), + ?_assertEqual("

\nLets let html through\n

", conv("

\nLets let html through\n

")), + ?_assertEqual("

\"login\"

", conv("![login](_underscore)")), + ?_assertEqual("

login

", conv("[login](_underscore)")), + ?_assertEqual("
    \n
  1. should be italic
  2. \n
  3. should be bold
  4. \n
  5. should be bold italic
  6. \n
", conv("\n 1. should be *italic*\n 2. should be **bold**\n 3. should be ***bold italic***")), + ?_assertEqual("
    \n
  • should be italic
  • \n
  • should be bold
  • \n
  • should be bold italic
  • \n
", conv("\n - should be *italic*\n - should be **bold**\n - should be ***bold italic***")), + ?_assertEqual("

some stuff yaycode more stuff more code!

", conv("some stuff `yaycode` more stuff `more code!`")), + ?_assertEqual("

\"Button\"

", conv("[![Button](/img/somebutton.png)](http://example.com/some/link)")), + ?_assertEqual("
alice\nbob\n
\n\n

chaz

", conv(" alice\n bob\nchaz")), + ?_assertEqual("
\n

alice\n bob\n chaz

\n
", conv("> alice\n> bob\n> chaz")), + ?_assertEqual("
    \n
  • a
  • \n
  • b
  • \n
", conv(" - a\n - b\n")), + ?_assertEqual("
    \n
  1. a
  2. \n
  3. b
  4. \n
", conv(" 1. a\n 2. b\n")), + ?_assertEqual("

blah \"blah\" blah

", conv("blah ![blah][1] blah\n\n\n [1]: http://example.com (title)")), + ?_assertEqual("

blah \"blah\" blah

", conv("blah ![blah][1] blah\n\n\n [1]: http://example.com \"title\"")), + ?_assertEqual("

blah \"blah\" blah

", conv("blah ![blah][1] blah\n\n\n [1]: http://example.com")), + ?_assertEqual("

Now is the winter of our discontent made glorious summer by this Son of York

", conv("Now is the winter of `our discontent` made glorious summer by this Son of York")), + ?_assertEqual("

blah blah blah

", conv("blah [blah][1] blah\n\n\n [1]: http://example.com (title)")), + ?_assertEqual("

blah blah blah

", conv("blah [blah][1] blah\n\n\n [1]: http://example.com \"title\"")), + ?_assertEqual("

blah blah blah

", conv("blah [blah][1] blah\n\n\n [1]: http://example.com")), + ?_assertEqual("

> blah

", conv("> blah\n-------------")), + ?_assertEqual("", conv(" \n")), + ?_assertEqual("

\"alt

", conv("![alt text][1]\n\n[1]: http://example.com")), + ?_assertEqual("

\"alt

", conv("![alt text][1]\n\n[1]: http://example.com \"optional title\"")), + ?_assertEqual("

link text

", conv("[link text][1]\n\n[1]: http://example.com")), + ?_assertEqual("

link text

", conv("[link text][1]\n\n[1]: http://example.com \"optional title\"")), + ?_assertEqual("

blah

\n\n

bleh

", conv("blah\n\n\nbleh")), + ?_assertEqual("

<div>blah</div>

", conv("`
blah
`")), + ?_assertEqual("

My link test

", conv("My [link][id] test\n[id]: http://example.com")), + ?_assertEqual("

My id test

", conv("My [id] test\n[id]: http://example.com")), + ?_assertEqual("

blah https://something.com:1234/a/path blah\na

", conv("blah blah\na")), + ?_assertEqual("

blah http://something.com:1234/a/path blah\na

", conv("blah blah\na")), + ?_assertEqual("

Some text \"hey\" there\na

", conv("[id]: /a/path\nSome text ![hey] [id] there\na")), + ?_assertEqual("

Some text \"hey\" there\na

", conv("[id]: /a/path\nSome text ![hey][id] there\na")), + ?_assertEqual("

Some text hey there\na

", conv("[id]: \t \t /a/path\nSome text [hey][id] there\na")), + ?_assertEqual("

Some text [id] there\na

", conv("[id]: /a/path\nSome text \\[id] there\na")), + ?_assertEqual("

Some text hey there\na

", conv("[id]: /a/path\nSome text [hey] [id] there\na")), + ?_assertEqual("

Some text hey there\na

", conv("[id]: /a/path\nSome text [hey][id] there\na")), + ?_assertEqual("

an \"\" image\na

", conv("an ![](path/jpg.jpg ) image\na")), + ?_assertEqual("

an \"Alt\" image\na

", conv("an ![Alt](path/jpg.jpg ) image\na")), + ?_assertEqual("

an \"Alt\" image\na

", conv("an ![Alt](path/jpg.jpg 'Title') image\na")), + ?_assertEqual("

an \"Alt\" image\na

", conv("an ![Alt](path/jpg.jpg \"Title\") image\na")), + ?_assertEqual("

an \"Alt\" image\na

", conv("an ![Alt] (path/jpg.jpg \"Title\") image\na")), + ?_assertEqual("

An example of link\na

", conv("An [example](http://example.com/) of link\na")), + ?_assertEqual("

An of link\na

", conv("An [](http://example.com/ \"Title\") of link\na")), + ?_assertEqual("

An example of link\na

", conv("An [example](http://example.com/ 'Title') of link\na")), + ?_assertEqual("

An example of link\na

", conv("An [example](http://example.com/ \"Title\") of link\na")), + ?_assertEqual("

An [example] (http://example.com/ \"Title\") of link\na

", conv("An [example] (http://example.com/ \"Title\") of link\na")), + ?_assertEqual("

a\na

", conv("a\na\n [id]: /example.com")), + ?_assertEqual("

a\na

", conv("a\na\n [id]: http://example.com")), + ?_assertEqual("

a\na

", conv("a\na\n[id]: ")), + ?_assertEqual("

a\na

", conv("a\na\n[id]: http://example.com")), + ?_assertEqual("

a\na

", conv("a\na\n[id]: http://example.com (Title)")), + ?_assertEqual("

a\na

", conv("a\na\n[id]: http://example.com \"Title\"")), + ?_assertEqual("

_blah\na

", conv("___blah\na")), + ?_assertEqual("

---blah\na

", conv("---blah\na")), + ?_assertEqual("

*blah\na

", conv("***blah\na")), + ?_assertEqual("
", conv("_ _ _")), + ?_assertEqual("
", conv("- - -")), + ?_assertEqual("
", conv("* * *")), + ?_assertEqual("
", conv("_____")), + ?_assertEqual("
", conv("-----")), + ?_assertEqual("
", conv("*****")), + ?_assertEqual("
", conv("___")), + ?_assertEqual("
", conv("---")), + ?_assertEqual("
", conv("***")), + ?_assertEqual("
<div>&\n
", conv("\t
&")), + ?_assertEqual("
<div>\n
", conv("\t
")), + ?_assertEqual("
    \n
  • a\n b
  • \n
", conv("+ a\n\t\tb")), + ?_assertEqual("
    \n
  • a\n b
  • \n
", conv("+ a\n \t b")), + ?_assertEqual("
    \n
  • a\n b
  • \n
", conv("+ a\n\t b")), + ?_assertEqual("
b\n
\n\n

c

", conv("\tb\n\n\n\n\nc")), + ?_assertEqual("
b\n
\n\n

c

", conv("\tb\n\n\n\nc")), + ?_assertEqual("
b\n
\n\n

c

", conv("\tb\n\n\nc")), + ?_assertEqual("
b\n
\n\n

c

", conv("\tb\n\nc")), + ?_assertEqual("
b\n
\n\n

c

", conv("\tb\nc")), + ?_assertEqual("
b\n
", conv("\tb")), + ?_assertEqual("
b\n
", conv(" b")), + ?_assertEqual("
    \n
  1. a

  2. \n
  3. b

  4. \n
  5. c

  6. \n
", conv("4. a\n\n5. b\n\n6. c")), + ?_assertEqual("
    \n
  1. a
  2. \n
  3. b
  4. \n
  5. c
  6. \n
", conv("4. a\n5. b\n6. c")), + ?_assertEqual("
    \n
  1. blah\nblah
  2. \n
", conv("4. blah\nblah")), + ?_assertEqual("

555.blah\na

", conv("555.blah\na")), + ?_assertEqual("

555 @blah\na

", conv("555 @blah\na")), + ?_assertEqual("
    \n
  1. blah
  2. \n
", conv("555. blah")), + ?_assertEqual("
    \n
  1. blah
  2. \n
", conv("4. blah")), + ?_assertEqual("
    \n
  1. blah
  2. \n
", conv("1. blah")), + ?_assertEqual("
    \n
  • blah\nblah
  • \n
", conv("- blah\nblah")), + ?_assertEqual("
    \n
  • a

  • \n
  • b

  • \n
  • c

  • \n
  • d
  • \n
", conv("- a\n\n+ b\n\n+ c\n* d")), + ?_assertEqual("
    \n
  • a

  • \n
  • b

  • \n
", conv("- a\n\n+ b")), + ?_assertEqual("
    \n
  • a

    \n\n

    XX+ b

  • \n
", conv("- a\n\n \n\t\n XX+ b")), + ?_assertEqual("
    \n
  • a

    \n\n

    XX+ b

  • \n
", conv("- a\n \n \n\t\n XX+ b")), + ?_assertEqual("
    \n
  • a

    \n\n

    XX+ b

  • \n
", conv("- a\n\n\n\n XX+ b")), + ?_assertEqual("
    \n
  • a
  • \n
\n\n

XX+ b

", conv("- a\n\n\n\nXX+ b")), + ?_assertEqual("
    \n
  • a
  • \n
  • b
  • \n
  • c
  • \n
", conv("- a\n+ b\n- c")), + ?_assertEqual("

-blah\na

", conv("-blah\na")), + ?_assertEqual("
    \n
  • blah
  • \n
", conv("- blah")), + ?_assertEqual("

*blah\na

", conv("*blah\na")), + ?_assertEqual("
    \n
  • blah
  • \n
", conv("* blah")), + ?_assertEqual("

+blah\na

", conv("+blah\na")), + ?_assertEqual("
    \n
  • blah
  • \n
", conv("+ blah")), + ?_assertEqual("

bleh

\n\n
\n

blah

\n
", conv("bleh\n> blah")), + ?_assertEqual("
\n

blah\n a

\n
", conv("> blah\na")), + ?_assertEqual("

blahblah

\n\n

bleh

", conv("# blahblah ###\nbleh")), + ?_assertEqual("
# blahblah
\n\n

bleh

", conv("####### blahblah\nbleh")), + ?_assertEqual("
blahblah
\n\n

bleh

", conv("###### blahblah\nbleh")), + ?_assertEqual("
blahblah
\n\n

bleh

", conv("##### blahblah\nbleh")), + ?_assertEqual("

blahblah

\n\n

bleh

", conv("#### blahblah\nbleh")), + ?_assertEqual("

blahblah

\n\n

bleh

", conv("### blahblah\nbleh")), + ?_assertEqual("

blahblah

\n\n

bleh

", conv("## blahblah\nbleh")), + ?_assertEqual("

blahblah

\n\n

bleh

", conv("# blahblah\nbleh")), + ?_assertEqual("

blahblah

", conv("# blahblah ###")), + ?_assertEqual("
# blahblah
", conv("####### blahblah")), + ?_assertEqual("
blahblah
", conv("###### blahblah")), + ?_assertEqual("
blahblah
", conv("##### blahblah")), + ?_assertEqual("

blahblah

", conv("#### blahblah")), + ?_assertEqual("

blahblah

", conv("### blahblah")), + ?_assertEqual("

blahblah

", conv("## blahblah")), + ?_assertEqual("

blahblah

", conv("# blahblah")), + ?_assertEqual("

> a

", conv("> a\n-")), + ?_assertEqual("

> a

", conv("> a\n=")), + ?_assertEqual("

blahblah

\n\n

blah

", conv("blahblah\n-----\nblah")), + ?_assertEqual("

blahblah

\n\n

blah

", conv("blahblah\n====\nblah")), + ?_assertEqual("

blahblah

", conv("blahblah\n-----")), + ?_assertEqual("

blahblah

", conv("blahblah\n====")), + % ?_assertEqual("

blah\nblah

", conv("blah\r\nblah\n")), + % ?_assertEqual("

blah\nblah

", conv("blah\r\nblah")), + ?_assertEqual("

blah\nblah

", conv("blah\nblah")), + ?_assertEqual("

you sad bastard\na

", conv("___you___ sad bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("__you__ sad bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("_you_ sad bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("***you*** sad bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("**you** sad bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("*you* sad bastard\na")), + ?_assertEqual("

you _sad_ bastard\na

", conv("you \\_sad\\_ bastard\na")), + ?_assertEqual("

you *sad* bastard\na

", conv("you \\*sad\\* bastard\na")), + ?_assertEqual("

yousadbastard\na

", conv("you_sad_bastard\na")), + ?_assertEqual("

yousadbastard\na

", conv("you*sad*bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("you ___sad___ bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("you __sad__ bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("you _sad_ bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("you ***sad*** bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("you **sad** bastard\na")), + ?_assertEqual("

you sad bastard\na

", conv("you *sad* bastard\na")), + ?_assertEqual("
#
\n\n

a

", conv("########\na")), + ?_assertEqual("
#
\n\n

a

", conv("#######\na")), + ?_assertEqual("
#
\n\n

a

", conv("######\na")), + ?_assertEqual("

#

\n\n

a

", conv("#####\na")), + ?_assertEqual("

#

\n\n

a

", conv("####\na")), + ?_assertEqual("

#

\n\n

a

", conv("###\na")), + ?_assertEqual("

#

\n\n

a

", conv("##\na")), + ?_assertEqual("

#\na

", conv("#\na")), + ?_assertEqual("

[\na

", conv("\n[\na")), + ?_assertEqual("

>\na

", conv("\n>\na")), + ?_assertEqual("

-\na

", conv("\n-\na")), + ?_assertEqual("

=\na

", conv("\n=\na")), + ?_assertEqual("

[\na

", conv("[\na")), + ?_assertEqual("

>\na

", conv(">\na")), + ?_assertEqual("

-\na

", conv("-\na")), + ?_assertEqual("

=\na

", conv("=\na")), + ?_assertEqual("

abc`def\na

", conv("abc\\`def\na")), + ?_assertEqual("

xyz\nab:c\na

", conv("xyz\r\nab:c\na")), + ?_assertEqual("

xyz\nab:c\na

", conv("xyz\nab:c\na")), + ?_assertEqual("

xyz ab:c\na

", conv("xyz\tab:c\na")), + ?_assertEqual("

xyz ab:c\na

", conv("xyz ab:c\na")), + ?_assertEqual("

xyz(ab:c\na

", conv("xyz(ab:c\na")), + ?_assertEqual("

xyz]ab:c\na

", conv("xyz]ab:c\na")), + ?_assertEqual("

xyz[ab:c\na

", conv("xyz[ab:c\na")), + ?_assertEqual("

xyz)ab:c\na

", conv("xyz)ab:c\na")), + ?_assertEqual("

xyz(ab:c\na

", conv("xyz(ab:c\na")), + ?_assertEqual("

xyz/ab:c\na

", conv("xyz/ab:c\na")), + ?_assertEqual("

xyz\\ab:c\na

", conv("xyz\\ab:c\na")), + ?_assertEqual("

xyz!ab:c\na

", conv("xyz!ab:c\na")), + ?_assertEqual("

xyz`ab:c\na

", conv("xyz`ab:c\na")), + ?_assertEqual("

xyz\"ab:c\na

", conv("xyz\"ab:c\na")), + ?_assertEqual("

xyz'ab:c\na

", conv("xyz'ab:c\na")), + ?_assertEqual("

xyz:ab:c\na

", conv("xyz:ab:c\na")), + ?_assertEqual("

xyz.ab:c\na

", conv("xyz.ab:c\na")), + ?_assertEqual("

xyz0ab:c\na

", conv("xyz0ab:c\na")), + ?_assertEqual("

xyz9ab:c\na

", conv("xyz9ab:c\na")), + ?_assertEqual("

xyz8ab:c\na

", conv("xyz8ab:c\na")), + ?_assertEqual("

xyz7ab:c\na

", conv("xyz7ab:c\na")), + ?_assertEqual("

xyz6ab:c\na

", conv("xyz6ab:c\na")), + ?_assertEqual("

xyz5ab:c\na

", conv("xyz5ab:c\na")), + ?_assertEqual("

xyz4ab:c\na

", conv("xyz4ab:c\na")), + ?_assertEqual("

xyz3ab:c\na

", conv("xyz3ab:c\na")), + ?_assertEqual("

xyz2ab:c\na

", conv("xyz2ab:c\na")), + ?_assertEqual("

xyz1ab:c\na

", conv("xyz1ab:c\na")), + ?_assertEqual("

xyz_ab:c\na

", conv("xyz_ab:c\na")), + ?_assertEqual("

xyz*ab:c\na

", conv("xyz*ab:c\na")), + ?_assertEqual("

xyz+ab:c\na

", conv("xyz+ab:c\na")), + ?_assertEqual("

xyz>ab:c\na

", conv("xyz>ab:c\na")), + ?_assertEqual("

xyz#ab:c\na

", conv("xyz#ab:c\na")), + ?_assertEqual("

xyz-ab:c\na

", conv("xyz-ab:c\na")), + ?_assertEqual("

xyz=ab:c\na

", conv("xyz=ab:c\na")), + ?_assertEqual("

xyz/ab:c\na

", conv("xyz/ab:c\na")), + ?_assertEqual("

ab:c\na

", conv("\r\n ab:c\na")), + ?_assertEqual("

ab:c\na

", conv("\n ab:c\na")), + ?_assertEqual("
 ab:c\n
\n\n

a

", conv("\t ab:c\na")), + ?_assertEqual("

ab:c\na

", conv(" ab:c\na")), + ?_assertEqual("

( ab:c\na

", conv("( ab:c\na")), + ?_assertEqual("

] ab:c\na

", conv("] ab:c\na")), + ?_assertEqual("

[ ab:c\na

", conv("[ ab:c\na")), + ?_assertEqual("

) ab:c\na

", conv(") ab:c\na")), + ?_assertEqual("

( ab:c\na

", conv("( ab:c\na")), + ?_assertEqual("

/ ab:c\na

", conv("/ ab:c\na")), + ?_assertEqual("

\\ ab:c\na

", conv("\\ ab:c\na")), + ?_assertEqual("

! ab:c\na

", conv("! ab:c\na")), + ?_assertEqual("

` ab:c\na

", conv("` ab:c\na")), + ?_assertEqual("

\" ab:c\na

", conv("\" ab:c\na")), + ?_assertEqual("

' ab:c\na

", conv("' ab:c\na")), + ?_assertEqual("

: ab:c\na

", conv(": ab:c\na")), + ?_assertEqual("

. ab:c\na

", conv(". ab:c\na")), + ?_assertEqual("

0 ab:c\na

", conv("0 ab:c\na")), + ?_assertEqual("

9 ab:c\na

", conv("9 ab:c\na")), + ?_assertEqual("

8 ab:c\na

", conv("8 ab:c\na")), + ?_assertEqual("

7 ab:c\na

", conv("7 ab:c\na")), + ?_assertEqual("

6 ab:c\na

", conv("6 ab:c\na")), + ?_assertEqual("

5 ab:c\na

", conv("5 ab:c\na")), + ?_assertEqual("

4 ab:c\na

", conv("4 ab:c\na")), + ?_assertEqual("

3 ab:c\na

", conv("3 ab:c\na")), + ?_assertEqual("

2 ab:c\na

", conv("2 ab:c\na")), + ?_assertEqual("

1 ab:c\na

", conv("1 ab:c\na")), + ?_assertEqual("

_ ab:c\na

", conv("_ ab:c\na")), + ?_assertEqual("
    \n
  • ab:c\na
  • \n
", conv("* ab:c\na")), + ?_assertEqual("
    \n
  • ab:c\na
  • \n
", conv("+ ab:c\na")), + ?_assertEqual("
\n

ab:c\n a

\n
", conv("> ab:c\na")), + ?_assertEqual("

ab:c

\n\n

a

", conv("# ab:c\na")), + ?_assertEqual("
    \n
  • ab:c\na
  • \n
", conv("- ab:c\na")), + ?_assertEqual("

= ab:c\na

", conv("= ab:c\na")), + ?_assertEqual("

/ ab:c\na

", conv("/ ab:c\na")), + ?_assertEqual("

< /ab:c\na

", conv("< /ab:c\na")), + ?_assertEqual("

< ab:c\na

", conv("< ab:c\na")), + ?_assertEqual("

ab:c\na

", conv("\r\nab:c\na")), + ?_assertEqual("

ab:c\na

", conv("\nab:c\na")), + ?_assertEqual("
ab:c\n
\n\n

a

", conv("\tab:c\na")), + ?_assertEqual("

ab:c\na

", conv(" ab:c\na")), + ?_assertEqual("

(ab:c\na

", conv("(ab:c\na")), + ?_assertEqual("

]ab:c\na

", conv("]ab:c\na")), + ?_assertEqual("

[ab:c\na

", conv("[ab:c\na")), + ?_assertEqual("

)ab:c\na

", conv(")ab:c\na")), + ?_assertEqual("

(ab:c\na

", conv("(ab:c\na")), + ?_assertEqual("

/ab:c\na

", conv("/ab:c\na")), + ?_assertEqual("

\\ab:c\na

", conv("\\ab:c\na")), + ?_assertEqual("

!ab:c\na

", conv("!ab:c\na")), + ?_assertEqual("

`ab:c\na

", conv("`ab:c\na")), + ?_assertEqual("

\"ab:c\na

", conv("\"ab:c\na")), + ?_assertEqual("

'ab:c\na

", conv("'ab:c\na")), + ?_assertEqual("

:ab:c\na

", conv(":ab:c\na")), + ?_assertEqual("

.ab:c\na

", conv(".ab:c\na")), + ?_assertEqual("

0ab:c\na

", conv("0ab:c\na")), + ?_assertEqual("

9ab:c\na

", conv("9ab:c\na")), + ?_assertEqual("

8ab:c\na

", conv("8ab:c\na")), + ?_assertEqual("

7ab:c\na

", conv("7ab:c\na")), + ?_assertEqual("

6ab:c\na

", conv("6ab:c\na")), + ?_assertEqual("

5ab:c\na

", conv("5ab:c\na")), + ?_assertEqual("

4ab:c\na

", conv("4ab:c\na")), + ?_assertEqual("

3ab:c\na

", conv("3ab:c\na")), + ?_assertEqual("

2ab:c\na

", conv("2ab:c\na")), + ?_assertEqual("

1ab:c\na

", conv("1ab:c\na")), + ?_assertEqual("

_ab:c\na

", conv("_ab:c\na")), + ?_assertEqual("

*ab:c\na

", conv("*ab:c\na")), + ?_assertEqual("

+ab:c\na

", conv("+ab:c\na")), + ?_assertEqual("
\n

ab:c\n a

\n
", conv(">ab:c\na")), + ?_assertEqual("

ab:c

\n\n

a

", conv("#ab:c\na")), + ?_assertEqual("

-ab:c\na

", conv("-ab:c\na")), + ?_assertEqual("

=ab:c\na

", conv("=ab:c\na")), + ?_assertEqual("

/ab:c\na

", conv("/ab:c\na")), + ?_assertEqual("

Hey\nHo!
\nLets Go

", conv(" \nHey\nHo! \nLets Go")), + ?_assertEqual("

Hey Ho
\nLets Go

", conv("Hey Ho\t\nLets Go")), + ?_assertEqual("

Hey Ho
\nLets Go

", conv("Hey Ho \nLets Go")), + ?_assertEqual("

Hey\nHo!\nHardy

", conv("Hey\nHo!\nHardy\n\n")), + ?_assertEqual("

Hey Ho!\na

", conv("Hey Ho!\na")), + ?_assertEqual("

3 <4\na

", conv(" 3 <4\na")), + ?_assertEqual("

3 < 4\na

", conv(" 3 < 4\na")), + ?_assertEqual("

3 > 4\na

", conv("3 > 4\na")), + ?_assertEqual("

a\nb\nc

", conv("a\nb\nc\n \n\t\n ")), + ?_assertEqual("

a\nb\nc

", conv("a\nb\nc\n\n\n")), + ?_assertEqual("", conv(" \n")), + ?_assertEqual("", conv("\t\n")), + ?_assertEqual("", conv("\n\n")), + ?_assertEqual("", conv("\n")) + ].