maruku 0.6.1 → 0.7.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. checksums.yaml +7 -0
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/MIT-LICENSE.txt +20 -0
  5. data/bin/maruku +153 -152
  6. data/bin/marutex +2 -29
  7. data/data/entities.xml +261 -0
  8. data/docs/math.md +14 -18
  9. data/lib/maruku.rb +65 -77
  10. data/lib/maruku/attributes.rb +109 -214
  11. data/lib/maruku/defaults.rb +45 -67
  12. data/lib/maruku/document.rb +43 -0
  13. data/lib/maruku/element.rb +112 -0
  14. data/lib/maruku/errors.rb +71 -0
  15. data/lib/maruku/ext/div.rb +105 -113
  16. data/lib/maruku/ext/fenced_code.rb +97 -0
  17. data/lib/maruku/ext/math.rb +22 -26
  18. data/lib/maruku/ext/math/elements.rb +20 -26
  19. data/lib/maruku/ext/math/mathml_engines/blahtex.rb +92 -104
  20. data/lib/maruku/ext/math/mathml_engines/itex2mml.rb +33 -26
  21. data/lib/maruku/ext/math/mathml_engines/none.rb +11 -19
  22. data/lib/maruku/ext/math/mathml_engines/ritex.rb +2 -4
  23. data/lib/maruku/ext/math/parsing.rb +107 -113
  24. data/lib/maruku/ext/math/to_html.rb +184 -187
  25. data/lib/maruku/ext/math/to_latex.rb +30 -21
  26. data/lib/maruku/helpers.rb +158 -257
  27. data/lib/maruku/html.rb +254 -0
  28. data/lib/maruku/input/charsource.rb +272 -319
  29. data/lib/maruku/input/extensions.rb +62 -63
  30. data/lib/maruku/input/html_helper.rb +220 -189
  31. data/lib/maruku/input/linesource.rb +90 -110
  32. data/lib/maruku/input/mdline.rb +129 -0
  33. data/lib/maruku/input/parse_block.rb +618 -612
  34. data/lib/maruku/input/parse_doc.rb +145 -215
  35. data/lib/maruku/input/parse_span.rb +658 -0
  36. data/lib/maruku/input/rubypants.rb +200 -128
  37. data/lib/maruku/inspect_element.rb +60 -0
  38. data/lib/maruku/maruku.rb +10 -31
  39. data/lib/maruku/output/entity_table.rb +33 -0
  40. data/lib/maruku/output/s5/fancy.rb +462 -462
  41. data/lib/maruku/output/s5/to_s5.rb +115 -135
  42. data/lib/maruku/output/to_html.rb +898 -983
  43. data/lib/maruku/output/to_latex.rb +561 -560
  44. data/lib/maruku/output/to_markdown.rb +207 -162
  45. data/lib/maruku/output/to_s.rb +11 -52
  46. data/lib/maruku/string_utils.rb +129 -179
  47. data/lib/maruku/toc.rb +185 -196
  48. data/lib/maruku/version.rb +33 -38
  49. data/spec/block_docs/abbrev.md +776 -0
  50. data/{tests/unittest → spec/block_docs}/abbreviations.md +11 -20
  51. data/{tests/unittest → spec/block_docs}/alt.md +2 -14
  52. data/{tests/unittest/pending → spec/block_docs}/amps.md +1 -13
  53. data/{tests/unittest → spec/block_docs}/attributes/att2.md +0 -12
  54. data/{tests/unittest → spec/block_docs}/attributes/att3.md +2 -14
  55. data/{tests/unittest → spec/block_docs}/attributes/attributes.md +12 -16
  56. data/{tests/unittest → spec/block_docs}/attributes/circular.md +0 -12
  57. data/{tests/unittest → spec/block_docs}/attributes/default.md +1 -13
  58. data/{tests/unittest → spec/block_docs}/blank.md +0 -12
  59. data/{tests/unittest → spec/block_docs}/blanks_in_code.md +16 -15
  60. data/{tests/unittest/loss.md → spec/block_docs/bug_def.md} +6 -18
  61. data/{tests/unittest → spec/block_docs}/bug_table.md +3 -15
  62. data/{tests/unittest → spec/block_docs}/code.md +7 -14
  63. data/{tests/unittest → spec/block_docs}/code2.md +4 -14
  64. data/{tests/unittest → spec/block_docs}/code3.md +12 -16
  65. data/{tests/unittest → spec/block_docs}/data_loss.md +2 -14
  66. data/{tests/unittest → spec/block_docs}/divs/div1.md +0 -12
  67. data/{tests/unittest → spec/block_docs}/divs/div2.md +0 -12
  68. data/{tests/unittest → spec/block_docs}/divs/div3_nest.md +3 -15
  69. data/{tests/unittest → spec/block_docs}/easy.md +1 -13
  70. data/spec/block_docs/email.md +29 -0
  71. data/{tests/unittest/pending → spec/block_docs}/empty_cells.md +3 -15
  72. data/{tests/unittest → spec/block_docs}/encoding/iso-8859-1.md +1 -14
  73. data/{tests/unittest → spec/block_docs}/encoding/utf-8.md +0 -12
  74. data/{tests/unittest → spec/block_docs}/entities.md +27 -29
  75. data/{tests/unittest/notyet → spec/block_docs}/escape.md +2 -14
  76. data/{tests/unittest → spec/block_docs}/escaping.md +11 -22
  77. data/{tests/unittest → spec/block_docs}/extra_dl.md +2 -13
  78. data/{tests/unittest → spec/block_docs}/extra_header_id.md +14 -20
  79. data/{tests/unittest → spec/block_docs}/extra_table1.md +3 -15
  80. data/spec/block_docs/fenced_code_blocks.md +66 -0
  81. data/spec/block_docs/fenced_code_blocks_highlighted.md +18 -0
  82. data/{tests/unittest → spec/block_docs}/footnotes.md +12 -24
  83. data/spec/block_docs/footnotes2.md +78 -0
  84. data/spec/block_docs/hard.md +25 -0
  85. data/spec/block_docs/header_after_par.md +62 -0
  86. data/{tests/unittest → spec/block_docs}/headers.md +10 -18
  87. data/{tests/unittest → spec/block_docs}/hex_entities.md +7 -18
  88. data/{tests/unittest → spec/block_docs}/hrule.md +5 -12
  89. data/{tests/unittest → spec/block_docs}/html3.md +1 -13
  90. data/{tests/unittest → spec/block_docs}/html4.md +2 -14
  91. data/{tests/unittest → spec/block_docs}/html5.md +2 -14
  92. data/spec/block_docs/html_block_in_para.md +22 -0
  93. data/spec/block_docs/html_inline.md +25 -0
  94. data/spec/block_docs/html_trailing.md +31 -0
  95. data/spec/block_docs/ie.md +62 -0
  96. data/spec/block_docs/iframe.md +29 -0
  97. data/{tests/unittest → spec/block_docs}/images.md +22 -28
  98. data/{tests/unittest → spec/block_docs}/images2.md +7 -17
  99. data/{tests/unittest → spec/block_docs}/inline_html.md +37 -67
  100. data/{tests/unittest → spec/block_docs}/inline_html2.md +1 -13
  101. data/spec/block_docs/inline_html_beginning.md +10 -0
  102. data/spec/block_docs/issue20.md +9 -0
  103. data/spec/block_docs/issue26.md +22 -0
  104. data/spec/block_docs/issue29.md +9 -0
  105. data/spec/block_docs/issue30.md +30 -0
  106. data/spec/block_docs/issue31.md +25 -0
  107. data/spec/block_docs/issue40.md +40 -0
  108. data/spec/block_docs/issue64.md +55 -0
  109. data/spec/block_docs/issue67.md +19 -0
  110. data/spec/block_docs/issue70.md +11 -0
  111. data/spec/block_docs/issue72.md +17 -0
  112. data/spec/block_docs/issue74.md +38 -0
  113. data/spec/block_docs/issue79.md +15 -0
  114. data/spec/block_docs/issue83.md +13 -0
  115. data/spec/block_docs/issue85.md +25 -0
  116. data/spec/block_docs/issue88.md +19 -0
  117. data/spec/block_docs/issue89.md +12 -0
  118. data/spec/block_docs/issue90.md +38 -0
  119. data/{tests/unittest/pending → spec/block_docs}/link.md +21 -18
  120. data/{tests/unittest → spec/block_docs}/links.md +33 -32
  121. data/spec/block_docs/links2.md +21 -0
  122. data/{tests/unittest → spec/block_docs}/list1.md +0 -12
  123. data/{tests/unittest → spec/block_docs}/list12.md +2 -14
  124. data/{tests/unittest → spec/block_docs}/list2.md +2 -14
  125. data/spec/block_docs/list_multipara.md +42 -0
  126. data/{tests/unittest → spec/block_docs}/lists.md +28 -29
  127. data/{tests/unittest → spec/block_docs}/lists10.md +2 -14
  128. data/spec/block_docs/lists11.md +23 -0
  129. data/spec/block_docs/lists12.md +43 -0
  130. data/spec/block_docs/lists13.md +55 -0
  131. data/spec/block_docs/lists14.md +61 -0
  132. data/spec/block_docs/lists15.md +36 -0
  133. data/spec/block_docs/lists6.md +88 -0
  134. data/spec/block_docs/lists7b.md +58 -0
  135. data/spec/block_docs/lists9.md +53 -0
  136. data/{tests/unittest → spec/block_docs}/lists_after_paragraph.md +19 -25
  137. data/spec/block_docs/lists_blank.md +35 -0
  138. data/{tests/unittest/list3.md → spec/block_docs/lists_blockquote_code.md} +2 -14
  139. data/{tests/unittest/list4.md → spec/block_docs/lists_need_blank_line.md} +50 -21
  140. data/spec/block_docs/lists_nested.md +44 -0
  141. data/spec/block_docs/lists_nested_blankline.md +28 -0
  142. data/spec/block_docs/lists_nested_deep.md +43 -0
  143. data/{tests/unittest → spec/block_docs}/lists_ol.md +37 -54
  144. data/spec/block_docs/lists_paraindent.md +47 -0
  145. data/spec/block_docs/lists_tab.md +54 -0
  146. data/spec/block_docs/loss.md +17 -0
  147. data/spec/block_docs/math-blahtex/equations.md +30 -0
  148. data/spec/block_docs/math-blahtex/inline.md +48 -0
  149. data/spec/block_docs/math-blahtex/math2.md +45 -0
  150. data/spec/block_docs/math-blahtex/table.md +25 -0
  151. data/spec/block_docs/math/embedded_invalid_svg.md +79 -0
  152. data/spec/block_docs/math/embedded_svg.md +97 -0
  153. data/spec/block_docs/math/equations.md +44 -0
  154. data/{tests/unittest → spec/block_docs}/math/inline.md +7 -19
  155. data/spec/block_docs/math/math2.md +45 -0
  156. data/{tests/unittest → spec/block_docs}/math/notmath.md +0 -12
  157. data/spec/block_docs/math/raw_mathml.md +87 -0
  158. data/spec/block_docs/math/table.md +25 -0
  159. data/{tests/unittest → spec/block_docs}/math/table2.md +5 -17
  160. data/{tests/unittest → spec/block_docs}/misc_sw.md +181 -118
  161. data/{tests/unittest → spec/block_docs}/olist.md +6 -18
  162. data/{tests/unittest → spec/block_docs}/one.md +0 -12
  163. data/{tests/unittest → spec/block_docs}/paragraph.md +0 -12
  164. data/{tests/unittest → spec/block_docs}/paragraph_rules/dont_merge_ref.md +4 -12
  165. data/{tests/unittest → spec/block_docs}/paragraph_rules/tab_is_blank.md +0 -12
  166. data/{tests/unittest → spec/block_docs}/paragraphs.md +1 -13
  167. data/{tests/unittest → spec/block_docs}/recover/recover_links.md +4 -16
  168. data/{tests/unittest/pending/ref.md → spec/block_docs/ref_with_period.md} +7 -16
  169. data/spec/block_docs/ref_with_title.md +22 -0
  170. data/{tests/unittest → spec/block_docs}/references/long_example.md +16 -23
  171. data/{tests/unittest → spec/block_docs}/references/spaces_and_numbers.md +0 -12
  172. data/{tests/unittest → spec/block_docs}/smartypants.md +24 -31
  173. data/{tests/unittest → spec/block_docs}/syntax_hl.md +13 -17
  174. data/{tests/unittest → spec/block_docs}/table_attributes.md +2 -14
  175. data/spec/block_docs/tables.md +58 -0
  176. data/{tests/unittest → spec/block_docs}/test.md +1 -13
  177. data/{tests/unittest/notyet → spec/block_docs}/ticks.md +1 -13
  178. data/spec/block_docs/toc.md +87 -0
  179. data/{tests/unittest/notyet → spec/block_docs}/triggering.md +14 -25
  180. data/{tests/unittest → spec/block_docs}/underscore_in_words.md +0 -12
  181. data/{tests/unittest → spec/block_docs}/wrapping.md +4 -16
  182. data/spec/block_docs/xml.md +33 -0
  183. data/{tests/unittest → spec/block_docs}/xml2.md +0 -12
  184. data/spec/block_docs/xml3.md +24 -0
  185. data/{tests/unittest → spec/block_docs}/xml_instruction.md +9 -20
  186. data/spec/block_spec.rb +110 -0
  187. data/spec/cli_spec.rb +8 -0
  188. data/spec/span_spec.rb +256 -0
  189. data/spec/spec_helper.rb +2 -0
  190. data/spec/to_html_utf8_spec.rb +13 -0
  191. metadata +205 -243
  192. metadata.gz.sig +3 -0
  193. data/Rakefile +0 -48
  194. data/bin/marudown +0 -29
  195. data/bin/marutest +0 -345
  196. data/docs/changelog.md +0 -334
  197. data/lib/maruku/errors_management.rb +0 -92
  198. data/lib/maruku/ext/math/latex_fix.rb +0 -12
  199. data/lib/maruku/input/parse_span_better.rb +0 -746
  200. data/lib/maruku/input/type_detection.rb +0 -147
  201. data/lib/maruku/output/to_latex_entities.rb +0 -367
  202. data/lib/maruku/output/to_latex_strings.rb +0 -64
  203. data/lib/maruku/structures.rb +0 -167
  204. data/lib/maruku/structures_inspect.rb +0 -87
  205. data/lib/maruku/structures_iterators.rb +0 -61
  206. data/lib/maruku/tests/benchmark.rb +0 -82
  207. data/lib/maruku/tests/new_parser.rb +0 -373
  208. data/lib/maruku/tests/tests.rb +0 -136
  209. data/lib/maruku/usage/example1.rb +0 -33
  210. data/tests/bugs/code_in_links.md +0 -101
  211. data/tests/bugs/complex_escaping.md +0 -38
  212. data/tests/math/syntax.md +0 -46
  213. data/tests/math_usage/document.md +0 -13
  214. data/tests/others/abbreviations.md +0 -11
  215. data/tests/others/blank.md +0 -4
  216. data/tests/others/code.md +0 -5
  217. data/tests/others/code2.md +0 -8
  218. data/tests/others/code3.md +0 -16
  219. data/tests/others/email.md +0 -4
  220. data/tests/others/entities.md +0 -19
  221. data/tests/others/escaping.md +0 -16
  222. data/tests/others/extra_dl.md +0 -101
  223. data/tests/others/extra_header_id.md +0 -13
  224. data/tests/others/extra_table1.md +0 -40
  225. data/tests/others/footnotes.md +0 -17
  226. data/tests/others/headers.md +0 -10
  227. data/tests/others/hrule.md +0 -10
  228. data/tests/others/images.md +0 -20
  229. data/tests/others/inline_html.md +0 -42
  230. data/tests/others/links.md +0 -38
  231. data/tests/others/list1.md +0 -4
  232. data/tests/others/list2.md +0 -5
  233. data/tests/others/list3.md +0 -8
  234. data/tests/others/lists.md +0 -32
  235. data/tests/others/lists_after_paragraph.md +0 -44
  236. data/tests/others/lists_ol.md +0 -39
  237. data/tests/others/misc_sw.md +0 -105
  238. data/tests/others/one.md +0 -1
  239. data/tests/others/paragraphs.md +0 -13
  240. data/tests/others/sss06.md +0 -352
  241. data/tests/others/test.md +0 -4
  242. data/tests/s5/s5profiling.md +0 -48
  243. data/tests/unittest/bug_def.md +0 -28
  244. data/tests/unittest/email.md +0 -32
  245. data/tests/unittest/html2.md +0 -34
  246. data/tests/unittest/ie.md +0 -61
  247. data/tests/unittest/links2.md +0 -34
  248. data/tests/unittest/lists11.md +0 -28
  249. data/tests/unittest/lists6.md +0 -53
  250. data/tests/unittest/lists9.md +0 -76
  251. data/tests/unittest/math/equations.md +0 -86
  252. data/tests/unittest/math/math2.md +0 -57
  253. data/tests/unittest/math/table.md +0 -37
  254. data/tests/unittest/notyet/header_after_par.md +0 -70
  255. data/tests/unittest/red_tests/abbrev.md +0 -1388
  256. data/tests/unittest/red_tests/lists7.md +0 -68
  257. data/tests/unittest/red_tests/lists7b.md +0 -128
  258. data/tests/unittest/red_tests/lists8.md +0 -76
  259. data/tests/unittest/red_tests/xml.md +0 -70
  260. data/tests/unittest/xml3.md +0 -38
  261. data/tests/utf8-files/simple.md +0 -1
  262. data/unit_test_block.sh +0 -5
  263. data/unit_test_span.sh +0 -3
