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/lib/maruku/to_markdown.rb
DELETED
@@ -1,110 +0,0 @@
|
|
1
|
-
class String
|
2
|
-
# XXX: markdown escaping
|
3
|
-
def to_md(c=nil)
|
4
|
-
to_s
|
5
|
-
end
|
6
|
-
|
7
|
-
# " andrea censi " => [" andrea ", "censi "]
|
8
|
-
def mysplit
|
9
|
-
split.map{|x| x+" "}
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
class MDElement
|
15
|
-
|
16
|
-
DefaultLineLength = 50
|
17
|
-
|
18
|
-
def to_md(context={})
|
19
|
-
children_to_md(context)
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_md_paragraph(context)
|
23
|
-
line_length = context[:line_length] || DefaultLineLength
|
24
|
-
wrap(@children, line_length)
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_md_li_span(context)
|
28
|
-
len = (context[:line_length] || DefaultLineLength) - 2
|
29
|
-
s = add_tabs(wrap(@children, len-2), 1, ' ')
|
30
|
-
s[0] = ?*
|
31
|
-
s + "\n"
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
# Some utilities
|
36
|
-
class MDElement
|
37
|
-
|
38
|
-
# Convert each child to html
|
39
|
-
def children_to_md(context)
|
40
|
-
array_to_md(@children, context)
|
41
|
-
end
|
42
|
-
|
43
|
-
def wrap(array, line_length)
|
44
|
-
out = ""
|
45
|
-
line = ""
|
46
|
-
array.each do |c|
|
47
|
-
if c.kind_of?(MDElement) && c.node_type == :linebreak
|
48
|
-
out << line.strip << " \n"; line="";
|
49
|
-
next
|
50
|
-
end
|
51
|
-
|
52
|
-
pieces =
|
53
|
-
if c.kind_of? String
|
54
|
-
c.to_md.mysplit
|
55
|
-
else
|
56
|
-
[c.to_md].flatten
|
57
|
-
end
|
58
|
-
|
59
|
-
# puts "Pieces: #{pieces.inspect}"
|
60
|
-
pieces.each do |p|
|
61
|
-
if p.size + line.size > line_length
|
62
|
-
out << line.strip << "\n";
|
63
|
-
line = ""
|
64
|
-
end
|
65
|
-
line << p
|
66
|
-
end
|
67
|
-
end
|
68
|
-
out << line.strip << "\n" if line.size > 0
|
69
|
-
out
|
70
|
-
end
|
71
|
-
|
72
|
-
|
73
|
-
def array_to_md(array, context, join_char='')
|
74
|
-
e = []
|
75
|
-
array.each do |c|
|
76
|
-
method = c.kind_of?(MDElement) ?
|
77
|
-
"to_md_#{c.node_type}" : "to_md"
|
78
|
-
|
79
|
-
if not c.respond_to?(method)
|
80
|
-
#raise "Object does not answer to #{method}: #{c.class} #{c.inspect[0,100]}"
|
81
|
-
tell_user "Using default for #{c.node_type}"
|
82
|
-
method = 'to_md'
|
83
|
-
end
|
84
|
-
|
85
|
-
# puts "#{c.inspect} created with method #{method}"
|
86
|
-
h = c.send(method, context)
|
87
|
-
|
88
|
-
if h.nil?
|
89
|
-
raise "Nil md for #{c.inspect} created with method #{method}"
|
90
|
-
end
|
91
|
-
|
92
|
-
if h.kind_of?Array
|
93
|
-
e = e + h
|
94
|
-
else
|
95
|
-
e << h
|
96
|
-
end
|
97
|
-
end
|
98
|
-
e.join(join_char)
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
|
103
|
-
class Maruku
|
104
|
-
alias old_md to_md
|
105
|
-
def to_md(context={})
|
106
|
-
s = old_md(context)
|
107
|
-
# puts s
|
108
|
-
s
|
109
|
-
end
|
110
|
-
end
|
data/lib/test.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
|
2
|
-
n=100
|
3
|
-
$buffer = "blah "*n+"boh"+"beh"*n
|
4
|
-
$index = n*5
|
5
|
-
|
6
|
-
def fun1(reg)
|
7
|
-
r2 = /^.{#{$index}}#{reg}/
|
8
|
-
r2.match($buffer)
|
9
|
-
end
|
10
|
-
|
11
|
-
def fun2(reg)
|
12
|
-
reg.match($buffer[$index, $buffer.size-$index])
|
13
|
-
end
|
14
|
-
|
15
|
-
r = /\w*/
|
16
|
-
a = Time.now
|
17
|
-
1000.times do
|
18
|
-
fun1(r)
|
19
|
-
end
|
20
|
-
|
21
|
-
b = Time.now
|
22
|
-
1000.times do
|
23
|
-
fun2(r)
|
24
|
-
end
|
25
|
-
|
26
|
-
c = Time.now
|
27
|
-
|
28
|
-
puts "fun1: #{b-a} sec"
|
29
|
-
puts "fun2: #{c-b} sec"
|