maruku 0.6.0 → 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (290) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE.txt +20 -0
  3. data/bin/maruku +153 -152
  4. data/bin/marutex +2 -29
  5. data/data/entities.xml +261 -0
  6. data/docs/markdown_syntax.md +9 -21
  7. data/docs/math.md +14 -18
  8. data/lib/maruku.rb +65 -78
  9. data/lib/maruku/attributes.rb +109 -214
  10. data/lib/maruku/defaults.rb +45 -67
  11. data/lib/maruku/document.rb +44 -0
  12. data/lib/maruku/element.rb +138 -0
  13. data/lib/maruku/errors.rb +80 -0
  14. data/lib/maruku/ext/div.rb +105 -113
  15. data/lib/maruku/ext/fenced_code.rb +97 -0
  16. data/lib/maruku/ext/math.rb +22 -26
  17. data/lib/maruku/ext/math/elements.rb +20 -26
  18. data/lib/maruku/ext/math/mathml_engines/blahtex.rb +92 -104
  19. data/lib/maruku/ext/math/mathml_engines/itex2mml.rb +33 -26
  20. data/lib/maruku/ext/math/mathml_engines/none.rb +11 -19
  21. data/lib/maruku/ext/math/mathml_engines/ritex.rb +2 -4
  22. data/lib/maruku/ext/math/parsing.rb +121 -115
  23. data/lib/maruku/ext/math/to_html.rb +202 -187
  24. data/lib/maruku/ext/math/to_latex.rb +34 -21
  25. data/lib/maruku/helpers.rb +158 -257
  26. data/lib/maruku/html.rb +251 -0
  27. data/lib/maruku/input/charsource.rb +272 -319
  28. data/lib/maruku/input/extensions.rb +62 -63
  29. data/lib/maruku/input/html_helper.rb +233 -189
  30. data/lib/maruku/input/linesource.rb +90 -110
  31. data/lib/maruku/input/mdline.rb +131 -0
  32. data/lib/maruku/input/parse_block.rb +736 -613
  33. data/lib/maruku/input/parse_doc.rb +145 -217
  34. data/lib/maruku/input/parse_span.rb +740 -0
  35. data/lib/maruku/inspect_element.rb +60 -0
  36. data/lib/maruku/maruku.rb +14 -30
  37. data/lib/maruku/output/entity_table.rb +37 -0
  38. data/lib/maruku/output/s5/fancy.rb +462 -462
  39. data/lib/maruku/output/s5/to_s5.rb +115 -135
  40. data/lib/maruku/output/to_html.rb +907 -983
  41. data/lib/maruku/output/to_latex.rb +571 -563
  42. data/lib/maruku/output/to_markdown.rb +207 -162
  43. data/lib/maruku/output/to_s.rb +10 -52
  44. data/lib/maruku/string_utils.rb +129 -179
  45. data/lib/maruku/toc.rb +185 -196
  46. data/lib/maruku/version.rb +33 -38
  47. data/spec/block_docs/abbrev.md +776 -0
  48. data/{tests/unittest → spec/block_docs}/abbreviations.md +11 -20
  49. data/spec/block_docs/abbreviations2.md +27 -0
  50. data/{tests/unittest → spec/block_docs}/alt.md +2 -14
  51. data/{tests/unittest/pending → spec/block_docs}/amps.md +1 -13
  52. data/spec/block_docs/attribute_sanitize.md +22 -0
  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/spec/block_docs/atx_headers.md +22 -0
  59. data/spec/block_docs/auto_cdata.md +48 -0
  60. data/spec/block_docs/bad_cites.md +30 -0
  61. data/spec/block_docs/bad_divrefs.md +30 -0
  62. data/{tests/unittest → spec/block_docs}/blank.md +0 -12
  63. data/{tests/unittest → spec/block_docs}/blanks_in_code.md +16 -15
  64. data/spec/block_docs/block_quotes.md +66 -0
  65. data/{tests/unittest/loss.md → spec/block_docs/bug_def.md} +6 -18
  66. data/{tests/unittest → spec/block_docs}/bug_table.md +7 -19
  67. data/spec/block_docs/cites.md +37 -0
  68. data/{tests/unittest → spec/block_docs}/code.md +7 -14
  69. data/{tests/unittest → spec/block_docs}/code2.md +4 -14
  70. data/{tests/unittest → spec/block_docs}/code3.md +12 -16
  71. data/spec/block_docs/code4.md +79 -0
  72. data/{tests/unittest → spec/block_docs}/data_loss.md +2 -14
  73. data/spec/block_docs/div_without_newline.md +16 -0
  74. data/{tests/unittest → spec/block_docs}/divs/div1.md +0 -12
  75. data/{tests/unittest → spec/block_docs}/divs/div2.md +0 -12
  76. data/{tests/unittest → spec/block_docs}/divs/div3_nest.md +3 -15
  77. data/{tests/unittest → spec/block_docs}/easy.md +1 -13
  78. data/spec/block_docs/email.md +29 -0
  79. data/spec/block_docs/empty_cells.md +31 -0
  80. data/{tests/unittest → spec/block_docs}/encoding/iso-8859-1.md +1 -14
  81. data/{tests/unittest → spec/block_docs}/encoding/utf-8.md +0 -12
  82. data/{tests/unittest → spec/block_docs}/entities.md +33 -41
  83. data/{tests/unittest/notyet → spec/block_docs}/escape.md +2 -14
  84. data/{tests/unittest → spec/block_docs}/escaping.md +11 -22
  85. data/{tests/unittest → spec/block_docs}/extra_dl.md +2 -13
  86. data/{tests/unittest → spec/block_docs}/extra_header_id.md +14 -20
  87. data/{tests/unittest → spec/block_docs}/extra_table1.md +9 -21
  88. data/spec/block_docs/fenced_code_blocks.md +58 -0
  89. data/spec/block_docs/fenced_code_blocks_highlighted.md +17 -0
  90. data/{tests/unittest → spec/block_docs}/footnotes.md +12 -24
  91. data/spec/block_docs/footnotes2.md +82 -0
  92. data/spec/block_docs/hard.md +25 -0
  93. data/spec/block_docs/header_after_par.md +62 -0
  94. data/{tests/unittest → spec/block_docs}/headers.md +10 -18
  95. data/{tests/unittest → spec/block_docs}/hex_entities.md +7 -18
  96. data/{tests/unittest → spec/block_docs}/hrule.md +5 -12
  97. data/{tests/unittest → spec/block_docs}/html3.md +1 -13
  98. data/{tests/unittest → spec/block_docs}/html4.md +2 -14
  99. data/{tests/unittest → spec/block_docs}/html5.md +2 -14
  100. data/spec/block_docs/html_block_in_para.md +22 -0
  101. data/spec/block_docs/html_inline.md +25 -0
  102. data/spec/block_docs/html_trailing.md +31 -0
  103. data/spec/block_docs/ie.md +62 -0
  104. data/spec/block_docs/iframe.md +29 -0
  105. data/spec/block_docs/ignore_bad_header.md +9 -0
  106. data/{tests/unittest → spec/block_docs}/images.md +22 -28
  107. data/{tests/unittest → spec/block_docs}/images2.md +7 -17
  108. data/{tests/unittest → spec/block_docs}/inline_html.md +37 -67
  109. data/{tests/unittest → spec/block_docs}/inline_html2.md +1 -13
  110. data/spec/block_docs/inline_html_beginning.md +10 -0
  111. data/spec/block_docs/issue106.md +78 -0
  112. data/spec/block_docs/issue115.md +20 -0
  113. data/spec/block_docs/issue117.md +13 -0
  114. data/spec/block_docs/issue120.md +48 -0
  115. data/spec/block_docs/issue123.md +11 -0
  116. data/spec/block_docs/issue124.md +16 -0
  117. data/spec/block_docs/issue126.md +9 -0
  118. data/spec/block_docs/issue130.md +11 -0
  119. data/spec/block_docs/issue20.md +9 -0
  120. data/spec/block_docs/issue26.md +22 -0
  121. data/spec/block_docs/issue29.md +9 -0
  122. data/spec/block_docs/issue30.md +30 -0
  123. data/spec/block_docs/issue31.md +25 -0
  124. data/spec/block_docs/issue40.md +52 -0
  125. data/spec/block_docs/issue64.md +55 -0
  126. data/spec/block_docs/issue67.md +19 -0
  127. data/spec/block_docs/issue70.md +11 -0
  128. data/spec/block_docs/issue72.md +17 -0
  129. data/spec/block_docs/issue74.md +38 -0
  130. data/spec/block_docs/issue79.md +15 -0
  131. data/spec/block_docs/issue83.md +13 -0
  132. data/spec/block_docs/issue85.md +25 -0
  133. data/spec/block_docs/issue88.md +19 -0
  134. data/spec/block_docs/issue89.md +12 -0
  135. data/spec/block_docs/issue90.md +38 -0
  136. data/{tests/unittest/pending → spec/block_docs}/link.md +21 -18
  137. data/{tests/unittest → spec/block_docs}/links.md +33 -32
  138. data/spec/block_docs/links2.md +21 -0
  139. data/{tests/unittest → spec/block_docs}/list1.md +0 -12
  140. data/{tests/unittest → spec/block_docs}/list12.md +2 -14
  141. data/{tests/unittest → spec/block_docs}/list2.md +2 -14
  142. data/spec/block_docs/list_multipara.md +42 -0
  143. data/{tests/unittest → spec/block_docs}/lists.md +28 -29
  144. data/{tests/unittest → spec/block_docs}/lists10.md +2 -14
  145. data/spec/block_docs/lists11.md +23 -0
  146. data/spec/block_docs/lists12.md +43 -0
  147. data/spec/block_docs/lists13.md +55 -0
  148. data/spec/block_docs/lists14.md +61 -0
  149. data/spec/block_docs/lists15.md +36 -0
  150. data/spec/block_docs/lists6.md +88 -0
  151. data/spec/block_docs/lists7b.md +58 -0
  152. data/spec/block_docs/lists9.md +53 -0
  153. data/{tests/unittest → spec/block_docs}/lists_after_paragraph.md +19 -25
  154. data/spec/block_docs/lists_blank.md +35 -0
  155. data/{tests/unittest/list3.md → spec/block_docs/lists_blockquote_code.md} +2 -14
  156. data/{tests/unittest/list4.md → spec/block_docs/lists_need_blank_line.md} +44 -29
  157. data/spec/block_docs/lists_nested.md +44 -0
  158. data/spec/block_docs/lists_nested_blankline.md +34 -0
  159. data/spec/block_docs/lists_nested_deep.md +43 -0
  160. data/spec/block_docs/lists_ol.md +129 -0
  161. data/spec/block_docs/lists_ol2.md +147 -0
  162. data/spec/block_docs/lists_paraindent.md +42 -0
  163. data/spec/block_docs/lists_tab.md +54 -0
  164. data/spec/block_docs/loss.md +17 -0
  165. data/spec/block_docs/math-blahtex/equations.md +29 -0
  166. data/spec/block_docs/math-blahtex/inline.md +48 -0
  167. data/spec/block_docs/math-blahtex/math2.md +52 -0
  168. data/spec/block_docs/math-blahtex/table.md +25 -0
  169. data/spec/block_docs/math/embedded_invalid_svg.md +108 -0
  170. data/spec/block_docs/math/embedded_svg.md +136 -0
  171. data/spec/block_docs/math/equations.md +49 -0
  172. data/spec/block_docs/math/inline.md +46 -0
  173. data/spec/block_docs/math/math2.md +53 -0
  174. data/{tests/unittest → spec/block_docs}/math/notmath.md +0 -12
  175. data/spec/block_docs/math/raw_mathml.md +87 -0
  176. data/spec/block_docs/math/spaces_after_inline_math.md +17 -0
  177. data/spec/block_docs/math/table.md +25 -0
  178. data/{tests/unittest → spec/block_docs}/math/table2.md +11 -23
  179. data/{tests/unittest → spec/block_docs}/misc_sw.md +184 -121
  180. data/{tests/unittest → spec/block_docs}/olist.md +6 -18
  181. data/{tests/unittest → spec/block_docs}/one.md +0 -12
  182. data/{tests/unittest → spec/block_docs}/paragraph.md +0 -12
  183. data/{tests/unittest → spec/block_docs}/paragraph_rules/dont_merge_ref.md +4 -12
  184. data/{tests/unittest → spec/block_docs}/paragraph_rules/tab_is_blank.md +0 -12
  185. data/{tests/unittest → spec/block_docs}/paragraphs.md +1 -13
  186. data/{tests/unittest → spec/block_docs}/recover/recover_links.md +4 -16
  187. data/{tests/unittest/pending/ref.md → spec/block_docs/ref_with_period.md} +7 -16
  188. data/spec/block_docs/ref_with_title.md +22 -0
  189. data/{tests/unittest → spec/block_docs}/references/long_example.md +16 -23
  190. data/{tests/unittest → spec/block_docs}/references/spaces_and_numbers.md +0 -12
  191. data/{tests/unittest → spec/block_docs}/smartypants.md +24 -31
  192. data/{tests/unittest → spec/block_docs}/syntax_hl.md +13 -17
  193. data/{tests/unittest → spec/block_docs}/table_attributes.md +6 -20
  194. data/spec/block_docs/table_colspan.md +41 -0
  195. data/spec/block_docs/tables.md +47 -0
  196. data/spec/block_docs/tables2.md +74 -0
  197. data/{tests/unittest → spec/block_docs}/test.md +1 -13
  198. data/{tests/unittest/notyet → spec/block_docs}/ticks.md +1 -13
  199. data/spec/block_docs/toc.md +87 -0
  200. data/{tests/unittest/notyet → spec/block_docs}/triggering.md +14 -25
  201. data/{tests/unittest → spec/block_docs}/underscore_in_words.md +0 -12
  202. data/{tests/unittest → spec/block_docs}/wrapping.md +4 -16
  203. data/spec/block_docs/xml.md +33 -0
  204. data/spec/block_docs/xml3.md +24 -0
  205. data/spec/block_docs/xml_comments.md +32 -0
  206. data/{tests/unittest → spec/block_docs}/xml_instruction.md +9 -20
  207. data/spec/block_spec.rb +110 -0
  208. data/spec/cli_spec.rb +8 -0
  209. data/spec/span_spec.rb +263 -0
  210. data/spec/spec_helper.rb +3 -0
  211. data/spec/to_html_utf8_spec.rb +13 -0
  212. metadata +218 -202
  213. data/Rakefile +0 -73
  214. data/bin/marudown +0 -29
  215. data/bin/marutest +0 -345
  216. data/docs/changelog.md +0 -334
  217. data/lib/maruku/errors_management.rb +0 -92
  218. data/lib/maruku/ext/math/latex_fix.rb +0 -12
  219. data/lib/maruku/input/parse_span_better.rb +0 -746
  220. data/lib/maruku/input/rubypants.rb +0 -225
  221. data/lib/maruku/input/type_detection.rb +0 -147
  222. data/lib/maruku/output/to_latex_entities.rb +0 -367
  223. data/lib/maruku/output/to_latex_strings.rb +0 -64
  224. data/lib/maruku/structures.rb +0 -167
  225. data/lib/maruku/structures_inspect.rb +0 -87
  226. data/lib/maruku/structures_iterators.rb +0 -61
  227. data/lib/maruku/tests/benchmark.rb +0 -82
  228. data/lib/maruku/tests/new_parser.rb +0 -373
  229. data/lib/maruku/tests/tests.rb +0 -136
  230. data/lib/maruku/usage/example1.rb +0 -33
  231. data/maruku_gem.rb +0 -33
  232. data/tests/bugs/code_in_links.md +0 -101
  233. data/tests/bugs/complex_escaping.md +0 -38
  234. data/tests/math/syntax.md +0 -46
  235. data/tests/math_usage/document.md +0 -13
  236. data/tests/others/abbreviations.md +0 -11
  237. data/tests/others/blank.md +0 -4
  238. data/tests/others/code.md +0 -5
  239. data/tests/others/code2.md +0 -8
  240. data/tests/others/code3.md +0 -16
  241. data/tests/others/email.md +0 -4
  242. data/tests/others/entities.md +0 -19
  243. data/tests/others/escaping.md +0 -16
  244. data/tests/others/extra_dl.md +0 -101
  245. data/tests/others/extra_header_id.md +0 -13
  246. data/tests/others/extra_table1.md +0 -40
  247. data/tests/others/footnotes.md +0 -17
  248. data/tests/others/headers.md +0 -10
  249. data/tests/others/hrule.md +0 -10
  250. data/tests/others/images.md +0 -20
  251. data/tests/others/inline_html.md +0 -42
  252. data/tests/others/links.md +0 -38
  253. data/tests/others/list1.md +0 -4
  254. data/tests/others/list2.md +0 -5
  255. data/tests/others/list3.md +0 -8
  256. data/tests/others/lists.md +0 -32
  257. data/tests/others/lists_after_paragraph.md +0 -44
  258. data/tests/others/lists_ol.md +0 -39
  259. data/tests/others/misc_sw.md +0 -105
  260. data/tests/others/one.md +0 -1
  261. data/tests/others/paragraphs.md +0 -13
  262. data/tests/others/sss06.md +0 -352
  263. data/tests/others/test.md +0 -4
  264. data/tests/s5/s5profiling.md +0 -48
  265. data/tests/unittest/bug_def.md +0 -28
  266. data/tests/unittest/email.md +0 -32
  267. data/tests/unittest/hang.md +0 -29
  268. data/tests/unittest/html2.md +0 -34
  269. data/tests/unittest/ie.md +0 -61
  270. data/tests/unittest/links2.md +0 -34
  271. data/tests/unittest/lists11.md +0 -28
  272. data/tests/unittest/lists6.md +0 -53
  273. data/tests/unittest/lists9.md +0 -76
  274. data/tests/unittest/lists_ol.md +0 -274
  275. data/tests/unittest/math/equations.md +0 -86
  276. data/tests/unittest/math/inline.md +0 -58
  277. data/tests/unittest/math/math2.md +0 -57
  278. data/tests/unittest/math/table.md +0 -37
  279. data/tests/unittest/notyet/header_after_par.md +0 -70
  280. data/tests/unittest/pending/empty_cells.md +0 -49
  281. data/tests/unittest/red_tests/abbrev.md +0 -1388
  282. data/tests/unittest/red_tests/lists7.md +0 -68
  283. data/tests/unittest/red_tests/lists7b.md +0 -128
  284. data/tests/unittest/red_tests/lists8.md +0 -76
  285. data/tests/unittest/red_tests/xml.md +0 -70
  286. data/tests/unittest/xml2.md +0 -31
  287. data/tests/unittest/xml3.md +0 -38
  288. data/tests/utf8-files/simple.md +0 -1
  289. data/unit_test_block.sh +0 -5
  290. data/unit_test_span.sh +0 -3
