maruku 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (108) hide show
  1. data/bin/{maruku0.3 → marudown} +6 -14
  2. data/bin/maruku +1 -1
  3. data/bin/marutest +37 -9
  4. data/docs/TOFIX.html +22 -0
  5. data/docs/TOFIX.md +3 -0
  6. data/docs/changelog-0.2.13.html +30 -0
  7. data/docs/changelog-0.2.13.md +6 -0
  8. data/docs/changelog-0.3.html +19 -5
  9. data/docs/faq.html +51 -40
  10. data/docs/faq.md +3 -3
  11. data/docs/hidden_o_n_squared.md +10 -0
  12. data/docs/index.html +84 -396
  13. data/docs/markdown_syntax.html +139 -330
  14. data/docs/markdown_syntax.md +80 -93
  15. data/docs/maruku.html +84 -396
  16. data/docs/maruku.md +88 -158
  17. data/docs/proposal.html +13 -106
  18. data/docs/proposal.md +3 -3
  19. data/docs/todo.html +38 -28
  20. data/lib/maruku.rb +77 -11
  21. data/lib/maruku/attributes.rb +186 -0
  22. data/lib/maruku/defaults.rb +40 -0
  23. data/lib/maruku/errors_management.rb +55 -39
  24. data/lib/maruku/helpers.rb +156 -72
  25. data/lib/maruku/input/charsource.rb +319 -0
  26. data/lib/maruku/{html_helper.rb → input/html_helper.rb} +30 -9
  27. data/lib/maruku/input/linesource.rb +111 -0
  28. data/lib/maruku/input/parse_block.rb +562 -0
  29. data/lib/maruku/{parse_doc.rb → input/parse_doc.rb} +60 -28
  30. data/lib/maruku/{parse_span_better.rb → input/parse_span_better.rb} +226 -256
  31. data/lib/maruku/input/type_detection.rb +137 -0
  32. data/lib/maruku/maruku.rb +33 -0
  33. data/lib/maruku/{to_html.rb → output/to_html.rb} +151 -132
  34. data/lib/maruku/{to_latex.rb → output/to_latex.rb} +31 -35
  35. data/lib/maruku/{to_latex_entities.rb → output/to_latex_entities.rb} +25 -3
  36. data/lib/maruku/output/to_latex_strings.rb +64 -0
  37. data/lib/maruku/output/to_markdown.rb +164 -0
  38. data/lib/maruku/{to_s.rb → output/to_s.rb} +6 -0
  39. data/lib/maruku/string_utils.rb +12 -181
  40. data/lib/maruku/structures.rb +91 -67
  41. data/lib/maruku/structures_inspect.rb +78 -0
  42. data/lib/maruku/structures_iterators.rb +24 -2
  43. data/lib/maruku/tests/benchmark.rb +41 -9
  44. data/lib/maruku/tests/new_parser.rb +317 -286
  45. data/lib/maruku/tests/tests.rb +20 -0
  46. data/lib/maruku/toc.rb +64 -64
  47. data/lib/maruku/usage/example1.rb +33 -0
  48. data/lib/maruku/version.rb +8 -2
  49. data/tests/unittest/abbreviations.md +27 -16
  50. data/tests/unittest/attributes/attributes.md +89 -0
  51. data/tests/unittest/attributes/circular.md +51 -0
  52. data/tests/unittest/attributes/default.md +47 -0
  53. data/tests/unittest/blank.md +10 -6
  54. data/tests/unittest/blanks_in_code.md +26 -26
  55. data/tests/unittest/code.md +9 -9
  56. data/tests/unittest/code2.md +12 -13
  57. data/tests/unittest/code3.md +34 -34
  58. data/tests/unittest/easy.md +9 -7
  59. data/tests/unittest/email.md +9 -7
  60. data/tests/unittest/encoding/iso-8859-1.md +41 -4
  61. data/tests/unittest/encoding/utf-8.md +6 -5
  62. data/tests/unittest/entities.md +52 -80
  63. data/tests/unittest/escaping.md +47 -35
  64. data/tests/unittest/extra_dl.md +19 -29
  65. data/tests/unittest/extra_header_id.md +31 -24
  66. data/tests/unittest/extra_table1.md +14 -32
  67. data/tests/unittest/footnotes.md +58 -42
  68. data/tests/unittest/headers.md +11 -11
  69. data/tests/unittest/hrule.md +14 -24
  70. data/tests/unittest/images.md +41 -26
  71. data/tests/unittest/inline_html.md +104 -56
  72. data/tests/unittest/inline_html2.md +38 -0
  73. data/tests/unittest/links.md +74 -33
  74. data/tests/unittest/list1.md +18 -15
  75. data/tests/unittest/list2.md +31 -13
  76. data/tests/unittest/list3.md +29 -28
  77. data/tests/unittest/list4.md +103 -12
  78. data/tests/unittest/lists.md +86 -53
  79. data/tests/unittest/lists6.md +53 -0
  80. data/tests/unittest/lists7.md +31 -0
  81. data/tests/unittest/lists_after_paragraph.md +105 -71
  82. data/tests/unittest/lists_ol.md +149 -73
  83. data/tests/unittest/misc_sw.md +366 -326
  84. data/tests/unittest/notyet/escape.md +10 -10
  85. data/tests/unittest/notyet/header_after_par.md +20 -14
  86. data/tests/unittest/notyet/ticks.md +8 -35
  87. data/tests/unittest/notyet/triggering.md +72 -45
  88. data/tests/unittest/olist.md +78 -0
  89. data/tests/unittest/one.md +5 -3
  90. data/tests/unittest/paragraph.md +5 -3
  91. data/tests/unittest/paragraph_rules/dont_merge_ref.md +15 -9
  92. data/tests/unittest/paragraph_rules/tab_is_blank.md +9 -5
  93. data/tests/unittest/paragraphs.md +21 -26
  94. data/tests/unittest/recover/recover_links.md +6 -5
  95. data/tests/unittest/references/long_example.md +39 -30
  96. data/tests/unittest/references/spaces_and_numbers.md +2 -2
  97. data/tests/unittest/syntax_hl.md +33 -31
  98. data/tests/unittest/test.md +4 -6
  99. data/tests/unittest/wrapping.md +43 -26
  100. metadata +160 -139
  101. data/docs/markdown_extra2.html +0 -87
  102. data/docs/markdown_extra2.md +0 -83
  103. data/docs/markdown_syntax_2.html +0 -152
  104. data/lib/maruku/parse_block.rb +0 -564
  105. data/lib/maruku/parse_span.rb +0 -451
  106. data/lib/maruku/to_latex_strings.rb +0 -59
  107. data/lib/maruku/to_markdown.rb +0 -110
  108. data/lib/test.rb +0 -29
@@ -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"