maruku 0.4.2.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/maruku +66 -20
- data/bin/marutest +12 -2
- data/docs/changelog.html +188 -23
- data/docs/changelog.md +128 -5
- data/docs/entity_test.html +245 -240
- data/docs/entity_test.md +2 -0
- data/docs/exd.html +181 -23
- data/docs/index.html +130 -349
- data/docs/markdown_syntax.html +55 -51
- data/docs/maruku.html +130 -349
- data/docs/maruku.md +154 -339
- data/docs/math.md +143 -0
- data/docs/proposal.html +16 -12
- data/lib/maruku.rb +6 -3
- data/lib/maruku/attributes.rb +7 -2
- data/lib/maruku/defaults.rb +27 -27
- data/lib/maruku/errors_management.rb +10 -9
- data/lib/maruku/ext/diagrams/diagrams.rb +8 -0
- data/lib/maruku/ext/diagrams/grid.rb +78 -0
- data/lib/maruku/ext/diagrams/inspect.rb +11 -0
- data/lib/maruku/ext/diagrams/layout.rb +105 -0
- data/lib/maruku/ext/diagrams/parser.rb +219 -0
- data/lib/maruku/ext/diagrams/structures.rb +168 -0
- data/lib/maruku/ext/diagrams/to_html.rb +37 -0
- data/lib/maruku/ext/diagrams/to_latex.rb +308 -0
- data/lib/maruku/ext/diagrams/unittest.rb +123 -0
- data/lib/maruku/ext/math.rb +11 -0
- data/lib/maruku/ext/math/elements.rb +26 -0
- data/lib/maruku/ext/math/mathml_engines/blahtex.rb +108 -0
- data/lib/maruku/ext/math/mathml_engines/itex2mml.rb +29 -0
- data/lib/maruku/ext/math/mathml_engines/none.rb +20 -0
- data/lib/maruku/ext/math/mathml_engines/ritex.rb +24 -0
- data/lib/maruku/ext/math/parsing.rb +82 -0
- data/lib/maruku/ext/math/to_html.rb +178 -0
- data/lib/maruku/ext/math/to_latex.rb +21 -0
- data/lib/maruku/helpers.rb +11 -0
- data/lib/maruku/input/charsource.rb +1 -1
- data/lib/maruku/input/extensions.rb +68 -0
- data/lib/maruku/input/html_helper.rb +91 -60
- data/lib/maruku/input/parse_block.rb +10 -9
- data/lib/maruku/input/parse_doc.rb +21 -13
- data/lib/maruku/input/parse_span_better.rb +19 -8
- data/lib/maruku/input/type_detection.rb +5 -3
- data/lib/maruku/output/to_html.rb +236 -67
- data/lib/maruku/output/to_latex.rb +69 -26
- data/lib/maruku/output/to_latex_entities.rb +14 -2
- data/lib/maruku/output/to_s.rb +8 -0
- data/lib/maruku/structures.rb +1 -1
- data/lib/maruku/tests/benchmark.rb +2 -2
- data/lib/maruku/tests/new_parser.rb +13 -5
- data/lib/maruku/version.rb +1 -1
- data/lib/sort_prof.rb +22 -0
- data/tests/diagrams/diagrams.md +54 -0
- data/tests/math/syntax.md +46 -0
- data/tests/math_usage/document.md +13 -0
- data/tests/unittest/attributes/attributes.md +50 -6
- data/tests/unittest/easy.md +1 -1
- data/tests/unittest/email.md +3 -3
- data/tests/unittest/entities.md +12 -7
- data/tests/unittest/escaping.md +4 -4
- data/tests/unittest/extra_table1.md +3 -1
- data/tests/unittest/footnotes.md +5 -5
- data/tests/unittest/headers.md +3 -3
- data/tests/unittest/images.md +7 -7
- data/tests/unittest/inline_html.md +51 -5
- data/tests/unittest/links.md +7 -7
- data/tests/unittest/list2.md +1 -1
- data/tests/unittest/lists.md +1 -1
- data/tests/unittest/lists_after_paragraph.md +1 -1
- data/tests/unittest/lists_ol.md +1 -1
- data/tests/unittest/math/equations.md +82 -0
- data/tests/unittest/math/inline.md +80 -0
- data/tests/unittest/math/table.md +51 -0
- data/tests/unittest/math/table2.md +67 -0
- data/tests/unittest/misc_sw.md +24 -24
- data/tests/unittest/notyet/ticks.md +1 -1
- data/tests/unittest/references/long_example.md +2 -2
- data/tests/unittest/smartypants.md +4 -4
- data/tests/unittest/xml.md +68 -0
- data/tests/unittest/xml2.md +36 -0
- data/tests/unittest/xml3.md +52 -0
- data/tests/unittest/xml_instruction.md +5 -5
- metadata +33 -4
- data/docs/a.html +0 -6
- data/docs/char.html +0 -1924
data/docs/markdown_syntax.html
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
<?xml version=
|
2
|
-
<!DOCTYPE html PUBLIC
|
3
|
-
|
4
|
-
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC
|
3
|
+
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
|
4
|
+
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
|
5
|
+
<html xmlns:svg='http://www.w3.org/2000/svg' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
6
|
+
<head><meta content='application/xhtml+xml;charset=utf-8' http-equiv='Content-type' /><title>Markdown: Syntax</title><link href='style.css' rel='stylesheet' type='text/css' />
|
7
|
+
</head>
|
8
|
+
<body>
|
5
9
|
<h1 id='markdown_syntax'>Markdown: Syntax</h1>
|
6
10
|
<ul id='ProjectSubmenu'>
|
7
11
|
<li><a href='/projects/markdown/' title='Markdown Project Page'>Main</a></li>
|
@@ -66,21 +70,21 @@
|
|
66
70
|
</li>
|
67
71
|
</ul>
|
68
72
|
|
69
|
-
<p><strong>Note:</strong> This document is itself written using Markdown; you can <a href='/projects/markdown/syntax.text'>see the source for it by adding
|
73
|
+
<p><strong>Note:</strong> This document is itself written using Markdown; you can <a href='/projects/markdown/syntax.text'>see the source for it by adding ‘.text’ to the URL</a>.</p>
|
70
74
|
<hr /><h2 id='overview'>Overview</h2><h3 id='philosophy'>Philosophy</h3>
|
71
75
|
<p>Markdown is intended to be as easy-to-read and easy-to-write as is feasible.</p>
|
72
76
|
|
73
|
-
<p>Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it
|
77
|
+
<p>Readability, however, is emphasized above all else. A Markdown-formatted document should be publishable as-is, as plain text, without looking like it’s been marked up with tags or formatting instructions. While Markdown’s syntax has been influenced by several existing text-to-HTML filters – including <a href='http://docutils.sourceforge.net/mirror/setext.html'>Setext</a>, <a href='http://www.aaronsw.com/2002/atx/'>atx</a>, <a href='http://textism.com/tools/textile/'>Textile</a>, <a href='http://docutils.sourceforge.net/rst.html'>reStructuredText</a>, <a href='http://www.triptico.com/software/grutatxt.html'>Grutatext</a>, and <a href='http://ettext.taint.org/doc/'>EtText</a> – the single biggest source of inspiration for Markdown’s syntax is the format of plain text email.</p>
|
74
78
|
|
75
|
-
<p>To this end, Markdown
|
79
|
+
<p>To this end, Markdown’s syntax is comprised entirely of punctuation characters, which punctuation characters have been carefully chosen so as to look like what they mean. E.g., asterisks around a word actually look like *emphasis*. Markdown lists look like, well, lists. Even blockquotes look like quoted passages of text, assuming you’ve ever used email.</p>
|
76
80
|
<h3 id='html'>Inline HTML</h3>
|
77
|
-
<p>Markdown
|
81
|
+
<p>Markdown’s syntax is intended for one purpose: to be used as a format for <em>writing</em> for the web.</p>
|
78
82
|
|
79
|
-
<p>Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is <em>not</em> to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em> format. Thus, Markdown
|
83
|
+
<p>Markdown is not a replacement for HTML, or even close to it. Its syntax is very small, corresponding only to a very small subset of HTML tags. The idea is <em>not</em> to create a syntax that makes it easier to insert HTML tags. In my opinion, HTML tags are already easy to insert. The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a <em>publishing</em> format; Markdown is a <em>writing</em> format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.</p>
|
80
84
|
|
81
|
-
<p>For any markup that is not covered by Markdown
|
85
|
+
<p>For any markup that is not covered by Markdown’s syntax, you simply use HTML itself. There’s no need to preface it or delimit it to indicate that you’re switching from Markdown to HTML; you just use the tags.</p>
|
82
86
|
|
83
|
-
<p>The only restrictions are that block-level HTML elements
|
87
|
+
<p>The only restrictions are that block-level HTML elements – e.g. <code><div></code>, <code><table></code>, <code><pre></code>, <code><p></code>, etc. – must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) <code><p></code> tags around HTML block-level tags.</p>
|
84
88
|
|
85
89
|
<p>For example, to add an HTML table to a Markdown article:</p>
|
86
90
|
<pre><code>This is a regular paragraph.
|
@@ -93,15 +97,15 @@
|
|
93
97
|
|
94
98
|
This is another regular paragraph.
|
95
99
|
</code></pre>
|
96
|
-
<p>Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can
|
100
|
+
<p>Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can’t use Markdown-style <code>*emphasis*</code> inside an HTML block.</p>
|
97
101
|
|
98
|
-
<p>Span-level HTML tags
|
102
|
+
<p>Span-level HTML tags – e.g. <code><span></code>, <code><cite></code>, or <code><del></code> – can be used anywhere in a Markdown paragraph, list item, or header. If you want, you can even use HTML tags instead of Markdown formatting; e.g. if you’d prefer to use HTML <code><a></code> or <code><img></code> tags instead of Markdown’s link or image syntax, go right ahead.</p>
|
99
103
|
|
100
104
|
<p>Unlike block-level HTML tags, Markdown syntax <em>is</em> processed within span-level tags.</p>
|
101
105
|
<h3 id='autoescape'>Automatic Escaping for Special Characters</h3>
|
102
106
|
<p>In HTML, there are two characters that demand special treatment: <code><</code> and <code>&</code>. Left angle brackets are used to start tags; ampersands are used to denote HTML entities. If you want to use them as literal characters, you must escape them as entities, e.g. <code>&lt;</code>, and <code>&amp;</code>.</p>
|
103
107
|
|
104
|
-
<p>Ampersands in particular are bedeviling for web writers. If you want to write about
|
108
|
+
<p>Ampersands in particular are bedeviling for web writers. If you want to write about ‘AT&T’, you need to write ’<code>AT&amp;T</code>’. You even need to escape ampersands within URLs. Thus, if you want to link to:</p>
|
105
109
|
<pre><code>http://images.google.com/images?num=30&q=larry+bird
|
106
110
|
</code></pre>
|
107
111
|
<p>you need to encode the URL as:</p>
|
@@ -128,24 +132,24 @@ This is another regular paragraph.
|
|
128
132
|
</code></pre>
|
129
133
|
<p>However, inside Markdown code spans and blocks, angle brackets and ampersands are <em>always</em> encoded automatically. This makes it easy to use Markdown to write about HTML code. (As opposed to raw HTML, which is a terrible format for writing about HTML syntax, because every single <code><</code> and <code>&</code> in your example code needs to be escaped.)</p>
|
130
134
|
<hr /><h2 id='block'>Block Elements</h2><h3 id='p'>Paragraphs and Line Breaks</h3>
|
131
|
-
<p>A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line
|
135
|
+
<p>A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line – a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.</p>
|
132
136
|
|
133
|
-
<p>The implication of the
|
137
|
+
<p>The implication of the “one or more consecutive lines of text” rule is that Markdown supports “hard-wrapped” text paragraphs. This differs significantly from most other text-to-HTML formatters (including Movable Type’s “Convert Line Breaks” option) which translate every line break character in a paragraph into a <code><br /></code> tag.</p>
|
134
138
|
|
135
139
|
<p>When you <em>do</em> want to insert a <code><br /></code> break tag using Markdown, you end a line with two or more spaces, then type return.</p>
|
136
140
|
|
137
|
-
<p>Yes, this takes a tad more effort to create a <code><br /></code>, but a simplistic
|
141
|
+
<p>Yes, this takes a tad more effort to create a <code><br /></code>, but a simplistic “every line break is a <code><br /></code>” rule wouldn’t work for Markdown. Markdown’s email-style <a href='#blockquote'>blockquoting</a> and multi-paragraph <a href='#list'>list items</a> work best – and look better – when you format them with hard breaks.</p>
|
138
142
|
<h3 id='header'>Headers</h3>
|
139
143
|
<p>Markdown supports two styles of headers, <a href='http://docutils.sourceforge.net/mirror/setext.html'>Setext</a> and <a href='http://www.aaronsw.com/2002/atx/'>atx</a>.</p>
|
140
144
|
|
141
|
-
<p>Setext-style headers are
|
145
|
+
<p>Setext-style headers are “underlined” using equal signs (for first-level headers) and dashes (for second-level headers). For example:</p>
|
142
146
|
<pre><code>This is an H1
|
143
147
|
=============
|
144
148
|
|
145
149
|
This is an H2
|
146
150
|
-------------
|
147
151
|
</code></pre>
|
148
|
-
<p>Any number of underlining <code>=</code
|
152
|
+
<p>Any number of underlining <code>=</code>’s or <code>-</code>’s will work.</p>
|
149
153
|
|
150
154
|
<p>Atx-style headers use 1-6 hash characters at the start of the line, corresponding to header levels 1-6. For example:</p>
|
151
155
|
<pre><code># This is an H1
|
@@ -154,7 +158,7 @@ This is an H2
|
|
154
158
|
|
155
159
|
###### This is an H6
|
156
160
|
</code></pre>
|
157
|
-
<p>Optionally, you may
|
161
|
+
<p>Optionally, you may “close” atx-style headers. This is purely cosmetic – you can use this if you think it looks better. The closing hashes don’t even need to match the number of hashes used to open the header. (The number of opening hashes determines the header level.) :</p>
|
158
162
|
<pre><code># This is an H1 #
|
159
163
|
|
160
164
|
## This is an H2 ##
|
@@ -162,7 +166,7 @@ This is an H2
|
|
162
166
|
### This is an H3 ######
|
163
167
|
|
164
168
|
</code></pre><h3 id='blockquote'>Blockquotes</h3>
|
165
|
-
<p>Markdown uses email-style <code>></code> characters for blockquoting. If you
|
169
|
+
<p>Markdown uses email-style <code>></code> characters for blockquoting. If you’re familiar with quoting passages of text in an email message, then you know how to create a blockquote in Markdown. It looks best if you hard wrap the text and put a <code>></code> before every line:</p>
|
166
170
|
<pre><code>> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
|
167
171
|
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
|
168
172
|
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
|
@@ -199,7 +203,7 @@ id sem consectetuer libero luctus adipiscing.
|
|
199
203
|
<h3 id='list'>Lists</h3>
|
200
204
|
<p>Markdown supports ordered (numbered) and unordered (bulleted) lists.</p>
|
201
205
|
|
202
|
-
<p>Unordered lists use asterisks, pluses, and hyphens
|
206
|
+
<p>Unordered lists use asterisks, pluses, and hyphens – interchangably – as list markers:</p>
|
203
207
|
<pre><code>* Red
|
204
208
|
* Green
|
205
209
|
* Blue
|
@@ -219,7 +223,7 @@ id sem consectetuer libero luctus adipiscing.
|
|
219
223
|
2. McHale
|
220
224
|
3. Parish
|
221
225
|
</code></pre>
|
222
|
-
<p>It
|
226
|
+
<p>It’s important to note that the actual numbers you use to mark the list have no effect on the HTML output Markdown produces. The HTML Markdown produces from the above list is:</p>
|
223
227
|
<pre><code><ol>
|
224
228
|
<li>Bird</li>
|
225
229
|
<li>McHale</li>
|
@@ -236,7 +240,7 @@ id sem consectetuer libero luctus adipiscing.
|
|
236
240
|
1. McHale
|
237
241
|
8. Parish
|
238
242
|
</code></pre>
|
239
|
-
<p>you
|
243
|
+
<p>you’d get the exact same HTML output. The point is, if you want to, you can use ordinal numbers in your ordered Markdown lists, so that the numbers in your source match the numbers in your published HTML. But if you want to be lazy, you don’t have to.</p>
|
240
244
|
|
241
245
|
<p>If you do use lazy list numbering, however, you should still start the list with the number 1. At some point in the future, Markdown may support starting ordered lists at an arbitrary number.</p>
|
242
246
|
|
@@ -249,7 +253,7 @@ id sem consectetuer libero luctus adipiscing.
|
|
249
253
|
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
|
250
254
|
Suspendisse id sem consectetuer libero luctus adipiscing.
|
251
255
|
</code></pre>
|
252
|
-
<p>But if you want to be lazy, you don
|
256
|
+
<p>But if you want to be lazy, you don’t have to:</p>
|
253
257
|
<pre><code>* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
|
254
258
|
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
|
255
259
|
viverra nec, fringilla in, laoreet vitae, risus.
|
@@ -297,19 +301,19 @@ sit amet, consectetuer adipiscing elit.
|
|
297
301
|
|
298
302
|
* Another item in the same list.
|
299
303
|
</code></pre>
|
300
|
-
<p>To put a blockquote within a list item, the blockquote
|
304
|
+
<p>To put a blockquote within a list item, the blockquote’s <code>></code> delimiters need to be indented:</p>
|
301
305
|
<pre><code>* A list item with a blockquote:
|
302
306
|
|
303
307
|
> This is a blockquote
|
304
308
|
> inside a list item.
|
305
309
|
</code></pre>
|
306
|
-
<p>To put a code block within a list item, the code block needs to be indented <em>twice</em>
|
310
|
+
<p>To put a code block within a list item, the code block needs to be indented <em>twice</em> – 8 spaces or two tabs:</p>
|
307
311
|
<pre><code>* A list item with a code block:
|
308
312
|
|
309
313
|
<code goes here>
|
310
314
|
|
311
315
|
</code></pre>
|
312
|
-
<p>It
|
316
|
+
<p>It’s worth noting that it’s possible to trigger an ordered list by accident, by writing something like this:</p>
|
313
317
|
<pre><code>1986. What a great season.
|
314
318
|
</code></pre>
|
315
319
|
<p>In other words, a <em>number-period-space</em> sequence at the beginning of a line. To avoid this, you can backslash-escape the period:</p>
|
@@ -330,7 +334,7 @@ sit amet, consectetuer adipiscing elit.
|
|
330
334
|
<pre><code>This is a code block.
|
331
335
|
</code></pre>
|
332
336
|
</code></pre>
|
333
|
-
<p>One level of indentation
|
337
|
+
<p>One level of indentation – 4 spaces or 1 tab – is removed from each line of the code block. For example, this:</p>
|
334
338
|
<pre><code>Here is an example of AppleScript:
|
335
339
|
|
336
340
|
tell application "Foo"
|
@@ -347,7 +351,7 @@ end tell
|
|
347
351
|
</code></pre>
|
348
352
|
<p>A code block continues until it reaches a line that is not indented (or the end of the article).</p>
|
349
353
|
|
350
|
-
<p>Within a code block, ampersands (<code>&</code>) and angle brackets (<code><</code> and <code>></code>) are automatically converted into HTML entities. This makes it very easy to include example HTML source code using Markdown
|
354
|
+
<p>Within a code block, ampersands (<code>&</code>) and angle brackets (<code><</code> and <code>></code>) are automatically converted into HTML entities. This makes it very easy to include example HTML source code using Markdown – just paste it and indent it, and Markdown will handle the hassle of encoding the ampersands and angle brackets. For example, this:</p>
|
351
355
|
<pre><code> <div class="footer">
|
352
356
|
&copy; 2004 Foo Corporation
|
353
357
|
</div>
|
@@ -358,7 +362,7 @@ end tell
|
|
358
362
|
&lt;/div&gt;
|
359
363
|
</code></pre>
|
360
364
|
</code></pre>
|
361
|
-
<p>Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it
|
365
|
+
<p>Regular Markdown syntax is not processed within code blocks. E.g., asterisks are just literal asterisks within a code block. This means it’s also easy to use Markdown to write about Markdown’s own syntax.</p>
|
362
366
|
<h3 id='hr'>Horizontal Rules</h3>
|
363
367
|
<p>You can produce a horizontal rule tag (<code><hr /></code>) by placing three or more hyphens, asterisks, or underscores on a line by themselves. If you wish, you may use spaces between the hyphens or asterisks. Each of the following lines will produce a horizontal rule:</p>
|
364
368
|
<pre><code>* * *
|
@@ -374,9 +378,9 @@ end tell
|
|
374
378
|
</code></pre><hr /><h2 id='span'>Span Elements</h2><h3 id='link'>Links</h3>
|
375
379
|
<p>Markdown supports two style of links: <em>inline</em> and <em>reference</em>.</p>
|
376
380
|
|
377
|
-
<p>In both styles, the link text is delimited by square brackets
|
381
|
+
<p>In both styles, the link text is delimited by <span>square brackets</span>.</p>
|
378
382
|
|
379
|
-
<p>To create an inline link, use a set of regular parentheses immediately after the link text
|
383
|
+
<p>To create an inline link, use a set of regular parentheses immediately after the link text’s closing square bracket. Inside the parentheses, put the URL where you want the link to point, along with an <em>optional</em> title for the link, surrounded in quotes. For example:</p>
|
380
384
|
<pre><code>This is [an example](http://example.com/ "Title") inline link.
|
381
385
|
|
382
386
|
[This link](http://example.net/) has no title attribute.
|
@@ -388,7 +392,7 @@ an example</a> inline link.</p>
|
|
388
392
|
<p><a href="http://example.net/">This link</a> has no
|
389
393
|
title attribute.</p>
|
390
394
|
</code></pre>
|
391
|
-
<p>If you
|
395
|
+
<p>If you’re referring to a local resource on the same server, you can use relative paths:</p>
|
392
396
|
<pre><code>See my [About](/about/) page for details.
|
393
397
|
</code></pre>
|
394
398
|
<p>Reference-style links use a second set of square brackets, inside which you place a label of your choosing to identify the link:</p>
|
@@ -430,13 +434,13 @@ title attribute.</p>
|
|
430
434
|
</code></pre>
|
431
435
|
<p>Link definitions are only used for creating links during Markdown processing, and are stripped from your document in the HTML output.</p>
|
432
436
|
|
433
|
-
<p>Link definition names may constist of letters, numbers, spaces, and punctuation
|
437
|
+
<p>Link definition names may constist of letters, numbers, spaces, and punctuation – but they are <em>not</em> case sensitive. E.g. these two links:</p>
|
434
438
|
<pre><code>[link text][a]
|
435
439
|
[link text][A]
|
436
440
|
</code></pre>
|
437
441
|
<p>are equivalent.</p>
|
438
442
|
|
439
|
-
<p>The <em>implicit link name</em> shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets
|
443
|
+
<p>The <em>implicit link name</em> shortcut allows you to omit the name of the link, in which case the link text itself is used as the name. Just use an empty set of square brackets – e.g., to link the word “Google” to the google.com web site, you could simply write:</p>
|
440
444
|
<pre><code>[Google][]
|
441
445
|
</code></pre>
|
442
446
|
<p>And then define the link:</p>
|
@@ -448,9 +452,9 @@ title attribute.</p>
|
|
448
452
|
<p>And then define the link:</p>
|
449
453
|
<pre><code>[Daring Fireball]: http://daringfireball.net/
|
450
454
|
</code></pre>
|
451
|
-
<p>Link definitions can be placed anywhere in your Markdown document. I tend to put them immediately after each paragraph in which they
|
455
|
+
<p>Link definitions can be placed anywhere in your Markdown document. I tend to put them immediately after each paragraph in which they’re used, but if you want, you can put them all at the end of your document, sort of like footnotes.</p>
|
452
456
|
|
453
|
-
<p>Here
|
457
|
+
<p>Here’s an example of reference links in action:</p>
|
454
458
|
<pre><code>I get 10 times more traffic from [Google] [1] than from
|
455
459
|
[Yahoo] [2] or [MSN] [3].
|
456
460
|
|
@@ -472,16 +476,16 @@ title="Google">Google</a> than from
|
|
472
476
|
<a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a>
|
473
477
|
or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
|
474
478
|
</code></pre>
|
475
|
-
<p>For comparison, here is the same paragraph written using Markdown
|
479
|
+
<p>For comparison, here is the same paragraph written using Markdown’s inline link style:</p>
|
476
480
|
<pre><code>I get 10 times more traffic from [Google](http://google.com/ "Google")
|
477
481
|
than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
|
478
482
|
[MSN](http://search.msn.com/ "MSN Search").
|
479
483
|
</code></pre>
|
480
|
-
<p>The point of reference-style links is not that they
|
484
|
+
<p>The point of reference-style links is not that they’re easier to write. The point is that with reference-style links, your document source is vastly more readable. Compare the above examples: using reference-style links, the paragraph itself is only 81 characters long; with inline-style links, it’s 176 characters; and as raw HTML, it’s 234 characters. In the raw HTML, there’s more markup than there is text.</p>
|
481
485
|
|
482
|
-
<p>With Markdown
|
486
|
+
<p>With Markdown’s reference-style links, a source document much more closely resembles the final output, as rendered in a browser. By allowing you to move the markup-related metadata out of the paragraph, you can add links without interrupting the narrative flow of your prose.</p>
|
483
487
|
<h3 id='em'>Emphasis</h3>
|
484
|
-
<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an HTML <code><em></code> tag; double <code>*</code
|
488
|
+
<p>Markdown treats asterisks (<code>*</code>) and underscores (<code>_</code>) as indicators of emphasis. Text wrapped with one <code>*</code> or <code>_</code> will be wrapped with an HTML <code><em></code> tag; double <code>*</code>’s or <code>_</code>’s will be wrapped with an HTML <code><strong></code> tag. E.g., this input:</p>
|
485
489
|
<pre><code>*single asterisks*
|
486
490
|
|
487
491
|
_single underscores_
|
@@ -504,7 +508,7 @@ __double underscores__
|
|
504
508
|
<p>Emphasis can be used in the middle of a word:</p>
|
505
509
|
<pre><code>un*fucking*believable
|
506
510
|
</code></pre>
|
507
|
-
<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it
|
511
|
+
<p>But if you surround an <code>*</code> or <code>_</code> with spaces, it’ll be treated as a literal asterisk or underscore.</p>
|
508
512
|
|
509
513
|
<p>To produce a literal asterisk or underscore at a position where it would otherwise be used as an emphasis delimiter, you can backslash escape it:</p>
|
510
514
|
<pre><code>\*this text is surrounded by literal asterisks\*
|
@@ -523,7 +527,7 @@ __double underscores__
|
|
523
527
|
<p>which will produce this:</p>
|
524
528
|
<pre><code><p><code>There is a literal backtick (`) here.</code></p>
|
525
529
|
</code></pre>
|
526
|
-
<p>The backtick delimiters surrounding a code span may include spaces
|
530
|
+
<p>The backtick delimiters surrounding a code span may include spaces – one after the opening, one before the closing. This allows you to place literal backtick characters at the beginning or end of a code span:</p>
|
527
531
|
<pre><code>A single backtick in a code span: `` ` ``
|
528
532
|
|
529
533
|
A backtick-delimited string in a code span: `` `foo` ``
|
@@ -548,7 +552,7 @@ equivalent of <code>&amp;mdash;</code>.</p>
|
|
548
552
|
|
549
553
|
|
550
554
|
</code></pre><h3 id='img'>Images</h3>
|
551
|
-
<p>Admittedly, it
|
555
|
+
<p>Admittedly, it’s fairly difficult to devise a “natural” syntax for placing images into a plain text document format.</p>
|
552
556
|
|
553
557
|
<p>Markdown uses an image syntax that is intended to resemble the syntax for links, allowing for two styles: <em>inline</em> and <em>reference</em>.</p>
|
554
558
|
|
@@ -570,12 +574,12 @@ equivalent of <code>&amp;mdash;</code>.</p>
|
|
570
574
|
<p>Reference-style image syntax looks like this:</p>
|
571
575
|
<pre><code>![Alt text][id]
|
572
576
|
</code></pre>
|
573
|
-
<p>Where
|
577
|
+
<p>Where “id” is the name of a defined image reference. Image references are defined using syntax identical to link references:</p>
|
574
578
|
<pre><code>[id]: url/to/image "Optional title attribute"
|
575
579
|
</code></pre>
|
576
580
|
<p>As of this writing, Markdown has no syntax for specifying the dimensions of an image; if this is important to you, you can simply use regular HTML <code><img></code> tags.</p>
|
577
581
|
<hr /><h2 id='misc'>Miscellaneous</h2><h3 id='autolink'>Automatic Links</h3>
|
578
|
-
<p>Markdown supports a shortcut style for creating
|
582
|
+
<p>Markdown supports a shortcut style for creating “automatic” links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:</p>
|
579
583
|
<pre><code><http://example.com/></code></pre>
|
580
584
|
<p>Markdown will turn this into:</p>
|
581
585
|
<pre><code><a href="http://example.com/">http://example.com/</a>
|
@@ -589,11 +593,11 @@ equivalent of <code>&amp;mdash;</code>.</p>
|
|
589
593
|
&#109;">&#x61;&#x64;&#x64;&#x72;&#x65;&#115;&#115;&#64;&#101;&#120;&#x61;
|
590
594
|
&#109;&#x70;&#x6C;e&#x2E;&#99;&#111;&#109;</a>
|
591
595
|
</code></pre>
|
592
|
-
<p>which will render in a browser as a clickable link to
|
596
|
+
<p>which will render in a browser as a clickable link to “address@example.com”.</p>
|
593
597
|
|
594
|
-
<p>(This sort of entity-encoding trick will indeed fool many, if not most, address-harvesting bots, but it definitely won
|
598
|
+
<p>(This sort of entity-encoding trick will indeed fool many, if not most, address-harvesting bots, but it definitely won’t fool all of them. It’s better than nothing, but an address published in this way will probably eventually start receiving spam.)</p>
|
595
599
|
<h3 id='backslash'>Backslash Escapes</h3>
|
596
|
-
<p>Markdown allows you to use backslash escapes to generate literal characters which would otherwise have special meaning in Markdown
|
600
|
+
<p>Markdown allows you to use backslash escapes to generate literal characters which would otherwise have special meaning in Markdown’s formatting syntax. For example, if you wanted to surround a word with literal asterisks (instead of an HTML <code><em></code> tag), you can backslashes before the asterisks, like this:</p>
|
597
601
|
<pre><code>\*literal asterisks\*
|
598
602
|
</code></pre>
|
599
603
|
<p>Markdown provides backslash escapes for the following characters:</p>
|
@@ -608,4 +612,4 @@ _ underscore
|
|
608
612
|
+ plus sign
|
609
613
|
- minus sign (hyphen)
|
610
614
|
. dot
|
611
|
-
! exclamation mark</code></pre><div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter for Ruby'>Maruku</a> at
|
615
|
+
! exclamation mark</code></pre><div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at 14:11 on Tuesday, January 23rd, 2007.</span></div></body></html>
|
data/docs/maruku.html
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
-
<?xml version=
|
2
|
-
<!DOCTYPE html PUBLIC
|
3
|
-
|
4
|
-
|
5
|
-
<
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC
|
3
|
+
"-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN"
|
4
|
+
"http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
|
5
|
+
<html xmlns:svg='http://www.w3.org/2000/svg' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
6
|
+
<head><meta content='application/xhtml+xml;charset=utf-8' http-equiv='Content-type' /><title>Maruku: a Markdown-superset interpreter</title><link href='style.css' rel='stylesheet' type='text/css' />
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<p><img src='logo.png' id='logo' alt='' /></p>
|
6
10
|
|
7
11
|
<h1 id='maruku_a_markdownsuperset_interpreter'>Mar<strong>u</strong>k<strong>u</strong>: a Markdown-superset interpreter</h1>
|
8
12
|
|
9
13
|
<p><a href='http://maruku.rubyforge.org/'>Maruku</a> is a Markdown interpreter written in <a href='http://www.ruby-lang.org'>Ruby</a>.</p>
|
10
14
|
|
11
15
|
<blockquote id='news'>
|
12
|
-
<p><a href='#release_notes'>Last release</a> is version 0.
|
16
|
+
<p><a href='#release_notes'>Last release</a> is version 0.5.0 – 2007-01-23.</p>
|
13
17
|
|
14
18
|
<p>Use this command to update:</p>
|
15
19
|
<pre><code>$ gem update maruku</code></pre></blockquote>
|
@@ -50,10 +54,10 @@
|
|
50
54
|
|
51
55
|
<p><strong>Authors</strong>: Maruku has been developed so far by <a href='http://www.dis.uniroma1.it/~acensi/'>Andrea Censi</a>. Contributors are most welcome!</p>
|
52
56
|
|
53
|
-
<p><strong>The name of the game</strong>: Maruku is the <a href='http://en.wikipedia.org/wiki/Romaji'>romaji</a> transliteration of the <a href='http://en.wikipedia.org/wiki/Katakana'>katakana</a> transliteration of
|
57
|
+
<p><strong>The name of the game</strong>: Maruku is the <a href='http://en.wikipedia.org/wiki/Romaji'>romaji</a> transliteration of the <a href='http://en.wikipedia.org/wiki/Katakana'>katakana</a> transliteration of “Mark”, the first word in Markdown. I chose this name because Ruby is Japanese, and also the sillable “ru” appears in Maruku.</p>
|
54
58
|
<hr />
|
55
59
|
<p>Table of contents: (<strong>auto-generated by Maruku!</strong>)</p>
|
56
|
-
<div class='maruku_toc'><ul style='list-style: none;'><li><span class='maruku_section_number'>1. </span><a href='#release_notes'>Release notes</a></li><li><span class='maruku_section_number'>2. </span><a href='#download'>Download</a><ul style='list-style: none;'><li><span class='maruku_section_number'>2.1. </span><a href='#bugs_report'>Bugs report</a></li></ul></li><li><span class='maruku_section_number'>3. </span><a href='#usage'>Usage</a><ul style='list-style: none;'><li><span class='maruku_section_number'>3.1. </span><a href='#
|
60
|
+
<div class='maruku_toc'><ul style='list-style: none;'><li><span class='maruku_section_number'>1. </span><a href='#release_notes'>Release notes</a></li><li><span class='maruku_section_number'>2. </span><a href='#download'>Download</a><ul style='list-style: none;'><li><span class='maruku_section_number'>2.1. </span><a href='#bugs_report'>Bugs report</a></li></ul></li><li><span class='maruku_section_number'>3. </span><a href='#usage'>Usage</a><ul style='list-style: none;'><li><span class='maruku_section_number'>3.1. </span><a href='#embedded_maruku'>Embedded Maruku</a></li><li><span class='maruku_section_number'>3.2. </span><a href='#from_the_command_line'>From the command line</a></li></ul></li><li><span class='maruku_section_number'>4. </span><a href='#maruku-and-bluecloth'>Maruku and Bluecloth</a></li><li><span class='maruku_section_number'>5. </span><a href='#maruku_summary_of_features'>Maruku summary of features</a><ul style='list-style: none;'><li><span class='maruku_section_number'>5.1. </span><a href='#meta'>New meta-data syntax</a></li><li><span class='maruku_section_number'>5.2. </span><a href='#toc-generation'>Automatic generation of the table of contents</a></li><li><span class='maruku_section_number'>5.3. </span><a href='#entities'>Use HTML entities</a></li><li><span class='maruku_section_number'>5.4. </span><a href='#this_header_contains_emphasis_strong_text_and_'>This header contains <em>emphasis</em> <strong>strong text</strong> and <code>code</code></a></li></ul></li><li><span class='maruku_section_number'>6. </span><a href='#extra'>Examples of PHP Markdown Extra syntax</a></li></ul></div><hr />
|
57
61
|
<h2 id='release_notes'><span class='maruku_section_number'>1. </span>Release notes</h2>
|
58
62
|
|
59
63
|
<p>Note: Maruku seems to be very robust, nevertheless it is still beta-level software. So if you want to use it in production environments, please check back in a month or so, while we squash the remaining bugs.</p>
|
@@ -62,244 +66,186 @@
|
|
62
66
|
|
63
67
|
<p>Have fun!</p>
|
64
68
|
|
65
|
-
<
|
69
|
+
<p>See the <a href='http://maruku.rubyforge.org/changelog.html#stable'>changelog</a>.</p>
|
66
70
|
|
67
|
-
<
|
68
|
-
<li>
|
69
|
-
<p>Adapted syntax to the <a href='http://maruku.rubyforge.org/proposal.html'>new meta-data proposal</a>.</p>
|
70
|
-
</li>
|
71
|
+
<h2 id='download'><span class='maruku_section_number'>2. </span>Download</h2>
|
71
72
|
|
72
|
-
<
|
73
|
-
<p>Changes in LaTeX export:</p>
|
73
|
+
<p>The development site is <a href='http://rubyforge.org/projects/maruku/'>http://rubyforge.org/projects/maruku/</a>.</p>
|
74
74
|
|
75
|
-
<
|
76
|
-
<
|
77
|
-
|
78
|
-
</
|
75
|
+
<p>Install with:</p>
|
76
|
+
<pre><code>$ gem install maruku
|
77
|
+
</code></pre>
|
78
|
+
<p>Released files can also be seen at <a href='http://rubyforge.org/frs/?group_id=2795'>http://rubyforge.org/frs/?group_id=2795</a>.</p>
|
79
79
|
|
80
|
-
<
|
81
|
-
<
|
82
|
-
|
83
|
-
|
84
|
-
LaTeX preamble: preamble.tex
|
80
|
+
<p>Anonymous access to the repository is possible with:</p>
|
81
|
+
<pre><code>$ svn checkout svn://rubyforge.org/var/svn/maruku/trunk
|
82
|
+
</code></pre>
|
83
|
+
<p>If you want commit access to the repository, just create an account on Rubyforge and <a href='http://www.dis.uniroma1.it/~acensi/contact.html'>drop me a mail</a>.</p>
|
85
84
|
|
86
|
-
|
87
|
-
</ul>
|
88
|
-
</li>
|
85
|
+
<h3 id='bugs_report'><span class='maruku_section_number'>2.1. </span>Bugs report</h3>
|
89
86
|
|
90
|
-
<
|
91
|
-
<p>Bug fixes</p>
|
87
|
+
<p>Use the <a href='http://rubyforge.org/tracker/?group_id=2795'>tracker</a> or <a href='http://www.dis.uniroma1.it/~acensi/contact.html'>drop me an email</a>.</p>
|
92
88
|
|
93
|
-
<
|
94
|
-
<li>
|
95
|
-
<p>Images were not given <code>id</code> or <code>class</code> attributes.</p>
|
96
|
-
</li>
|
89
|
+
<h2 id='usage'><span class='maruku_section_number'>3. </span>Usage</h2>
|
97
90
|
|
98
|
-
<
|
99
|
-
<p>Fixed bug in LaTeX export with handling of <code><</code>,<code>></code> enclosed URLs: <code><google.com></code>.</p>
|
100
|
-
</li>
|
101
|
-
</ul>
|
102
|
-
</li>
|
103
|
-
</ul>
|
91
|
+
<h3 id='embedded_maruku'><span class='maruku_section_number'>3.1. </span>Embedded Maruku</h3>
|
104
92
|
|
105
|
-
<
|
93
|
+
<p>This is the basic usage:</p>
|
94
|
+
<pre><code>require 'rubygems'
|
95
|
+
require 'maruku'
|
106
96
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
<
|
111
|
-
|
112
|
-
|
113
|
-
<p
|
114
|
-
|
97
|
+
doc = Maruku.new(markdown_string)
|
98
|
+
puts doc.to_html
|
99
|
+
</code></pre>
|
100
|
+
<p>The method <code>to_html</code> outputs only an HTML fragment, while the method <code>to_html_document</code> outputs a complete XHTML 1.0 document:</p>
|
101
|
+
<pre><code>puts doc.to_html_document
|
102
|
+
</code></pre>
|
103
|
+
<p>You can have the REXML document tree with:</p>
|
104
|
+
<pre><code>tree = doc.to_html_document_tree
|
105
|
+
</code></pre>
|
106
|
+
<h3 id='from_the_command_line'><span class='maruku_section_number'>3.2. </span>From the command line</h3>
|
115
107
|
|
116
|
-
<p>
|
117
|
-
</li>
|
108
|
+
<p>There is one command-line program installed: <code>maruku</code>.</p>
|
118
109
|
|
119
|
-
<
|
120
|
-
<
|
121
|
-
</
|
110
|
+
<p>Without arguments, it converts Markdown to HTML:</p>
|
111
|
+
<pre><code>$ maruku file.md # creates file.html</code></pre>
|
112
|
+
<p>With the <code>--pdf</code> arguments, it converts Markdown to LaTeX, then calls <code>pdflatex</code> to transform to PDF:</p>
|
113
|
+
<pre><code>$ maruku --pdf file.md # creates file.tex and file.pdf</code></pre>
|
114
|
+
<h2 id='maruku-and-bluecloth'><span class='maruku_section_number'>4. </span>Maruku and Bluecloth</h2>
|
122
115
|
|
123
|
-
<
|
124
|
-
<p>Changes in LaTeX export:</p>
|
116
|
+
<p>The other Ruby implementation of Markdown is <a href='http://www.deveiate.org/projects/BlueCloth'>Bluecloth</a>.</p>
|
125
117
|
|
126
|
-
<
|
127
|
-
<li>
|
128
|
-
<p>Now Japanese text rendering sort of works, using the following packages:</p>
|
129
|
-
<pre><code>\usepackage[C40]{fontenc}
|
130
|
-
\usepackage[cjkjis]{ucs}
|
131
|
-
\usepackage[utf8x]{inputenc}
|
132
|
-
</code></pre>
|
133
|
-
<p>Nevertheless, I could only get bitmap fonts working – probably it’s a problem with my setup.</p>
|
118
|
+
<p>Maruku is much different in philosophy from Bluecloth: the biggest difference is that <em>parsing</em> is separated from <em>rendering</em>. In Maruku, an in-memory representation of the Markdown document is created. Instead, Bluecloth mantains the document in memory as a String at all times, and does a series of <code>gsub</code> to transform to HTML.</p>
|
134
119
|
|
135
|
-
<p>
|
136
|
-
</li>
|
120
|
+
<p>Maruku is usually faster than Bluecloth. Bluecloth is faster for very small documents. Bluecloth sometimes chokes on very big documents (it is reported that the blame should be on Ruby’s regexp implementation).</p>
|
137
121
|
|
138
|
-
<
|
139
|
-
<
|
140
|
-
|
122
|
+
<p>This is the canonical benchmark (the Markdown specification), executed with Ruby 1.8.5 on a Powerbook 1.5GhZ:</p>
|
123
|
+
<pre><code>BlueCloth (to_html): parsing 0.01 sec + rendering 1.87 sec = 1.88 sec (1.00x)
|
124
|
+
Maruku (to_html): parsing 0.66 sec + rendering 0.43 sec = 1.09 sec (1.73x)
|
125
|
+
Maruku (to_latex): parsing 0.67 sec + rendering 0.23 sec = 0.90 sec (2.10x)
|
126
|
+
</code></pre>
|
127
|
+
<p>Please note that Maruku has a lot more features and therefore is looking for much more patterns in the file.</p>
|
141
128
|
|
142
|
-
<
|
143
|
-
<p>External packages are <code>require</code>d only if needed.</p>
|
144
|
-
</li>
|
129
|
+
<h2 id='maruku_summary_of_features'><span class='maruku_section_number'>5. </span>Maruku summary of features</h2>
|
145
130
|
|
131
|
+
<ul>
|
146
132
|
<li>
|
147
|
-
<p>
|
148
|
-
</li>
|
149
|
-
</ul>
|
150
|
-
</li>
|
151
|
-
</ul>
|
152
|
-
|
153
|
-
<h4 id='changes_in_04'>Changes in 0.4</h4>
|
133
|
+
<p>Supported syntax</p>
|
154
134
|
|
155
135
|
<ul>
|
156
|
-
<li
|
157
|
-
|
158
|
-
<li>General refactorization of the code and much cleaner error reporting.</li>
|
136
|
+
<li><a href='http://daringfireball.net/projects/markdown/syntax'>Basic Markdown</a></li>
|
159
137
|
|
160
|
-
<li
|
138
|
+
<li><a href='#extra'>Markdown Extra</a></li>
|
161
139
|
|
162
|
-
<li>
|
163
|
-
|
164
|
-
<li>Added unit-tests for block-level elements.</li>
|
140
|
+
<li><a href='#meta'>Meta-data syntax</a></li>
|
165
141
|
</ul>
|
142
|
+
</li>
|
166
143
|
|
167
|
-
<
|
144
|
+
<li>
|
145
|
+
<p>Output</p>
|
168
146
|
|
169
147
|
<ul>
|
170
148
|
<li>
|
171
|
-
<p>
|
172
|
-
|
173
|
-
<p>Now Maruku is almost 2x faster than Bluecloth, while having more features.</p>
|
149
|
+
<p>XHTML</p>
|
174
150
|
|
175
|
-
<
|
176
|
-
<
|
177
|
-
|
178
|
-
Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pre>
|
179
|
-
<p>This is the result of running <code>lib/maruku/tests/benchmark.rb</code> on the Markdown specification.</p>
|
151
|
+
<ul>
|
152
|
+
<li>Syntax highlighting via the <a href='http://syntax.rubyforge.org/'><code>syntax</code></a> library.</li>
|
153
|
+
</ul>
|
180
154
|
</li>
|
181
155
|
|
182
156
|
<li>
|
183
|
-
<p>
|
184
|
-
</li>
|
157
|
+
<p>LaTeX</p>
|
185
158
|
|
186
|
-
<
|
187
|
-
<
|
159
|
+
<ul>
|
160
|
+
<li><a href='#entities'>Translation of HTML entities to LaTeX</a></li>
|
161
|
+
|
162
|
+
<li>Syntax highlighting via the <a href='http://www.ctan.org/tex-archive/macros/latex/contrib/listings/'><code>listings</code></a> package.</li>
|
163
|
+
</ul>
|
164
|
+
</li>
|
165
|
+
</ul>
|
188
166
|
</li>
|
189
167
|
|
190
168
|
<li>
|
191
|
-
<p>
|
169
|
+
<p>Misc</p>
|
192
170
|
|
193
|
-
<
|
194
|
-
<
|
195
|
-
</
|
196
|
-
<p>then syntax errors will cause an exception to be raised (you can catch this and retry).</p>
|
171
|
+
<ul>
|
172
|
+
<li>
|
173
|
+
<p><a href='exd.html'>Documentation for supported attributes</a></p>
|
197
174
|
</li>
|
198
175
|
|
199
176
|
<li>
|
200
|
-
<p>
|
177
|
+
<p><a href='#toc-generation'>Automatic generation of the TOC</a></p>
|
178
|
+
</li>
|
179
|
+
</ul>
|
201
180
|
</li>
|
202
181
|
</ul>
|
203
182
|
|
204
|
-
<p>
|
183
|
+
<p><strong>Experimental features (not released yet)</strong></p>
|
205
184
|
|
206
185
|
<ul>
|
207
|
-
<li>
|
208
|
-
<p>UTF-8 input/output works OK for HTML, however I am having pain trying to export to LaTeX. I want at least Japanese characters support, so if you know how to do this you are very welcome to give me an hand.</p>
|
209
|
-
|
210
|
-
<p>For example: in the HTML version, you should see accented characters in this parenthesis:</p>
|
211
|
-
|
212
|
-
<blockquote>
|
213
|
-
<p>(àèìòù)</p>
|
214
|
-
</blockquote>
|
215
|
-
|
216
|
-
<p>and Japanese text in these other parentheses:</p>
|
217
|
-
|
218
|
-
<blockquote>
|
219
|
-
<p>(カタカナで 私の 名前は アンドレア チェンシ です).</p>
|
186
|
+
<li><a href='http://maruku.rubyforge.org/math.xhtml'>LaTeX Math syntax</a> (not enabled by default)</li>
|
220
187
|
|
221
|
-
<
|
222
|
-
</blockquote>
|
188
|
+
<li>An extension system for adding new syntax is available, but the API is bound to change in the future, so please don’t use it.</li>
|
223
189
|
|
224
|
-
<
|
225
|
-
</li>
|
190
|
+
<li>LaTeX to MathML using either one of <a href='http://ritex.rubyforge.org'><code>ritex</code></a>, <a href='http://golem.ph.utexas.edu/~distler/code/itexToMML/'><code>itex2mml</code></a>, <a href='http://www.blahtex.org'><code>blahtex</code></a>.</li>
|
226
191
|
|
227
|
-
<li>
|
228
|
-
|
229
|
-
</li>
|
192
|
+
<li>LaTeX to PNG using <a href='http://www.blahtex.org'><code>blahtex</code></a>.</li>
|
193
|
+
</ul>
|
230
194
|
|
231
|
-
<
|
232
|
-
<p>Exporting to Markdown (pretty printing).</p>
|
233
|
-
</li>
|
195
|
+
<h3 id='meta'><span class='maruku_section_number'>5.1. </span>New meta-data syntax</h3>
|
234
196
|
|
235
|
-
<
|
236
|
-
<p>Exporting to HTML splitting in multiple files.</p>
|
237
|
-
</li>
|
238
|
-
|
239
|
-
<li>
|
240
|
-
<p>RubyPants.</p>
|
241
|
-
</li>
|
197
|
+
<p>Maruku implements a syntax that allows to attach “meta” information to objects.</p>
|
242
198
|
|
243
|
-
<
|
244
|
-
<p>Support for images in PDF.</p>
|
245
|
-
</li>
|
246
|
-
</ul>
|
199
|
+
<p>See <a href='http://maruku.rubyforge.org/proposal.html'>this proposal</a> for how to attach metadata to the elements.</p>
|
247
200
|
|
248
|
-
<
|
201
|
+
<p>See the <a href='exd.html'>documentation for supported attributes</a>.</p>
|
249
202
|
|
250
|
-
<p>
|
203
|
+
<p>Meta-data for the document itself is specified through the use of email headers:</p>
|
204
|
+
<pre><code>Title: A simple document containing meta-headers
|
205
|
+
CSS: style.css
|
251
206
|
|
252
|
-
|
253
|
-
<pre><code>$ gem install maruku
|
207
|
+
Content of the document
|
254
208
|
</code></pre>
|
255
|
-
<p>
|
256
|
-
|
257
|
-
<p>Anonymous access to the repository is possible with:</p>
|
258
|
-
<pre><code>$ svn checkout svn://rubyforge.org/var/svn/maruku
|
209
|
+
<p>When creating the document through</p>
|
210
|
+
<pre><code>Maruku.new(s).to_html_document
|
259
211
|
</code></pre>
|
260
|
-
<p>
|
212
|
+
<p>the title and stylesheet are added as expected.</p>
|
261
213
|
|
262
|
-
<
|
214
|
+
<p>Meta-data keys are assumed to be case-insensitive.</p>
|
263
215
|
|
264
|
-
<
|
216
|
+
<h3 id='toc-generation'><span class='maruku_section_number'>5.2. </span>Automatic generation of the table of contents</h3>
|
265
217
|
|
266
|
-
<
|
218
|
+
<p>If you create a list, and then set the <code>toc</code> attribute, when rendering Maruku will create an auto-generated table of contents.</p>
|
219
|
+
<pre><code>* This will become a table of contents (this text will be scraped).
|
220
|
+
{:toc}
|
221
|
+
</code></pre>
|
222
|
+
<p>You can see an example of this at the beginning of this document.</p>
|
267
223
|
|
268
|
-
<
|
269
|
-
<pre><code>require 'rubygems'
|
270
|
-
require 'maruku'
|
224
|
+
<h3 id='entities'><span class='maruku_section_number'>5.3. </span>Use HTML entities</h3>
|
271
225
|
|
272
|
-
|
273
|
-
|
274
|
-
</code></
|
275
|
-
|
276
|
-
|
277
|
-
</
|
278
|
-
<p>
|
279
|
-
<pre><code>tree = doc.to_html_document_tree
|
280
|
-
</code></pre>
|
281
|
-
<h3 id='from_the_command_line'><span class='maruku_section_number'>3.1. </span>From the command line</h3>
|
226
|
+
<p>If you want to use HTML entities, go on! We will take care of the translation to LaTeX:</p>
|
227
|
+
<table><thead><tr><th>Entity</th><th>Result</th></tr></thead><tbody><tr><td style='text-align: left;'><code>&copy;</code></td><td style='text-align: left;'>©</td>
|
228
|
+
</tr><tr><td style='text-align: left;'><code>&pound;</code></td><td style='text-align: left;'>£</td>
|
229
|
+
</tr><tr><td style='text-align: left;'><code>&lambda;</code></td><td style='text-align: left;'>λ</td>
|
230
|
+
</tr><tr><td style='text-align: left;'><code>&mdash;</code></td><td style='text-align: left;'>—</td>
|
231
|
+
</tr></tbody></table>
|
232
|
+
<p>See the <a href='http://maruku.rubyforge.org/entity_test.html'>list of supported entities</a> (<a href='http://maruku.rubyforge.org/entity_test.pdf'>pdf</a>).</p>
|
282
233
|
|
283
|
-
<
|
234
|
+
<h3 id='this_header_contains_emphasis_strong_text_and_'><span class='maruku_section_number'>5.4. </span>This header contains <em>emphasis</em> <strong>strong text</strong> and <code>code</code></h3>
|
284
235
|
|
285
|
-
<
|
286
|
-
<li>
|
287
|
-
<p><code>maruku</code> converts Markdown to HTML:</p>
|
288
|
-
<pre><code>$ maruku file.md # creates file.html</code></pre></li>
|
236
|
+
<p>Note that this header contains formatting and it still works, also in the table of contents.</p>
|
289
237
|
|
290
|
-
<
|
291
|
-
<p><code>marutex</code> converts Markdown to LaTeX, then calls <code>pdflatex</code> to transform to PDF:</p>
|
292
|
-
<pre><code>$ marutex file.md # creates file.tex and file.pdf</code></pre></li>
|
293
|
-
</ul>
|
238
|
+
<p>And <a href='#features'>This is a <em>link</em> with <strong>all</strong> <strong><em>sort</em></strong> of <code>weird stuff</code></a> in the text.</p>
|
294
239
|
|
295
|
-
<h2 id='extra'><span class='maruku_section_number'>
|
240
|
+
<h2 id='extra'><span class='maruku_section_number'>6. </span>Examples of PHP Markdown Extra syntax</h2>
|
296
241
|
|
297
242
|
<ul>
|
298
243
|
<li>
|
299
244
|
<p>tables</p>
|
300
245
|
<pre><code>Col1 | Very very long head | Very very long head|
|
301
246
|
-----|:-------------------:|-------------------:|
|
302
|
-
cell | center-align | right-align |</code></pre><table><thead><tr><th>Col1</th><th>Very very long head</th><th>Very very long head</th></tr></thead><tbody><tr><td style='text-align: left;'>cell</td><td style='text-align: center;'>center-align</td><td style='text-align: right;'>right-align</td
|
247
|
+
cell | center-align | right-align |</code></pre><table><thead><tr><th>Col1</th><th>Very very long head</th><th>Very very long head</th></tr></thead><tbody><tr><td style='text-align: left;'>cell</td><td style='text-align: center;'>center-align</td><td style='text-align: right;'>right-align</td>
|
248
|
+
</tr></tbody></table></li>
|
303
249
|
|
304
250
|
<li>
|
305
251
|
<p>footnotes <sup id='fnref:1'><a href='#fn:1' rel='footnote'>1</a></sup></p>
|
@@ -338,181 +284,16 @@ cell | center-align | right-align |</code></pre><table><thead><tr>
|
|
338
284
|
<p>abbreviations or <abbr title='Simply an abbreviation'>ABB</abbr> for short.</p>
|
339
285
|
</li>
|
340
286
|
</ul>
|
287
|
+
<!--
|
288
|
+
Future developments {#future}
|
341
289
|
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
<p>Maruku is much different in philosophy from Bluecloth: the biggest difference is that <em>parsing</em> is separated from <em>rendering</em>. In Maruku, an in-memory representation of the Markdown document is created. Instead, Bluecloth mantains the document in memory as a String at all times, and does a series of <code>gsub</code> to transform to HTML.</p>
|
347
|
-
|
348
|
-
<p>The in-memory representation makes it very easy to export to various formats (at the moment HTML and LaTeX/PDF; the next is pretty-printed Markdown).</p>
|
349
|
-
|
350
|
-
<p>Other improvements over Bluecloth:</p>
|
351
|
-
|
352
|
-
<ul>
|
353
|
-
<li>
|
354
|
-
<p>the HTML output is provided also as a <code>REXML</code> document tree.</p>
|
355
|
-
</li>
|
356
|
-
|
357
|
-
<li>
|
358
|
-
<p>PHP Markdown Syntax support.</p>
|
359
|
-
</li>
|
360
|
-
</ul>
|
361
|
-
|
362
|
-
<h2 id='meta'><span class='maruku_section_number'>6. </span>New meta-data syntax</h2>
|
363
|
-
|
364
|
-
<p>Maruku implements a syntax that allows to attach “meta” information to objects.</p>
|
365
|
-
|
366
|
-
<h3 id='metadata_for_blocklevel_and_spanlevel_elements'><span class='maruku_section_number'>6.1. </span>Meta-data for block-level and span-level elements</h3>
|
367
|
-
|
368
|
-
<p>See <a href='http://maruku.rubyforge.org/proposal.html'>this proposal</a>.</p>
|
369
|
-
|
370
|
-
<h3 id='metadata_for_the_document'><span class='maruku_section_number'>6.2. </span>Meta-data for the document</h3>
|
371
|
-
|
372
|
-
<p>Meta-data for the document itself is specified through the use of email headers:</p>
|
373
|
-
<pre><code>Title: A simple document containing meta-headers
|
374
|
-
CSS: style.css
|
375
|
-
|
376
|
-
Content of the document
|
377
|
-
</code></pre>
|
378
|
-
<p>When creating the document through</p>
|
379
|
-
<pre><code>Maruku.new(s).to_html_document
|
380
|
-
</code></pre>
|
381
|
-
<p>the title and stylesheet are added as expected.</p>
|
382
|
-
|
383
|
-
<p>Meta-data keys are assumed to be case-insensitive.</p>
|
384
|
-
<hr />
|
385
|
-
<h3 id='metalist'><span class='maruku_section_number'>6.3. </span>List of meta-data</h3>
|
386
|
-
|
387
|
-
<dl>
|
388
|
-
<dt><strong><code>title</code>, <code>subject</code></strong></dt>
|
389
|
-
|
390
|
-
<dd>
|
391
|
-
<p>(document) Sets the title of the document (HTML: used in the <code>TITLE</code> element).</p>
|
392
|
-
</dd>
|
393
|
-
|
394
|
-
<dt><strong><code>use_numbered_headers</code></strong></dt>
|
395
|
-
|
396
|
-
<dd>
|
397
|
-
<p>(document) If <code>true</code>, headers are numbered (just like this document). Default is <code>false</code>.</p>
|
398
|
-
</dd>
|
399
|
-
|
400
|
-
<dt><strong><code>css</code></strong></dt>
|
401
|
-
|
402
|
-
<dd>
|
403
|
-
<p>(document, HTML) Url of stylesheet.</p>
|
404
|
-
</dd>
|
405
|
-
|
406
|
-
<dt><strong><code>html_use_syntax</code></strong></dt>
|
407
|
-
|
408
|
-
<dd>
|
409
|
-
<p>(document, HTML) If set, use the <a href='http://syntax.rubyforge.org/'>Ruby <code>syntax</code> library</a> to add source highlighting.</p>
|
410
|
-
</dd>
|
411
|
-
|
412
|
-
<dt><strong><code>latex_use_listings</code></strong></dt>
|
413
|
-
|
414
|
-
<dd>
|
415
|
-
<p>(document, LaTeX) If set, use the fancy <a href='http://www.ctan.org/tex-archive/macros/latex/contrib/listings/'><code>listings</code> package</a> for better displaying code blocks.</p>
|
416
|
-
|
417
|
-
<p>If not set, use standard <code>verbatim</code> environment.</p>
|
418
|
-
</dd>
|
419
|
-
|
420
|
-
<dt><strong><code>style</code>, <code>id</code>, <code>class</code></strong></dt>
|
421
|
-
|
422
|
-
<dd>
|
423
|
-
<p>(any block object, HTML) Standard CSS attributes are copied.</p>
|
424
|
-
</dd>
|
425
|
-
|
426
|
-
<dt><strong><code>lang</code></strong></dt>
|
427
|
-
|
428
|
-
<dd>
|
429
|
-
<p>(code blocks) Name of programming language (<code>ruby</code>) for syntax highlighting.</p>
|
430
|
-
|
431
|
-
<p>Default for this is <code>code_lang</code> in document.</p>
|
432
|
-
|
433
|
-
<p>Syntax highlighting is delegated to the <a href='http://syntax.rubyforge.org/'><code>syntax</code> library</a> for HTML output and to the <a href='http://www.ctan.org/tex-archive/macros/latex/contrib/listings/'><code>listings</code> package</a> for LaTeX output.</p>
|
434
|
-
</dd>
|
435
|
-
|
436
|
-
<dt><strong><code>code_show_spaces</code></strong></dt>
|
437
|
-
|
438
|
-
<dd>
|
439
|
-
<p>Shows tabs and newlines (default is read in the document object).</p>
|
440
|
-
</dd>
|
441
|
-
|
442
|
-
<dt><strong><code>code_background_color</code></strong></dt>
|
443
|
-
|
444
|
-
<dd>
|
445
|
-
<p>Background color for code blocks. (default is read in the document object).</p>
|
446
|
-
|
447
|
-
<p>The format is either a named color (<code>green</code>, <code>red</code>) or a CSS color of the form <code>#ff00ff</code>.</p>
|
448
|
-
|
449
|
-
<ul>
|
450
|
-
<li>
|
451
|
-
<p>for <strong>HTML output</strong>, the value is put straight in the <code>background-color</code> CSS property of the block.</p>
|
452
|
-
</li>
|
453
|
-
|
454
|
-
<li>
|
455
|
-
<p>for <strong>LaTeX output</strong>, if it is a named color, it must be a color accepted by the LaTeX <code>color</code> packages. If it is of the form <code>#ff00ff</code>, Maruku defines a color using the <code>\color[rgb]{r,g,b}</code> macro.</p>
|
456
|
-
|
457
|
-
<p>For example, for <code>#0000ff</code>, the macro is called as: <code>\color[rgb]{0,0,1}</code>.</p>
|
458
|
-
</li>
|
459
|
-
</ul>
|
460
|
-
</dd>
|
461
|
-
</dl>
|
462
|
-
|
463
|
-
<h3 id='examples'><span class='maruku_section_number'>6.4. </span>Examples</h3>
|
464
|
-
|
465
|
-
<p>An example of this is the following:</p>
|
466
|
-
<pre><code> One space
|
467
|
-
Two spaces
|
468
|
-
Tab, space, tab
|
469
|
-
Tab, tab, tab and all is green!
|
470
|
-
{:code_show_spaces code_background_color=#ffeedd}</code></pre>
|
471
|
-
<p>That will produce:</p>
|
472
|
-
<pre style='background-color: #ffeedd;'><code>¬One¬space
|
473
|
-
¬¬Two¬spaces
|
474
|
-
» ¬» Tab,¬space,¬tab
|
475
|
-
» » » Tab,¬tab,¬tab¬and¬all¬is¬green!</code></pre>
|
476
|
-
<p>Or highlighting (support depends on languages):</p>
|
477
|
-
<pre><code> <div style="text-align:center">Div</div>
|
478
|
-
{:lang=html}
|
479
|
-
</code></pre>
|
480
|
-
<p>produces:</p>
|
481
|
-
<pre class='xml'><span class='punct'><</span><span class='tag'>div</span> <span class='attribute'>style</span><span class='punct'>="</span><span class='string'>text-align:center</span><span class='punct'>"></span>Div<span class='punct'></</span><span class='tag'>div</span><span class='punct'>></span></pre><hr />
|
482
|
-
<h2 id='features'><span class='maruku_section_number'>7. </span>Other Features</h2>
|
483
|
-
|
484
|
-
<h3 id='automatic_generation_of_the_table_of_contents'><span class='maruku_section_number'>7.1. </span>Automatic generation of the table of contents</h3>
|
485
|
-
|
486
|
-
<p>If you create a list, and then set the <code>toc</code> attribute, when rendering Maruku will create an auto-generated table of contents.</p>
|
487
|
-
<pre><code>* This will become a table of contents (this text will be scraped).
|
488
|
-
{:toc}
|
489
|
-
</code></pre>
|
490
|
-
<p>You can see an example of this at the beginning of this document.</p>
|
491
|
-
|
492
|
-
<h3 id='this_header_contains_emphasis_strong_text_and_'><span class='maruku_section_number'>7.2. </span>This header contains <em>emphasis</em> <strong>strong text</strong> and <code>code</code></h3>
|
493
|
-
|
494
|
-
<p>Note that this header contains formatting and it still works, also in the table of contents.</p>
|
495
|
-
|
496
|
-
<p>And <a href='#features'>This is a <em>link</em> with <strong>all</strong> <strong><em>sort</em></strong> of <code>weird stuff</code></a> in the text.</p>
|
497
|
-
|
498
|
-
<h3 id='use_html_entities'><span class='maruku_section_number'>7.3. </span>Use HTML entities</h3>
|
499
|
-
|
500
|
-
<p>If you want to use HTML entities, go on! We will take care of the translation to LaTeX:</p>
|
501
|
-
<table><thead><tr><th>Entity</th><th>Result</th></tr></thead><tbody><tr><td style='text-align: left;'><code>&copy;</code></td><td style='text-align: left;'>©</td></tr><tr><td style='text-align: left;'><code>&pound;</code></td><td style='text-align: left;'>£</td></tr><tr><td style='text-align: left;'><code>a&nbsp;b</code></td><td style='text-align: left;'>a b</td></tr><tr><td style='text-align: left;'><code>&lambda;</code></td><td style='text-align: left;'>λ</td></tr><tr><td style='text-align: left;'><code>&mdash;</code></td><td style='text-align: left;'>—</td></tr></tbody></table>
|
502
|
-
<h2 id='future'><span class='maruku_section_number'>8. </span>Future developments</h2>
|
503
|
-
|
504
|
-
<p>I think that <a href='http://sophos.berkeley.edu/macfarlane/pandoc/'>Pandoc</a> and <a href='http://fletcher.freeshell.org/wiki/MultiMarkdown'>MultiMarkdown</a> are very cool projects. However, they are written in Haskell and Perl, respectively. I would love to have an equivalent in Ruby.</p>
|
505
|
-
|
506
|
-
<h3 id='a_syntax_for_adding_math'><span class='maruku_section_number'>8.1. </span>A syntax for adding math</h3>
|
507
|
-
|
508
|
-
<p>Something inspired from LaTeX should be familiar to all:</p>
|
509
|
-
<pre><code>This is inline math: $\alpha$
|
510
|
-
|
511
|
-
|
512
|
-
This is an equation with label:
|
290
|
+
I think that [Pandoc] and [MultiMarkdown] are very cool projects.
|
291
|
+
However, they are written in Haskell and Perl, respectively.
|
292
|
+
I would love to have an equivalent in Ruby.
|
513
293
|
|
514
|
-
|
294
|
+
[Pandoc]: http://sophos.berkeley.edu/macfarlane/pandoc/
|
295
|
+
[MultiMarkdown]: http://fletcher.freeshell.org/wiki/MultiMarkdown
|
515
296
|
|
516
|
-
|
297
|
+
--><div class='footnotes'><hr /><ol><li id='fn:1'>
|
517
298
|
<p>I really was missing those.</p>
|
518
|
-
<a href='#fnref:1' rev='footnote'>↩</a></li></ol></div></body></html>
|
299
|
+
<a href='#fnref:1' rev='footnote'>↩</a></li></ol></div><div class='maruku_signature'><hr /><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown-superset interpreter for Ruby'>Maruku</a> at 14:11 on Tuesday, January 23rd, 2007.</span></div></body></html>
|