maruku 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/{maruku0.3 → marudown} +6 -14
- data/bin/maruku +1 -1
- data/bin/marutest +37 -9
- data/docs/TOFIX.html +22 -0
- data/docs/TOFIX.md +3 -0
- data/docs/changelog-0.2.13.html +30 -0
- data/docs/changelog-0.2.13.md +6 -0
- data/docs/changelog-0.3.html +19 -5
- data/docs/faq.html +51 -40
- data/docs/faq.md +3 -3
- data/docs/hidden_o_n_squared.md +10 -0
- data/docs/index.html +84 -396
- data/docs/markdown_syntax.html +139 -330
- data/docs/markdown_syntax.md +80 -93
- data/docs/maruku.html +84 -396
- data/docs/maruku.md +88 -158
- data/docs/proposal.html +13 -106
- data/docs/proposal.md +3 -3
- data/docs/todo.html +38 -28
- data/lib/maruku.rb +77 -11
- data/lib/maruku/attributes.rb +186 -0
- data/lib/maruku/defaults.rb +40 -0
- data/lib/maruku/errors_management.rb +55 -39
- data/lib/maruku/helpers.rb +156 -72
- data/lib/maruku/input/charsource.rb +319 -0
- data/lib/maruku/{html_helper.rb → input/html_helper.rb} +30 -9
- data/lib/maruku/input/linesource.rb +111 -0
- data/lib/maruku/input/parse_block.rb +562 -0
- data/lib/maruku/{parse_doc.rb → input/parse_doc.rb} +60 -28
- data/lib/maruku/{parse_span_better.rb → input/parse_span_better.rb} +226 -256
- data/lib/maruku/input/type_detection.rb +137 -0
- data/lib/maruku/maruku.rb +33 -0
- data/lib/maruku/{to_html.rb → output/to_html.rb} +151 -132
- data/lib/maruku/{to_latex.rb → output/to_latex.rb} +31 -35
- data/lib/maruku/{to_latex_entities.rb → output/to_latex_entities.rb} +25 -3
- data/lib/maruku/output/to_latex_strings.rb +64 -0
- data/lib/maruku/output/to_markdown.rb +164 -0
- data/lib/maruku/{to_s.rb → output/to_s.rb} +6 -0
- data/lib/maruku/string_utils.rb +12 -181
- data/lib/maruku/structures.rb +91 -67
- data/lib/maruku/structures_inspect.rb +78 -0
- data/lib/maruku/structures_iterators.rb +24 -2
- data/lib/maruku/tests/benchmark.rb +41 -9
- data/lib/maruku/tests/new_parser.rb +317 -286
- data/lib/maruku/tests/tests.rb +20 -0
- data/lib/maruku/toc.rb +64 -64
- data/lib/maruku/usage/example1.rb +33 -0
- data/lib/maruku/version.rb +8 -2
- data/tests/unittest/abbreviations.md +27 -16
- data/tests/unittest/attributes/attributes.md +89 -0
- data/tests/unittest/attributes/circular.md +51 -0
- data/tests/unittest/attributes/default.md +47 -0
- data/tests/unittest/blank.md +10 -6
- data/tests/unittest/blanks_in_code.md +26 -26
- data/tests/unittest/code.md +9 -9
- data/tests/unittest/code2.md +12 -13
- data/tests/unittest/code3.md +34 -34
- data/tests/unittest/easy.md +9 -7
- data/tests/unittest/email.md +9 -7
- data/tests/unittest/encoding/iso-8859-1.md +41 -4
- data/tests/unittest/encoding/utf-8.md +6 -5
- data/tests/unittest/entities.md +52 -80
- data/tests/unittest/escaping.md +47 -35
- data/tests/unittest/extra_dl.md +19 -29
- data/tests/unittest/extra_header_id.md +31 -24
- data/tests/unittest/extra_table1.md +14 -32
- data/tests/unittest/footnotes.md +58 -42
- data/tests/unittest/headers.md +11 -11
- data/tests/unittest/hrule.md +14 -24
- data/tests/unittest/images.md +41 -26
- data/tests/unittest/inline_html.md +104 -56
- data/tests/unittest/inline_html2.md +38 -0
- data/tests/unittest/links.md +74 -33
- data/tests/unittest/list1.md +18 -15
- data/tests/unittest/list2.md +31 -13
- data/tests/unittest/list3.md +29 -28
- data/tests/unittest/list4.md +103 -12
- data/tests/unittest/lists.md +86 -53
- data/tests/unittest/lists6.md +53 -0
- data/tests/unittest/lists7.md +31 -0
- data/tests/unittest/lists_after_paragraph.md +105 -71
- data/tests/unittest/lists_ol.md +149 -73
- data/tests/unittest/misc_sw.md +366 -326
- data/tests/unittest/notyet/escape.md +10 -10
- data/tests/unittest/notyet/header_after_par.md +20 -14
- data/tests/unittest/notyet/ticks.md +8 -35
- data/tests/unittest/notyet/triggering.md +72 -45
- data/tests/unittest/olist.md +78 -0
- data/tests/unittest/one.md +5 -3
- data/tests/unittest/paragraph.md +5 -3
- data/tests/unittest/paragraph_rules/dont_merge_ref.md +15 -9
- data/tests/unittest/paragraph_rules/tab_is_blank.md +9 -5
- data/tests/unittest/paragraphs.md +21 -26
- data/tests/unittest/recover/recover_links.md +6 -5
- data/tests/unittest/references/long_example.md +39 -30
- data/tests/unittest/references/spaces_and_numbers.md +2 -2
- data/tests/unittest/syntax_hl.md +33 -31
- data/tests/unittest/test.md +4 -6
- data/tests/unittest/wrapping.md +43 -26
- metadata +160 -139
- data/docs/markdown_extra2.html +0 -87
- data/docs/markdown_extra2.md +0 -83
- data/docs/markdown_syntax_2.html +0 -152
- data/lib/maruku/parse_block.rb +0 -564
- data/lib/maruku/parse_span.rb +0 -451
- data/lib/maruku/to_latex_strings.rb +0 -59
- data/lib/maruku/to_markdown.rb +0 -110
- data/lib/test.rb +0 -29
data/bin/{maruku0.3 → marudown}
RENAMED
@@ -2,9 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'maruku'
|
4
4
|
|
5
|
-
require 'maruku/parse_span_better'
|
6
|
-
|
7
|
-
#if File.basename($0) =~ /^maruku/
|
8
5
|
# If we are given filenames, convert each file
|
9
6
|
if not ARGV.empty?
|
10
7
|
ARGV.each do |f|
|
@@ -14,24 +11,19 @@ require 'maruku/parse_span_better'
|
|
14
11
|
input = File.open(f,'r').read
|
15
12
|
|
16
13
|
# create Maruku
|
17
|
-
doc = Maruku.new(input)
|
18
|
-
|
19
|
-
# puts doc.inspect
|
14
|
+
doc = Maruku.new(input, {:on_error=>:warning})
|
20
15
|
# convert to a complete html document
|
21
|
-
|
16
|
+
output = doc.to_md
|
22
17
|
|
23
18
|
# write to file
|
24
19
|
dir = File.dirname(f)
|
25
|
-
filename = File.basename(f, File.extname(f)) + ".
|
20
|
+
filename = File.basename(f, File.extname(f)) + ".txt"
|
26
21
|
|
27
|
-
|
28
|
-
File.open(
|
22
|
+
output = File.join(dir, filename)
|
23
|
+
File.open(output,'w') do |f| f.puts html end
|
29
24
|
end
|
30
25
|
else
|
31
26
|
# else, act as a filter
|
32
27
|
data = $stdin.read
|
33
|
-
puts Maruku.new(data).
|
28
|
+
puts Maruku.new(data, {:on_error=>:warning}).to_md
|
34
29
|
end
|
35
|
-
#eend
|
36
|
-
|
37
|
-
|
data/bin/maruku
CHANGED
data/bin/marutest
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'maruku'
|
4
4
|
|
5
|
-
require 'maruku/parse_span_better'
|
6
|
-
|
7
5
|
#MARKER = "\n***EOF***\n"
|
8
6
|
SPLIT = %r{\n\*\*\*[^\*]+\*\*\*\n}m
|
9
7
|
|
@@ -11,12 +9,32 @@ def marker(x)
|
|
11
9
|
"\n*** Output of #{x} ***\n"
|
12
10
|
end
|
13
11
|
|
14
|
-
|
12
|
+
def equals(a, b)
|
13
|
+
a = a.split("\n")
|
14
|
+
b = b.split("\n")
|
15
|
+
|
16
|
+
for i in 0..([a.size-1,b.size-1].max)
|
17
|
+
la = a[i]
|
18
|
+
lb = b[i]
|
19
|
+
if la != lb
|
20
|
+
puts "\n"
|
21
|
+
puts "Line #{i}:\n#{la.inspect}\n"
|
22
|
+
puts "#{lb.inspect}\n"
|
23
|
+
return false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
return true
|
27
|
+
end
|
28
|
+
|
29
|
+
TOTEST = [:inspect,:to_html,:to_latex,:to_md,:to_s]
|
15
30
|
|
16
31
|
def run_test(filename, its_ok, verbose=true)
|
17
32
|
# read file content
|
18
33
|
input = (f=File.open(filename,'r')).read; f.close
|
19
34
|
|
35
|
+
output_html = File.join(File.dirname(filename),
|
36
|
+
File.basename(filename, File.extname(filename)) + ".html")
|
37
|
+
|
20
38
|
# split the input in sections
|
21
39
|
|
22
40
|
stuff = input.split(SPLIT)
|
@@ -24,7 +42,7 @@ def run_test(filename, its_ok, verbose=true)
|
|
24
42
|
comment = stuff.shift
|
25
43
|
params_s = stuff.shift
|
26
44
|
|
27
|
-
params = eval(params_s)
|
45
|
+
params = eval(params_s||'{}')
|
28
46
|
if params == nil
|
29
47
|
raise "Null params? #{params_s.inspect}"
|
30
48
|
end
|
@@ -55,7 +73,10 @@ def run_test(filename, its_ok, verbose=true)
|
|
55
73
|
puts actual[s]
|
56
74
|
end
|
57
75
|
end
|
58
|
-
|
76
|
+
|
77
|
+
File.open(output_html, 'w') do |f|
|
78
|
+
f.write actual[:to_html]
|
79
|
+
end
|
59
80
|
|
60
81
|
begin
|
61
82
|
m = Maruku.new
|
@@ -78,9 +99,11 @@ def run_test(filename, its_ok, verbose=true)
|
|
78
99
|
end
|
79
100
|
end
|
80
101
|
|
102
|
+
m = Maruku.new
|
103
|
+
|
104
|
+
|
81
105
|
if not its_ok.include? :inspect
|
82
106
|
begin
|
83
|
-
m = Maruku.new
|
84
107
|
d = m.instance_eval(expected[:inspect])
|
85
108
|
# puts "Eval: #{d.inspect}"
|
86
109
|
expected[:inspect] = d.inspect
|
@@ -91,15 +114,20 @@ def run_test(filename, its_ok, verbose=true)
|
|
91
114
|
end
|
92
115
|
end
|
93
116
|
|
94
|
-
|
117
|
+
# m.instance_eval(actual[:inspect]) != m.instance_eval(expected[:inspect])
|
118
|
+
|
119
|
+
# actual[:inspect] = m.instance_eval(actual[:inspect])
|
120
|
+
# expected[:inspect] = m.instance_eval(expected[:inspect])
|
121
|
+
|
122
|
+
|
95
123
|
TOTEST.each do |x|
|
96
|
-
if actual[x]
|
124
|
+
if not equals(actual[x], expected[x])
|
97
125
|
if its_ok.include? x
|
98
126
|
expected[x] = actual[x]
|
99
127
|
$stdout.write " relax:#{x} "
|
100
128
|
relaxed << x
|
101
129
|
else
|
102
|
-
actual[x] = "-----| WARNING | -----\n" + actual[x]
|
130
|
+
actual[x] = "-----| WARNING | -----\n" + actual[x].to_s
|
103
131
|
failed << x
|
104
132
|
end
|
105
133
|
end
|
data/docs/TOFIX.html
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version='1.0' encoding='utf-8'?>
|
2
|
+
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
3
|
+
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
4
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
5
|
+
<head><meta content='text/html; charset=utf-8' http-equiv='Content-type' />
|
6
|
+
<title></title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<ul>
|
10
|
+
<li>id degli header</li>
|
11
|
+
</ul>
|
12
|
+
|
13
|
+
<div class='footnotes'>
|
14
|
+
<hr />
|
15
|
+
|
16
|
+
<ol />
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class='maruku_signature'>
|
20
|
+
<hr />
|
21
|
+
<span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter'>Maruku</a> at 20:36 on Friday, January 05th, 2007.</span></div>
|
22
|
+
</body></html>
|
data/docs/TOFIX.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
<?xml version='1.0' encoding='utf-8'?>
|
2
|
+
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
3
|
+
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
4
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
5
|
+
<head><meta content='text/html; charset=utf-8' http-equiv='Content-type' />
|
6
|
+
<title></title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<p>Maruku Version 0.2.13:</p>
|
10
|
+
|
11
|
+
<ul>
|
12
|
+
<li>better handling of inline HTML code.</li>
|
13
|
+
|
14
|
+
<li>Handle HTML comments.</li>
|
15
|
+
|
16
|
+
<li>Sanitizes HR and IMG tags if you don't close them.</li>
|
17
|
+
|
18
|
+
<li>documentation included in HTML format</li>
|
19
|
+
</ul>
|
20
|
+
|
21
|
+
<div class='footnotes'>
|
22
|
+
<hr />
|
23
|
+
|
24
|
+
<ol />
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<div class='maruku_signature'>
|
28
|
+
<hr />
|
29
|
+
<span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter'>Maruku</a> at 20:36 on Friday, January 05th, 2007.</span></div>
|
30
|
+
</body></html>
|
data/docs/changelog-0.3.html
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
3
3
|
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
4
4
|
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
5
|
-
<head
|
5
|
+
<head><meta content='text/html; charset=utf-8' http-equiv='Content-type' />
|
6
6
|
<title></title>
|
7
7
|
|
8
8
|
<link href='style.css' rel='stylesheet' type='text/css' />
|
9
9
|
</head>
|
10
10
|
<body>
|
11
|
-
<h2 id='release_notes__version_030_january_3rd_2007'>Release notes - version 0.3.0 (January 3rd, 2007)
|
11
|
+
<h2 id='release_notes__version_030_january_3rd_2007'>Release notes - version 0.3.0 (January 3rd, 2007)<!--{:id=>"release_notes__version_030_january_3rd_2007"}--></h2>
|
12
12
|
|
13
13
|
<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>
|
14
14
|
|
@@ -63,13 +63,13 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
63
63
|
<li>
|
64
64
|
<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>
|
65
65
|
|
66
|
-
<p>For example: in the HTML version, you should see accented characters in this parenthesis
|
66
|
+
<p>For example: in the HTML version, you should see accented characters in this parenthesis:</p>
|
67
67
|
|
68
68
|
<blockquote>
|
69
69
|
<p>(àèìòù)</p>
|
70
70
|
</blockquote>
|
71
71
|
|
72
|
-
<p>and Japanese text in these other
|
72
|
+
<p>and Japanese text in these other parentheses:</p>
|
73
73
|
|
74
74
|
<blockquote>
|
75
75
|
<p>(カタカナで 私の 名前は アンドレア チェンシ です).</p>
|
@@ -91,9 +91,23 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
91
91
|
<li>
|
92
92
|
<p>Exporting to HTML splitting in multiple files.</p>
|
93
93
|
</li>
|
94
|
+
|
95
|
+
<li>
|
96
|
+
<p>RubyPants.</p>
|
97
|
+
</li>
|
98
|
+
|
99
|
+
<li>
|
100
|
+
<p>Support for images in PDF.</p>
|
101
|
+
</li>
|
94
102
|
</ul>
|
95
103
|
|
104
|
+
<div class='footnotes'>
|
105
|
+
<hr />
|
106
|
+
|
107
|
+
<ol />
|
108
|
+
</div>
|
109
|
+
|
96
110
|
<div class='maruku_signature'>
|
97
111
|
<hr />
|
98
|
-
<span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter'>Maruku</a> at
|
112
|
+
<span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter'>Maruku</a> at 20:36 on Friday, January 05th, 2007.</span></div>
|
99
113
|
</body></html>
|
data/docs/faq.html
CHANGED
@@ -1,46 +1,57 @@
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
2
2
|
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
3
3
|
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
4
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
5
|
+
<head><meta content='text/html; charset=utf-8' http-equiv='Content-type' />
|
6
|
+
<title></title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<h2 id='frequently_asked_questions'>Frequently asked questions<!--{:id=>"frequently_asked_questions"}--></h2>
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
11
|
+
<ul>
|
12
|
+
<li>
|
13
|
+
<p><em>Does Maruku supports internationalizations?</em></p>
|
14
|
+
|
15
|
+
<p>Maruku workflow:</p>
|
16
|
+
|
17
|
+
<ul>
|
18
|
+
<li>input is assumed to be in UTF-8, unless an encoding is specified.</li>
|
19
|
+
|
20
|
+
<li>the internal representation is UTF-8.</li>
|
21
|
+
|
22
|
+
<li>the HTML output is in UTF-8.</li>
|
23
|
+
|
24
|
+
<li>the LaTeX output does not work yet for arbitrary UTF-8 characters (please help me if you can).</li>
|
25
|
+
</ul>
|
26
|
+
|
27
|
+
<p>The following are some examples of UTF-8 special chars:</p>
|
28
|
+
|
29
|
+
<blockquote>
|
30
|
+
<p>Maruku in katakana: マルク<br />
|
31
|
+
Māku: マーク<br />
|
32
|
+
Accented italian letters: àèéìòù<br />
|
33
|
+
Andrea Censi: アンドレア チェンシ</p>
|
34
|
+
</blockquote>
|
35
|
+
|
36
|
+
<p>The internal format is again UTF-8.</p>
|
37
|
+
|
38
|
+
<p>The HTML output is encoded in UTF-8, and the <code>encoding</code> is set in the xml header:</p>
|
39
|
+
|
40
|
+
<pre><code><?xml version='1.0' encoding='utf-8'?>
|
32
41
|
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
42
|
+
</code></pre>
|
43
|
+
|
44
|
+
<p>However, the LaTeX output does not work yet for arbitrary UTF-8 strings. I need help for this.</p>
|
45
|
+
</li>
|
46
|
+
</ul>
|
47
|
+
|
48
|
+
<div class='footnotes'>
|
49
|
+
<hr />
|
50
|
+
|
51
|
+
<ol />
|
52
|
+
</div>
|
33
53
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
></ul
|
39
|
-
><div class='maruku_signature'
|
40
|
-
><hr /
|
41
|
-
><span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter'>Maruku</a
|
42
|
-
> at 18:10 on Tuesday, January 02nd, 2007.</span
|
43
|
-
></div
|
44
|
-
></body
|
45
|
-
></html
|
46
|
-
>
|
54
|
+
<div class='maruku_signature'>
|
55
|
+
<hr />
|
56
|
+
<span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter'>Maruku</a> at 20:36 on Friday, January 05th, 2007.</span></div>
|
57
|
+
</body></html>
|
data/docs/faq.md
CHANGED
@@ -2,7 +2,7 @@ Frequently asked questions
|
|
2
2
|
--------------------------
|
3
3
|
|
4
4
|
|
5
|
-
*
|
5
|
+
* *Does Maruku supports internationalizations?*
|
6
6
|
|
7
7
|
Maruku workflow:
|
8
8
|
|
@@ -25,8 +25,8 @@ Frequently asked questions
|
|
25
25
|
The HTML output is encoded in UTF-8, and
|
26
26
|
the `encoding` is set in the xml header:
|
27
27
|
|
28
|
-
|
29
|
-
|
28
|
+
<?xml version='1.0' encoding='utf-8'?>
|
29
|
+
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
30
30
|
|
31
31
|
However, the LaTeX output does not work yet for arbitrary
|
32
32
|
UTF-8 strings. I need help for this.
|
data/docs/index.html
CHANGED
@@ -1,13 +1,7 @@
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
2
2
|
<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN'
|
3
3
|
'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
|
4
|
-
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
|
5
|
-
<head>
|
6
|
-
<title>Maruku: a Markdown-superset interpreter</title>
|
7
|
-
|
8
|
-
<link href='style.css' rel='stylesheet' type='text/css' />
|
9
|
-
</head>
|
10
|
-
<body>
|
4
|
+
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'><head><meta content='text/html; charset=utf-8' http-equiv='Content-type' /><title>Maruku: a Markdown-superset interpreter</title><link href='style.css' rel='stylesheet' type='text/css' /></head><body>
|
11
5
|
<h1 id='maruku_a_markdownsuperset_interpreter'>Mar<strong>u</strong>k<strong>u</strong>: a Markdown-superset interpreter</h1>
|
12
6
|
|
13
7
|
<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>
|
@@ -15,7 +9,7 @@
|
|
15
9
|
<p>Maruku allows you to write in an easy-to-read-and-write syntax, like this:</p>
|
16
10
|
|
17
11
|
<blockquote>
|
18
|
-
<p><a href='http://maruku.rubyforge.org/maruku.md'>This document in Markdown</a
|
12
|
+
<p><a href='http://maruku.rubyforge.org/maruku.md'>This document in Markdown</a></p>
|
19
13
|
</blockquote>
|
20
14
|
|
21
15
|
<p>Then it can be translated to HTML:</p>
|
@@ -38,85 +32,43 @@
|
|
38
32
|
</li>
|
39
33
|
|
40
34
|
<li>
|
41
|
-
<p>all the improvements in <a href='http://www.michelf.com/projects/php-markdown/extra/'>PHP Markdown Extra</a
|
35
|
+
<p>all the improvements in <a href='http://www.michelf.com/projects/php-markdown/extra/'>PHP Markdown Extra</a>.</p>
|
42
36
|
</li>
|
43
37
|
|
44
38
|
<li>
|
45
|
-
<p>a new <a href='
|
39
|
+
<p>a new <a href='http://maruku.rubyforge.org/proposal.html'>meta-data syntax</a></p>
|
46
40
|
</li>
|
47
41
|
</ul>
|
48
42
|
|
49
43
|
<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>
|
50
44
|
|
51
45
|
<p><strong>The name of the game</strong>: Maruku is the <a href='http://en.wikipedia.org/wiki/Romaji'>romaji</a> translitteration of the <a href='http://en.wikipedia.org/wiki/Katakana'>katakana</a> translitteration of "Mark", the first word in Markdown. I chose this name because Ruby is Japanese, and also the sillable "ru" appears in Maruku.</p>
|
52
|
-
|
53
46
|
<hr />
|
54
|
-
|
55
47
|
<p>Table of contents: (<strong>auto-generated by Maruku!</strong>)</p>
|
48
|
+
<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='#from_the_command_line'>From the command line</a></li></ul></li><li><span class='maruku_section_number'>4. </span><a href='#extra'>Examples of PHP Markdown Extra syntax</a></li><li><span class='maruku_section_number'>5. </span><a href='#maruku-and-bluecloth'>Maruku and Bluecloth</a></li><li><span class='maruku_section_number'>6. </span><a href='#meta'>New meta-data syntax</a><ul style='list-style: none;'><li><span class='maruku_section_number'>6.1. </span><a href='#metadata_for_blocklevel_and_spanlevel_elements'>Meta-data for block-level and span-level elements</a></li><li><span class='maruku_section_number'>6.2. </span><a href='#metadata_for_the_document'>Meta-data for the document</a></li><li><span class='maruku_section_number'>6.3. </span><a href='#metalist'>List of meta-data</a></li><li><span class='maruku_section_number'>6.4. </span><a href='#examples'>Examples</a></li></ul></li><li><span class='maruku_section_number'>7. </span><a href='#features'>Other Features</a><ul style='list-style: none;'><li><span class='maruku_section_number'>7.1. </span><a href='#automatic_generation_of_the_table_of_contents'>Automatic generation of the table of contents</a></li><li><span class='maruku_section_number'>7.2. </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><li><span class='maruku_section_number'>7.3. </span><a href='#use_html_entities'>Use HTML entities</a></li></ul></li><li><span class='maruku_section_number'>8. </span><a href='#future'>Future developments</a><ul style='list-style: none;'><li><span class='maruku_section_number'>8.1. </span><a href='#a_syntax_for_adding_math'>A syntax for adding math</a></li></ul></li></ul></div><hr />
|
49
|
+
<h2 id='release_notes'><span class='maruku_section_number'>1. </span>Release notes</h2>
|
56
50
|
|
57
|
-
<
|
58
|
-
<ul style='list-style: none;'>
|
59
|
-
<li><span class='maruku_section_number'>1. </span><a href='#release_notes'>Release notes - version 0.3.0 (January 3rd, 2007)</a></li>
|
60
|
-
|
61
|
-
<li><span class='maruku_section_number'>2. </span><a href='#download'>Download</a>
|
62
|
-
<ul style='list-style: none;'>
|
63
|
-
<li><span class='maruku_section_number'>2.1. </span><a href='#bugs_report'>Bugs report</a></li>
|
64
|
-
</ul>
|
65
|
-
</li>
|
66
|
-
|
67
|
-
<li><span class='maruku_section_number'>3. </span><a href='#usage'>Usage</a>
|
68
|
-
<ul style='list-style: none;'>
|
69
|
-
<li><span class='maruku_section_number'>3.1. </span><a href='#from_the_command_line'>From the command line</a></li>
|
70
|
-
</ul>
|
71
|
-
</li>
|
72
|
-
|
73
|
-
<li><span class='maruku_section_number'>4. </span><a href='#extra'>Examples of PHP Markdown Extra syntax</a></li>
|
74
|
-
|
75
|
-
<li><span class='maruku_section_number'>5. </span><a href='#maruku-and-bluecloth'>Maruku and Bluecloth</a></li>
|
76
|
-
|
77
|
-
<li><span class='maruku_section_number'>6. </span><a href='#meta'>New meta-data syntax</a>
|
78
|
-
<ul style='list-style: none;'>
|
79
|
-
<li><span class='maruku_section_number'>6.1. </span><a href='#metadata_for_the_document'>Meta-data for the document</a></li>
|
51
|
+
<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>
|
80
52
|
|
81
|
-
<
|
53
|
+
<p>In the meantime, feel free to toy around, and please signal problems, request features, by <a href='http://www.dis.uniroma1.it/~acensi/contact.html'>contacting me</a> or using the <a href='http://rubyforge.org/tracker/?group_id=2795'>tracker</a>. For issues about the Markdown syntax itself and improvements to it, please write to the <a href='http://six.pairlist.net/mailman/listinfo/markdown-discuss'>Markdown-discuss mailing list</a>.</p>
|
82
54
|
|
83
|
-
<
|
55
|
+
<p>Have fun!</p>
|
84
56
|
|
85
|
-
<
|
57
|
+
<h4 id='changes_in_04'>Changes in 0.4</h4>
|
86
58
|
|
87
|
-
<
|
88
|
-
</
|
89
|
-
</li>
|
59
|
+
<ul>
|
60
|
+
<li>First implementation of <a href='http://maruku.rubyforge.org/proposal.html'>the new meta-data syntax</a>.</li>
|
90
61
|
|
91
|
-
<li
|
92
|
-
<ul style='list-style: none;'>
|
93
|
-
<li><span class='maruku_section_number'>7.1. </span><a href='#automatic_generation_of_the_table_of_contents'>Automatic generation of the table of contents</a></li>
|
62
|
+
<li>General refactorization of the code and much cleaner error reporting.</li>
|
94
63
|
|
95
|
-
<li
|
64
|
+
<li>Created <a href='http://maruku.rubyforge.org/rdoc/'>the RDOC documentation</a>.</li>
|
96
65
|
|
97
|
-
<li
|
98
|
-
</ul>
|
99
|
-
</li>
|
66
|
+
<li>The <code>add_whitespace</code> method took too much time -- it was O(n^2).</li>
|
100
67
|
|
101
|
-
<li
|
102
|
-
<ul style='list-style: none;'>
|
103
|
-
<li><span class='maruku_section_number'>8.1. </span><a href='#a_syntax_for_adding_math'>A syntax for adding math</a></li>
|
104
|
-
</ul>
|
105
|
-
</li>
|
68
|
+
<li>Added unit-tests for block-level elements.</li>
|
106
69
|
</ul>
|
107
|
-
</div>
|
108
|
-
|
109
|
-
<hr />
|
110
70
|
|
111
|
-
<
|
112
|
-
|
113
|
-
<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>
|
114
|
-
|
115
|
-
<p>In the meantime, feel free to toy around, and please signal problems, request features, by <a href='http://www.dis.uniroma1.it/~acensi/contact.html'>contacting me</a> or using the <a href='http://rubyforge.org/tracker/?group_id=2795'>tracker</a>. For issues about the Markdown syntax itself and improvements to it, please write to the <a href='http://six.pairlist.net/mailman/listinfo/markdown-discuss'>Markdown-discuss mailing list</a>.</p>
|
116
|
-
|
117
|
-
<p>Have fun!</p>
|
118
|
-
|
119
|
-
<p>Changes in 0.3.0:</p>
|
71
|
+
<h4 id='changes_in_03'>Changes in 0.3</h4>
|
120
72
|
|
121
73
|
<ul>
|
122
74
|
<li>
|
@@ -125,11 +77,9 @@
|
|
125
77
|
<p>Now Maruku is almost 2x faster than Bluecloth, while having more features.</p>
|
126
78
|
|
127
79
|
<p>Here are some benchmarks:</p>
|
128
|
-
|
129
80
|
<pre><code>BlueCloth (to_html): parsing 0.00 sec + rendering 1.54 sec = 1.55 sec
|
130
81
|
Maruku (to_html): parsing 0.47 sec + rendering 0.38 sec = 0.85 sec
|
131
82
|
Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pre>
|
132
|
-
|
133
83
|
<p>This is the result of running <code>lib/maruku/tests/benchmark.rb</code> on the Markdown specification.</p>
|
134
84
|
</li>
|
135
85
|
|
@@ -145,10 +95,8 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
145
95
|
<p>Error management: Having a real parser, Maruku warns you about syntax issues.</p>
|
146
96
|
|
147
97
|
<p>The default action is to warn and try to continue. If you do this:</p>
|
148
|
-
|
149
98
|
<pre><code>Maruku.new(string, {:on_error => :raise})
|
150
99
|
</code></pre>
|
151
|
-
|
152
100
|
<p>then syntax errors will cause an exception to be raised (you can catch this and retry).</p>
|
153
101
|
</li>
|
154
102
|
|
@@ -163,13 +111,13 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
163
111
|
<li>
|
164
112
|
<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>
|
165
113
|
|
166
|
-
<p>For example: in the HTML version, you should see accented characters in this parenthesis
|
114
|
+
<p>For example: in the HTML version, you should see accented characters in this parenthesis:</p>
|
167
115
|
|
168
116
|
<blockquote>
|
169
117
|
<p>(àèìòù)</p>
|
170
118
|
</blockquote>
|
171
119
|
|
172
|
-
<p>and Japanese text in these other parentheses
|
120
|
+
<p>and Japanese text in these other parentheses:</p>
|
173
121
|
|
174
122
|
<blockquote>
|
175
123
|
<p>(カタカナで 私の 名前は アンドレア チェンシ です).</p>
|
@@ -206,17 +154,11 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
206
154
|
<p>The development site is <a href='http://rubyforge.org/projects/maruku/'>http://rubyforge.org/projects/maruku/</a>.</p>
|
207
155
|
|
208
156
|
<p>Install with:</p>
|
209
|
-
|
210
|
-
<pre><code>$ gem install maruku
|
211
|
-
</code></pre>
|
212
|
-
|
157
|
+
<pre class='shell' style='background-color: #efefff;'>$ gem install maruku</pre>
|
213
158
|
<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>
|
214
159
|
|
215
160
|
<p>Anonymous access to the repository is possible with:</p>
|
216
|
-
|
217
|
-
<pre><code>$ svn checkout svn://rubyforge.org/var/svn/maruku
|
218
|
-
</code></pre>
|
219
|
-
|
161
|
+
<pre class='shell' style='background-color: #efefff;'>$ svn checkout svn://rubyforge.org/var/svn/maruku</pre>
|
220
162
|
<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>
|
221
163
|
|
222
164
|
<h3 id='bugs_report'><span class='maruku_section_number'>2.1. </span>Bugs report</h3>
|
@@ -226,21 +168,15 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
226
168
|
<h2 id='usage'><span class='maruku_section_number'>3. </span>Usage</h2>
|
227
169
|
|
228
170
|
<p>This is the basic usage:</p>
|
229
|
-
|
230
|
-
<pre class='ruby'><span class='ident'>require</span> <span class='punct'>'</span><span class='string'>rubygems</span><span class='punct'>'</span>
|
171
|
+
<pre class='ruby' style='background-color: #efffef;'><span class='ident'>require</span> <span class='punct'>'</span><span class='string'>rubygems</span><span class='punct'>'</span>
|
231
172
|
<span class='ident'>require</span> <span class='punct'>'</span><span class='string'>maruku</span><span class='punct'>'</span>
|
232
173
|
|
233
174
|
<span class='ident'>doc</span> <span class='punct'>=</span> <span class='constant'>Maruku</span><span class='punct'>.</span><span class='ident'>new</span><span class='punct'>(</span><span class='ident'>markdown_string</span><span class='punct'>)</span>
|
234
175
|
<span class='ident'>puts</span> <span class='ident'>doc</span><span class='punct'>.</span><span class='ident'>to_html</span></pre>
|
235
|
-
|
236
176
|
<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>
|
237
|
-
|
238
|
-
<pre class='ruby'><span class='ident'>puts</span> <span class='ident'>doc</span><span class='punct'>.</span><span class='ident'>to_html_document</span></pre>
|
239
|
-
|
177
|
+
<pre class='ruby' style='background-color: #efffef;'><span class='ident'>puts</span> <span class='ident'>doc</span><span class='punct'>.</span><span class='ident'>to_html_document</span></pre>
|
240
178
|
<p>You can have the REXML document tree with:</p>
|
241
|
-
|
242
|
-
<pre class='ruby'><span class='ident'>tree</span> <span class='punct'>=</span> <span class='ident'>doc</span><span class='punct'>.</span><span class='ident'>to_html_document_tree</span></pre>
|
243
|
-
|
179
|
+
<pre class='ruby' style='background-color: #efffef;'><span class='ident'>tree</span> <span class='punct'>=</span> <span class='ident'>doc</span><span class='punct'>.</span><span class='ident'>to_html_document_tree</span></pre>
|
244
180
|
<h3 id='from_the_command_line'><span class='maruku_section_number'>3.1. </span>From the command line</h3>
|
245
181
|
|
246
182
|
<p>There are two command-line programs installed: <code>maruku</code> and <code>marutex</code>.</p>
|
@@ -248,15 +184,11 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
248
184
|
<ul>
|
249
185
|
<li>
|
250
186
|
<p><code>maruku</code> converts Markdown to HTML:</p>
|
251
|
-
|
252
|
-
<pre><code>$ maruku file.md # creates file.html</code></pre>
|
253
|
-
</li>
|
187
|
+
<pre class='shell' style='background-color: #efefff;'>$ maruku file.md # creates file.html</pre></li>
|
254
188
|
|
255
189
|
<li>
|
256
|
-
<p><code>marutex</code> converts Markdown to LaTeX, then calls <code>pdflatex</code> to transform to PDF
|
257
|
-
|
258
|
-
<pre><code>$ marutex file.md # creates file.tex and file.pdf</code></pre>
|
259
|
-
</li>
|
190
|
+
<p><code>marutex</code> converts Markdown to LaTeX, then calls <code>pdflatex</code> to transform to PDF:</p>
|
191
|
+
<pre class='shell' style='background-color: #efefff;'>$ marutex file.md # creates file.tex and file.pdf</pre></li>
|
260
192
|
</ul>
|
261
193
|
|
262
194
|
<h2 id='extra'><span class='maruku_section_number'>4. </span>Examples of PHP Markdown Extra syntax</h2>
|
@@ -264,76 +196,36 @@ Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec</code></pr
|
|
264
196
|
<ul>
|
265
197
|
<li>
|
266
198
|
<p>tables</p>
|
267
|
-
|
268
|
-
<pre><code>Col1 | Very very long head | Very very long head|
|
199
|
+
<pre class='markdown' style='background-color: #ffefef;'>Col1 | Very very long head | Very very long head|
|
269
200
|
-----|:-------------------:|-------------------:|
|
270
|
-
cell | center-align | right-align
|
271
|
-
</code></pre>
|
272
|
-
|
273
|
-
<table class='example'>
|
274
|
-
<thead>
|
275
|
-
<tr><th>Col1</th><th>Very very long head</th><th>Very very long head</th></tr>
|
276
|
-
</thead>
|
277
|
-
<tbody>
|
278
|
-
<tr>
|
279
|
-
<td style='text-align: left;'>cell</td>
|
280
|
-
|
281
|
-
<td style='text-align: center;'>center-align</td>
|
282
|
-
|
283
|
-
<td style='text-align: right;'>right-align</td>
|
284
|
-
</tr>
|
285
|
-
</tbody></table>
|
286
|
-
</li>
|
201
|
+
cell | center-align | right-align |</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></tr></tbody></table></li>
|
287
202
|
|
288
203
|
<li>
|
289
204
|
<p>footnotes <sup id='fnref:1'><a href='#fn:1' rel='footnote'>1</a></sup></p>
|
205
|
+
<pre class='markdown' style='background-color: #ffefef;'>* footnotes [^foot]
|
290
206
|
|
291
|
-
|
292
|
-
|
293
|
-
[^foot]: I really was missing those.</code></pre>
|
294
|
-
</li>
|
295
|
-
|
296
|
-
<li>
|
297
|
-
<p>Markdown inside HTML elememnts</p>
|
298
|
-
</li>
|
207
|
+
[^foot]: I really was missing those.</pre></li>
|
299
208
|
</ul>
|
300
209
|
|
301
|
-
<
|
210
|
+
<ul>
|
211
|
+
<li>
|
212
|
+
<p>Markdown inside HTML elements</p>
|
213
|
+
<pre><code><div markdown="1" style="border: solid 1px black">
|
302
214
|
This is a div with Markdown **strong text**
|
303
|
-
|
304
|
-
|
305
|
-
<div style='border: solid 1px black'>
|
215
|
+
</div></code></pre><div style='border: solid 1px black'>
|
306
216
|
<p>This is a div with Markdown <strong>strong text</strong></p>
|
307
|
-
</div>
|
217
|
+
</div></li>
|
308
218
|
|
309
|
-
<ul>
|
310
219
|
<li>
|
311
220
|
<p>header ids</p>
|
312
|
-
|
313
|
-
<pre><code>## Download ## {#download}
|
314
|
-
</code></pre>
|
315
|
-
|
221
|
+
<pre class='markdown' style='background-color: #ffefef;'>## Download ## {#download}</pre>
|
316
222
|
<p>For example, <a href='#download'>a link to the download</a> header.</p>
|
317
|
-
|
318
|
-
<p>Note that you can use also the new <a href='#meta'>meta-data syntax</a> for the same purpose:</p>
|
319
|
-
|
320
|
-
<pre><code>@ id: download
|
321
|
-
## Header ## </code></pre>
|
322
223
|
</li>
|
323
224
|
|
324
225
|
<li>
|
325
226
|
<p>definition lists</p>
|
326
|
-
|
327
|
-
|
328
|
-
: something very hard to parse
|
329
|
-
</code></pre>
|
330
|
-
|
331
|
-
<dl>
|
332
|
-
<dt>Definition list</dt>
|
333
|
-
|
334
|
-
<dd>something very hard to parse</dd>
|
335
|
-
</dl>
|
336
|
-
</li>
|
227
|
+
<pre class='markdown' style='background-color: #ffefef;'>Definition list
|
228
|
+
: something very hard to parse</pre><dl><dt>Definition list</dt><dd>something very hard to parse</dd></dl></li>
|
337
229
|
|
338
230
|
<li>
|
339
231
|
<p>abbreviations or <abbr title='Simply an abbreviation'>ABB</abbr> for short.</p>
|
@@ -342,7 +234,7 @@ cell | center-align | right-align |
|
|
342
234
|
|
343
235
|
<h2 id='maruku-and-bluecloth'><span class='maruku_section_number'>5. </span>Maruku and Bluecloth</h2>
|
344
236
|
|
345
|
-
<p>The other Ruby implementation of Markdown is <a href='http://www.deveiate.org/projects/BlueCloth'>Bluecloth</a
|
237
|
+
<p>The other Ruby implementation of Markdown is <a href='http://www.deveiate.org/projects/BlueCloth'>Bluecloth</a>.</p>
|
346
238
|
|
347
239
|
<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>
|
348
240
|
|
@@ -364,175 +256,50 @@ cell | center-align | right-align |
|
|
364
256
|
|
365
257
|
<p>Maruku implements a syntax that allows to attach "meta" information to objects.</p>
|
366
258
|
|
367
|
-
<h3 id='
|
368
|
-
|
369
|
-
<p>Meta-data for the document itself is specified through the use of email headers:</p>
|
370
|
-
|
371
|
-
<pre><code>Title: A simple document containing meta-headers
|
372
|
-
CSS: style.css
|
259
|
+
<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>
|
373
260
|
|
374
|
-
|
375
|
-
</code></pre>
|
261
|
+
<p>See <a href='http://maruku.rubyforge.org/proposal.html'>this proposal</a>.</p>
|
376
262
|
|
377
|
-
<
|
263
|
+
<h3 id='metadata_for_the_document'><span class='maruku_section_number'>6.2. </span>Meta-data for the document</h3>
|
378
264
|
|
379
|
-
<
|
265
|
+
<p>Meta-data for the document itself is specified through the use of email headers:</p>
|
266
|
+
<pre class='markdown' style='background-color: #ffefef;'>Title: A simple document containing meta-headers
|
267
|
+
CSS: style.css
|
380
268
|
|
269
|
+
Content of the document</pre>
|
270
|
+
<p>When creating the document through</p>
|
271
|
+
<pre class='ruby' style='background-color: #efffef;'><span class='constant'>Maruku</span><span class='punct'>.</span><span class='ident'>new</span><span class='punct'>(</span><span class='ident'>s</span><span class='punct'>).</span><span class='ident'>to_html_document</span></pre>
|
381
272
|
<p>the title and stylesheet are added as expected.</p>
|
382
273
|
|
383
274
|
<p>Meta-data keys are assumed to be case-insensitive.</p>
|
384
|
-
|
385
|
-
<h3 id='metadata_for_elements'><span class='maruku_section_number'>6.2. </span>Meta-data for elements</h3>
|
386
|
-
|
387
|
-
<p>Maruku introduces a new syntax for attaching metadata to paragraphs, tables, and so on.</p>
|
388
|
-
|
389
|
-
<p>For example, consider the creation of two paragraphs:</p>
|
390
|
-
|
391
|
-
<pre><code>Paragraph 1 is a warning.
|
392
|
-
|
393
|
-
Paragraph 2
|
394
|
-
</code></pre>
|
395
|
-
|
396
|
-
<p>Now you really want to attach a 'class' attribute to the paragraphs (for example for CSS styling). Maruku allows you to use:</p>
|
397
|
-
|
398
|
-
<pre><code>@ class: warning
|
399
|
-
Paragraph 1 is a warning
|
400
|
-
|
401
|
-
Paragraph 2
|
402
|
-
|
403
|
-
</code></pre>
|
404
|
-
|
405
|
-
<p>You can add more by separating with a <code>;</code>:</p>
|
406
|
-
|
407
|
-
<pre><code>@ class: warning; id: warning1
|
408
|
-
Paragraph 1 is a warning
|
409
|
-
</code></pre>
|
410
|
-
|
411
|
-
<p>A meta-data declaration is composed of </p>
|
412
|
-
|
413
|
-
<ol>
|
414
|
-
<li>newline</li>
|
415
|
-
|
416
|
-
<li>an at-symbol <code>@</code></li>
|
417
|
-
|
418
|
-
<li>a series of name-value pairs. Each name-value is separated by a colon <code>:</code>, pairs are separated by semi-colons <code>;</code> </li>
|
419
|
-
</ol>
|
420
|
-
|
421
|
-
<p>Many declaration can be used, and they refer to <em>the following</em> object:</p>
|
422
|
-
|
423
|
-
<pre><code>@ class: warning
|
424
|
-
@ id: warning1
|
425
|
-
Paragraph 1 is a warning
|
426
|
-
</code></pre>
|
427
|
-
|
428
|
-
<p>These can also be separated by newlines:</p>
|
429
|
-
|
430
|
-
<pre><code>@ class: warning
|
431
|
-
|
432
|
-
@ id: warning1
|
433
|
-
|
434
|
-
Paragraph 1 is a warning
|
435
|
-
|
436
|
-
</code></pre>
|
437
|
-
|
438
|
-
<h3 id='shortcuts'><span class='maruku_section_number'>6.3. </span>Shortcuts</h3>
|
439
|
-
|
440
|
-
<p>This:</p>
|
441
|
-
|
442
|
-
<pre><code>@ .xyz
|
443
|
-
Paragraph
|
444
|
-
</code></pre>
|
445
|
-
|
446
|
-
<p>is equivalent to:</p>
|
447
|
-
|
448
|
-
<pre><code>@ class: xyz
|
449
|
-
Paragraph
|
450
|
-
</code></pre>
|
451
|
-
|
452
|
-
<p>This:</p>
|
453
|
-
|
454
|
-
<pre><code>@ #xyz
|
455
|
-
Paragraph
|
456
|
-
</code></pre>
|
457
|
-
|
458
|
-
<p>is equivalent to:</p>
|
459
|
-
|
460
|
-
<pre><code>@ id: xyz
|
461
|
-
Paragraph
|
462
|
-
</code></pre>
|
463
|
-
|
464
|
-
<p>Also, if the value is not present, it defaults to <code>true</code>:</p>
|
465
|
-
|
466
|
-
<pre><code>@ test
|
467
|
-
|
468
|
-
This paragraph has the attribute `test` set to `true`.
|
469
|
-
</code></pre>
|
470
|
-
|
471
275
|
<hr />
|
472
|
-
|
473
|
-
<
|
474
|
-
|
475
|
-
<dl>
|
476
|
-
<dt><strong><code>title</code>, <code>subject</code></strong></dt>
|
477
|
-
|
478
|
-
<dd>
|
276
|
+
<h3 id='metalist'><span class='maruku_section_number'>6.3. </span>List of meta-data</h3>
|
277
|
+
<dl><dt><strong><code>title</code>, <code>subject</code></strong></dt><dd>
|
479
278
|
<p>(document) Sets the title of the document (HTML: used in the <code>TITLE</code> element).</p>
|
480
|
-
</dd>
|
481
|
-
|
482
|
-
<dt><strong><code>use_numbered_headers</code></strong></dt>
|
483
|
-
|
484
|
-
<dd>
|
279
|
+
</dd><dt><strong><code>use_numbered_headers</code></strong></dt><dd>
|
485
280
|
<p>(document) If <code>true</code>, headers are numbered (just like this document). Default is <code>false</code>.</p>
|
486
|
-
</dd>
|
487
|
-
|
488
|
-
<dt><strong><code>css</code></strong></dt>
|
489
|
-
|
490
|
-
<dd>
|
281
|
+
</dd><dt><strong><code>css</code></strong></dt><dd>
|
491
282
|
<p>(document, HTML) Url of stylesheet.</p>
|
492
|
-
</dd>
|
493
|
-
|
494
|
-
<dt><strong><code>html_use_syntax</code></strong></dt>
|
495
|
-
|
496
|
-
<dd>
|
283
|
+
</dd><dt><strong><code>html_use_syntax</code></strong></dt><dd>
|
497
284
|
<p>(document, HTML) If set, use the <a href='http://syntax.rubyforge.org/'>Ruby <code>syntax</code> library</a> to add source highlighting.</p>
|
498
|
-
</dd>
|
499
|
-
|
500
|
-
<dt><strong><code>latex_use_listings</code></strong></dt>
|
501
|
-
|
502
|
-
<dd>
|
285
|
+
</dd><dt><strong><code>latex_use_listings</code></strong></dt><dd>
|
503
286
|
<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>
|
504
287
|
|
505
|
-
<p>
|
506
|
-
</dd>
|
507
|
-
|
508
|
-
<dt><strong><code>style</code>, <code>id</code>, <code>class</code></strong></dt>
|
509
|
-
|
510
|
-
<dd>
|
288
|
+
<p>If not set, use standard <code>verbatim</code> environment.</p>
|
289
|
+
</dd><dt><strong><code>style</code>, <code>id</code>, <code>class</code></strong></dt><dd>
|
511
290
|
<p>(any block object, HTML) Standard CSS attributes are copied.</p>
|
512
|
-
</dd>
|
513
|
-
|
514
|
-
<dt><strong><code>lang</code></strong></dt>
|
515
|
-
|
516
|
-
<dd>
|
291
|
+
</dd><dt><strong><code>lang</code></strong></dt><dd>
|
517
292
|
<p>(code blocks) Name of programming language (<code>ruby</code>) for syntax highlighting.</p>
|
518
293
|
|
519
|
-
<p>
|
520
|
-
|
521
|
-
<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>
|
522
|
-
</dd>
|
523
|
-
|
524
|
-
<dt><strong><code>code_show_spaces</code></strong></dt>
|
294
|
+
<p>Default for this is <code>code_lang</code> in document.</p>
|
525
295
|
|
526
|
-
<
|
296
|
+
<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>
|
297
|
+
</dd><dt><strong><code>code_show_spaces</code></strong></dt><dd>
|
527
298
|
<p>Shows tabs and newlines (default is read in the document object).</p>
|
528
|
-
</dd>
|
529
|
-
|
530
|
-
<dt><strong><code>code_background_color</code></strong></dt>
|
531
|
-
|
532
|
-
<dd>
|
299
|
+
</dd><dt><strong><code>code_background_color</code></strong></dt><dd>
|
533
300
|
<p>Background color for code blocks. (default is read in the document object).</p>
|
534
301
|
|
535
|
-
<p>The format is either a named color (<code>green</code>, <code>red</code>) or a CSS color of the form <code>#ff00ff</code
|
302
|
+
<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>
|
536
303
|
|
537
304
|
<ul>
|
538
305
|
<li>
|
@@ -540,68 +307,39 @@ This paragraph has the attribute `test` set to `true`.
|
|
540
307
|
</li>
|
541
308
|
|
542
309
|
<li>
|
543
|
-
<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
|
310
|
+
<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>
|
544
311
|
|
545
312
|
<p>For example, for <code>#0000ff</code>, the macro is called as: <code>\color[rgb]{0,0,1}</code>.</p>
|
546
313
|
</li>
|
547
314
|
</ul>
|
548
|
-
</dd>
|
549
|
-
</
|
550
|
-
|
551
|
-
<h3 id='examples'><span class='maruku_section_number'>6.5. </span>Examples</h3>
|
315
|
+
</dd></dl>
|
316
|
+
<h3 id='examples'><span class='maruku_section_number'>6.4. </span>Examples</h3>
|
552
317
|
|
553
318
|
<p>An example of this is the following:</p>
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
» » ¬» Tab,¬space,¬tab
|
560
|
-
» » » » Tab,¬tab,¬tab¬and¬all¬is¬green!
|
561
|
-
</code></pre>
|
562
|
-
|
319
|
+
<pre class='markdown' style='background-color: #ffefef;'> One space
|
320
|
+
Two spaces
|
321
|
+
Tab, space, tab
|
322
|
+
Tab, tab, tab and all is green!
|
323
|
+
{code_show_spaces code_background_color=#ffeedd}</pre>
|
563
324
|
<p>That will produce:</p>
|
564
|
-
|
565
|
-
<pre style='background-color: green;'><code>¬One¬space
|
325
|
+
<pre style='background-color: #ffeedd;'><code>¬One¬space
|
566
326
|
¬¬Two¬spaces
|
567
327
|
» ¬» Tab,¬space,¬tab
|
568
|
-
» » » Tab,¬tab,¬tab¬and¬all¬is¬green
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
<pre><code>@ code_background_color: #455678
|
574
|
-
|
575
|
-
A strange color
|
576
|
-
</code></pre>
|
577
|
-
|
578
|
-
<p>produces:</p>
|
579
|
-
|
580
|
-
<pre style='background-color: #455678;'><code>A strange color
|
581
|
-
</code></pre>
|
582
|
-
|
583
|
-
<p>Or highlighting (does not work well yet):</p>
|
584
|
-
|
585
|
-
<pre><code>@ lang: xml
|
586
|
-
<div style="text-align:center">Div</div>
|
328
|
+
» » » Tab,¬tab,¬tab¬and¬all¬is¬green!</code></pre>
|
329
|
+
<p>Or highlighting (support depends on languages):</p>
|
330
|
+
<pre><code> <div style="text-align:center">Div</div>
|
331
|
+
{lang=html}
|
587
332
|
</code></pre>
|
588
|
-
|
589
333
|
<p>produces:</p>
|
590
|
-
|
591
|
-
<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>
|
592
|
-
|
593
|
-
<hr />
|
594
|
-
|
334
|
+
<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 />
|
595
335
|
<h2 id='features'><span class='maruku_section_number'>7. </span>Other Features</h2>
|
596
336
|
|
597
337
|
<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>
|
598
338
|
|
599
339
|
<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>
|
600
|
-
|
601
|
-
|
602
|
-
* This will become a table of contents (this text will be scraped).
|
340
|
+
<pre><code>* This will become a table of contents (this text will be scraped).
|
341
|
+
{toc}
|
603
342
|
</code></pre>
|
604
|
-
|
605
343
|
<p>You can see an example of this at the beginning of this document.</p>
|
606
344
|
|
607
345
|
<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>
|
@@ -613,43 +351,7 @@ This paragraph has the attribute `test` set to `true`.
|
|
613
351
|
<h3 id='use_html_entities'><span class='maruku_section_number'>7.3. </span>Use HTML entities</h3>
|
614
352
|
|
615
353
|
<p>If you want to use HTML entities, go on! We will take care of the translation to LaTeX:</p>
|
616
|
-
|
617
|
-
<table>
|
618
|
-
<thead>
|
619
|
-
<tr><th>Entity</th><th>Result</th></tr>
|
620
|
-
</thead>
|
621
|
-
<tbody>
|
622
|
-
<tr>
|
623
|
-
<td style='text-align: left;'><code>&copy;</code></td>
|
624
|
-
|
625
|
-
<td style='text-align: left;'>©</td>
|
626
|
-
</tr>
|
627
|
-
|
628
|
-
<tr>
|
629
|
-
<td style='text-align: left;'><code>&pound;</code></td>
|
630
|
-
|
631
|
-
<td style='text-align: left;'>£</td>
|
632
|
-
</tr>
|
633
|
-
|
634
|
-
<tr>
|
635
|
-
<td style='text-align: left;'><code>a&nbsp;b</code></td>
|
636
|
-
|
637
|
-
<td style='text-align: left;'>a b</td>
|
638
|
-
</tr>
|
639
|
-
|
640
|
-
<tr>
|
641
|
-
<td style='text-align: left;'><code>&lambda;</code></td>
|
642
|
-
|
643
|
-
<td style='text-align: left;'>λ</td>
|
644
|
-
</tr>
|
645
|
-
|
646
|
-
<tr>
|
647
|
-
<td style='text-align: left;'><code>&mdash;</code></td>
|
648
|
-
|
649
|
-
<td style='text-align: left;'>—</td>
|
650
|
-
</tr>
|
651
|
-
</tbody></table>
|
652
|
-
|
354
|
+
<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>
|
653
355
|
<h2 id='future'><span class='maruku_section_number'>8. </span>Future developments</h2>
|
654
356
|
|
655
357
|
<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>
|
@@ -657,7 +359,6 @@ This paragraph has the attribute `test` set to `true`.
|
|
657
359
|
<h3 id='a_syntax_for_adding_math'><span class='maruku_section_number'>8.1. </span>A syntax for adding math</h3>
|
658
360
|
|
659
361
|
<p>Something inspired from LaTeX should be familiar to all:</p>
|
660
|
-
|
661
362
|
<pre><code>This is inline math: $\alpha$
|
662
363
|
|
663
364
|
|
@@ -665,19 +366,6 @@ This is an equation with label:
|
|
665
366
|
|
666
367
|
$ \alpha = \beta + \gamma $ (eq:1)
|
667
368
|
|
668
|
-
This is a reference to equation: please see (eq:1)</code></pre>
|
669
|
-
|
670
|
-
<div class='
|
671
|
-
<hr />
|
672
|
-
|
673
|
-
<ol>
|
674
|
-
<li id='fn:1'>
|
675
|
-
<p>I really was missing those.<a href='#fnref:1' rev='footnote'>↩</a></p>
|
676
|
-
</li>
|
677
|
-
</ol>
|
678
|
-
</div>
|
679
|
-
|
680
|
-
<div class='maruku_signature'>
|
681
|
-
<hr />
|
682
|
-
<span style='font-size: small; font-style: italic'>Created by <a href='http://maruku.rubyforge.org' title='Maruku: a Markdown interpreter'>Maruku</a> at 00:33 on Wednesday, January 03rd, 2007.</span></div>
|
683
|
-
</body></html>
|
369
|
+
This is a reference to equation: please see (eq:1)</code></pre><div class='footnotes'><hr /><ol><li id='fn:1'>
|
370
|
+
<p>I really was missing those.</p>
|
371
|
+
<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 interpreter'>Maruku</a> at 21:05 on Saturday, January 06th, 2007.</span></div></body></html>
|