data/Rakefile DELETED
@@ -1,73 +0,0 @@
1
- require 'rubygems'
2
- Gem::manage_gems
3
- require 'rake/gempackagetask'
4
-
5
- require 'maruku_gem'
6
-
7
- task :default => [:package]
8
-
9
- Rake::GemPackageTask.new($spec) do |pkg|
10
- pkg.need_zip = true
11
- pkg.need_tar = true
12
- end
13
-
14
- PKG_NAME = 'maruku'
15
- PKG_FILE_NAME = "#{PKG_NAME}-#{MaRuKu::Version}"
16
- RUBY_FORGE_PROJECT = PKG_NAME
17
- RUBY_FORGE_USER = 'andrea'
18
-
19
- RELEASE_NAME = MaRuKu::Version
20
- RUBY_FORGE_GROUPID = '2795'
21
- RUBY_FORGE_PACKAGEID = '3292'
22
-
23
- desc "Publish the release files to RubyForge."
24
- task :release => [:gem, :package] do
25
- system("rubyforge login --username #{RUBY_FORGE_USER}")
26
-
27
- gem = "pkg/#{PKG_FILE_NAME}.gem"
28
- # -n notes/#{Maruku::Version}.txt
29
- cmd = "rubyforge add_release %s %s \"%s\" %s" %
30
- [RUBY_FORGE_GROUPID, RUBY_FORGE_PACKAGEID, RELEASE_NAME, gem]
31
-
32
- puts cmd
33
- system(cmd)
34
-
35
- files = ["gem", "tgz", "zip"].map { |ext| "pkg/#{PKG_FILE_NAME}.#{ext}" }
36
- files.each do |file|
37
- # system("rubyforge add_file %s %s %s %s" %
38
- # [RUBY_FORGE_GROUPID, RUBY_FORGE_PACKAGEID, RELEASE_NAME, file])
39
- end
40
- end
41
-
42
- task :test => [:markdown_span_tests, :markdown_block_tests]
43
-
44
- task :markdown_block_tests do
45
- tests = Dir['tests/unittest/**/*.md'].join(' ')
46
- puts "Executing tests #{tests}"
47
- # ok = marutest(tests)
48
- ok = system "ruby -Ilib bin/marutest #{tests}"
49
- raise "Failed block unittest" if not ok
50
- end
51
-
52
- task :markdown_span_tests do
53
- ok = system( "ruby -Ilib lib/maruku/tests/new_parser.rb v b")
54
- raise "Failed span unittest" if not ok
55
- end
56
-
57
- require 'rake/rdoctask'
58
-
59
- Rake::RDocTask.new do |rdoc|
60
- files = [#'README', 'LICENSE', 'COPYING',
61
- 'lib/**/*.rb',
62
- 'rdoc/*.rdoc'#, 'test/*.rb'
63
- ]
64
- rdoc.rdoc_files.add(files)
65
- rdoc.main = "rdoc/main.rdoc" # page to start on
66
- rdoc.title = "Maruku Documentation"
67
- rdoc.template = "jamis.rb"
68
- rdoc.rdoc_dir = 'doc' # rdoc output folder
69
- rdoc.options << '--line-numbers' << '--inline-source'
70
- end
71
-
72
-
73
-
@@ -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
-