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
@@ -18,12 +18,12 @@ md_el(:document,[
18
18
  "Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet."
19
19
  ]),
20
20
  md_el(:ul,[
21
- md_el(:li_span,[
21
+ md_el(:li,[
22
22
  "Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet Lorem ipsum Break:",
23
23
  md_el(:linebreak,[],{},[]),
24
24
  "Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet"
25
25
  ],{:want_my_paragraph=>false},[]),
26
- md_el(:li_span,[
26
+ md_el(:li,[
27
27
  "Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet"
28
28
  ],{:want_my_paragraph=>false},[])
29
29
  ],{},[])
@@ -54,26 +54,14 @@ Lorem ipsum dolor amet. Lorem ipsum
54
54
  dolor amet. Lorem ipsum dolor amet.
55
55
  Lorem ipsum dolor amet.
56
56
 
57
- -orem ipsum dolor amet. Lorem ipsum
57
+ - Lorem ipsum dolor amet. Lorem ipsum
58
58
  dolor amet. Lorem ipsum dolor amet.
59
59
  Lorem ipsum dolor amet Lorem ipsum
60
60
  Break:
61
61
  Lorem ipsum dolor amet. Lorem ipsum
62
62
  dolor amet. Lorem ipsum dolor amet
63
- -orem ipsum dolor amet. Lorem ipsum
63
+ - Lorem ipsum dolor amet. Lorem ipsum
64
64
  dolor amet. Lorem ipsum dolor amet.
65
65
  Lorem ipsum dolor amet
66
66
  *** Output of to_s ***
67
67
  Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Break:Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet.Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet Lorem ipsum Break:Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor ametLorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet. Lorem ipsum dolor amet
68
- *** EOF ***
69
-
70
-
71
-
72
- OK!
73
-
74
-
75
-
76
- *** Output of Markdown.pl ***
77
- (not used anymore)
78
- *** Output of Markdown.pl (parsed) ***
79
- (not used anymore)
@@ -0,0 +1,33 @@
1
+ JRUBY NOKOGIRI PENDING - Write a comment here
2
+ (JRuby Nokogiri is broken for empty tags: https://github.com/sparklemotion/nokogiri/issues/971)
3
+ *** Parameters: ***
4
+ {:on_error=>:raise}
5
+ *** Markdown input: ***
6
+
7
+ <svg/>
8
+
9
+ <svg:svg xmlns:svg="http://www.w3.org/2000/svg"
10
+ width="600px" height="400px">
11
+ <svg:g id="group">
12
+ <svg:circle id="circ1" r="1cm" cx="3cm" cy="3cm" style="fill:red;"></svg:circle>
13
+ <svg:circle id="circ2" r="1cm" cx="7cm" cy="3cm" style="fill:red;" />
14
+ </svg:g>
15
+ </svg:svg>
16
+
17
+ *** Output of inspect ***
18
+ md_el(:document,[
19
+ md_html("<svg/>"),
20
+ md_html("<svg:svg xmlns:svg=\"http://www.w3.org/2000/svg\"\nwidth=\"600px\" height=\"400px\">\n <svg:g id=\"group\">\n\t<svg:circle id=\"circ1\" r=\"1cm\" cx=\"3cm\" cy=\"3cm\" style=\"fill:red;\"></svg:circle>\n\t<svg:circle id=\"circ2\" r=\"1cm\" cx=\"7cm\" cy=\"3cm\" style=\"fill:red;\" />\n </svg:g>\n</svg:svg>")
21
+ ],{},[])
22
+ *** Output of to_html ***
23
+ <svg></svg><svg:svg xmlns:svg="http://www.w3.org/2000/svg" width="600px" height="400px">
24
+ <svg:g id="group">
25
+ <svg:circle id="circ1" r="1cm" cx="3cm" cy="3cm" style="fill:red;"></svg:circle>
26
+ <svg:circle id="circ2" r="1cm" cx="7cm" cy="3cm" style="fill:red;"></svg:circle>
27
+ </svg:g>
28
+ </svg:svg>
29
+ *** Output of to_latex ***
30
+
31
+ *** Output of to_md ***
32
+
33
+ *** Output of to_s ***
@@ -0,0 +1,24 @@
1
+ The markdown="1" attribute does NOT get recursively applied
2
+ *** Parameters: ***
3
+ {}
4
+ *** Markdown input: ***
5
+ <table markdown='1'>
6
+ Blah
7
+ <thead>
8
+ <tr><td>*em*</td></tr>
9
+ </thead>
10
+ </table>
11
+
12
+ *** Output of inspect ***
13
+ md_el(:document,[
14
+ md_html("<table markdown='1'>\n\tBlah\n\t<thead>\n\t\t<tr><td>*em*</td></tr>\n\t</thead>\n</table>")
15
+ ],{},[])
16
+ *** Output of to_html ***
17
+ <table>
18
+ Blah
19
+ <thead>
20
+ <tr><td>*em*</td></tr>
21
+ </thead>
22
+ </table>
23
+
24
+
@@ -0,0 +1,32 @@
1
+ XML Comments need to be handled properly.
2
+ Note that output is kind of weird because we modify the comment in order to let REXML parse it due to https://bugs.ruby-lang.org/issues/9277.
3
+ *** Parameters: ***
4
+ {}
5
+ *** Markdown input: ***
6
+ <!--
7
+ &rsquo;
8
+ -->
9
+
10
+ <!-- declarations for <head> & <body> -->
11
+
12
+ <!-- -- is invalid -->
13
+
14
+ <!-- -- is
15
+ invalid -->
16
+
17
+ *** Output of inspect ***
18
+ md_el(:document,[md_html("<!--\n&rsquo;\n-->"),
19
+ md_html("<!-- declarations for <head> & <body> -->"),
20
+ md_html("<!-- - - is invalid -->"),
21
+ md_html("<!-- - - is\ninvalid -->")])
22
+ *** Output of to_html ***
23
+ <!--
24
+ &rsquo;
25
+ -->
26
+
27
+ <!-- declarations for <head> & <body> -->
28
+
29
+ <!-- - - is invalid -->
30
+
31
+ <!-- - - is
32
+ invalid -->
@@ -3,12 +3,12 @@ Directives should be preserved.
3
3
  {}
4
4
  *** Markdown input: ***
5
5
 
6
- <? noTarget?>
7
- <?php ?>
8
- <?xml ?>
6
+ <? noTarget?>
7
+ <?php ?>
8
+ <?xml ?>
9
9
  <?mrk ?>
10
10
 
11
- Targets <? noTarget?> <?php ?> <?xml ?> <?mrk ?>
11
+ Targets <? noTarget?> <?php ?> <?xml ?> <?mrk ?> !
12
12
 
13
13
  Inside: <?mrk puts "Inside: Hello" ?> last
14
14
 
@@ -27,7 +27,8 @@ md_el(:document,[
27
27
  " ",
28
28
  md_el(:xml_instr,[],{:code=>"",:target=>"xml"},[]),
29
29
  " ",
30
- md_el(:xml_instr,[],{:code=>"",:target=>"mrk"},[])
30
+ md_el(:xml_instr,[],{:code=>"",:target=>"mrk"},[]),
31
+ " !"
31
32
  ]),
32
33
  md_par([
33
34
  "Inside: ",
@@ -36,12 +37,12 @@ md_el(:document,[
36
37
  ])
37
38
  ],{},[])
38
39
  *** Output of to_html ***
39
- <? noTarget?><?php ?><?xml ?><?mrk ?>
40
- <p>Targets <? noTarget?> <?php ?> <?xml ?> <?mrk ?></p>
40
+ &lt;? noTarget?&gt;<?php ?><?xml ?><?mrk ?>
41
+ <p>Targets &lt;?noTarget?&gt; <?php ?> <?xml ?> <?mrk ?> !</p>
41
42
 
42
43
  <p>Inside: <?mrk puts "Inside: Hello"?> last</p>
43
44
  *** Output of to_latex ***
44
- Targets
45
+ Targets !
45
46
 
46
47
  Inside: last
47
48
  *** Output of to_md ***
@@ -50,15 +51,3 @@ Targets
50
51
  Inside: last
51
52
  *** Output of to_s ***
52
53
  Targets Inside: last
53
- *** EOF ***
54
-
55
-
56
-
57
- OK!
58
-
59
-
60
-
61
- *** Output of Markdown.pl ***
62
- (not used anymore)
63
- *** Output of Markdown.pl (parsed) ***
64
- (not used anymore)
@@ -0,0 +1,110 @@
1
+ # encoding: UTF-8
2
+ Encoding.default_external=('UTF-8') if ''.respond_to?(:force_encoding)
3
+
4
+ require File.dirname(__FILE__) + '/spec_helper'
5
+ require 'rspec'
6
+ require 'maruku'
7
+ require 'nokogiri/diff'
8
+
9
+ # Allow us to test both HTML parser backends
10
+ MaRuKu::Globals[:html_parser] = ENV['HTML_PARSER'] if ENV['HTML_PARSER']
11
+
12
+ puts "Using HTML parser: #{MaRuKu::Globals[:html_parser]}"
13
+
14
+ # :to_md and :to_s tests are disabled for now
15
+ METHODS = [:to_html, :to_latex]
16
+
17
+ def which(cmd)
18
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
19
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
20
+ exts.each { |ext|
21
+ exe = File.join(path, "#{cmd}#{ext}")
22
+ return exe if File.executable? exe
23
+ }
24
+ end
25
+ return nil
26
+ end
27
+
28
+ if which('blahtex')
29
+ HAS_BLAHTEX = true
30
+ else
31
+ HAS_BLAHTEX = false
32
+ puts "Install 'blahtex' to run blahtex math tests"
33
+ end
34
+
35
+ describe "A Maruku doc" do
36
+ before(:all) do
37
+ @old_stderr = $stderr
38
+ $stderr = StringIO.new
39
+ end
40
+
41
+ after(:all) do
42
+ $stderr = @old_stderr
43
+ end
44
+
45
+ Dir[File.dirname(__FILE__) + "/block_docs/**/*.md"].each do |md|
46
+ next if md =~ /blahtex/ && !HAS_BLAHTEX
47
+
48
+ md_pretty = md.sub(File.dirname(__FILE__) + '/', '')
49
+
50
+ describe "#{md_pretty} (using #{MaRuKu::Globals[:html_parser]})" do
51
+ input = File.read(md).split(/\n\*{3}[^*\n]+\*{3}\n/m)
52
+ input = ["Write a comment here", "{}", input.first] if input.size == 1
53
+ comment = input.shift.strip
54
+ params = input.shift || ''
55
+ markdown = input.shift || ''
56
+ ast = input.shift || ''
57
+ expected = METHODS.zip(input).inject({}) {|h, (k, v)| h[k] = v ? v.strip : '' ; h}
58
+
59
+ pending "#{comment} - #{md_pretty}" and next if comment.start_with?("PENDING")
60
+ pending "#{comment} - #{md_pretty}" and next if comment.start_with?("REXML PENDING") && MaRuKu::Globals[:html_parser] == 'rexml'
61
+ pending "#{comment} - #{md_pretty}" and next if comment.start_with?("JRUBY PENDING") && RUBY_PLATFORM == 'java'
62
+ pending "#{comment} - #{md_pretty}" and next if comment.start_with?("JRUBY NOKOGIRI PENDING") && RUBY_PLATFORM == 'java' && MaRuKu::Globals[:html_parser] == 'nokogiri'
63
+
64
+ before(:each) do
65
+ $already_warned_itex2mml = false
66
+ @doc = Maruku.new(markdown, eval(params))
67
+ end
68
+
69
+ it "should read in the output of #inspect as the same document" do
70
+ Maruku.new.instance_eval("#coding: utf-8\n#{@doc.inspect}", md).should == @doc
71
+ end
72
+
73
+ unless ast.strip.empty?
74
+ it "should produce the given AST" do
75
+ @doc.should == Maruku.new.instance_eval(ast, md)
76
+ end
77
+ end
78
+
79
+ unless expected[:to_html].strip.empty?
80
+ it "should have the expected to_html output" do
81
+ res = @doc.to_html.strip
82
+ pending "install itex2mml to run these tests" if $already_warned_itex2mml
83
+
84
+ resdoc = Nokogiri::XML("<dummy>#{res}</dummy>")
85
+ expdoc = Nokogiri::XML("<dummy>#{expected[:to_html]}</dummy>")
86
+
87
+ diff = ""
88
+ changed = false
89
+ expdoc.diff(resdoc) do |change, node|
90
+ diff << "#{change} #{node.inspect}\n"
91
+ changed = true unless change == ' ' || (node.text? && node.content =~ /\A\s*\Z/m)
92
+ end
93
+
94
+ if changed
95
+ res.should == expected[:to_html]
96
+ end
97
+ end
98
+ end
99
+
100
+ unless expected[:to_latex].strip.empty?
101
+ it "should have the expected to_latex output" do
102
+ res = @doc.to_latex.strip
103
+ res.should == expected[:to_latex]
104
+ end
105
+ end
106
+ end
107
+ end
108
+
109
+
110
+ end
@@ -0,0 +1,8 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ describe "The maruku CLI" do
4
+ it "has a nonzero exit code on invalid options" do
5
+ `ruby -Ilib bin/maruku --foo 2>&1`
6
+ $?.exitstatus.should_not == 0
7
+ end
8
+ end
@@ -0,0 +1,263 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+ require 'rspec'
3
+ require 'maruku'
4
+
5
+ EXPECTATIONS = Maruku.new.instance_eval do
6
+ [
7
+ ["", [], 'Empty string gives empty list'],
8
+ ["a", ["a"], 'Easy char'],
9
+ [" a", ["a"], 'First space in the paragraph is ignored'],
10
+ ["a\n \n", ["a"], 'Last spaces in the paragraphs are ignored'],
11
+ [' ', [], 'One char => nothing'],
12
+ [' ', [], 'Two chars => nothing'],
13
+ ['a b', ['a b'], 'Spaces are compressed'],
14
+ ['a b', ['a b'], 'Newlines are spaces'],
15
+ ["a\nb", ['a b'], 'Newlines are spaces'],
16
+ ["a\n b", ['a b'], 'Compress newlines 1'],
17
+ ["a \nb", ['a b'], 'Compress newlines 2'],
18
+ [" \nb", ['b'], 'Compress newlines 3'],
19
+ ["\nb", ['b'], 'Compress newlines 4'],
20
+ ["b\n", ['b'], 'Compress newlines 5'],
21
+ ["\n", [], 'Compress newlines 6'],
22
+ ["\n\n\n", [], 'Compress newlines 7'],
23
+
24
+ # Code blocks
25
+ ["`" , :raise, 'Unclosed single ticks'],
26
+ ["``" , [md_entity("ldquo")], 'Empty code block'],
27
+ ["`a`" , [md_code('a')], 'Simple inline code'],
28
+ ["`` ` ``" , [md_code('`')], ],
29
+ ["`` \\` ``" , [md_code('\\`')], ],
30
+ ["``a``" , [md_code('a')], ],
31
+ ["`` a ``" , [md_code('a')], ],
32
+
33
+ # Newlines
34
+ ["a \n", ['a',md_el(:linebreak)], 'Two spaces give br.'],
35
+ ["a \n", ['a'], 'Newlines 2'],
36
+ [" \n", [md_el(:linebreak)], 'Newlines 3'],
37
+ [" \n \n", [md_el(:linebreak),md_el(:linebreak)],'Newlines 4'],
38
+ [" \na \n", [md_el(:linebreak),'a',md_el(:linebreak)],'Newlines 5'],
39
+
40
+ # Inline HTML
41
+ ["a < b", ['a < b'], '< can be on itself'],
42
+ ["<hr>", [md_html('<hr />')], 'HR will be sanitized'],
43
+ ["<hr/>", [md_html('<hr />')], 'Closed tag is ok'],
44
+ ["<hr />", [md_html('<hr />')], 'Closed tag is ok 2'],
45
+ ["<hr/>a", [md_html('<hr />'),'a'], 'Closed tag is ok 2'],
46
+ ["<em></em>a", [md_html('<em></em>'),'a'], 'Inline HTML 1'],
47
+ ["<em>e</em>a", [md_html('<em>e</em>'),'a'], 'Inline HTML 2'],
48
+ ["a<em>e</em>b", ['a',md_html('<em>e</em>'),'b'], 'Inline HTML 3'],
49
+ ["<em>e</em>a<em>f</em>",
50
+ [md_html('<em>e</em>'),'a',md_html('<em>f</em>')],
51
+ 'Inline HTML 4'],
52
+ ["<em>e</em><em>f</em>a",
53
+ [md_html('<em>e</em>'),md_html('<em>f</em>'),'a'],
54
+ 'Inline HTML 5'],
55
+
56
+ ["<img src='a' />", [md_html("<img src='a' />")], 'Attributes'],
57
+ ["<img src='a'/>"],
58
+
59
+ # emphasis
60
+ ["**", :raise, 'Unclosed double **'],
61
+ ["\\*", ['*'], 'Escaping of *'],
62
+ ["a *b* ", ['a ', md_em('b')], 'Emphasis 1'],
63
+ ["a *b*", ['a ', md_em('b')], 'Emphasis 2'],
64
+ ["a * b", ['a * b'], 'Emphasis 3'],
65
+ ["a * b*", :raise, 'Unclosed emphasis'],
66
+ # same with underscore
67
+ ["__", :raise, 'Unclosed double __'],
68
+ ["\\_", ['_'], 'Escaping of _'],
69
+ ["a _b_ ", ['a ', md_em('b')], 'Emphasis 4'],
70
+ ["a _b_", ['a ', md_em('b')], 'Emphasis 5'],
71
+ ["a _ b", ['a _ b'], 'Emphasis 6'],
72
+ ["a _ b_", :raise, 'Unclosed emphasis'],
73
+ ["_b_", [md_em('b')], 'Emphasis 7'],
74
+ ["_b_ _c_", [md_em('b'),' ',md_em('c')], 'Emphasis 8'],
75
+ ["_b__c_", [md_em('b'),md_em('c')], 'Emphasis 9', true], # PENDING
76
+ # underscores in word
77
+ ["mod_ruby", ['mod_ruby'], 'Word with underscore'],
78
+ # strong
79
+ ["**a*", :raise, 'Unclosed double ** 2'],
80
+ ["\\**a*", ['*', md_em('a')], 'Escaping of *'],
81
+ ["a **b** ", ['a ', md_strong('b')], 'Emphasis 1'],
82
+ ["a **b**", ['a ', md_strong('b')], 'Emphasis 2'],
83
+ ["a ** b", ['a ** b'], 'Emphasis 3'],
84
+ ["a ** b**", :raise, 'Unclosed emphasis'],
85
+ ["**b****c**", [md_strong('b'),md_strong('c')], 'Emphasis 9'],
86
+ ["*italic***bold***italic*", [md_em('italic'), md_strong('bold'), md_em('italic')], 'Bold inbetween italics'], # Issue #103
87
+ # strong (with underscore)
88
+ ["__a_", :raise, 'Unclosed double __ 2'],
89
+
90
+ ["a __b__ ", ['a ', md_strong('b')], 'Emphasis 1'],
91
+ ["a __b__", ['a ', md_strong('b')], 'Emphasis 2'],
92
+ ["a __ b", ['a __ b'], 'Emphasis 3'],
93
+ ["a __ b__", :raise, 'Unclosed emphasis'],
94
+ ["__b____c__", [md_strong('b'),md_strong('c')], 'Emphasis 9'],
95
+ # extra strong
96
+ ["***a**", :raise, 'Unclosed triple *** '],
97
+ ["\\***a**", ['*', md_strong('a')], 'Escaping of *'],
98
+ ["a ***b*** ", ['a ', md_emstrong('b')], 'Strong elements'],
99
+ ["a ***b***", ['a ', md_emstrong('b')]],
100
+ ["a *** b", ['a *** b']],
101
+ ["a ** * b", ['a ** * b']],
102
+ ["***b******c***", [md_emstrong('b'),md_emstrong('c')]],
103
+ ["a *** b***", :raise, 'Unclosed emphasis'],
104
+ # same with underscores
105
+ ["___a__", :raise, 'Unclosed triple *** '],
106
+ ["a ___b___ ", ['a ', md_emstrong('b')], 'Strong elements'],
107
+ ["a ___b___", ['a ', md_emstrong('b')]],
108
+ ["a ___ b", ['a ___ b']],
109
+ ["a __ _ b", ['a __ _ b']],
110
+ ["___b______c___", [md_emstrong('b'),md_emstrong('c')]],
111
+ ["a ___ b___", :raise, 'Unclosed emphasis'],
112
+ # mixing is bad
113
+ ["*a_", :raise, 'Mixing is bad'],
114
+ ["_a*", :raise],
115
+ ["**a__", :raise],
116
+ ["__a**", :raise],
117
+ ["___a***", :raise],
118
+ ["***a___", :raise],
119
+ ["*This is in italic, and this is **bold**.*", [md_em(["This is in italic, and this is ", md_strong("bold"), "."])], 'Issue #23'],
120
+
121
+ # links of the form [text][ref]
122
+ ["\\[a]", ["[a]"], 'Escaping 1'],
123
+ ["\\[a\\]", ["[a]"], 'Escaping 2'],
124
+ # This is valid in the new Markdown version
125
+ ["[a]", [ md_link(["a"],nil)], 'Empty link'],
126
+ ["[a][]", [ md_link(["a"],'')] ],
127
+ ["[a][]b", [ md_link(["a"],''),'b'], 'Empty link'],
128
+ ["[a\\]][]", [ md_link(["a]"],'')], 'Escape inside link (throw ?] away)'],
129
+
130
+ ["[a", :raise, 'Link not closed'],
131
+ ["[a][", :raise, 'Ref not closed'],
132
+
133
+ # links of the form [text](url)
134
+ ["\\[a](b)", ["[a](b)"], 'Links'],
135
+ ["[a](url)c", [md_im_link(['a'],'url'),'c'], 'url'],
136
+ ["[a]( url )c" ],
137
+ ["[a] ( url )c" ],
138
+ ["[a] ( url)c" ],
139
+
140
+ ["[a](ur:/l/ 'Title')", [md_im_link(['a'],'ur:/l/','Title')],
141
+ 'url and title'],
142
+ ["[a] ( ur:/l/ \"Title\")" ],
143
+ ["[a] ( ur:/l/ \"Title\")" ],
144
+ ["[a]( ur:/l/ Title)", :raise, "Must quote title" ],
145
+
146
+ ["[a](url 'Tit\\\"l\\\\e')", [md_im_link(['a'],'url','Tit"l\\e')],
147
+ 'url and title escaped'],
148
+ ["[a] ( url \"Tit\\\"l\\\\e\")" ],
149
+ ["[a] ( url \"Tit\\\"l\\\\e\" )" ],
150
+ ['[a] ( url "Tit\\"l\\\\e" )' ],
151
+ ["[a]()", [md_im_link(['a'],'')], 'No URL is OK'],
152
+
153
+ ["[a](\"Title\")", :raise, "No url specified" ],
154
+ ["[a](url \"Title)", :raise, "Unclosed quotes" ],
155
+ ["[a](url \"Title\\\")", :raise],
156
+ ["[a](url \"Title\" ", :raise],
157
+
158
+ ["[a](url \'Title\")", :raise, "Mixing is bad" ],
159
+ ["[a](url \"Title\')"],
160
+
161
+ ["[a](/url)", [md_im_link(['a'],'/url')], 'Funny chars in url'],
162
+ ["[a](#url)", [md_im_link(['a'],'#url')]],
163
+ ["[a](</script?foo=1&bar=2>)", [md_im_link(['a'],'/script?foo=1&bar=2')]],
164
+
165
+ # Links to URLs that contain closing parentheses. #128
166
+ ['[a](url())', [md_im_link(['a'],'url()')], 'Link with parentheses 1', true], # PENDING
167
+ ['[a](url\(\))', [md_im_link(['a'],'url()')], 'Link with parentheses 2', true], # PENDING
168
+ ['[a](url()foo)', [md_im_link(['a'],'url()foo')], 'Link with parentheses 3', true], # PENDING
169
+ ['[a](url(foo))', [md_im_link(['a'],'url(foo)')], 'Link with parentheses 4', true], # PENDING
170
+
171
+ # Images
172
+ ["\\![a](url)", ['!', md_im_link(['a'],'url') ], 'Escaping images'],
173
+
174
+ ["![a](url)", [md_im_image(['a'],'url')], 'Image no title'],
175
+ ["![a]( url )" ],
176
+ ["![a] ( url )" ],
177
+ ["![a] ( url)" ],
178
+
179
+ ["![a](url 'ti\"tle')", [md_im_image(['a'],'url','ti"tle')], 'Image with title'],
180
+ ['![a]( url "ti\\"tle")' ],
181
+
182
+ ["![a](url", :raise, 'Invalid images'],
183
+ ["![a( url )" ],
184
+ ["![a] ('url )" ],
185
+
186
+ ["![a][imref]", [md_image(['a'],'imref')], 'Image with ref'],
187
+ ["![a][ imref]", [md_image(['a'],' imref')], 'Image with ref'],
188
+ ["![a][ imref ]", [md_image(['a'],' imref ' )], 'Image with ref'],
189
+ ["![a][\timref\t]", [md_image(['a'],"\timref\t")], 'Image with ref'],
190
+
191
+
192
+ ['<http://example.com/?foo=1&bar=2>',
193
+ [md_url('http://example.com/?foo=1&bar=2')], 'Immediate link'],
194
+ ['<https://example.com/?foo=1&bar=2>',
195
+ [md_url('https://example.com/?foo=1&bar=2')], 'Immediate link https'],
196
+ ['a<http://example.com/?foo=1&bar=2>b',
197
+ ['a',md_url('http://example.com/?foo=1&bar=2'),'b'] ],
198
+ ['<andrea@censi.org>',
199
+ [md_email('andrea@censi.org')], 'Email address'],
200
+ ['<mailto:andrea@censi.org>'],
201
+ ["Developmen <http://rubyforge.org/projects/maruku/>",
202
+ ["Developmen ", md_url("http://rubyforge.org/projects/maruku/")]],
203
+ ["a<!-- -->b", ['a',md_html('<!-- -->'),'b'],
204
+ 'HTML Comment'],
205
+
206
+ ["a<!--", :raise, 'Bad HTML Comment'],
207
+ ["a<!-- ", :raise, 'Bad HTML Comment'],
208
+
209
+ ["<?xml <?!--!`3 ?>", [md_xml_instr('xml','<?!--!`3')], 'XML processing instruction'],
210
+ ["<? <?!--!`3 ?>", [md_xml_instr('','<?!--!`3')] ],
211
+
212
+ ["<? ", :raise, 'Bad Server directive'],
213
+
214
+ ["a <b", :raise, 'Bad HTML 1'],
215
+ ["<b", :raise, 'Bad HTML 2'],
216
+ ["<b!", :raise, 'Bad HTML 3'],
217
+ ['`<div>`, `<table>`, `<pre>`, `<p>`',
218
+ [md_code('<div>'),', ',md_code('<table>'),', ',
219
+ md_code('<pre>'),', ',md_code('<p>')],
220
+ 'Multiple HTML tags'],
221
+
222
+ ["&andrea", ["&andrea"], 'Parsing of entities'],
223
+ # no escaping is allowed
224
+ ["\\&andrea;", ["\\", md_entity("andrea")]],
225
+ ["l&andrea;", ["l", md_entity('andrea')] ],
226
+ ["&&andrea;", ["&", md_entity('andrea')] ],
227
+ ["&123;;&amp;",[md_entity('123'),';',md_entity('amp')]],
228
+
229
+ ["a\nThe [syntax page] [s] provides",
230
+ ['a The ', md_link(['syntax page'],'s'), ' provides'], 'Regression'],
231
+
232
+ ['![a](url "ti"tle")', [md_im_image(['a'],'url','ti"tle')],
233
+ "Image with quotes"],
234
+ ['![a](url \'ti"tle\')' ],
235
+
236
+ ['[bar](/url/ "Title with "quotes" inside")',
237
+ [md_im_link(["bar"],'/url/', 'Title with "quotes" inside')],
238
+ "Link with quotes"],
239
+ ]
240
+ end
241
+
242
+ EXPECTATIONS.each_cons(2) {|l, r| r[1] ||= l[1]}
243
+
244
+ describe "The Maruku span parser" do
245
+ before(:each) do
246
+ @doc = Maruku.new
247
+ @doc.attributes[:on_error] = :raise
248
+ end
249
+
250
+ EXPECTATIONS.each do |md, res, comment, pend|
251
+ if res == :raise
252
+ it "should raise an error (#{comment}) for \"#{md}\"" do
253
+ pending if pend
254
+ lambda {@doc.parse_span(md)}.should raise_error(Maruku::Exception)
255
+ end
256
+ else
257
+ it "should parse \"#{md}\" as #{res.inspect}" do
258
+ pending if pend
259
+ @doc.parse_span(md).should == res
260
+ end
261
+ end
262
+ end
263
+ end