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
@@ -1,17 +1,6 @@
1
- css: style.css
2
-
3
1
  Markdown: Syntax
4
2
  ================
5
3
 
6
- <ul id="ProjectSubmenu">
7
- <li><a href="/projects/markdown/" title="Markdown Project Page">Main</a></li>
8
- <li><a href="/projects/markdown/basics" title="Markdown Basics">Basics</a></li>
9
- <li><a class="selected" title="Markdown Syntax Documentation">Syntax</a></li>
10
- <li><a href="/projects/markdown/license" title="Pricing and License Information">License</a></li>
11
- <li><a href="/projects/markdown/dingus" title="Online Markdown Web Form">Dingus</a></li>
12
- </ul>
13
-
14
-
15
4
  * [Overview](#overview)
16
5
  * [Philosophy](#philosophy)
17
6
  * [Inline HTML](#html)
@@ -256,7 +245,7 @@ wrap the text and put a `>` before every line:
256
245
  > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
257
246
  > consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
258
247
  > Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
259
- >
248
+ >
260
249
  > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
261
250
  > id sem consectetuer libero luctus adipiscing.
262
251
 
@@ -283,12 +272,12 @@ Blockquotes can contain other Markdown elements, including headers, lists,
283
272
  and code blocks:
284
273
 
285
274
  > ## This is a header.
286
- >
275
+ >
287
276
  > 1. This is the first list item.
288
277
  > 2. This is the second list item.
289
- >
278
+ >
290
279
  > Here's some example code:
291
- >
280
+ >
292
281
  > return shell_exec("echo $input | $markdown_script");
293
282
 
294
283
  Any decent text editor should make email-style quoting easy. For
@@ -569,7 +558,7 @@ Will produce:
569
558
  If you're referring to a local resource on the same server, you can
570
559
  use relative paths:
571
560
 
572
- See my [About](/about/) page for details.
561
+ See my [About](/about/) page for details.
573
562
 
574
563
  Reference-style links use a second set of square brackets, inside
575
564
  which you place a label of your choosing to identify the link:
@@ -643,7 +632,7 @@ multiple words in the link text:
643
632
  Visit [Daring Fireball][] for more information.
644
633
 
645
634
  And then define the link:
646
-
635
+
647
636
  [Daring Fireball]: http://daringfireball.net/
648
637
 
649
638
  Link definitions can be placed anywhere in your Markdown document. I
@@ -767,13 +756,13 @@ one after the opening, one before the closing. This allows you to place
767
756
  literal backtick characters at the beginning or end of a code span:
768
757
 
769
758
  A single backtick in a code span: `` ` ``
770
-
759
+
771
760
  A backtick-delimited string in a code span: `` `foo` ``
772
761
 
773
762
  will produce:
774
763
 
775
764
  <p>A single backtick in a code span: <code>`</code></p>
776
-
765
+
777
766
  <p>A backtick-delimited string in a code span: <code>`foo`</code></p>
778
767
 
779
768
  With a code span, ampersands and angle brackets are encoded as HTML
@@ -844,7 +833,7 @@ use regular HTML `<img>` tags.
844
833
  Markdown supports a shortcut style for creating "automatic" links for URLs and email addresses: simply surround the URL or email address with angle brackets. What this means is that if you want to show the actual text of a URL or email address, and also have it be a clickable link, you can do this:
845
834
 
846
835
  <http://example.com/>
847
-
836
+
848
837
  Markdown will turn this into:
849
838
 
850
839
  <a href="http://example.com/">http://example.com/</a>
@@ -896,4 +885,3 @@ Markdown provides backslash escapes for the following characters:
896
885
  - minus sign (hyphen)
897
886
  . dot
898
887
  ! exclamation mark
899
-
@@ -9,11 +9,7 @@ Math support in Maruku
9
9
 
10
10
  This document describes Maruku's support of inline LaTeX-style math.
11
11
 
12
- At the moment, **these features are experimental**, are probably
13
- buggy and the syntax and implementation are bound to change in
14
- the near future.
15
-
16
- Also, there are many subtleties of which one must care for
12
+ There are many subtleties of which one must care for
17
13
  correctly serving the XHTML+MathML document to browsers.
18
14
  In fact, *this documentation is __not__ enough to get you started*,
19
15
  unless you feel very adventurous.
@@ -118,7 +114,7 @@ You have to enable the math extension like this:
118
114
 
119
115
  Use the following to choose the engine:
120
116
 
121
- MaRuKu::Globals[:html_math_engine] = 'ritex'
117
+ MaRuKu::Globals[:html_math_engine] = 'itex2mml'
122
118
  MaRuKu::Globals[:html_png_engine] = 'blahtex'
123
119
 
124
120
  Available MathML engines are 'none', 'itex2mml', 'blahtex'.
@@ -129,21 +125,13 @@ External libraries needed
129
125
 
130
126
  To output MathML or PNGs, it is needed to install one of the following libraries
131
127
 
132
- ### Using `ritex` ### {#using_ritex}
133
-
134
- Install with
135
-
136
- $ gem install ritex
137
-
138
- ritex's abilities are very limited, but it is the easiest to install.
139
-
140
128
  ### Using `itex2mml` ### {#using_itex2mml}
141
129
 
142
130
  itex2mml supports much more LaTeX commands/environments than ritex.
143
131
 
144
- Install itex2mml using the instructions at:
132
+ Install itextomml with
145
133
 
146
- > <http://golem.ph.utexas.edu/~distler/blog/itex2MML.html>
134
+ $ gem install itextomml
147
135
 
148
136
  This is a summary of the available LaTeX commands:
149
137
 
@@ -152,10 +140,18 @@ This is a summary of the available LaTeX commands:
152
140
  Moreover, [Jacques Distler] is integrating Maruku+itex2mml+[Instiki].
153
141
  You can find more information here:
154
142
 
155
- > <http://golem.ph.utexas.edu/~distler/blog/archives/001111.html>
143
+ > <http://golem.ph.utexas.edu/wiki/instiki/show/HomePage>
156
144
 
157
145
  [Jacques Distler]: http://golem.ph.utexas.edu/~distler
158
- [instiki]: http://www.instiki.org
146
+ [instiki]: http://golem.ph.utexas.edu/wiki/instiki/show/HomePage
147
+
148
+ ### Using `ritex` ### {#using_ritex}
149
+
150
+ Install with
151
+
152
+ $ gem install ritex
153
+
154
+ ritex's abilities are very limited, but it is the easiest to install since, unlike `itextomml`, it is a pure-ruby implementation.
159
155
 
160
156
  ### Using `blahtex` ### {#using_blahtex}
161
157
 
@@ -1,83 +1,74 @@
1
1
  #--
2
- # Copyright (C) 2006 Andrea Censi <andrea (at) rubyforge.org>
2
+ # Copyright (c) 2006 Andrea Censi
3
3
  #
4
- # This file is part of Maruku.
5
- #
6
- # Maruku is free software; you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation; either version 2 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Maruku is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Maruku; if not, write to the Free Software
18
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
22
  #++
20
23
 
21
- require 'rexml/document'
22
-
23
- # :include:MaRuKu.txt
24
24
  module MaRuKu
25
-
26
- module In
27
- module Markdown
28
- module SpanLevelParser; end
29
- module BlockLevelParser; end
30
- end
31
- # more to come?
32
- end
33
-
34
- module Out
35
- # Functions for exporting to MarkDown.
36
- module Markdown; end
37
- # Functions for exporting to HTML.
38
- module HTML; end
39
- # Functions for exporting to Latex
40
- module Latex; end
41
- end
42
-
43
- # These are strings utilities.
44
- module Strings; end
45
-
46
- module Helpers; end
47
-
48
- module Errors; end
49
-
50
- class MDElement
51
- include REXML
52
- include MaRuKu
53
- include Out::Markdown
54
- include Out::HTML
55
- include Out::Latex
56
- include Strings
57
- include Helpers
58
- include Errors
59
- end
60
-
61
-
62
- class MDDocument < MDElement
63
- include In::Markdown
64
- include In::Markdown::SpanLevelParser
65
- include In::Markdown::BlockLevelParser
66
- end
25
+ module In
26
+ module Markdown
27
+ module SpanLevelParser; end
28
+ module BlockLevelParser; end
29
+ end
30
+ end
31
+
32
+ module Out
33
+ module Markdown; end
34
+ module HTML; end
35
+ module Latex; end
36
+ end
37
+
38
+ module Strings; end
39
+
40
+ module Helpers; end
41
+
42
+ module Errors; end
43
+
44
+ class MDElement
45
+ include MaRuKu
46
+ include Out::Markdown
47
+ include Out::HTML
48
+ include Out::Latex
49
+ include Strings
50
+ include Helpers
51
+ include Errors
52
+ end
53
+
54
+ class MDDocument < MDElement
55
+ include In::Markdown
56
+ include In::Markdown::SpanLevelParser
57
+ include In::Markdown::BlockLevelParser
58
+ end
67
59
  end
68
60
 
69
- # This is the public interface
70
61
  class Maruku < MaRuKu::MDDocument; end
71
62
 
72
63
 
73
-
74
- require 'rexml/document'
75
-
76
64
  # Structures definition
77
- require 'maruku/structures'
78
- require 'maruku/structures_inspect'
65
+ require 'maruku/attributes'
66
+ require 'maruku/element'
67
+ require 'maruku/document'
68
+ require 'maruku/inspect_element'
79
69
 
80
70
  require 'maruku/defaults'
71
+
81
72
  # Less typing
82
73
  require 'maruku/helpers'
83
74
 
@@ -87,7 +78,7 @@ require 'maruku/input/parse_doc'
87
78
  # Ugly things kept in a closet
88
79
  require 'maruku/string_utils'
89
80
  require 'maruku/input/linesource'
90
- require 'maruku/input/type_detection'
81
+ require 'maruku/input/mdline'
91
82
 
92
83
  # A class for reading and sanitizing inline HTML
93
84
  require 'maruku/input/html_helper'
@@ -97,34 +88,31 @@ require 'maruku/input/parse_block'
97
88
 
98
89
  # Code for parsing Markdown span-level elements
99
90
  require 'maruku/input/charsource'
100
- require 'maruku/input/parse_span_better'
101
- require 'maruku/input/rubypants'
91
+ require 'maruku/input/parse_span'
102
92
 
103
93
  require 'maruku/input/extensions'
104
94
 
105
- require 'maruku/attributes'
106
-
107
- require 'maruku/structures_iterators'
108
-
109
- require 'maruku/errors_management'
95
+ require 'maruku/errors'
110
96
 
111
97
  # Code for creating a table of contents
112
98
  require 'maruku/toc'
113
99
 
114
100
  # Support for div Markdown extension
115
101
  require 'maruku/ext/div'
102
+ # Support for fenced codeblocks extension
103
+ require 'maruku/ext/fenced_code'
116
104
 
117
105
  # Version and URL
118
106
  require 'maruku/version'
119
107
 
108
+ # Entity conversion for HTML and LaTeX
109
+ require 'maruku/output/entity_table'
120
110
 
121
111
  # Exporting to html
122
112
  require 'maruku/output/to_html'
123
113
 
124
114
  # Exporting to latex
125
115
  require 'maruku/output/to_latex'
126
- require 'maruku/output/to_latex_strings'
127
- require 'maruku/output/to_latex_entities'
128
116
 
129
117
  # Pretty print
130
118
  require 'maruku/output/to_markdown'
@@ -138,4 +126,3 @@ require 'maruku/output/to_s'
138
126
 
139
127
  # class Maruku is the global interface
140
128
  require 'maruku/maruku'
141
-
@@ -1,227 +1,122 @@
1
- #--
2
- # Copyright (C) 2006 Andrea Censi <andrea (at) rubyforge.org>
3
- #
4
- # This file is part of Maruku.
5
- #
6
- # Maruku is free software; you can redistribute it and/or modify
7
- # it under the terms of the GNU General Public License as published by
8
- # the Free Software Foundation; either version 2 of the License, or
9
- # (at your option) any later version.
10
- #
11
- # Maruku is distributed in the hope that it will be useful,
12
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- # GNU General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU General Public License
17
- # along with Maruku; if not, write to the Free Software
18
- # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19
- #++
1
+ module MaRuKu
2
+ # This represents a list of attributes specified in the Markdown document
3
+ # that apply to a Markdown-generated tag.
4
+ # What was `{#id .class key="val" ref}` in the Markdown
5
+ # is parsed into `[[:id, 'id'], [:class, 'class'], ['key', 'val'], [:ref, 'ref']]`.
6
+ class AttributeList < Array
7
+ def to_s
8
+ map do |k, v|
9
+ value = quote_if_needed(v)
10
+ case k
11
+ when :id; "#" + value
12
+ when :class; "." + value
13
+ when :ref; value
14
+ else quote_if_needed(k) + "=" + value
15
+ end
16
+ end.join(' ')
17
+ end
18
+ alias to_md to_s
20
19
 
20
+ private
21
21
 
22
- class String
23
- def quote_if_needed
24
- if /[\s\'\"]/.match self
25
- inspect
26
- else
27
- self
28
- end
29
- end
30
- end
31
-
32
- module MaRuKu;
33
- MagicChar = ':'
34
-
35
- class AttributeList < Array
36
-
37
- # An attribute list becomes
38
- # {#id .cl key="val" ref}
39
- # [ [:id, 'id'], [:class, 'id'], ['key', 'val'], [ :ref, 'ref' ]]
22
+ def quote_if_needed(str)
23
+ (str =~ /[\s'"]/) ? str.inspect : str
24
+ end
25
+ end
40
26
 
41
- private :push
42
-
43
- def push_key_val(key, val);
44
- raise "Bad #{key.inspect}=#{val.inspect}" if not key and val
45
- push [key, val]
46
- end
47
- def push_ref(ref_id);
48
-
49
- raise "Bad :ref #{ref_id.inspect}" if not ref_id
50
- push [:ref, ref_id+""]
27
+ module In::Markdown::SpanLevelParser
28
+ def md_al(s = [])
29
+ AttributeList.new(s)
30
+ end
51
31
 
52
- # p "Now ", self ########################################
53
- end
54
- def push_class(val);
55
- raise "Bad :id #{val.inspect}" if not val
56
- push [:class, val]
57
- end
58
- def push_id(val);
59
- raise "Bad :id #{val.inspect}" if not val
60
- push [:id, val]
61
- end
62
-
63
- def to_s
64
- map do |k,v|
65
- case k
66
- when :id; "#" + v.quote_if_needed
67
- when :class; "." + v.quote_if_needed
68
- when :ref; v.quote_if_needed
69
- else k.quote_if_needed + "=" + v.quote_if_needed
70
- end
71
- end . join(' ')
72
- end
73
- alias to_md to_s
74
- end
75
-
76
- end
32
+ # @return [AttributeList, nil]
33
+ def read_attribute_list(src, con=nil, break_on_chars=nil)
34
+ break_on_chars = Array(break_on_chars)
35
+ separators = break_on_chars + ['=', ' ', "\t"]
36
+ escaped = Maruku::EscapedCharInQuotes
77
37
 
78
- module MaRuKu; module In; module Markdown; module SpanLevelParser
79
-
80
- def unit_tests_for_attribute_lists
81
- [
82
- [ "", [], "Empty lists are allowed" ],
83
- [ "=", :throw, "Bad char to begin a list with." ],
84
- [ "a =b", :throw, "No whitespace before `=`." ],
85
- [ "a= b", :throw, "No whitespace after `=`." ],
38
+ al = AttributeList.new
39
+ loop do
40
+ src.consume_whitespace
41
+ break if break_on_chars.include? src.cur_char
86
42
 
87
- [ "a b", [[:ref, 'a'],[:ref, 'b']], "More than one ref" ],
88
- [ "a b c", [[:ref, 'a'],[:ref, 'b'],[:ref, 'c']], "More than one ref" ],
89
- [ "hello notfound", [[:ref, 'hello'],[:ref, 'notfound']]],
43
+ case src.cur_char
44
+ when ':'
45
+ src.ignore_char
46
+ when nil
47
+ break # we're done here.
48
+ when '=' # error
49
+ src.ignore_char
50
+ maruku_error "In attribute lists, cannot start identifier with `=`."
51
+ tell_user "Ignoring and continuing."
52
+ when '#' # id definition
53
+ src.ignore_char
54
+ if id = read_quoted_or_unquoted(src, con, escaped, separators)
55
+ al << [:id, id]
56
+ else
57
+ maruku_error 'Could not read `id` attribute.', src, con
58
+ tell_user 'Ignoring bad `id` attribute.'
59
+ end
60
+ when '.' # class definition
61
+ src.ignore_char
62
+ if klass = read_quoted_or_unquoted(src, con, escaped, separators)
63
+ al << [:class, klass]
64
+ else
65
+ maruku_error 'Could not read `class` attribute.', src, con
66
+ tell_user 'Ignoring bad `class` attribute.'
67
+ end
68
+ else
69
+ unless key = read_quoted_or_unquoted(src, con, escaped, separators)
70
+ maruku_error 'Could not read key or reference.'
71
+ next
72
+ end
90
73
 
91
- [ "'a'", [[:ref, 'a']], "Quoted value." ],
92
- [ '"a"' ],
74
+ if src.cur_char != '=' && key.length > 0
75
+ al << [:ref, key]
76
+ next
77
+ end
93
78
 
94
- [ "a=b", [['a','b']], "Simple key/val" ],
95
- [ "'a'=b" ],
96
- [ "'a'='b'" ],
97
- [ "a='b'" ],
79
+ src.ignore_char # skip the =
80
+ if val = read_quoted_or_unquoted(src, con, escaped, separators)
81
+ al << [key, val]
82
+ else
83
+ maruku_error "Could not read value for key #{key.inspect}.", src, con
84
+ tell_user "Ignoring key #{key.inspect}"
85
+ end
86
+ end
87
+ end
88
+ al
89
+ end
98
90
 
99
- [ 'a="b\'"', [['a',"b\'"]], "Key/val with quotes" ],
100
- [ 'a=b\''],
101
- [ 'a="\\\'b\'"', [['a',"\'b\'"]], "Key/val with quotes" ],
102
-
103
- ['"', :throw, "Unclosed quotes"],
104
- ["'"],
105
- ["'a "],
106
- ['"a '],
107
-
108
- [ "#a", [[:id, 'a']], "Simple ID" ],
109
- [ "#'a'" ],
110
- [ '#"a"' ],
91
+ def merge_ial(elements, src, con)
92
+ # Apply each IAL to the element before
93
+ (elements + [nil]).each_cons(3) do |before, e, after|
94
+ next unless ial?(e)
111
95
 
112
- [ "#", :throw, "Unfinished '#'." ],
113
- [ ".", :throw, "Unfinished '.'." ],
114
- [ "# a", :throw, "No white-space after '#'." ],
115
- [ ". a", :throw, "No white-space after '.' ." ],
116
-
117
- [ "a=b c=d", [['a','b'],['c','d']], "Tabbing" ],
118
- [ " \ta=b \tc='d' "],
119
- [ "\t a=b\t c='d'\t\t"],
120
-
121
- [ ".\"a'", :throw, "Mixing quotes is bad." ],
122
-
123
- ].map { |s, expected, comment|
124
- @expected = (expected ||= @expected)
125
- @comment = (comment ||= (last=@comment) )
126
- (comment == last && (comment += (@count+=1).to_s)) || @count = 1
127
- expected = [md_ial(expected)] if expected.kind_of? Array
128
- ["{#{MagicChar}#{s}}", expected, "Attributes: #{comment}"]
129
- }
130
- end
131
-
132
- def md_al(s=[]); AttributeList.new(s) end
96
+ if before.kind_of? MDElement
97
+ before.al = e.ial
98
+ elsif after.kind_of? MDElement
99
+ after.al = e.ial
100
+ else
101
+ maruku_error <<ERR, src, con
102
+ It's unclear which element the attribute list {:#{e.ial.to_s}}
103
+ is referring to. The element before is a #{before.class},
104
+ the element after is a #{after.class}.
105
+ before: #{before.inspect}
106
+ after: #{after.inspect}
107
+ ERR
108
+ end
109
+ end
133
110
 
134
- # returns nil or an AttributeList
135
- def read_attribute_list(src, con, break_on_chars)
136
-
137
- separators = break_on_chars + [?=,?\ ,?\t]
138
- escaped = Maruku::EscapedCharInQuotes
139
-
140
- al = AttributeList.new
141
- while true
142
- src.consume_whitespace
143
- break if break_on_chars.include? src.cur_char
144
-
145
- case src.cur_char
146
- when nil
147
- maruku_error "Attribute list terminated by EOF:\n "+
148
- "#{al.inspect}" , src, con
149
- tell_user "I try to continue and return partial attribute list:\n"+
150
- al.inspect
151
- break
152
- when ?= # error
153
- maruku_error "In attribute lists, cannot start identifier with `=`."
154
- tell_user "I try to continue"
155
- src.ignore_char
156
- when ?# # id definition
157
- src.ignore_char
158
- if id = read_quoted_or_unquoted(src, con, escaped, separators)
159
- al.push_id id
160
- else
161
- maruku_error 'Could not read `id` attribute.', src, con
162
- tell_user 'Trying to ignore bad `id` attribute.'
163
- end
164
- when ?. # class definition
165
- src.ignore_char
166
- if klass = read_quoted_or_unquoted(src, con, escaped, separators)
167
- al.push_class klass
168
- else
169
- maruku_error 'Could not read `class` attribute.', src, con
170
- tell_user 'Trying to ignore bad `class` attribute.'
171
- end
172
- else
173
- if key = read_quoted_or_unquoted(src, con, escaped, separators)
174
- if src.cur_char == ?=
175
- src.ignore_char # skip the =
176
- if val = read_quoted_or_unquoted(src, con, escaped, separators)
177
- al.push_key_val(key, val)
178
- else
179
- maruku_error "Could not read value for key #{key.inspect}.",
180
- src, con
181
- tell_user "Ignoring key #{key.inspect}."
182
- end
183
- else
184
- al.push_ref key
185
- end
186
- else
187
- maruku_error 'Could not read key or reference.'
188
- end
189
- end # case
190
- end # while true
191
- al
192
- end
193
-
194
-
195
- # We need a helper
196
- def is_ial(e); e.kind_of? MDElement and e.node_type == :ial end
111
+ unless Globals[:debug_keep_ials]
112
+ elements.delete_if {|x| ial?(x) && x != elements.first}
113
+ end
114
+ end
197
115
 
198
- def merge_ial(elements, src, con)
116
+ private
199
117
 
200
- # Apply each IAL to the element before
201
- elements.each_with_index do |e, i|
202
- if is_ial(e) && i>= 1 then
203
- before = elements[i-1]
204
- after = elements[i+1]
205
- if before.kind_of? MDElement
206
- before.al = e.ial
207
- elsif after.kind_of? MDElement
208
- after.al = e.ial
209
- else
210
- maruku_error "It is not clear to me what element this IAL {:#{e.ial.to_md}} \n"+
211
- "is referring to. The element before is a #{before.class.to_s}, \n"+
212
- "the element after is a #{after.class.to_s}.\n"+
213
- "\n before: #{before.inspect}"+
214
- "\n after: #{after.inspect}",
215
- src, con
216
- # xxx dire se c'è empty vicino
217
- end
218
- end
219
- end
220
-
221
- if not Globals[:debug_keep_ials]
222
- elements.delete_if {|x| is_ial(x) unless x == elements.first}
223
- end
224
- end
225
-
226
- end end end end
227
- #module MaRuKu; module In; module Markdown; module SpanLevelParser
118
+ def ial?(e)
119
+ e.is_a?(MDElement) && e.node_type == :ial
120
+ end
121
+ end
122
+ end