@@ -0,0 +1,3 @@
1
+ Z
2
+ �L���B��w��o�������,]{%U��һ<H�ij�֠K��Lb<[-Rk�2�9���>I�S��噻|�ˢ V�,�Yp �i6핿���Z�Zۇ�* ��ƽz�(𮐭��0b��*��]�M�I6�D�f+�[\�����LH��K�t ۚ��"��&�ڔO��
3
+ |�E���w�^���&�Z
data/Rakefile DELETED
@@ -1,48 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
-
4
- begin
5
- Bundler.setup(:default, :development)
6
- rescue Bundler::BundlerError => e
7
- $stderr.puts e.message
8
- $stderr.puts "Run `bundle install` to install missing gems"
9
- exit e.status_code
10
- end
11
-
12
- require 'rake/clean'
13
- require 'rake/rdoctask'
14
-
15
- task :default => :spec
16
- CLEAN.replace %w(pkg doc)
17
-
18
- Bundler::GemHelper.install_tasks
19
-
20
- desc "Run all tests"
21
- task :test => [:markdown_span_tests, :markdown_block_tests]
22
-
23
- desc "Run block-level tests"
24
- task :markdown_block_tests do
25
- tests = Dir['tests/unittest/**/*.md'].join(' ')
26
- puts "Executing tests #{tests}"
27
- ok = system "ruby -Ilib bin/marutest #{tests}"
28
- raise "Failed block unittest" if not ok
29
- end
30
-
31
- desc "Run span-level tests"
32
- task :markdown_span_tests do
33
- ok = system( "ruby -Ilib lib/maruku/tests/new_parser.rb v b")
34
- raise "Failed span unittest" if not ok
35
- end
36
-
37
- Rake::RDocTask.new do |rdoc|
38
- files = [#'README', 'LICENSE', 'COPYING',
39
- 'lib/**/*.rb',
40
- 'rdoc/*.rdoc'#, 'test/*.rb'
41
- ]
42
- rdoc.rdoc_files.add(files)
43
- rdoc.main = "rdoc/main.rdoc" # page to start on
44
- rdoc.title = "Maruku Documentation"
45
- rdoc.template = "jamis.rb"
46
- rdoc.rdoc_dir = 'doc' # rdoc output folder
47
- rdoc.options << '--line-numbers' << '--inline-source'
48
- end
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'maruku'
4
-
5
- # If we are given filenames, convert each file
6
- if not ARGV.empty?
7
- ARGV.each do |f|
8
- puts "Opening #{f}"
9
-
10
- # read file content
11
- input = File.open(f,'r').read
12
-
13
- # create Maruku
14
- doc = Maruku.new(input, {:on_error=>:warning})
15
- # convert to a complete html document
16
- output = doc.to_md
17
-
18
- # write to file
19
- dir = File.dirname(f)
20
- filename = File.basename(f, File.extname(f)) + ".txt"
21
-
22
- output = File.join(dir, filename)
23
- File.open(output,'w') do |f| f.puts html end
24
- end
25
- else
26
- # else, act as a filter
27
- data = $stdin.read
28
- puts Maruku.new(data, {:on_error=>:warning}).to_md
29
- end
@@ -1,345 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'maruku'
4
- require 'maruku/textile2'
5
-
6
- $marutest_language = :markdown
7
-
8
- #MARKER = "\n***EOF***\n"
9
- SPLIT = %r{\n\*\*\*[^\*]+\*\*\*\n}m
10
-
11
- def marker(x)
12
- "\n*** Output of #{x} ***\n"
13
- end
14
-
15
- def write_lines(i, j, lines, prefix, i_star)
16
- i = [i, 0].max
17
- j = [j, lines.size-1].min
18
- for a in i..j
19
- l = lines[a].gsub(/\t/,' ')
20
- puts( ("%s %3d" % [prefix, a]) +
21
- (a==i_star ? " -->" : " ")+lines[a])
22
- end
23
- end
24
-
25
- # a = expected b = found
26
- def equals(a, b)
27
- a = a.split("\n")
28
- b = b.split("\n")
29
-
30
- for i in 0..([a.size-1,b.size-1].max)
31
- la = a[i]
32
- lb = b[i]
33
- if la != lb
34
- puts "\n"
35
-
36
-
37
- write_lines(i-3, i+3, a, "expected", i )
38
- write_lines(i-3, i+3, b, " found", i )
39
- return false
40
- end
41
- end
42
- return true
43
- end
44
-
45
- TOTEST = [:inspect,:to_html,:to_latex,:to_md,:to_s]
46
-
47
- def run_test(filename, its_ok, verbose=true)
48
- # read file content
49
- input = (f=File.open(filename,'r')).read; f.close
50
-
51
- output_html = File.join(File.dirname(filename),
52
- File.basename(filename, File.extname(filename)) + ".html")
53
-
54
- # split the input in sections
55
-
56
- stuff = input.split(SPLIT)
57
- if stuff.size == 1
58
- stuff[2] = stuff[0]
59
- stuff[0] = "Write a comment here"
60
- stuff[1] = "{} # params "
61
- end
62
-
63
- comment = stuff.shift
64
- params_s = stuff.shift
65
-
66
- params = eval(params_s||'{}')
67
- if params == nil
68
- raise "Null params? #{params_s.inspect}"
69
- end
70
-
71
- markdown = stuff.shift
72
-
73
- # puts "comment: #{markdown.inspect}"
74
- # puts "markdown: #{markdown.inspect}"
75
-
76
- failed = []
77
- relaxed = []
78
- crashed = []
79
- actual = {}
80
-
81
- doc =
82
- if $marutest_language == :markdown
83
- Maruku.new(markdown, params)
84
- else
85
- MaRuKu.textile2(markdown, params)
86
- end
87
-
88
- for s in TOTEST
89
- begin
90
- if s==:to_html
91
- actual[s] = doc.to_html
92
- else
93
- actual[s] = doc.send s
94
- raise "Methods #{s} gave nil" if not actual[s]
95
- end
96
- rescue Exception => e
97
- crashed << s
98
- actual[s] = e.inspect+ "\n"+ e.backtrace.join("\n")
99
- puts actual[s]
100
- end
101
- end
102
-
103
- File.open(output_html, 'w') do |f|
104
- f.write doc.to_html_document
105
- end
106
-
107
- begin
108
- m = Maruku.new
109
- d = m.instance_eval(actual[:inspect])
110
- rescue Exception => e
111
- s = e.inspect + e.backtrace.join("\n")
112
- raise "Inspect is not correct:\n ========\n#{actual[:inspect]}"+
113
- "============\n #{s}"
114
- end
115
-
116
- expected = {}
117
- if (stuff.size < TOTEST.size)
118
- $stdout.write " (first time!) "
119
- TOTEST.each do |x| expected[x] = actual[x] end
120
- else
121
- TOTEST.each_index do |i|
122
- symbol = TOTEST[i]
123
- expected[symbol] = stuff[i]
124
- # puts "symbol: #{symbol.inspect} = #{stuff[i].inspect}"
125
- end
126
- end
127
-
128
- m = Maruku.new
129
-
130
-
131
- if not its_ok.include? :inspect
132
- begin
133
- d = m.instance_eval(expected[:inspect])
134
- # puts "Eval: #{d.inspect}"
135
- expected[:inspect] = d.inspect
136
- rescue Exception => e
137
- s = e.inspect + e.backtrace.join("\n")
138
- raise "Cannot eval user-provided string:\n #{expected[:inspect].to_s}"+
139
- "\n #{s}"
140
- end
141
- end
142
-
143
- # m.instance_eval(actual[:inspect]) != m.instance_eval(expected[:inspect])
144
-
145
- # actual[:inspect] = m.instance_eval(actual[:inspect])
146
- # expected[:inspect] = m.instance_eval(expected[:inspect])
147
-
148
-
149
- TOTEST.each do |x|
150
- expected[x].strip!
151
- actual[x].strip!
152
- if not equals(expected[x], actual[x])
153
- if its_ok.include? x
154
- expected[x] = actual[x]
155
- $stdout.write " relax:#{x} "
156
- relaxed << x
157
- else
158
- actual[x] = "-----| WARNING | -----\n" + actual[x].to_s
159
- failed << x
160
- end
161
- end
162
- end
163
-
164
- f = File.open(filename, 'w')
165
-
166
- f.write comment
167
- f.write "\n*** Parameters: ***\n"
168
- f.write params_s
169
- f.write "\n*** Markdown input: ***\n"
170
- f.write markdown
171
-
172
- TOTEST.each do |x|
173
- f.write marker(x)
174
- f.write expected[x]
175
- end
176
- f.write "\n*** EOF ***\n"
177
-
178
- if not failed.empty? or not crashed.empty?
179
-
180
- f.puts "\n\n\n\nFailed tests: #{failed.inspect} \n"
181
-
182
- TOTEST.each do |x|
183
- f.write marker(x)
184
- f.write actual[x]
185
- end
186
-
187
- else
188
- f.puts "\n\n\n\tOK!\n\n\n"
189
- end
190
-
191
-
192
- if false
193
- md_pl = markdown_pl(markdown)
194
-
195
- f.write "\n*** Output of Markdown.pl ***\n"
196
- f.write md_pl
197
-
198
- f.write "\n*** Output of Markdown.pl (parsed) ***\n"
199
- begin
200
- doc = REXML::Document.new("<div>#{md_pl}</div>",{
201
- :compress_whitespace=>['div','p'],
202
- :ignore_whitespace_nodes=>['div','p'],
203
- :respect_whitespace=>['pre','code']
204
- })
205
- div = doc.root
206
- xml =""
207
- div.write_children(xml,indent=1,transitive=true,ie_hack=false)
208
- f.write xml
209
- rescue Exception=>e
210
- f.puts "Error: #{e.inspect}"
211
- end
212
- f.close
213
- else
214
- f.write "\n*** Output of Markdown.pl ***\n"
215
- f.write "(not used anymore)"
216
-
217
- f.write "\n*** Output of Markdown.pl (parsed) ***\n"
218
- f.write "(not used anymore)"
219
- end
220
-
221
- return failed, relaxed, crashed
222
- end
223
-
224
- def markdown_pl(markdown)
225
- tmp1 = "/tmp/marutest1"
226
- tmp2 = "/tmp/marutest2"
227
- File.open(tmp1,'w') do |f| f.puts markdown end
228
- system "Markdown.pl < #{tmp1} > #{tmp2}"
229
- f = File.open(tmp2,'r')
230
- s = f.read
231
- f.close
232
- s
233
- end
234
-
235
- def passed?(args, arg)
236
- if args.include? arg
237
- args.delete arg
238
- true
239
- else
240
- false
241
- end
242
- end
243
-
244
- def marutest(args)
245
- dont_worry = []
246
- TOTEST.each do |x|
247
- arg = "ok:#{x}"
248
- # puts arg
249
- if passed?(args, arg)
250
- dont_worry << x
251
- end
252
- end
253
-
254
- if passed?(args, 'ok')
255
- dont_worry = TOTEST.clone
256
- end
257
-
258
- if dont_worry.size > 0
259
- puts "Relaxed on #{dont_worry.inspect}"
260
- end
261
-
262
-
263
- failed = {}
264
- relaxed = {}
265
-
266
- args.each do |f|
267
- $stdout.write f + ' '*(50-f.size) + " "
268
- $stdout.flush
269
- tf, tr, tcrashed = run_test(f, dont_worry)
270
-
271
- tf = tf + tcrashed
272
-
273
-
274
- if tr.size > 0
275
- $stdout.write " relax #{tr.inspect} "
276
- end
277
-
278
- if tf.size>0
279
- $stdout.write " failed on #{tf.inspect} "
280
- else
281
- $stdout.write " OK "
282
- end
283
-
284
- if tcrashed.size > 0
285
- $stdout.write " CRASHED on #{tcrashed.inspect}"
286
- end
287
-
288
- $stdout.write "\n"
289
-
290
- failed[f] = tf
291
- relaxed[f] = tr
292
- end
293
-
294
- num_failed = 0
295
- failed_cat = {}
296
-
297
- puts "\n\n\n**** FINAL REPORT ****\n\n"
298
-
299
-
300
- if failed.size > 0
301
- failed.each do |file, fl|
302
- num_failed += fl.size
303
- if fl.size > 0
304
- puts "\t#{file}\tfailed on #{fl.inspect}"
305
- end
306
- fl.each do |x|
307
- failed_cat[x] = failed_cat[x] || 0
308
- failed_cat[x] = failed_cat[x] + 1
309
- end
310
- end
311
- end
312
-
313
- if dont_worry.size > 0
314
- puts "Relaxed on #{dont_worry.inspect}"
315
- end
316
-
317
- if relaxed.size > 0
318
- relaxed.each do |file, r|
319
- if r.size > 0
320
- puts "\t#{file}\t\trelaxed on #{r.inspect}"
321
- end
322
- end
323
- end
324
-
325
- if failed_cat.size > 0
326
- puts "\nCategories:\n"
327
-
328
- failed_cat.each do |x, num|
329
- puts "\t#{x.inspect} \tfailed #{num}/#{args.size}"
330
- end
331
- end
332
-
333
- return num_failed == 0
334
- end
335
-
336
- if File.basename(__FILE__) == 'marutest'
337
- if ARGV.empty?
338
- puts "marutest is a tool for running Maruku's unittest."
339
- exit 1
340
- end
341
- ok = marutest(ARGV.clone)
342
-
343
- exit ok ? 0 : -1
344
- end
345
-
@@ -1,334 +0,0 @@
1
- CSS: style.css
2
- LaTeX CJK: true
3
- HTML use syntax: true
4
-
5
- <!-- #### Changes in the development version (**not yet released**) #### {#last} -->
6
-
7
- #### Changes in 0.5.6 #### {#stable}
8
-
9
- * News:
10
-
11
- - Now Maruku is in the official Gentoo Portage tree (done by [Aggelos Orfanakos])
12
-
13
- * New stuff:
14
-
15
- - Attribute `maruku_signature` defaults to false. (many people asked this)
16
- - unittests scripts are included in the distribution.
17
- - New attribute `filter_html`: if true, raw HTML/XML is discarded. (asked by Marik)
18
- - Command line: if output file is `-`, Maruku writes to stdout.
19
-
20
- * Bug fixes:
21
-
22
- * Another tiny bug in HTML parsing.
23
- * In latex, `\linebreak` was used instead of `\newline` (reported by Sam Kleinman)
24
- * Fixed bug with non-alpha numeric characters in ref.ids (reported by Aggelos Orfanakos)
25
-
26
-
27
- * Pending bugs/feature requests:
28
-
29
- - Maruku does not allow 3-space indented lists.
30
- - Lists item whose first character is UTF8 are not recognized (reported by Aggelos Orfanakos)
31
- - Maruku cannot output `"`-delimited attributes, because `REXML` does not support it.
32
-
33
- [Aggelos Orfanakos]: http://agorf.gr/
34
-
35
- #### Changes in 0.5.5 ####
36
-
37
- * Features:
38
-
39
- * Input of HTML numeric entities:
40
-
41
- Examples of numeric character references include &#169; or &#xA9;
42
- for the copyright symbol, &#913; or &#x391; for the Greek capital
43
- letter alpha, and &#1575; or &#x627; for the Arabic letter alef.
44
-
45
- > Examples of numeric character references include &#169; or &#xA9;
46
- > for the copyright symbol, &#913; or &#x391; for the Greek capital
47
- > letter alpha, and &#1575; or &#x627; for the Arabic letter alef.
48
-
49
- * Bug fixes:
50
-
51
- * Alt text was ignored for images.
52
- * Fixed minor bug in reading HTML inside paragraph.
53
- * Changed rules for block-level HTML to make it similar to Markdown.pl.
54
- For example:
55
-
56
- Paragraph
57
- <div></div>
58
-
59
- will be translated to
60
-
61
- <p>Paragraph
62
- <div></div></p>
63
-
64
- while this:
65
-
66
- Paragraph
67
-
68
- <div></div>
69
-
70
- becomes
71
-
72
- <p>Paragraph</p>
73
-
74
- <div></div>
75
-
76
- * **Pending bugs**: there are some problems when parsing lists. It is difficult
77
- to get it right because the spec is very fuzzy. At the moment, list items
78
- cannot be indented by more than 1 space.
79
-
80
- #### Changes in 0.5.4 ####
81
-
82
- * Features:
83
-
84
- * [All HTML attributes](http://www.w3.org/TR/html4/index/attributes.html) are supported.
85
-
86
- > Science is a wonderful thing if one does not
87
- > have to earn one's living at it.
88
- {: cite="http://en.wikiquote.org/wiki/Albert_Einstein"}
89
-
90
- * Attribute `doc_prefix`.
91
-
92
- * Math:
93
-
94
- * `\begin{equation}` and `\end{equation}` are understood.
95
- * Math parsing enabled per-instance using the `math_enabled` attribute.
96
- * `math_numbered` attribute.
97
-
98
- * Bug fixes:
99
-
100
- * Runs quietly with `ruby -w`.
101
- * Fixed a bug which could cause data-loss when reading indented lines.
102
-
103
-
104
- #### Changes in 0.5.3 ####
105
-
106
- * Features:
107
-
108
- * [All HTML `table` attributes](http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1)
109
- can be used (`summary`, `width`, `frame`, `rules`,
110
- `border`, `cellspacing`, `cellpadding`).
111
-
112
- The next version will hopefully use all HTML attributes.
113
-
114
-
115
- <!-- A version of Markdown that is more Japanese or something -->
116
-
117
- * Bug fixes:
118
-
119
- * Crash on this line: (found by Aggelos Orfanakos)
120
-
121
- [test][]:
122
-
123
- * Regression with attribute system (found by Charles)
124
-
125
- #### Changes in 0.5.1 ####
126
-
127
- * Bug fixes:
128
-
129
- * Workaround for Internet Explorer bug:
130
- be very sure that `&apos;` is always written as `&#39;`.
131
-
132
- * Support for empty images ref: `![image]` and `![image][]`.
133
-
134
- * Fixed bug in parsing attribute lists definitions.
135
-
136
- * Minor things:
137
-
138
- * Now code blocks are written as a `<code>` element inside a `<pre>`, and
139
- `<code>` elements have both `class` and `lang` attributes set
140
- to the specified language.
141
-
142
- Example:
143
-
144
- Example
145
- {:lang=ruby}
146
- {:lang=markdown}
147
-
148
- produces:
149
-
150
- <pre><code class='ruby' lang='ruby'>Example</code></pre>
151
- {:lang=xml}
152
-
153
- #### Changes in 0.5.0 ####
154
-
155
- * Syntax changes:
156
-
157
- * Compatibility with newest Markdown.pl: `[text]` as a synonim of `[text][]`.
158
-
159
- * Meta data: the first IAL in a span environment now refers to the parent.
160
- This makes it possible to set attributes for cells:
161
-
162
- Head | Head |
163
- ---------------+-------+--
164
- {:r} Hello + ...
165
-
166
- {:r: scope='row'}
167
-
168
- The first cell will have the `scope` attribute set to `row`.
169
-
170
- * New settings:
171
-
172
- * Disable the Maruku signature by setting `maruku signature: false`
173
-
174
- * Stricter doctype. By the way -- did I mention it? --
175
- **Maruku HTML has always been proper validating XHTML strict**
176
- (if a page does not validate, please report it as a bug).
177
-
178
- Of course, this only matters when using `maruku` as a standalone
179
- program.
180
-
181
- * I have updated the XHTML DTD used to support MathML:
182
- currently using XHTML+MathML+SVG.
183
- * Content-type set to `application/xhtml+xml`
184
- * All entities are written as numeric entities.
185
-
186
- * Bug fixes
187
-
188
- * Many fixes in the code handling the sanitizing of inline HTML.
189
- * `markdown=1` did not propagate to children.
190
- * LaTeX: An exception was raised if an unknown entity was used.
191
-
192
- #### Changes in 0.4.2 ####
193
-
194
- * Adapted syntax to the [new meta-data proposal][proposal].
195
-
196
- * Changes in LaTeX export:
197
-
198
- * Links to external URLs are blue by default.
199
-
200
- * New attributes: `latex_preamble` to add a custom preamble,
201
- and `latex_cjk` to add packages for UTF-8 Japanese characters.
202
- (**support for this is still shaky**). Example:
203
-
204
- Title: my document
205
- LaTeX CJK: true
206
- LaTeX preamble: preamble.tex
207
-
208
- Content
209
-
210
- * Bug fixes
211
-
212
- + Images were not given `id` or `class` attributes.
213
-
214
- + Fixed bug in LaTeX export with handling of `<`,`>` enclosed URLs: `<google.com>`.
215
-
216
- #### Changes in 0.4.1 aka "Typographer" ####
217
-
218
- * Implemented SmartyPants support:
219
-
220
- 'Twas a "test" to 'remember' -- in the '90s
221
- --- while I was <<ok>>. She was 6\"12\'.
222
- > 'Twas a "test" to 'remember' -- in the '90s --- while I was <<ok>>.
223
- > She was 6\"12\'.
224
-
225
- I adapted the code from RubyPants.
226
-
227
- * Server directives between `<? ?>` are properly preserved.
228
- * Changes in LaTeX export:
229
-
230
- * Now Japanese text rendering sort of works, using the following packages:
231
-
232
- \usepackage[C40]{fontenc}
233
- \usepackage[cjkjis]{ucs}
234
- \usepackage[utf8x]{inputenc}
235
-
236
- Nevertheless, I could only get bitmap fonts working -- probably it's a problem
237
- with my setup.
238
-
239
- A quick test: 日本、中国、ひらがな、カタカナ。
240
-
241
- * Fixed bugs in rendering of immediate links.
242
- * External packages are `require`d only if needed.
243
- * More symbols supported.
244
- See the symbol list
245
- [in HTML](http://maruku.rubyforge.org/entity_test.html) and
246
- [in PDF](http://maruku.rubyforge.org/entity_test.pdf).
247
-
248
-
249
- #### Changes in 0.4 ####
250
-
251
- * First implementation of [the new meta-data syntax][meta].
252
- * General refactorization of the code and much cleaner error reporting.
253
- * Created [the RDOC documentation][rdoc].
254
- * The `add_whitespace` method took too much time -- it was O(n^2).
255
- * Added unit-tests for block-level elements.
256
-
257
- [rdoc]: http://maruku.rubyforge.org/rdoc/
258
- [meta]: http://maruku.rubyforge.org/proposal.html
259
-
260
-
261
-
262
- [Jacques Distler]: http://golem.ph.utexas.edu/~distler
263
- [itex2MML]: http://golem.ph.utexas.edu/~distler/blog/itex2MML.html
264
- [math]: http://rubyforge.maruku.org/math.html
265
-
266
-
267
- #### Changes in 0.3 ####
268
-
269
- * A real parser is used instead of a regexp-based system, also for span-level
270
- elements.
271
-
272
- Now Maruku is almost 2x faster than Bluecloth, while having more features.
273
-
274
- Here are some benchmarks:
275
-
276
- BlueCloth (to_html): parsing 0.00 sec + rendering 1.54 sec = 1.55 sec
277
- Maruku (to_html): parsing 0.47 sec + rendering 0.38 sec = 0.85 sec
278
- Maruku (to_latex): parsing 0.49 sec + rendering 0.25 sec = 0.73 sec
279
-
280
- This is the result of running `lib/maruku/tests/benchmark.rb` on the Markdown
281
- specification.
282
-
283
- * Prettier HTML output by adding whitespace.
284
-
285
- * Added a full suite of unit-tests for the span-level parser.
286
-
287
- * Error management: Having a real parser, Maruku warns you about syntax issues.
288
-
289
- The default action is to warn and try to continue. If you do this:
290
-
291
- Maruku.new(string, {:on_error => :raise})
292
-
293
- then syntax errors will cause an exception to be raised (you can catch this
294
- and retry).
295
-
296
- * Fixed a series of bugs in handling inline HTML code.
297
-
298
- Immediate TODO-list:
299
-
300
- * UTF-8 input/output works OK for HTML, however I am having pain trying to export
301
- to LaTeX. I want at least Japanese characters support, so if you know how to
302
- do this you are very welcome to give me an hand.
303
-
304
- For example: in the HTML version, you should see accented characters in this
305
- parenthesis:
306
-
307
- > (àèìòù)
308
-
309
- and Japanese text in these other parentheses:
310
-
311
- > (カタカナで 私の 名前は アンドレア チェンシ です).
312
- >
313
- > (日本のガルは 大好き、でも、日本語は難しですから、そうぞ 英語話すガルを おしえてください).
314
-
315
- In the LaTeX version, these do not appear. I know how to do LaTeX with
316
- ISO-8859-1 encoding (European characters), but I'm struggling with half-baked
317
- solutions for UTF-8 encoded documents.
318
-
319
- * Implement the [new meta-data proposal][proposal].
320
-
321
- * Exporting to Markdown (pretty printing).
322
-
323
- * Exporting to HTML splitting in multiple files.
324
-
325
- * RubyPants.
326
-
327
- * Support for images in PDF.
328
-
329
-
330
- [proposal]: http://maruku.rubyforge.org/proposal.html
331
- [contact]: http://www.dis.uniroma1.it/~acensi/contact.html
332
- [markdown-discuss]: http://six.pairlist.net/mailman/listinfo/markdown-discuss
333
- [tracker]: http://rubyforge.org/tracker/?group_id=2795
334
-