patcito-maruku 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. data/AUTHORS +23 -0
  2. data/LICENSE +340 -0
  3. data/README.md +73 -0
  4. data/bin/maruku +196 -0
  5. data/bin/marutex +4 -0
  6. data/data/entities.xml +261 -0
  7. data/docs/changelog.md +334 -0
  8. data/docs/div_syntax.md +36 -0
  9. data/docs/entity_test.md +23 -0
  10. data/docs/markdown_syntax.md +899 -0
  11. data/docs/maruku.md +346 -0
  12. data/docs/math.md +194 -0
  13. data/docs/other_stuff.md +51 -0
  14. data/docs/proposal.md +309 -0
  15. data/docs/website/src/bluecloth.md +25 -0
  16. data/docs/website/src/download.md +31 -0
  17. data/docs/website/src/maruku.md +261 -0
  18. data/docs/website/src/proposal.md +271 -0
  19. data/lib/maruku.rb +132 -0
  20. data/lib/maruku/attributes.rb +138 -0
  21. data/lib/maruku/defaults.rb +69 -0
  22. data/lib/maruku/errors.rb +89 -0
  23. data/lib/maruku/ext/div.rb +121 -0
  24. data/lib/maruku/ext/fenced_code.rb +78 -0
  25. data/lib/maruku/ext/math.rb +37 -0
  26. data/lib/maruku/ext/math/elements.rb +21 -0
  27. data/lib/maruku/ext/math/latex_fix.rb +12 -0
  28. data/lib/maruku/ext/math/mathml_engines/blahtex.rb +93 -0
  29. data/lib/maruku/ext/math/mathml_engines/itex2mml.rb +39 -0
  30. data/lib/maruku/ext/math/mathml_engines/none.rb +21 -0
  31. data/lib/maruku/ext/math/mathml_engines/ritex.rb +24 -0
  32. data/lib/maruku/ext/math/parsing.rb +125 -0
  33. data/lib/maruku/ext/math/to_html.rb +237 -0
  34. data/lib/maruku/ext/math/to_latex.rb +36 -0
  35. data/lib/maruku/ext/yaml.rb +43 -0
  36. data/lib/maruku/helpers.rb +214 -0
  37. data/lib/maruku/input/charsource.rb +326 -0
  38. data/lib/maruku/input/extensions.rb +69 -0
  39. data/lib/maruku/input/html_helper.rb +189 -0
  40. data/lib/maruku/input/linesource.rb +111 -0
  41. data/lib/maruku/input/parse_block.rb +608 -0
  42. data/lib/maruku/input/parse_doc.rb +240 -0
  43. data/lib/maruku/input/parse_span_better.rb +746 -0
  44. data/lib/maruku/input/rubypants.rb +225 -0
  45. data/lib/maruku/input/type_detection.rb +147 -0
  46. data/lib/maruku/input_textile2/t2_parser.rb +163 -0
  47. data/lib/maruku/maruku.rb +31 -0
  48. data/lib/maruku/output/s5/fancy.rb +756 -0
  49. data/lib/maruku/output/s5/to_s5.rb +138 -0
  50. data/lib/maruku/output/to_html.rb +994 -0
  51. data/lib/maruku/output/to_latex.rb +580 -0
  52. data/lib/maruku/output/to_latex_entities.rb +101 -0
  53. data/lib/maruku/output/to_latex_strings.rb +64 -0
  54. data/lib/maruku/output/to_markdown.rb +164 -0
  55. data/lib/maruku/output/to_s.rb +54 -0
  56. data/lib/maruku/string_utils.rb +185 -0
  57. data/lib/maruku/structures.rb +143 -0
  58. data/lib/maruku/structures_inspect.rb +51 -0
  59. data/lib/maruku/structures_iterators.rb +48 -0
  60. data/lib/maruku/textile2.rb +1 -0
  61. data/lib/maruku/toc.rb +214 -0
  62. data/lib/maruku/usage/example1.rb +33 -0
  63. data/lib/maruku/version +0 -0
  64. data/lib/maruku/version.rb +54 -0
  65. data/spec/block_docs/abbreviations.md +52 -0
  66. data/spec/block_docs/alt.md +17 -0
  67. data/spec/block_docs/attributes/att2.md +20 -0
  68. data/spec/block_docs/attributes/att3.md +28 -0
  69. data/spec/block_docs/attributes/attributes.md +57 -0
  70. data/spec/block_docs/attributes/circular.md +26 -0
  71. data/spec/block_docs/attributes/default.md +22 -0
  72. data/spec/block_docs/blank.md +24 -0
  73. data/spec/block_docs/blanks_in_code.md +75 -0
  74. data/spec/block_docs/bug_def.md +16 -0
  75. data/spec/block_docs/bug_table.md +46 -0
  76. data/spec/block_docs/code.md +34 -0
  77. data/spec/block_docs/code2.md +28 -0
  78. data/spec/block_docs/code3.md +71 -0
  79. data/spec/block_docs/data_loss.md +25 -0
  80. data/spec/block_docs/divs/div1.md +167 -0
  81. data/spec/block_docs/divs/div2.md +21 -0
  82. data/spec/block_docs/divs/div3_nest.md +45 -0
  83. data/spec/block_docs/easy.md +15 -0
  84. data/spec/block_docs/email.md +20 -0
  85. data/spec/block_docs/encoding/iso-8859-1.md +23 -0
  86. data/spec/block_docs/encoding/utf-8.md +18 -0
  87. data/spec/block_docs/entities.md +94 -0
  88. data/spec/block_docs/escaping.md +67 -0
  89. data/spec/block_docs/extra_dl.md +52 -0
  90. data/spec/block_docs/extra_header_id.md +63 -0
  91. data/spec/block_docs/extra_table1.md +37 -0
  92. data/spec/block_docs/footnotes.md +97 -0
  93. data/spec/block_docs/headers.md +37 -0
  94. data/spec/block_docs/hex_entities.md +37 -0
  95. data/spec/block_docs/hrule.md +39 -0
  96. data/spec/block_docs/html2.md +22 -0
  97. data/spec/block_docs/html3.md +31 -0
  98. data/spec/block_docs/html4.md +25 -0
  99. data/spec/block_docs/html5.md +23 -0
  100. data/spec/block_docs/ie.md +49 -0
  101. data/spec/block_docs/images.md +90 -0
  102. data/spec/block_docs/images2.md +31 -0
  103. data/spec/block_docs/inline_html.md +152 -0
  104. data/spec/block_docs/inline_html2.md +21 -0
  105. data/spec/block_docs/links.md +152 -0
  106. data/spec/block_docs/links2.md +22 -0
  107. data/spec/block_docs/list1.md +46 -0
  108. data/spec/block_docs/list12.md +28 -0
  109. data/spec/block_docs/list2.md +56 -0
  110. data/spec/block_docs/list3.md +64 -0
  111. data/spec/block_docs/list4.md +89 -0
  112. data/spec/block_docs/lists.md +192 -0
  113. data/spec/block_docs/lists10.md +34 -0
  114. data/spec/block_docs/lists11.md +23 -0
  115. data/spec/block_docs/lists6.md +41 -0
  116. data/spec/block_docs/lists9.md +64 -0
  117. data/spec/block_docs/lists_after_paragraph.md +208 -0
  118. data/spec/block_docs/lists_ol.md +262 -0
  119. data/spec/block_docs/loss.md +16 -0
  120. data/spec/block_docs/math/equations.md +45 -0
  121. data/spec/block_docs/math/inline.md +46 -0
  122. data/spec/block_docs/math/math2.md +45 -0
  123. data/spec/block_docs/math/notmath.md +25 -0
  124. data/spec/block_docs/math/table.md +25 -0
  125. data/spec/block_docs/math/table2.md +42 -0
  126. data/spec/block_docs/misc_sw.md +525 -0
  127. data/spec/block_docs/notyet/escape.md +21 -0
  128. data/spec/block_docs/notyet/header_after_par.md +58 -0
  129. data/spec/block_docs/notyet/ticks.md +18 -0
  130. data/spec/block_docs/notyet/triggering.md +157 -0
  131. data/spec/block_docs/olist.md +45 -0
  132. data/spec/block_docs/one.md +15 -0
  133. data/spec/block_docs/paragraph.md +16 -0
  134. data/spec/block_docs/paragraph_rules/dont_merge_ref.md +42 -0
  135. data/spec/block_docs/paragraph_rules/tab_is_blank.md +24 -0
  136. data/spec/block_docs/paragraphs.md +46 -0
  137. data/spec/block_docs/pending/amps.md +15 -0
  138. data/spec/block_docs/pending/empty_cells.md +37 -0
  139. data/spec/block_docs/pending/link.md +72 -0
  140. data/spec/block_docs/pending/ref.md +21 -0
  141. data/spec/block_docs/recover/recover_links.md +15 -0
  142. data/spec/block_docs/red_tests/abbrev.md +679 -0
  143. data/spec/block_docs/red_tests/lists7.md +32 -0
  144. data/spec/block_docs/red_tests/lists7b.md +65 -0
  145. data/spec/block_docs/red_tests/lists8.md +42 -0
  146. data/spec/block_docs/red_tests/ref.md +23 -0
  147. data/spec/block_docs/red_tests/xml.md +35 -0
  148. data/spec/block_docs/references/long_example.md +71 -0
  149. data/spec/block_docs/references/spaces_and_numbers.md +15 -0
  150. data/spec/block_docs/smartypants.md +114 -0
  151. data/spec/block_docs/syntax_hl.md +52 -0
  152. data/spec/block_docs/table_attributes.md +34 -0
  153. data/spec/block_docs/test.md +19 -0
  154. data/spec/block_docs/underscore_in_words.md +15 -0
  155. data/spec/block_docs/wrapping.md +67 -0
  156. data/spec/block_docs/xml2.md +19 -0
  157. data/spec/block_docs/xml3.md +26 -0
  158. data/spec/block_docs/xml_instruction.md +52 -0
  159. data/spec/block_spec.rb +49 -0
  160. data/spec/span_spec.rb +254 -0
  161. data/spec/spec_helper.rb +6 -0
  162. metadata +247 -0
@@ -0,0 +1,36 @@
1
+ ## Option number 1 ##
2
+
3
+ * `[ ]{0,3}\+={2,}` pushes the stack
4
+ * `[ ]{0,3}\-={2,}` pops the stack
5
+
6
+ +================ {#id}
7
+ IAL can be put on the same line of a push
8
+
9
+ +== {#id2}
10
+ Or on the same line of a pop:
11
+ -==
12
+
13
+ -==============
14
+
15
+ ## Option number 2 ##
16
+
17
+ Double braces:
18
+
19
+ {{
20
+
21
+ }}{}
22
+
23
+ I don't like, it gets too messy because there are
24
+ too many braces.
25
+
26
+
27
+
28
+ +================ {#id}
29
+
30
+ nested div:
31
+
32
+ +========================
33
+ inside nested DIV
34
+ -========================
35
+
36
+ -==============
@@ -0,0 +1,23 @@
1
+
2
+ List of symbols supported by Maruku
3
+ ===================================
4
+
5
+ <?maruku
6
+ MaRuKu::Out::Latex.need_entity_table
7
+
8
+ all = []
9
+ ENTITY_TABLE.each do |k, e|
10
+ if k.kind_of? String
11
+ all << (h=md_code("&#{e.html_entity};")) <<
12
+ " " << md_entity(e.html_entity) <<
13
+ " (" << (l=md_code(e.latex_string)) << ") \n" <<
14
+ md_entity('nbsp')<<md_entity('nbsp')<<md_entity('nbsp')
15
+
16
+ h.attributes[:code_background_color] = '#eef'
17
+ l.attributes[:code_background_color] = '#ffe'
18
+ end
19
+ end
20
+ @doc.children.push md_par(all)
21
+
22
+ ?>
23
+
@@ -0,0 +1,899 @@
1
+ css: style.css
2
+
3
+ Markdown: Syntax
4
+ ================
5
+
6
+ <ul id="ProjectSubmenu">
7
+ <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
8
+ <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
9
+ <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
10
+ <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
11
+ <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
12
+ </ul>
13
+
14
+
15
+ * [Overview](#overview)
16
+ * [Philosophy](#philosophy)
17
+ * [Inline HTML](#html)
18
+ * [Automatic Escaping for Special Characters](#autoescape)
19
+ * [Block Elements](#block)
20
+ * [Paragraphs and Line Breaks](#p)
21
+ * [Headers](#header)
22
+ * [Blockquotes](#blockquote)
23
+ * [Lists](#list)
24
+ * [Code Blocks](#precode)
25
+ * [Horizontal Rules](#hr)
26
+ * [Span Elements](#span)
27
+ * [Links](#link)
28
+ * [Emphasis](#em)
29
+ * [Code](#code)
30
+ * [Images](#img)
31
+ * [Miscellaneous](#misc)
32
+ * [Backslash Escapes](#backslash)
33
+ * [Automatic Links](#autolink)
34
+
35
+
36
+ **Note:** This document is itself written using Markdown; you
37
+ can [see the source for it by adding '.text' to the URL][src].
38
+
39
+ [src]: /projects/markdown/syntax.text
40
+
41
+ * * *
42
+
43
+ <h2 id="overview">Overview</h2>
44
+
45
+ <h3 id="philosophy">Philosophy</h3>
46
+
47
+ Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
48
+
49
+ Readability, however, is emphasized above all else. A Markdown-formatted
50
+ document should be publishable as-is, as plain text, without looking
51
+ like it's been marked up with tags or formatting instructions. While
52
+ Markdown's syntax has been influenced by several existing text-to-HTML
53
+ filters -- including [Setext] [1], [atx] [2], [Textile] [3], [reStructuredText] [4],
54
+ [Grutatext] [5], and [EtText] [6] -- the single biggest source of
55
+ inspiration for Markdown's syntax is the format of plain text email.
56
+
57
+ [1]: http://docutils.sourceforge.net/mirror/setext.html
58
+ [2]: http://www.aaronsw.com/2002/atx/
59
+ [3]: http://textism.com/tools/textile/
60
+ [4]: http://docutils.sourceforge.net/rst.html
61
+ [5]: http://www.triptico.com/software/grutatxt.html
62
+ [6]: http://ettext.taint.org/doc/
63
+
64
+ To this end, Markdown's syntax is comprised entirely of punctuation
65
+ characters, which punctuation characters have been carefully chosen so
66
+ as to look like what they mean. E.g., asterisks around a word actually
67
+ look like \*emphasis\*. Markdown lists look like, well, lists. Even
68
+ blockquotes look like quoted passages of text, assuming you've ever
69
+ used email.
70
+
71
+
72
+
73
+ <h3 id="html">Inline HTML</h3>
74
+
75
+ Markdown's syntax is intended for one purpose: to be used as a
76
+ format for *writing* for the web.
77
+
78
+ Markdown is not a replacement for HTML, or even close to it. Its
79
+ syntax is very small, corresponding only to a very small subset of
80
+ HTML tags. The idea is *not* to create a syntax that makes it easier
81
+ to insert HTML tags. In my opinion, HTML tags are already easy to
82
+ insert. The idea for Markdown is to make it easy to read, write, and
83
+ edit prose. HTML is a *publishing* format; Markdown is a *writing*
84
+ format. Thus, Markdown's formatting syntax only addresses issues that
85
+ can be conveyed in plain text.
86
+
87
+ For any markup that is not covered by Markdown's syntax, you simply
88
+ use HTML itself. There's no need to preface it or delimit it to
89
+ indicate that you're switching from Markdown to HTML; you just use
90
+ the tags.
91
+
92
+ The only restrictions are that block-level HTML elements -- e.g. `<div>`,
93
+ `<table>`, `<pre>`, `<p>`, etc. -- must be separated from surrounding
94
+ content by blank lines, and the start and end tags of the block should
95
+ not be indented with tabs or spaces. Markdown is smart enough not
96
+ to add extra (unwanted) `<p>` tags around HTML block-level tags.
97
+
98
+ For example, to add an HTML table to a Markdown article:
99
+
100
+ This is a regular paragraph.
101
+
102
+ <table>
103
+ <tr>
104
+ <td>Foo</td>
105
+ </tr>
106
+ </table>
107
+
108
+ This is another regular paragraph.
109
+
110
+ Note that Markdown formatting syntax is not processed within block-level
111
+ HTML tags. E.g., you can't use Markdown-style `*emphasis*` inside an
112
+ HTML block.
113
+
114
+ Span-level HTML tags -- e.g. `<span>`, `<cite>`, or `<del>` -- can be
115
+ used anywhere in a Markdown paragraph, list item, or header. If you
116
+ want, you can even use HTML tags instead of Markdown formatting; e.g. if
117
+ you'd prefer to use HTML `<a>` or `<img>` tags instead of Markdown's
118
+ link or image syntax, go right ahead.
119
+
120
+ Unlike block-level HTML tags, Markdown syntax *is* processed within
121
+ span-level tags.
122
+
123
+
124
+ <h3 id="autoescape">Automatic Escaping for Special Characters</h3>
125
+
126
+ In HTML, there are two characters that demand special treatment: `<`
127
+ and `&`. Left angle brackets are used to start tags; ampersands are
128
+ used to denote HTML entities. If you want to use them as literal
129
+ characters, you must escape them as entities, e.g. `&lt;`, and
130
+ `&amp;`.
131
+
132
+ Ampersands in particular are bedeviling for web writers. If you want to
133
+ write about 'AT&T', you need to write '`AT&amp;T`'. You even need to
134
+ escape ampersands within URLs. Thus, if you want to link to:
135
+
136
+ http://images.google.com/images?num=30&q=larry+bird
137
+
138
+ you need to encode the URL as:
139
+
140
+ http://images.google.com/images?num=30&amp;q=larry+bird
141
+
142
+ in your anchor tag `href` attribute. Needless to say, this is easy to
143
+ forget, and is probably the single most common source of HTML validation
144
+ errors in otherwise well-marked-up web sites.
145
+
146
+ Markdown allows you to use these characters naturally, taking care of
147
+ all the necessary escaping for you. If you use an ampersand as part of
148
+ an HTML entity, it remains unchanged; otherwise it will be translated
149
+ into `&amp;`.
150
+
151
+ So, if you want to include a copyright symbol in your article, you can write:
152
+
153
+ &copy;
154
+
155
+ and Markdown will leave it alone. But if you write:
156
+
157
+ AT&T
158
+
159
+ Markdown will translate it to:
160
+
161
+ AT&amp;T
162
+
163
+ Similarly, because Markdown supports [inline HTML](#html), if you use
164
+ angle brackets as delimiters for HTML tags, Markdown will treat them as
165
+ such. But if you write:
166
+
167
+ 4 < 5
168
+
169
+ Markdown will translate it to:
170
+
171
+ 4 &lt; 5
172
+
173
+ However, inside Markdown code spans and blocks, angle brackets and
174
+ ampersands are *always* encoded automatically. This makes it easy to use
175
+ Markdown to write about HTML code. (As opposed to raw HTML, which is a
176
+ terrible format for writing about HTML syntax, because every single `<`
177
+ and `&` in your example code needs to be escaped.)
178
+
179
+
180
+ * * *
181
+
182
+
183
+ <h2 id="block">Block Elements</h2>
184
+
185
+
186
+ <h3 id="p">Paragraphs and Line Breaks</h3>
187
+
188
+ A paragraph is simply one or more consecutive lines of text, separated
189
+ by one or more blank lines. (A blank line is any line that looks like a
190
+ blank line -- a line containing nothing but spaces or tabs is considered
191
+ blank.) Normal paragraphs should not be indented with spaces or tabs.
192
+
193
+ The implication of the "one or more consecutive lines of text" rule is
194
+ that Markdown supports "hard-wrapped" text paragraphs. This differs
195
+ significantly from most other text-to-HTML formatters (including Movable
196
+ Type's "Convert Line Breaks" option) which translate every line break
197
+ character in a paragraph into a `<br />` tag.
198
+
199
+ When you *do* want to insert a `<br />` break tag using Markdown, you
200
+ end a line with two or more spaces, then type return.
201
+
202
+ Yes, this takes a tad more effort to create a `<br />`, but a simplistic
203
+ "every line break is a `<br />`" rule wouldn't work for Markdown.
204
+ Markdown's email-style [blockquoting][bq] and multi-paragraph [list items][l]
205
+ work best -- and look better -- when you format them with hard breaks.
206
+
207
+ [bq]: #blockquote
208
+ [l]: #list
209
+
210
+
211
+
212
+ <h3 id="header">Headers</h3>
213
+
214
+ Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
215
+
216
+ Setext-style headers are "underlined" using equal signs (for first-level
217
+ headers) and dashes (for second-level headers). For example:
218
+
219
+ This is an H1
220
+ =============
221
+
222
+ This is an H2
223
+ -------------
224
+
225
+ Any number of underlining `=`'s or `-`'s will work.
226
+
227
+ Atx-style headers use 1-6 hash characters at the start of the line,
228
+ corresponding to header levels 1-6. For example:
229
+
230
+ # This is an H1
231
+
232
+ ## This is an H2
233
+
234
+ ###### This is an H6
235
+
236
+ Optionally, you may "close" atx-style headers. This is purely
237
+ cosmetic -- you can use this if you think it looks better. The
238
+ closing hashes don't even need to match the number of hashes
239
+ used to open the header. (The number of opening hashes
240
+ determines the header level.) :
241
+
242
+ # This is an H1 #
243
+
244
+ ## This is an H2 ##
245
+
246
+ ### This is an H3 ######
247
+
248
+
249
+ <h3 id="blockquote">Blockquotes</h3>
250
+
251
+ Markdown uses email-style `>` characters for blockquoting. If you're
252
+ familiar with quoting passages of text in an email message, then you
253
+ know how to create a blockquote in Markdown. It looks best if you hard
254
+ wrap the text and put a `>` before every line:
255
+
256
+ > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
257
+ > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
258
+ > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
259
+ >
260
+ > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
261
+ > id sem consectetuer libero luctus adipiscing.
262
+
263
+ Markdown allows you to be lazy and only put the `>` before the first
264
+ line of a hard-wrapped paragraph:
265
+
266
+ > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
267
+ consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
268
+ Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
269
+
270
+ > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
271
+ id sem consectetuer libero luctus adipiscing.
272
+
273
+ Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
274
+ adding additional levels of `>`:
275
+
276
+ > This is the first level of quoting.
277
+ >
278
+ > > This is nested blockquote.
279
+ >
280
+ > Back to the first level.
281
+
282
+ Blockquotes can contain other Markdown elements, including headers, lists,
283
+ and code blocks:
284
+
285
+ > ## This is a header.
286
+ >
287
+ > 1. This is the first list item.
288
+ > 2. This is the second list item.
289
+ >
290
+ > Here's some example code:
291
+ >
292
+ > return shell_exec("echo $input | $markdown_script");
293
+
294
+ Any decent text editor should make email-style quoting easy. For
295
+ example, with BBEdit, you can make a selection and choose Increase
296
+ Quote Level from the Text menu.
297
+
298
+
299
+ <h3 id="list">Lists</h3>
300
+
301
+ Markdown supports ordered (numbered) and unordered (bulleted) lists.
302
+
303
+ Unordered lists use asterisks, pluses, and hyphens -- interchangably
304
+ -- as list markers:
305
+
306
+ * Red
307
+ * Green
308
+ * Blue
309
+
310
+ is equivalent to:
311
+
312
+ + Red
313
+ + Green
314
+ + Blue
315
+
316
+ and:
317
+
318
+ - Red
319
+ - Green
320
+ - Blue
321
+
322
+ Ordered lists use numbers followed by periods:
323
+
324
+ 1. Bird
325
+ 2. McHale
326
+ 3. Parish
327
+
328
+ It's important to note that the actual numbers you use to mark the
329
+ list have no effect on the HTML output Markdown produces. The HTML
330
+ Markdown produces from the above list is:
331
+
332
+ <ol>
333
+ <li>Bird</li>
334
+ <li>McHale</li>
335
+ <li>Parish</li>
336
+ </ol>
337
+
338
+ If you instead wrote the list in Markdown like this:
339
+
340
+ 1. Bird
341
+ 1. McHale
342
+ 1. Parish
343
+
344
+ or even:
345
+
346
+ 3. Bird
347
+ 1. McHale
348
+ 8. Parish
349
+
350
+ you'd get the exact same HTML output. The point is, if you want to,
351
+ you can use ordinal numbers in your ordered Markdown lists, so that
352
+ the numbers in your source match the numbers in your published HTML.
353
+ But if you want to be lazy, you don't have to.
354
+
355
+ If you do use lazy list numbering, however, you should still start the
356
+ list with the number 1. At some point in the future, Markdown may support
357
+ starting ordered lists at an arbitrary number.
358
+
359
+ List markers typically start at the left margin, but may be indented by
360
+ up to three spaces. List markers must be followed by one or more spaces
361
+ or a tab.
362
+
363
+ To make lists look nice, you can wrap items with hanging indents:
364
+
365
+ * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
366
+ Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
367
+ viverra nec, fringilla in, laoreet vitae, risus.
368
+ * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
369
+ Suspendisse id sem consectetuer libero luctus adipiscing.
370
+
371
+ But if you want to be lazy, you don't have to:
372
+
373
+ * Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
374
+ Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
375
+ viverra nec, fringilla in, laoreet vitae, risus.
376
+ * Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
377
+ Suspendisse id sem consectetuer libero luctus adipiscing.
378
+
379
+ If list items are separated by blank lines, Markdown will wrap the
380
+ items in `<p>` tags in the HTML output. For example, this input:
381
+
382
+ * Bird
383
+ * Magic
384
+
385
+ will turn into:
386
+
387
+ <ul>
388
+ <li>Bird</li>
389
+ <li>Magic</li>
390
+ </ul>
391
+
392
+ But this:
393
+
394
+ * Bird
395
+
396
+ * Magic
397
+
398
+ will turn into:
399
+
400
+ <ul>
401
+ <li><p>Bird</p></li>
402
+ <li><p>Magic</p></li>
403
+ </ul>
404
+
405
+ List items may consist of multiple paragraphs. Each subsequent
406
+ paragraph in a list item must be intended by either 4 spaces
407
+ or one tab:
408
+
409
+ 1. This is a list item with two paragraphs. Lorem ipsum dolor
410
+ sit amet, consectetuer adipiscing elit. Aliquam hendrerit
411
+ mi posuere lectus.
412
+
413
+ Vestibulum enim wisi, viverra nec, fringilla in, laoreet
414
+ vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
415
+ sit amet velit.
416
+
417
+ 2. Suspendisse id sem consectetuer libero luctus adipiscing.
418
+
419
+ It looks nice if you indent every line of the subsequent
420
+ paragraphs, but here again, Markdown will allow you to be
421
+ lazy:
422
+
423
+ * This is a list item with two paragraphs.
424
+
425
+ This is the second paragraph in the list item. You're
426
+ only required to indent the first line. Lorem ipsum dolor
427
+ sit amet, consectetuer adipiscing elit.
428
+
429
+ * Another item in the same list.
430
+
431
+ To put a blockquote within a list item, the blockquote's `>`
432
+ delimiters need to be indented:
433
+
434
+ * A list item with a blockquote:
435
+
436
+ > This is a blockquote
437
+ > inside a list item.
438
+
439
+ To put a code block within a list item, the code block needs
440
+ to be indented *twice* -- 8 spaces or two tabs:
441
+
442
+ * A list item with a code block:
443
+
444
+ <code goes here>
445
+
446
+
447
+ It's worth noting that it's possible to trigger an ordered list by
448
+ accident, by writing something like this:
449
+
450
+ 1986. What a great season.
451
+
452
+ In other words, a *number-period-space* sequence at the beginning of a
453
+ line. To avoid this, you can backslash-escape the period:
454
+
455
+ 1986\. What a great season.
456
+
457
+
458
+
459
+ <h3 id="precode">Code Blocks</h3>
460
+
461
+ Pre-formatted code blocks are used for writing about programming or
462
+ markup source code. Rather than forming normal paragraphs, the lines
463
+ of a code block are interpreted literally. Markdown wraps a code block
464
+ in both `<pre>` and `<code>` tags.
465
+
466
+ To produce a code block in Markdown, simply indent every line of the
467
+ block by at least 4 spaces or 1 tab. For example, given this input:
468
+
469
+ This is a normal paragraph:
470
+
471
+ This is a code block.
472
+
473
+ Markdown will generate:
474
+
475
+ <p>This is a normal paragraph:</p>
476
+
477
+ <pre><code>This is a code block.
478
+ </code></pre>
479
+
480
+ One level of indentation -- 4 spaces or 1 tab -- is removed from each
481
+ line of the code block. For example, this:
482
+
483
+ Here is an example of AppleScript:
484
+
485
+ tell application "Foo"
486
+ beep
487
+ end tell
488
+
489
+ will turn into:
490
+
491
+ <p>Here is an example of AppleScript:</p>
492
+
493
+ <pre><code>tell application "Foo"
494
+ beep
495
+ end tell
496
+ </code></pre>
497
+
498
+ A code block continues until it reaches a line that is not indented
499
+ (or the end of the article).
500
+
501
+ Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
502
+ are automatically converted into HTML entities. This makes it very
503
+ easy to include example HTML source code using Markdown -- just paste
504
+ it and indent it, and Markdown will handle the hassle of encoding the
505
+ ampersands and angle brackets. For example, this:
506
+
507
+ <div class="footer">
508
+ &copy; 2004 Foo Corporation
509
+ </div>
510
+
511
+ will turn into:
512
+
513
+ <pre><code>&lt;div class="footer"&gt;
514
+ &amp;copy; 2004 Foo Corporation
515
+ &lt;/div&gt;
516
+ </code></pre>
517
+
518
+ Regular Markdown syntax is not processed within code blocks. E.g.,
519
+ asterisks are just literal asterisks within a code block. This means
520
+ it's also easy to use Markdown to write about Markdown's own syntax.
521
+
522
+
523
+
524
+ <h3 id="hr">Horizontal Rules</h3>
525
+
526
+ You can produce a horizontal rule tag (`<hr />`) by placing three or
527
+ more hyphens, asterisks, or underscores on a line by themselves. If you
528
+ wish, you may use spaces between the hyphens or asterisks. Each of the
529
+ following lines will produce a horizontal rule:
530
+
531
+ * * *
532
+
533
+ ***
534
+
535
+ *****
536
+
537
+ - - -
538
+
539
+ ---------------------------------------
540
+
541
+
542
+ * * *
543
+
544
+ <h2 id="span">Span Elements</h2>
545
+
546
+ <h3 id="link">Links</h3>
547
+
548
+ Markdown supports two style of links: *inline* and *reference*.
549
+
550
+ In both styles, the link text is delimited by [square brackets].
551
+
552
+ To create an inline link, use a set of regular parentheses immediately
553
+ after the link text's closing square bracket. Inside the parentheses,
554
+ put the URL where you want the link to point, along with an *optional*
555
+ title for the link, surrounded in quotes. For example:
556
+
557
+ This is [an example](http://example.com/ "Title") inline link.
558
+
559
+ [This link](http://example.net/) has no title attribute.
560
+
561
+ Will produce:
562
+
563
+ <p>This is <a href="http://example.com/" title="Title">
564
+ an example</a> inline link.</p>
565
+
566
+ <p><a href="http://example.net/">This link</a> has no
567
+ title attribute.</p>
568
+
569
+ If you're referring to a local resource on the same server, you can
570
+ use relative paths:
571
+
572
+ See my [About](/about/) page for details.
573
+
574
+ Reference-style links use a second set of square brackets, inside
575
+ which you place a label of your choosing to identify the link:
576
+
577
+ This is [an example][id] reference-style link.
578
+
579
+ You can optionally use a space to separate the sets of brackets:
580
+
581
+ This is [an example] [id] reference-style link.
582
+
583
+ Then, anywhere in the document, you define your link label like this,
584
+ on a line by itself:
585
+
586
+ [id]: http://example.com/ "Optional Title Here"
587
+
588
+ That is:
589
+
590
+ * Square brackets containing the link identifier (optionally
591
+ indented from the left margin using up to three spaces);
592
+ * followed by a colon;
593
+ * followed by one or more spaces (or tabs);
594
+ * followed by the URL for the link;
595
+ * optionally followed by a title attribute for the link, enclosed
596
+ in double or single quotes, or enclosed in parentheses.
597
+
598
+ The following three link definitions are equivalent:
599
+
600
+ [foo]: http://example.com/ "Optional Title Here"
601
+ [foo]: http://example.com/ 'Optional Title Here'
602
+ [foo]: http://example.com/ (Optional Title Here)
603
+
604
+ **Note:** There is a known bug in Markdown.pl 1.0.1 which prevents
605
+ single quotes from being used to delimit link titles.
606
+
607
+ The link URL may, optionally, be surrounded by angle brackets:
608
+
609
+ [id]: <http://example.com/> "Optional Title Here"
610
+
611
+ You can put the title attribute on the next line and use extra spaces
612
+ or tabs for padding, which tends to look better with longer URLs:
613
+
614
+ [id]: http://example.com/longish/path/to/resource/here
615
+ "Optional Title Here"
616
+
617
+ Link definitions are only used for creating links during Markdown
618
+ processing, and are stripped from your document in the HTML output.
619
+
620
+ Link definition names may constist of letters, numbers, spaces, and
621
+ punctuation -- but they are *not* case sensitive. E.g. these two
622
+ links:
623
+
624
+ [link text][a]
625
+ [link text][A]
626
+
627
+ are equivalent.
628
+
629
+ The *implicit link name* shortcut allows you to omit the name of the
630
+ link, in which case the link text itself is used as the name.
631
+ Just use an empty set of square brackets -- e.g., to link the word
632
+ "Google" to the google.com web site, you could simply write:
633
+
634
+ [Google][]
635
+
636
+ And then define the link:
637
+
638
+ [Google]: http://google.com/
639
+
640
+ Because link names may contain spaces, this shortcut even works for
641
+ multiple words in the link text:
642
+
643
+ Visit [Daring Fireball][] for more information.
644
+
645
+ And then define the link:
646
+
647
+ [Daring Fireball]: http://daringfireball.net/
648
+
649
+ Link definitions can be placed anywhere in your Markdown document. I
650
+ tend to put them immediately after each paragraph in which they're
651
+ used, but if you want, you can put them all at the end of your
652
+ document, sort of like footnotes.
653
+
654
+ Here's an example of reference links in action:
655
+
656
+ I get 10 times more traffic from [Google] [1] than from
657
+ [Yahoo] [2] or [MSN] [3].
658
+
659
+ [1]: http://google.com/ "Google"
660
+ [2]: http://search.yahoo.com/ "Yahoo Search"
661
+ [3]: http://search.msn.com/ "MSN Search"
662
+
663
+ Using the implicit link name shortcut, you could instead write:
664
+
665
+ I get 10 times more traffic from [Google][] than from
666
+ [Yahoo][] or [MSN][].
667
+
668
+ [google]: http://google.com/ "Google"
669
+ [yahoo]: http://search.yahoo.com/ "Yahoo Search"
670
+ [msn]: http://search.msn.com/ "MSN Search"
671
+
672
+ Both of the above examples will produce the following HTML output:
673
+
674
+ <p>I get 10 times more traffic from <a href="http://google.com/"
675
+ title="Google">Google</a> than from
676
+ <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
677
+ or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
678
+
679
+ For comparison, here is the same paragraph written using
680
+ Markdown's inline link style:
681
+
682
+ I get 10 times more traffic from [Google](http://google.com/ "Google")
683
+ than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
684
+ [MSN](http://search.msn.com/ "MSN Search").
685
+
686
+ The point of reference-style links is not that they're easier to
687
+ write. The point is that with reference-style links, your document
688
+ source is vastly more readable. Compare the above examples: using
689
+ reference-style links, the paragraph itself is only 81 characters
690
+ long; with inline-style links, it's 176 characters; and as raw HTML,
691
+ it's 234 characters. In the raw HTML, there's more markup than there
692
+ is text.
693
+
694
+ With Markdown's reference-style links, a source document much more
695
+ closely resembles the final output, as rendered in a browser. By
696
+ allowing you to move the markup-related metadata out of the paragraph,
697
+ you can add links without interrupting the narrative flow of your
698
+ prose.
699
+
700
+
701
+ <h3 id="em">Emphasis</h3>
702
+
703
+ Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
704
+ emphasis. Text wrapped with one `*` or `_` will be wrapped with an
705
+ HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
706
+ `<strong>` tag. E.g., this input:
707
+
708
+ *single asterisks*
709
+
710
+ _single underscores_
711
+
712
+ **double asterisks**
713
+
714
+ __double underscores__
715
+
716
+ will produce:
717
+
718
+ <em>single asterisks</em>
719
+
720
+ <em>single underscores</em>
721
+
722
+ <strong>double asterisks</strong>
723
+
724
+ <strong>double underscores</strong>
725
+
726
+ You can use whichever style you prefer; the lone restriction is that
727
+ the same character must be used to open and close an emphasis span.
728
+
729
+ Emphasis can be used in the middle of a word:
730
+
731
+ un*fucking*believable
732
+
733
+ But if you surround an `*` or `_` with spaces, it'll be treated as a
734
+ literal asterisk or underscore.
735
+
736
+ To produce a literal asterisk or underscore at a position where it
737
+ would otherwise be used as an emphasis delimiter, you can backslash
738
+ escape it:
739
+
740
+ \*this text is surrounded by literal asterisks\*
741
+
742
+
743
+
744
+ <h3 id="code">Code</h3>
745
+
746
+ To indicate a span of code, wrap it with backtick quotes (`` ` ``).
747
+ Unlike a pre-formatted code block, a code span indicates code within a
748
+ normal paragraph. For example:
749
+
750
+ Use the `printf()` function.
751
+
752
+ will produce:
753
+
754
+ <p>Use the <code>printf()</code> function.</p>
755
+
756
+ To include a literal backtick character within a code span, you can use
757
+ multiple backticks as the opening and closing delimiters:
758
+
759
+ ``There is a literal backtick (`) here.``
760
+
761
+ which will produce this:
762
+
763
+ <p><code>There is a literal backtick (`) here.</code></p>
764
+
765
+ The backtick delimiters surrounding a code span may include spaces --
766
+ one after the opening, one before the closing. This allows you to place
767
+ literal backtick characters at the beginning or end of a code span:
768
+
769
+ A single backtick in a code span: `` ` ``
770
+
771
+ A backtick-delimited string in a code span: `` `foo` ``
772
+
773
+ will produce:
774
+
775
+ <p>A single backtick in a code span: <code>`</code></p>
776
+
777
+ <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
778
+
779
+ With a code span, ampersands and angle brackets are encoded as HTML
780
+ entities automatically, which makes it easy to include example HTML
781
+ tags. Markdown will turn this:
782
+
783
+ Please don't use any `<blink>` tags.
784
+
785
+ into:
786
+
787
+ <p>Please don't use any <code>&lt;blink&gt;</code> tags.</p>
788
+
789
+ You can write this:
790
+
791
+ `&#8212;` is the decimal-encoded equivalent of `&mdash;`.
792
+
793
+ to produce:
794
+
795
+ <p><code>&amp;#8212;</code> is the decimal-encoded
796
+ equivalent of <code>&amp;mdash;</code>.</p>
797
+
798
+
799
+
800
+ <h3 id="img">Images</h3>
801
+
802
+ Admittedly, it's fairly difficult to devise a "natural" syntax for
803
+ placing images into a plain text document format.
804
+
805
+ Markdown uses an image syntax that is intended to resemble the syntax
806
+ for links, allowing for two styles: *inline* and *reference*.
807
+
808
+ Inline image syntax looks like this:
809
+
810
+ ![Alt text](/path/to/img.jpg)
811
+
812
+ ![Alt text](/path/to/img.jpg "Optional title")
813
+
814
+ That is:
815
+
816
+ * An exclamation mark: `!`;
817
+ * followed by a set of square brackets, containing the `alt`
818
+ attribute text for the image;
819
+ * followed by a set of parentheses, containing the URL or path to
820
+ the image, and an optional `title` attribute enclosed in double
821
+ or single quotes.
822
+
823
+ Reference-style image syntax looks like this:
824
+
825
+ ![Alt text][id]
826
+
827
+ Where "id" is the name of a defined image reference. Image references
828
+ are defined using syntax identical to link references:
829
+
830
+ [id]: url/to/image "Optional title attribute"
831
+
832
+ As of this writing, Markdown has no syntax for specifying the
833
+ dimensions of an image; if this is important to you, you can simply
834
+ use regular HTML `<img>` tags.
835
+
836
+
837
+ * * *
838
+
839
+
840
+ <h2 id="misc">Miscellaneous</h2>
841
+
842
+ <h3 id="autolink">Automatic Links</h3>
843
+
844
+ 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:
845
+
846
+ <http://example.com/>
847
+
848
+ Markdown will turn this into:
849
+
850
+ <a href="http://example.com/">http://example.com/</a>
851
+
852
+ Automatic links for email addresses work similarly, except that
853
+ Markdown will also perform a bit of randomized decimal and hex
854
+ entity-encoding to help obscure your address from address-harvesting
855
+ spambots. For example, Markdown will turn this:
856
+
857
+ <address@example.com>
858
+
859
+ into something like this:
860
+
861
+ <a href="&#x6D;&#x61;i&#x6C;&#x74;&#x6F;:&#x61;&#x64;&#x64;&#x72;&#x65;
862
+ &#115;&#115;&#64;&#101;&#120;&#x61;&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;
863
+ &#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
864
+ &#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
865
+
866
+ which will render in a browser as a clickable link to "address@example.com".
867
+
868
+ (This sort of entity-encoding trick will indeed fool many, if not
869
+ most, address-harvesting bots, but it definitely won't fool all of
870
+ them. It's better than nothing, but an address published in this way
871
+ will probably eventually start receiving spam.)
872
+
873
+
874
+
875
+ <h3 id="backslash">Backslash Escapes</h3>
876
+
877
+ Markdown allows you to use backslash escapes to generate literal
878
+ characters which would otherwise have special meaning in Markdown's
879
+ formatting syntax. For example, if you wanted to surround a word with
880
+ literal asterisks (instead of an HTML `<em>` tag), you can backslashes
881
+ before the asterisks, like this:
882
+
883
+ \*literal asterisks\*
884
+
885
+ Markdown provides backslash escapes for the following characters:
886
+
887
+ \ backslash
888
+ ` backtick
889
+ * asterisk
890
+ _ underscore
891
+ {} curly braces
892
+ [] square brackets
893
+ () parentheses
894
+ # hash mark
895
+ + plus sign
896
+ - minus sign (hyphen)
897
+ . dot
898
+ ! exclamation mark
899
+