docgenerator 2.1.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (324) hide show
  1. checksums.yaml +4 -4
  2. data/lib/docgenerator.rb +18 -18
  3. data/lib/docgenerator/characters.rb +1 -0
  4. data/lib/docgenerator/css.rb +5 -0
  5. data/lib/docgenerator/document.rb +7 -2
  6. data/lib/docgenerator/element.rb +2 -2
  7. data/lib/docgenerator/elements.rb +69 -2
  8. data/lib/docgenerator/index.rb +1 -1
  9. data/lib/docgenerator/packages/listings.rb +94 -94
  10. data/lib/docgenerator/packages/multicol.rb +1 -1
  11. data/lib/docgenerator/packages/pdfpages.rb +2 -1
  12. data/lib/docgenerator/packages/rubycode4doc.rb +173 -172
  13. data/lib/docgenerator/packages/struktex.rb +395 -379
  14. data/lib/docgenerator/packages/todonotes.rb +2 -2
  15. data/lib/docgenerator/packages/url.rb +4 -0
  16. data/lib/docgenerator/sections.rb +24 -2
  17. data/lib/docgenerator/tabular.rb +59 -14
  18. data/lib/docgenerator/templates/docgenerator_template.rb +1 -0
  19. data/lib/docgenerator/templates/docgenerator_template.yaml +30 -1
  20. data/lib/docgenerator/version.rb +13 -1
  21. data/meta_test_and_doc/build__meta.rb +3 -10
  22. data/meta_test_and_doc/build_doc.rb +4 -2
  23. data/meta_test_and_doc/build_test.rb +21 -17
  24. data/meta_test_and_doc/manpages/images.rb +152 -0
  25. data/unittest/expected/test_document_toc_article.latex +6 -6
  26. data/unittest/expected_struktex/test_struktex_krug.creole +5 -5
  27. data/unittest/expected_struktex/test_struktex_krug.wiki +5 -5
  28. data/unittest/expected_struktex/test_struktex_statement.creole +4 -4
  29. data/unittest/expected_struktex/test_struktex_statement.wiki +4 -4
  30. data/unittest/expected_templates/test_report_utf8.tex +34 -0
  31. data/unittest/expected_templates/test_standalone.tex +2 -1
  32. data/unittest/unittest_docgenerator.rb +37 -30
  33. data/unittest/unittest_docgenerator_characters.rb +113 -60
  34. data/unittest/unittest_docgenerator_runtex.rb +16 -12
  35. data/unittest/unittest_packages_multicol.rb +4 -9
  36. data/unittest/unittest_packages_struktex.rb +66 -90
  37. data/unittest/unittest_rubycode4doc.rb +38 -241
  38. data/unittest/unittest_templates.rb +4 -8
  39. metadata +23 -560
  40. data/examples/creole_example.rb +0 -81
  41. data/examples/creole_example_footnote.rb +0 -67
  42. data/examples/creole_example_new_plugin.rb +0 -51
  43. data/examples/creole_example_placeholder.rb +0 -77
  44. data/examples/creole_example_rail.rb +0 -154
  45. data/examples/creole_example_rubycode.rb +0 -144
  46. data/examples/creole_example_struktex.rb +0 -169
  47. data/examples/creole_example_tabular.rb +0 -97
  48. data/examples/wiki2docgenerator_example.rb +0 -299
  49. data/lib/creole/creole2doc.rb +0 -954
  50. data/lib/creole/creole_characters.rb +0 -120
  51. data/lib/creole/creole_inclusion_and_plugins.rb +0 -96
  52. data/lib/creole/creole_inclusions.rb +0 -154
  53. data/lib/creole/creole_placeholder.rb +0 -171
  54. data/lib/creole/creole_plugins.rb +0 -230
  55. data/lib/creole/creole_tabular.rb +0 -401
  56. data/lib/creole/plugins/rail.rb +0 -181
  57. data/lib/creole/plugins/rubycode4creole.rb +0 -136
  58. data/lib/creole/plugins/struktex.rb +0 -59
  59. data/lib/creole/plugins/todonotes.rb +0 -77
  60. data/lib/wiki2doc/plugins/rubycode4wiki.rb +0 -53
  61. data/lib/wiki2doc/plugins/struktex.rb +0 -12
  62. data/lib/wiki2doc/wiki2docgenerator.rb +0 -1276
  63. data/lib/wiki2doc/wikimedia_document.rb +0 -24
  64. data/meta_test_and_doc/manpages/packages.rb +0 -13
  65. data/unittest/Red_Flower.jpg +0 -0
  66. data/unittest/creole1.0test.txt +0 -128
  67. data/unittest/creole_testtext.creole +0 -11
  68. data/unittest/expected_creole/test_creole.html +0 -3
  69. data/unittest/expected_creole/test_creole_characters_all.creole +0 -28
  70. data/unittest/expected_creole/test_creole_characters_all.html +0 -18
  71. data/unittest/expected_creole/test_creole_characters_all.latex +0 -36
  72. data/unittest/expected_creole/test_creole_characters_special.html +0 -10
  73. data/unittest/expected_creole/test_creole_characters_special.latex +0 -18
  74. data/unittest/expected_creole/test_creole_comment.context +0 -11
  75. data/unittest/expected_creole/test_creole_comment.creole +0 -12
  76. data/unittest/expected_creole/test_creole_comment.html +0 -9
  77. data/unittest/expected_creole/test_creole_comment.latex +0 -11
  78. data/unittest/expected_creole/test_creole_countdown.html +0 -3
  79. data/unittest/expected_creole/test_creole_countdown.latex +0 -4
  80. data/unittest/expected_creole/test_creole_creole1.0test.html +0 -182
  81. data/unittest/expected_creole/test_creole_creole1.0test.latex +0 -253
  82. data/unittest/expected_creole/test_creole_creole1.0test.text +0 -160
  83. data/unittest/expected_creole/test_creole_footnotes.html +0 -9
  84. data/unittest/expected_creole/test_creole_footnotes.latex +0 -14
  85. data/unittest/expected_creole/test_creole_footnotes_groupid.html +0 -15
  86. data/unittest/expected_creole/test_creole_footnotes_label.html +0 -9
  87. data/unittest/expected_creole/test_creole_headings.html +0 -17
  88. data/unittest/expected_creole/test_creole_headings.latex +0 -19
  89. data/unittest/expected_creole/test_creole_headings.text +0 -48
  90. data/unittest/expected_creole/test_creole_headings.wiki +0 -37
  91. data/unittest/expected_creole/test_creole_hr.html +0 -7
  92. data/unittest/expected_creole/test_creole_hr.latex +0 -9
  93. data/unittest/expected_creole/test_creole_hr.text +0 -4
  94. data/unittest/expected_creole/test_creole_ignore.html +0 -3
  95. data/unittest/expected_creole/test_creole_ignore.latex +0 -4
  96. data/unittest/expected_creole/test_creole_ignore.text +0 -2
  97. data/unittest/expected_creole/test_creole_inline.html +0 -3
  98. data/unittest/expected_creole/test_creole_inline.latex +0 -4
  99. data/unittest/expected_creole/test_creole_inline.text +0 -2
  100. data/unittest/expected_creole/test_creole_inline_apostroph.html +0 -6
  101. data/unittest/expected_creole/test_creole_inline_apostroph.latex +0 -8
  102. data/unittest/expected_creole/test_creole_inline_apostroph.text +0 -4
  103. data/unittest/expected_creole/test_creole_inline_ruby.html +0 -12
  104. data/unittest/expected_creole/test_creole_inline_ruby.latex +0 -20
  105. data/unittest/expected_creole/test_creole_inline_ruby_raw.html +0 -6
  106. data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +0 -8
  107. data/unittest/expected_creole/test_creole_input.normsource +0 -25
  108. data/unittest/expected_creole/test_creole_input.normsource_1.8 +0 -23
  109. data/unittest/expected_creole/test_creole_input_file_simple.html +0 -15
  110. data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +0 -15
  111. data/unittest/expected_creole/test_creole_label.html +0 -12
  112. data/unittest/expected_creole/test_creole_label.latex +0 -15
  113. data/unittest/expected_creole/test_creole_line_break.html +0 -6
  114. data/unittest/expected_creole/test_creole_line_break.latex +0 -8
  115. data/unittest/expected_creole/test_creole_links_explicit_internal.html +0 -6
  116. data/unittest/expected_creole/test_creole_links_explicit_internal.text +0 -4
  117. data/unittest/expected_creole/test_creole_links_explicit_with_em.html +0 -3
  118. data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +0 -4
  119. data/unittest/expected_creole/test_creole_links_explicit_with_em.text +0 -2
  120. data/unittest/expected_creole/test_creole_links_external.html +0 -6
  121. data/unittest/expected_creole/test_creole_links_external.latex +0 -8
  122. data/unittest/expected_creole/test_creole_links_external.text +0 -4
  123. data/unittest/expected_creole/test_creole_links_external_implicit.html +0 -9
  124. data/unittest/expected_creole/test_creole_links_external_implicit.latex +0 -12
  125. data/unittest/expected_creole/test_creole_links_external_implicit.text +0 -6
  126. data/unittest/expected_creole/test_creole_links_file.html +0 -6
  127. data/unittest/expected_creole/test_creole_links_file.latex +0 -8
  128. data/unittest/expected_creole/test_creole_links_file.text +0 -4
  129. data/unittest/expected_creole/test_creole_links_implicit_end.creole +0 -4
  130. data/unittest/expected_creole/test_creole_links_implicit_end.html +0 -3
  131. data/unittest/expected_creole/test_creole_links_implicit_end.latex +0 -4
  132. data/unittest/expected_creole/test_creole_list_ol.html +0 -12
  133. data/unittest/expected_creole/test_creole_list_ol.latex +0 -22
  134. data/unittest/expected_creole/test_creole_list_ol_after_ul.html +0 -12
  135. data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +0 -20
  136. data/unittest/expected_creole/test_creole_list_ol_after_ul.text +0 -6
  137. data/unittest/expected_creole/test_creole_list_ol_ul.html +0 -15
  138. data/unittest/expected_creole/test_creole_list_ol_ul.latex +0 -26
  139. data/unittest/expected_creole/test_creole_list_ul.html +0 -22
  140. data/unittest/expected_creole/test_creole_list_ul.latex +0 -40
  141. data/unittest/expected_creole/test_creole_list_ul.normsource +0 -89
  142. data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +0 -83
  143. data/unittest/expected_creole/test_creole_list_ul_too_much.html +0 -24
  144. data/unittest/expected_creole/test_creole_list_ul_too_much.latex +0 -44
  145. data/unittest/expected_creole/test_creole_list_ulul_without_ul.html +0 -6
  146. data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +0 -12
  147. data/unittest/expected_creole/test_creole_mix_titles_list.html +0 -10
  148. data/unittest/expected_creole/test_creole_mix_titles_list.latex +0 -18
  149. data/unittest/expected_creole/test_creole_mix_titles_list.text +0 -12
  150. data/unittest/expected_creole/test_creole_newline.html +0 -9
  151. data/unittest/expected_creole/test_creole_newline.latex +0 -11
  152. data/unittest/expected_creole/test_creole_newline.text +0 -7
  153. data/unittest/expected_creole/test_creole_paragraphs.html +0 -6
  154. data/unittest/expected_creole/test_creole_paragraphs.latex +0 -8
  155. data/unittest/expected_creole/test_creole_paragraphs.normsource +0 -29
  156. data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +0 -27
  157. data/unittest/expected_creole/test_creole_paragraphs.text +0 -4
  158. data/unittest/expected_creole/test_creole_paragraphs.wiki +0 -4
  159. data/unittest/expected_creole/test_creole_paragraphs_wrap.html +0 -5
  160. data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +0 -6
  161. data/unittest/expected_creole/test_creole_paragraphs_wrap.text +0 -4
  162. data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +0 -4
  163. data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +0 -9
  164. data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +0 -11
  165. data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +0 -7
  166. data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +0 -7
  167. data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +0 -5
  168. data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +0 -6
  169. data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +0 -4
  170. data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +0 -4
  171. data/unittest/expected_creole/test_creole_picture_link.html +0 -6
  172. data/unittest/expected_creole/test_creole_pictures.html +0 -10
  173. data/unittest/expected_creole/test_creole_pictures.latex +0 -13
  174. data/unittest/expected_creole/test_creole_pictures_css.html +0 -6
  175. data/unittest/expected_creole/test_creole_pictures_css.latex +0 -8
  176. data/unittest/expected_creole/test_creole_pictures_imgclass.html +0 -6
  177. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +0 -8
  178. data/unittest/expected_creole/test_creole_pictures_longdesc.html +0 -3
  179. data/unittest/expected_creole/test_creole_pictures_width.html +0 -3
  180. data/unittest/expected_creole/test_creole_pictures_width.latex +0 -4
  181. data/unittest/expected_creole/test_creole_placeholders_html.html +0 -7
  182. data/unittest/expected_creole/test_creole_placeholders_html.latex +0 -8
  183. data/unittest/expected_creole/test_creole_placeholders_html.text +0 -4
  184. data/unittest/expected_creole/test_creole_placeholders_latex.html +0 -6
  185. data/unittest/expected_creole/test_creole_placeholders_latex.latex +0 -9
  186. data/unittest/expected_creole/test_creole_placeholders_latex.text +0 -4
  187. data/unittest/expected_creole/test_creole_short_html.html +0 -3
  188. data/unittest/expected_creole/test_creole_short_html.latex +0 -4
  189. data/unittest/expected_creole/test_creole_short_html.text +0 -2
  190. data/unittest/expected_creole/test_creole_shy.creole +0 -6
  191. data/unittest/expected_creole/test_creole_shy.html +0 -6
  192. data/unittest/expected_creole/test_creole_shy.latex +0 -8
  193. data/unittest/expected_creole/test_creole_shy.text +0 -4
  194. data/unittest/expected_creole/test_creole_tabular.creole +0 -22
  195. data/unittest/expected_creole/test_creole_tabular.html +0 -20
  196. data/unittest/expected_creole/test_creole_tabular.latex +0 -22
  197. data/unittest/expected_creole/test_creole_tabular_creole.creole +0 -19
  198. data/unittest/expected_creole/test_creole_tabular_creole.html +0 -18
  199. data/unittest/expected_creole/test_creole_tabular_creole.latex +0 -19
  200. data/unittest/expected_creole/test_creole_tabular_css.creole +0 -24
  201. data/unittest/expected_creole/test_creole_tabular_css.html +0 -20
  202. data/unittest/expected_creole/test_creole_tabular_css.latex +0 -22
  203. data/unittest/expected_creole/test_creole_tabular_multicols.creole +0 -16
  204. data/unittest/expected_creole/test_creole_tabular_multicols.html +0 -14
  205. data/unittest/expected_creole/test_creole_tabular_multicols.latex +0 -16
  206. data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +0 -22
  207. data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +0 -21
  208. data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +0 -20
  209. data/unittest/expected_creole/test_creole_toc.html +0 -13
  210. data/unittest/expected_creole/test_creole_toc.latex +0 -22
  211. data/unittest/expected_creole/test_creole_toc.text +0 -4
  212. data/unittest/expected_creole/test_creole_toc_level.html +0 -7
  213. data/unittest/expected_creole/test_creole_toc_level.latex +0 -10
  214. data/unittest/expected_creole/test_creole_toc_level.text +0 -3
  215. data/unittest/expected_creole/test_creole_toc_level_text.html +0 -8
  216. data/unittest/expected_creole/test_creole_toc_level_text.latex +0 -9
  217. data/unittest/expected_creole/test_creole_toc_text.html +0 -5
  218. data/unittest/expected_creole/test_creole_toc_text.latex +0 -5
  219. data/unittest/expected_creole/test_creole_ul_multiple_line.html +0 -7
  220. data/unittest/expected_creole/test_creole_ul_multiple_line.latex +0 -14
  221. data/unittest/expected_creole/test_creole_ul_with_blank.html +0 -11
  222. data/unittest/expected_creole/test_creole_ul_with_blank.latex +0 -20
  223. data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
  224. data/unittest/expected_creole/test_creole_ul_with_bold.html +0 -11
  225. data/unittest/expected_creole/test_creole_ul_with_bold.latex +0 -18
  226. data/unittest/expected_creole/test_creole_ul_with_bold.text +0 -7
  227. data/unittest/expected_creole/test_creole_verbatim.html +0 -25
  228. data/unittest/expected_creole/test_creole_verbatim.latex +0 -33
  229. data/unittest/expected_creole/test_creole_verbatim.text +0 -17
  230. data/unittest/expected_creole/test_creole_verbatim_inline.html +0 -6
  231. data/unittest/expected_creole/test_creole_verbatim_inline.latex +0 -8
  232. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +0 -6
  233. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +0 -8
  234. data/unittest/expected_creole_rail/test_rail_creole_object.tex +0 -33
  235. data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +0 -40
  236. data/unittest/expected_rubycode4doc/creole_complete.html +0 -26
  237. data/unittest/expected_rubycode4doc/creole_complete.tex +0 -40
  238. data/unittest/expected_rubycode4doc/creole_in_tab.html +0 -4
  239. data/unittest/expected_rubycode4doc/creole_in_tab.tex +0 -6
  240. data/unittest/expected_rubycode4doc/creole_inline_ruby.html +0 -7
  241. data/unittest/expected_rubycode4doc/creole_output.html +0 -2
  242. data/unittest/expected_rubycode4doc/creole_output.tex +0 -4
  243. data/unittest/expected_rubycode4doc/creole_rubycode.html +0 -1
  244. data/unittest/expected_rubycode4doc/creole_rubycode.tex +0 -3
  245. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +0 -1
  246. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +0 -3
  247. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +0 -3
  248. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +0 -5
  249. data/unittest/expected_rubycode4doc/wiki_1.html +0 -8
  250. data/unittest/expected_rubycode4doc/wiki_2.html +0 -8
  251. data/unittest/expected_rubycode4doc/wiki_3.html +0 -9
  252. data/unittest/expected_rubycode4doc/wiki_immediate_1.html +0 -5
  253. data/unittest/expected_rubycode4doc/wiki_immediate_2.html +0 -5
  254. data/unittest/expected_rubycode4doc/wiki_immediate_3.html +0 -8
  255. data/unittest/expected_rubycode4doc/wiki_immediate_full.html +0 -21
  256. data/unittest/expected_wikimedia/test_wiki.html +0 -6
  257. data/unittest/expected_wikimedia/test_wiki.latex +0 -12
  258. data/unittest/expected_wikimedia/test_wiki.text +0 -14
  259. data/unittest/expected_wikimedia/test_wiki.wiki +0 -12
  260. data/unittest/expected_wikimedia/test_wiki_description.html +0 -7
  261. data/unittest/expected_wikimedia/test_wiki_description.latex +0 -11
  262. data/unittest/expected_wikimedia/test_wiki_description.text +0 -6
  263. data/unittest/expected_wikimedia/test_wiki_description.wiki +0 -6
  264. data/unittest/expected_wikimedia/test_wiki_footnote.html +0 -8
  265. data/unittest/expected_wikimedia/test_wiki_footnote.latex +0 -17
  266. data/unittest/expected_wikimedia/test_wiki_footnote.text +0 -10
  267. data/unittest/expected_wikimedia/test_wiki_footnote.wiki +0 -10
  268. data/unittest/expected_wikimedia/test_wiki_footnote_2.html +0 -8
  269. data/unittest/expected_wikimedia/test_wiki_footnote_groupid.html +0 -21
  270. data/unittest/expected_wikimedia/test_wiki_html_code.html +0 -7
  271. data/unittest/expected_wikimedia/test_wiki_html_code.latex +0 -10
  272. data/unittest/expected_wikimedia/test_wiki_html_code.text +0 -6
  273. data/unittest/expected_wikimedia/test_wiki_html_code.wiki +0 -6
  274. data/unittest/expected_wikimedia/test_wiki_inline.html +0 -6
  275. data/unittest/expected_wikimedia/test_wiki_inline.latex +0 -12
  276. data/unittest/expected_wikimedia/test_wiki_inline.text +0 -8
  277. data/unittest/expected_wikimedia/test_wiki_inline.wiki +0 -8
  278. data/unittest/expected_wikimedia/test_wiki_label.html +0 -6
  279. data/unittest/expected_wikimedia/test_wiki_link.html +0 -8
  280. data/unittest/expected_wikimedia/test_wiki_link.latex +0 -17
  281. data/unittest/expected_wikimedia/test_wiki_link.wiki +0 -11
  282. data/unittest/expected_wikimedia/test_wiki_list_ol.html +0 -24
  283. data/unittest/expected_wikimedia/test_wiki_list_ol.latex +0 -30
  284. data/unittest/expected_wikimedia/test_wiki_list_ol.text +0 -10
  285. data/unittest/expected_wikimedia/test_wiki_list_ol.wiki +0 -12
  286. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.html +0 -16
  287. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.latex +0 -24
  288. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.text +0 -8
  289. data/unittest/expected_wikimedia/test_wiki_list_ol_after_ul.wiki +0 -10
  290. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.html +0 -24
  291. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.latex +0 -30
  292. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.text +0 -10
  293. data/unittest/expected_wikimedia/test_wiki_list_ol_ul.wiki +0 -12
  294. data/unittest/expected_wikimedia/test_wiki_list_ul.html +0 -24
  295. data/unittest/expected_wikimedia/test_wiki_list_ul.latex +0 -30
  296. data/unittest/expected_wikimedia/test_wiki_list_ul.text +0 -10
  297. data/unittest/expected_wikimedia/test_wiki_list_ul.wiki +0 -12
  298. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.html +0 -39
  299. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.latex +0 -51
  300. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.text +0 -11
  301. data/unittest/expected_wikimedia/test_wiki_list_ul_too_much.wiki +0 -15
  302. data/unittest/expected_wikimedia/test_wiki_picture.html +0 -55
  303. data/unittest/expected_wikimedia/test_wiki_picture.latex +0 -76
  304. data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +0 -5
  305. data/unittest/expected_wikimedia/test_wiki_tab1.html +0 -30
  306. data/unittest/expected_wikimedia/test_wiki_tab1.latex +0 -30
  307. data/unittest/expected_wikimedia/test_wiki_tab1.wiki +0 -29
  308. data/unittest/expected_wikimedia/test_wiki_textformatting.html +0 -7
  309. data/unittest/expected_wikimedia/test_wiki_textformatting.latex +0 -16
  310. data/unittest/expected_wikimedia/test_wiki_textformatting.text +0 -11
  311. data/unittest/expected_wikimedia/test_wiki_textformatting.wiki +0 -9
  312. data/unittest/expected_wikimedia/test_wiki_toc.html +0 -9
  313. data/unittest/expected_wikimedia/test_wiki_toc.latex +0 -18
  314. data/unittest/expected_wikimedia/test_wiki_toc.text +0 -21
  315. data/unittest/expected_wikimedia/test_wiki_toc.wiki +0 -18
  316. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.html +0 -18
  317. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.latex +0 -19
  318. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.text +0 -6
  319. data/unittest/expected_wikimedia/test_wiki_ul_multiple_line.wiki +0 -7
  320. data/unittest/unittest_creole.rb +0 -1361
  321. data/unittest/unittest_creole_placeholders.rb +0 -150
  322. data/unittest/unittest_creole_plugin_rail.rb +0 -147
  323. data/unittest/unittest_creole_tabular.rb +0 -207
  324. data/unittest/unittest_wikimedia.rb +0 -479
@@ -1,954 +0,0 @@
1
- #encoding: utf-8
2
- =begin rdoc
3
- This is a Creole-to-Docgenerator converter.
4
- The Docgenerator-data can be exported as
5
- - HTML
6
- - LaTeX
7
- - Creole
8
- - Wikimedia-like wiki
9
- - Plain text
10
-
11
- For another Creole-to-XHTML converter see
12
- https://rubyforge.org/projects/wikicreole/
13
-
14
- More about creole at http://www.wikicreole.org/
15
- =end
16
-
17
- $:.unshift("..") if $0 == __FILE__ #for test purposes.
18
- require 'docgenerator'
19
-
20
- module Docgenerator
21
-
22
- =begin rdoc
23
- Collect the classes to handle Creole-input.
24
-
25
- More about creole at http://www.wikicreole.org/
26
- =end
27
- module Creole
28
-
29
- =begin rdoc
30
- Some class definitions for the Creole-class.
31
- =end
32
- class Creole
33
-
34
- #Little structure to store the parsing result.
35
- Creole_line = Struct.new('Creole_line', :type, :content, :add_info)
36
-
37
- #Hash with Characters.
38
- #This characters will be converted into elements.
39
- CHARACTERS = {
40
- '%' => element(:'%'),
41
- '$' => element(:'$'),
42
- '&' => element(:ampersand),
43
- '->' => element(:rightarrow),
44
- '=>' => element(:Rightarrow),
45
- '<-' => element(:leftarrow),
46
- '<=' => element(:Leftarrow),
47
- '_' => element(:underscore),
48
- '…' => element(:ldots),
49
- '‚' => element(:sbquo), # einfaches low-9-Zeichen, U+201A , &#8218;
50
- '’' => element(:rsquo), #'zu &#8217;
51
- '„' => element(:bdquo), #"auf &#8222; #bottom double quote
52
- '“' => element(:ldquo), #"zu &#8220; #left double quote
53
- '”' => element(:rdquo), #right double quote
54
- '–' => element(:ndash), # &#8211;
55
- '—' => element(:mdash), # &#8211;
56
- }
57
-
58
- =begin rdoc
59
- Add a quick online-help.
60
- =end
61
- def self.help( option = :syntax)
62
- hlp = []
63
- hlp << "==Creole help #{option}"
64
- case option
65
- when :syntax
66
- hlp << <<Syntax
67
- Headings:
68
- = Level 1 (largest) =
69
- == Level 2 ==
70
- see also Creole.help(:headings)
71
-
72
- Bold And Italics:
73
- ** Bold
74
- // Italics
75
- You can close them. If not, the markup end with the paragraph.
76
-
77
- Links: See Creole.help(:links)
78
-
79
- Coming from Wikimedia/wiki2docgenerator? Check Creole.help(:wikimedia)
80
- Familiar with Creole? Check Creole.help(:creole) for differences.
81
- Syntax
82
- when :creole
83
- hlp << <<creole
84
- creole2doc has some special features:
85
- *headings allows labels ([key] direct after the =)
86
- *line breaks are ignored, the text is wrapped.
87
- (you can set it off with option :wrap_at => 0)
88
- creole
89
- when :wikimedia
90
- hlp << <<tripfalls
91
- Main Trippfalls when you used wiki2docgenerator before:
92
-
93
- Lists: You need an empty line after a list.
94
- #Listentry 2
95
-
96
- Text afterwords
97
- tripfalls
98
- when :headings
99
- hlp << <<headings
100
- Headings:
101
- = Level 1 (largest) =
102
- == Level 2 ==
103
- === Level 3 ===
104
- ==== Level 4 ====
105
- ===== Level 5 =====
106
- ====== Level 6 ======
107
- === Also level 3
108
- === Also level 3 =
109
- === Also level 3 ==
110
- === **not** //parsed// ===
111
- Headings with label:
112
- =[lev1] Level 1 (largest) =
113
- ==[lev1.1] Level 2 ==
114
-
115
- The content is not parsed.
116
- Details see http://www.wikicreole.org/wiki/Headings
117
- headings
118
- when :links
119
- hlp << <<links
120
- Explicit:
121
- * [[http://ruby.lickert.net/docgenerator]]
122
- * [[http://ruby.lickert.net/docgenerator|Details on docgenerator.rb]]
123
-
124
- Implicit:
125
- * http://ruby.lickert.net/docgenerator
126
- links
127
- when :tabular
128
- hlp << <<tabular
129
- Wikimedia-like syntax:
130
- <<<tabular
131
- |!columns=3
132
- |!columndescription=ccc
133
- |=1
134
- |=2
135
- |=3
136
- |-
137
- |eins
138
- |zwei
139
- |drei
140
- |-
141
- |one
142
- |two
143
- |three
144
- >>>
145
- tabular
146
- else
147
- hlp << "Undefined help for #{option.inspect}"
148
- end
149
- return hlp.join("\n")
150
- end
151
- end #Creole
152
-
153
- #Load sub-classes.
154
- #~ Dir.chdir(File.dirname(__FILE__)){
155
- require_relative 'creole_placeholder.rb'
156
- require_relative 'creole_tabular.rb'
157
- require_relative 'creole_inclusion_and_plugins.rb'
158
- #~ begin require 'privat/creole_affiliate.rb'; rescue LoadError; end #Just some privat extension
159
-
160
- require 'log4r'
161
-
162
- =begin rdoc
163
- Build a document.
164
- This is just a little combination of the classes Document and Creole.
165
-
166
- For the future: This class could allow features t build one TeX-file and
167
- multiple HTML (corresponding to pages).
168
-
169
- HTML-pagebreak could be forced with ======== or something similar.
170
- =end
171
- class Creole_document
172
-
173
- =begin rdoc
174
- Define a creole document. The settings are forwarded to Document#new()
175
-
176
- Some settings are used only directly in Creole_document.
177
- - :with_toc: Add a table of contents at the beginning of the document.
178
- - :content: Wiki-text. Same as Creole_document#<<
179
- - :logname: Name for Creole#log
180
- =end
181
- def initialize( settings = {} )
182
- @with_toc = settings[:with_toc ]
183
- settings.delete(:with_toc) #Avoid error message in Document.new
184
- settings[:logname] ||= 'CreoleDoc' #Just a name for easier debugging/logging
185
-
186
- @creole = Creole.new(
187
- #Get content if available and delete setting to avoid error message in Document.new
188
- :logname => settings.delete(:logname), #for logger
189
- :content => settings.delete(:content),
190
- :ignore => settings.delete(:ignore),
191
- :targetdir => settings.delete(:targetdir)
192
- )
193
- #fixme/ideen parameter
194
- #preamble -> vor wiki-texten
195
- #post -> nach wiki-texten
196
-
197
- @doc = Document.new(settings)
198
-
199
- @doc.runtex = settings[:runtex] if settings[:runtex]
200
-
201
- @log = @doc.log
202
-
203
- @doc.body << creole
204
-
205
- end
206
- #The related document
207
- attr_reader :doc
208
- #The related creole-object
209
- attr_reader :creole
210
- #Add content to the wiki.
211
- def << (content)
212
- @creole << content
213
- end
214
- =begin rdoc
215
- Save the creole document.
216
-
217
- If requested, the tableofcontents is added.
218
- The first Creole_document#save decides, which variant is added (html/tex)
219
- =end
220
- def save( filename, options = {} )
221
- if @with_toc
222
- @doc.body.insertbefore(creole, element(:htmlonly,{}, creole.toc(:level => @with_toc )))
223
- @doc.body.insertbefore(creole, element(:latexonly,{},element(:tableofcontents).cr))
224
- case @with_toc
225
- when Numeric
226
- @doc.head << element(:latexonly,{},"\\setcounter{tocdepth}{#{@with_toc}}\n")
227
- end
228
- @with_toc = false #Add it only once
229
- end #@with_toc
230
-
231
- @doc.save(filename, options )
232
- end
233
- #Use runtex if available.
234
- def runtex=(option)
235
- @doc.runtex = option
236
- end
237
- end
238
- =begin rdoc
239
- Creole is a standard wiki-syntax for wikitexts.
240
- Definition see http://www.wikicreole.org
241
-
242
- I liked this definition.
243
- When you look at the website, you get a definition and
244
- you get an explanation, why it is like this. - great!
245
-
246
- This class gets a creole-text and translate it to elements of the docgenerator,
247
- they can be used by Document or directly like Element#to_doc.
248
-
249
- Example:
250
- wiki = Creole.new()
251
- wiki << <<txt
252
- =Test document
253
- This is a little test text with **bold** and //italic// text.
254
- txt
255
- wiki.to_latex()
256
-
257
- Often I use it in combination with "Here"-Documents with __END__:
258
-
259
- require 'creole/creole2doc'
260
-
261
- doc = Creole_document.new()
262
- doc << DATA
263
- doc.save('test.html')
264
- __ END__
265
- Content
266
- --
267
- Im Code beispiel steht __<space>END__
268
- Würde dort __END__ stehen, hätte rdoc einen Fehler.
269
- ++
270
- =end
271
- class Creole
272
- class << Creole
273
- #Define a default for targetdir-option in Creole.new.
274
- attr_accessor :targetdir
275
- end
276
-
277
- =begin rdoc
278
- Define the Creole-object.
279
-
280
- Options:
281
- * :log => Logger to catch information.
282
-
283
- Alternativ you have access to the default logger via Creole#log
284
- * :targetdir => directory, where you want to save the result.
285
-
286
- This directory is important for checks for internal links.
287
-
288
- You may change the default '.' with
289
- Docgenerator::Creole::Creole.targetdir = 'mysubdir'
290
- * :ignore: A regex describing parts to be ignored during text parsing. e.g. /^#~.*$/ for usage with scite.
291
- * :encoding: The encoding used for creole.
292
- Default is UTF-8
293
- =end
294
- def initialize( options = {} )
295
- @options = {
296
- :logname => 'Creole', #Just a name for easier debugging/logging
297
- :targetdir => self.class.targetdir || '.',
298
- :wrap_at => 75, #Default line wrapping
299
- #~ :parsetest => false #Make an immediate test for parsing #fixme
300
- #~ :placeholders =
301
- #Definition how to handle the sectioning.
302
- :title_levels => {
303
- 0 => nil,
304
- 1 => :h1,
305
- 2 => :h2,
306
- 3 => :h3,
307
- 4 => :h4,
308
- 5 => :h5,
309
- 6 => :h6,
310
- },
311
- :ignore => nil, #Define a "local" comment, e.g /^#~.*$/
312
- :encoding => __ENCODING__,
313
- }.update(options)
314
- @placeholders = Placeholders::Collection.dup
315
- @inclusions = Inclusions::Collection.dup
316
- @plugins = Plugins::Collection.dup
317
-
318
- #Store the given source text
319
- @source = []
320
- #Store the pre-parsed content
321
- @normsource = []
322
- @toc = [] #Collection of all heading lines
323
- @footnotegroups = {} #Collection of footnote groups
324
-
325
- @targetdir = @options[:targetdir] if @options[:targetdir]
326
-
327
- @log = @options[:log]
328
- @log = Log4r::Logger.new(@options[:logname], Log4r::INFO) unless @log
329
- @log.outputters = Log4r::StdoutOutputter.new('log_stdout') if @log.outputters.empty?
330
-
331
- @creation_caller = caller.first
332
- self << @options[:content] if @options[:content]
333
- end
334
-
335
- #Hash with placeholders.
336
- #
337
- #Placeholders are used with <<<'name'.
338
- #This accessor is needed to add more placeholders for specific wikis.
339
- #Default: Creole::Placeholders
340
- attr_reader :placeholders
341
- attr_reader :options
342
-
343
- #Hash with inclusions.
344
- #This accessor is needed to add more inclusions for specific wikis.
345
- #Default: Creole::Inclusions
346
- attr_reader :inclusions
347
- #Hash with all plugins
348
- #This accessor is needed to add more plugins for specific wikis.
349
- #Default: Creole::Plugins
350
- attr_reader :plugins
351
- #All footnotegroups of the wiki
352
- attr_reader :footnotegroups
353
-
354
- #Error Class
355
- class InputError < ArgumentError; end
356
- =begin rdoc
357
- Get some content.
358
- Strings are taken like strings.
359
- Array items are handled like lines.
360
-
361
- It is possible to add the content of a file. Just add the open file handle.
362
- In case of ruby scripts, the part after __END__ is used as input.
363
-
364
- Content added with << starts always with a new paragraph, but it may contain
365
- multiple paragraphs, lists...
366
- =end
367
- def << ( input )
368
- case input
369
- when String
370
- source = input
371
- when Array
372
- #Items of the array are handled like single lines.
373
- #The chomp avoid double \n (the array items may already have their own newlines).
374
- source = input.map{|item| item.chomp}.join("\n") #ohne doppelte xx
375
- when File
376
- #If file is a ruby script, then use the wiki-code after __END__
377
- #
378
- #Often scripts contains there own text content after __END__.
379
- #So we have to catch, if << is called with DATA
380
- if /\.rb\Z/ =~ input.path and $0 != input.path
381
- @log.info("Take content of #{input.inspect} after __END__") if @log.info?
382
- begin
383
- line = input.readline while line != "__END__\n"
384
- rescue EOFError
385
- @log.error("No __END__ found in #{input.inspect}") if @log.error?
386
- end
387
- end
388
- #Read the code
389
- source = input.readlines.join
390
- else
391
- raise InputError, "Don't know, how to handle #{input.class} in Creole#<<"
392
- end
393
- begin
394
- source_enc = source.encode(@options[:encoding])
395
- rescue Encoding::UndefinedConversionError => err
396
- @log.warn("Encoding conversion error <#{err}>") if @log.warn?
397
- source_enc = source.encode(@options[:encoding], :undef => :replace)
398
- end
399
- @source << source_enc
400
- #Parse the given source.
401
- #This is done immediate, so you have a chance to localize the line, where an error occurs.
402
- #(Some errors are reported later during to_doc).
403
- #fixme: option to parse immediate at << or later
404
- #immediate_parse => true...
405
- @normsource.push( *parse( source_enc ) )
406
- end #<< ( input )
407
- =begin rdoc
408
- Parse the given creole code and build a "normalized source"
409
- =end
410
- def parse( source = @source )
411
-
412
- normsource = []
413
- statusflag = nil #Variable to store the actual status. nil = nothing special.
414
- normsource << Creole_line.new(:dummy)
415
-
416
- if ! source.respond_to?(:each_with_index)
417
- #Ruby 1.9 removed each from String
418
- if source.respond_to? :each_line
419
- source = source.each_line
420
- else
421
- @log.fatal("Unable to parse #{source.class}: #{source.inspect}" ) if @log.fatal?
422
- return normsource
423
- end
424
- end
425
-
426
-
427
- #
428
- #Check code line by line
429
- #
430
- source.each_with_index{|line, lineno|
431
- #Check special status
432
- case statusflag
433
- when nil #Nothing to do
434
- when :pre
435
- line =~ /\}\}\}/ ? statusflag = nil : normsource.last.content << line
436
- next
437
- when :placeholder
438
- #~ if line =~ /^>>>$/ #did not catch each system specific line end.
439
- if line =~ /^>>>(\r\n?|\n)/
440
- statusflag = nil
441
- normsource.last.content.close
442
- else
443
- normsource.last.content << line
444
- end
445
- next
446
- else
447
- @log.fatal("Undefinded status #{statusflag}: #{line.inspect}" ) if @log.fatal?
448
- end #statusflag
449
-
450
- #
451
- #Parse the wiki text on line level (main structure)
452
- case line
453
- #Skip this line, if it correspond to a special comment-pattern.
454
- #Can be used for application-specific comments.
455
- #
456
- #Example:
457
- # :ignore => /^(#~.*)$/
458
- #This comment is created by scite using Ctrl-Q (for ruby-scripts).
459
- when @options[:ignore]
460
- @log.info("Found comment in line %2i: %s" % [
461
- lineno, #line.inspect
462
- [$~.pre_match, '<<', $1, '>>', $~.post_match].join.strip,
463
- ]) if @log.info?
464
- #Headings
465
- #http://www.wikicreole.org/wiki/Headings
466
- #
467
- #Modification of standard: Labels are possible.
468
- when /^(=+)(?:\[(.*)\])?(.+?)(=*)\s*$/
469
- normsource << Creole_line.new(:title, $3, :level => $1.size, :label => $2 )
470
- @toc << normsource.last
471
- #Creole doesn't need a trailing ===, but when it is ther, it should be correct
472
- if $1.size != $4.size and $4.size > 0
473
- @log.warn("Heading problem #{$1} doesn't match <#{$4}>: #{line.inspect}" ) if @log.warn?
474
- end
475
- if $~.post_match !~ /\s*/
476
- @log.warn("Ignore text #{$~.post_match.inspect} after title <#{line.inspect}>" ) if @log.warn?
477
- end
478
- #And close the actual level
479
- #See unit test test_creole_mix_titles_list
480
- normsource << Creole_line.new(:dummy )
481
- #Empty line
482
- when /^\s*$/
483
- normsource << Creole_line.new(:dummy )
484
- when /^----\s*$/
485
- normsource << Creole_line.new(:hr )
486
- #List entry
487
- when /^\s*((\*|\#)+)/
488
- normsource << Creole_line.new(:list, $~.post_match, :listtype => $1 )
489
- #Tabular
490
- when /^\|/
491
- #fixme tab soll in par...
492
- #~ normsource.last << Creole_line.new(:placeholder,
493
- #~ ... unless anpassen...
494
- normsource << Creole_line.new(:placeholder,
495
- @placeholders['creole_tabular'].new(self),
496
- :start => lineno
497
- ) unless normsource.last.content.is_a?(Creole_tab)
498
- normsource.last.content << line
499
- #http://www.wikicreole.org/wiki/PreformattedAndNowiki
500
- when /^\{\{\{\s*$/ #Kind of verbatim
501
- normsource << Creole_line.new(:pre, [], :start => lineno )
502
- statusflag = :pre
503
- #~ when /^<<<(.*)\|?(.*?)/ #fixme options for placeholders?
504
- when /^<<<(.*)/
505
- ph, par = $1.split(/\|/,2)
506
- placeholder = @placeholders[ph].new(self, par)
507
- if placeholder.instance_of?(Placeholders::Dummy)
508
- @log.warn("Unknown placeholder #{ph.inspect} used in line #{lineno}" ) if @log.warn?
509
- end
510
- normsource << Creole_line.new(:placeholder, placeholder, :start => lineno )
511
- statusflag = :placeholder
512
- else
513
- case normsource.last.type
514
- when :par, :list
515
- normsource.last.content << line
516
- else
517
- normsource << Creole_line.new(:par, line )
518
- end
519
- end
520
- }
521
- case statusflag
522
- when nil #ok
523
- when :pre
524
- @log.warn("Unclosed verbatim found (start at #{normsource.last.add_info[:start]})" ) if @log.warn?
525
- #~ raise ''
526
- when :placeholder
527
- #One possible source: Regexp $ is system specific.
528
- @log.warn("Unclosed placeholder #{normsource.last.type} (start at #{normsource.last.add_info[:start]})" ) if @log.warn?
529
- else
530
- @log.warn("Wiki ends with status #{statusflag.inspect}" ) if @log.warn?
531
- end
532
- return normsource
533
- end #parse
534
- #Logger to collect messages.
535
- attr_reader :log
536
- #Returns the source as it was received
537
- attr_reader :source
538
- #The pre-parsed content.
539
- attr_reader :normsource
540
- #Directory for the target.
541
- #Can be used to check internal links (images, local files...)
542
- attr_reader :targetdir
543
-
544
- =begin rdoc
545
- Return a table of contents as a list.
546
- =end
547
- def toc( i_options = {})
548
- options = {
549
- :listtype => :ul,
550
- :level => 4,
551
- #~ :startlevel => 1,
552
- }.update(i_options)
553
-
554
- if ! options[:level].is_a?(Fixnum)
555
- @log.error("Toc: toclevel is no number but '#{options[:level].inspect}'. Set 4") if @log.error?
556
- options[:level] = 4
557
- end
558
-
559
-
560
- toclist = []
561
- toclabel = [0] #help variable to construct labels
562
- listtype = '*'
563
- case options[:listtype]
564
- when '*', :ul, :itemize
565
- listtype = '*'
566
- when '#', :ol, :enumerate
567
- listtype = '#'
568
- else
569
- @log.error("Toc: Unknown listtype #{options[:listtype]}") if @log.error?
570
- end
571
-
572
- @toc.each{|tocentry|
573
- level = tocentry.add_info[:level]
574
- #Skip deeper levels then wanted.
575
- next if level > options[:level]
576
-
577
- #Build the label
578
- if level > toclabel.size
579
- toclabel << 0
580
- elsif level < toclabel.size
581
- toclabel.pop
582
- end
583
- #Happens if there is a jump gap on section levels (subsubsection inside section without subsection)
584
- if ! toclabel[level-1]
585
- @log.warn("Missing toclevel for <#{tocentry.content}> #{tocentry.add_info.inspect}")
586
- #add dummy level
587
- toclabel << 0
588
- toclist << "#{listtype * ( level - 1)} ---"
589
- end
590
- toclabel[level-1] = toclabel[level-1] + 1
591
-
592
- #Check if there was already a label.
593
- #If yes: use it. If not: build a new one with the help of toclabel.
594
- if tocentry.add_info[:label]
595
- label = tocentry.add_info[:label]
596
- else
597
- label = tocentry.add_info[:label] = toclabel.join('-')
598
- end
599
-
600
- #Feature to create the toc if higher levels are missing /start at h3...)
601
- #~ if level < options[:startlevel]
602
- #~ @log.warn( "toc: TOC starts not at #{options[:startlevel]}, but level #{level}" ) if @log.warn?
603
- #~ next
604
- #~ end
605
-
606
- toclist << "#{listtype * level}[[##{label}|#{tocentry.content}]]"
607
- }
608
- toclist = <<toc
609
- <<<html
610
- <div class = 'toc'>
611
- >>>
612
- #{toclist.join("\n")}
613
- <<<html
614
- </div>
615
- >>>
616
- toc
617
-
618
- return Creole.new( :content => toclist, :log => @log )
619
- end #toc
620
- =begin rdoc
621
- Wrapping mechanism for texts.
622
-
623
- Don't do anything, if line_width is 0.
624
-
625
- See also http://stackoverflow.com/questions/7548968/format-output-to-40-characters-long-per-line/7549032#7549032
626
- and http://forum.ruby-portal.de/viewtopic.php?t=3844&p=24578
627
- =end
628
- def word_wrap(text, line_width = @options[:wrap_at] )
629
- return text if line_width <= 0
630
- text.gsub(/\n/, ' ').gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1\n").strip
631
- end
632
- =begin rdoc
633
- Prepare document.
634
- =end
635
- def to_doc( target, options = {} )
636
- options[:log] = @log unless options[:log]
637
- #
638
- #Delete again all footnotegroups.
639
- #Else you get footnotes doubled.
640
- @footnotegroups = {} #Collection of footnote groups
641
- return normsource2elements( @normsource, options ).to_doc(target, options)
642
- end #to_doc
643
- =begin rdoc
644
- Take the given normsource and build a list of elements.
645
- Used by
646
- - Creole#to_doc
647
- - Creole_ruby#to_doc
648
- =end
649
- def normsource2elements( normsource, options )
650
- doc = []
651
- elements = {} #little collector for lists
652
- normsource.each{|line|
653
- case line.type
654
- when :dummy
655
- elements = {}
656
- #Here we define the sectioning.
657
- #line.add_info[:level] contains the number of = from the wiki.
658
- #
659
- when :title
660
-
661
- doc << element(@options[:title_levels][line.add_info[:level]], {
662
- :id => line.add_info[:label]
663
- #inline or not?
664
- #Required for filenames with _
665
- #But: http://www.wikicreole.org/wiki/Headings says no.
666
- #Make decision depending on a setting?
667
- }, line.content ).cr
668
- #~ }, inline(line.content, options ) ).cr
669
- when :list
670
- key = line.add_info[:listtype]
671
- if ! elements[key]
672
- case key[-1,1]
673
- when '*'; elements[key] = element(:ul).cR
674
- when '#'; elements[key] = element(:ol).cR
675
- else
676
- options[:log].error("Undefined listtype #{key[-1,1]}") if options[:log].error?
677
- end
678
- if key.size == 1 #new list, add to document
679
- doc << elements[key]
680
- elsif parent_list = elements[key[0,key.size-1]] #new sublist, add to "parent"
681
- parent_list << element(:li).cr unless parent_list.content.last.is_a?(:li)
682
- parent_list.content.last << elements[key]
683
- else #sublist without parent.
684
- options[:log].error("List #{key} with missing superlist") if options[:log].error?
685
- doc << element(:comment,{},'Sublist without superlist - move on top level').cr #add pending list on top level.
686
- doc << elements[key] #add pending list on top level.
687
- end
688
- end
689
- elements.each{|ekey, list|
690
- case ekey
691
- when key
692
- list << element(:li,{}, inline(line.content, options) ).cr
693
- else
694
- elements.delete(ekey) if ekey.size >= key.size
695
- end
696
- }
697
- when :pre
698
- doc << element(:verbatim, {}, line.content ).cR
699
- when :hr
700
- doc << element(:hr).cr
701
- when :placeholder
702
- doc << line.content
703
- when :par
704
- doc << element(:par, {}, inline(line.content, options)).cR
705
- else
706
- options[:log].error("Wrong line type #{ line.type.inspect }") if options[:log].error?
707
- end
708
- }
709
-
710
- return doc
711
- end #to_doc_internal
712
- =begin rdoc
713
- Parse the inline text.
714
-
715
- Options is a Hash and may contain:
716
- * :log (default: @log)
717
- =end
718
- def inline( text, options )
719
-
720
- raise ArgumentError, "Creole#inline: Options no Hash" unless options.is_a?(Hash)
721
- options[:log] = @log unless options[:log]
722
- options[:plugins] = @plugins unless options[:plugins]
723
- options[:inclusions] = @inclusions unless options[:inclusions]
724
-
725
- res = [] #result
726
- stack = [] #
727
-
728
- #~ http_regex =
729
- #fixme: Only once to reduce runtime
730
- splitregex = Regexp.new(
731
- '(' + [
732
- '\[\[.+?\]\]', # [[...links]]
733
- 'https?:\/\/.+?(\s|\Z)', #including the next space!!
734
- '\*\*', #bold
735
- '\/\/', #emph
736
- '\\\\\\\\', #newline
737
- '\{\{\{.*?\}\}\}', #inline verbatim
738
- '\{\{.*?\}\}', #images/inclusion
739
- '<<.*?>>', #Plugins
740
- CHARACTERS.keys.join('|')
741
- ].join('|') + ')'
742
- )
743
- #Splitt along 'active' elements.
744
- #~ @options[:wrap_at]
745
- #~ text.gsub(/\n/, ' ').split(splitregex).each{|el|
746
- text.split(splitregex).each{|el|
747
- case el
748
- when '**' #bold
749
- if stack.last.is_a?(:textbf)
750
- stack.pop #leave bold area
751
- else
752
- stack << newel = element(:textbf) #enter bold area
753
- if stack.size > 1
754
- stack[-2] << newel
755
- else
756
- res << newel
757
- end
758
- end
759
- when '//' #italic
760
- if stack.last.is_a?(:emph)
761
- stack.pop #leave italic area
762
- else
763
- stack << newel = element(:emph) #enter italic area
764
- if stack.size > 1
765
- stack[-2] << newel
766
- else
767
- res << newel
768
- end
769
- end
770
- when '\\\\' #newline
771
- ( stack.last ? stack.last : res ) << element(:newline).cr
772
- #Something like [[http:...]]
773
- when %r{^\[\[(.+?)(?:\|(.*?))?\]\]} #Link
774
- link = $1
775
- linktext = $2 ? $2 : $1
776
- case link
777
- when /^(https?|ftp):\/\/.+?/
778
- link = link
779
- #local file via file://...
780
- when /^(file):\/\/(.+)/
781
- link = link
782
- check_link_existence( $2, options[:log] )
783
- when /^\./, /\S:[\\\/]/ #lokal file
784
- link = link
785
- check_link_existence( link, options[:log] )
786
- when /^#/ #internal link
787
- link = link
788
- #fixme tex?
789
- else #internal link
790
- #This is normally the wiki-links.
791
- #But this is no wiki, it's a documentgenerator with wiki syntax.
792
- options[:log].warn("Unclear link <#{el}> #{self.inspect}") if options[:log].warn?
793
- link = link
794
- end
795
- if link == linktext #Avoid replacement of // inside linktext
796
- href = element(:a, {:href=>link}, linktext )
797
- else
798
- href = element(:a, {:href=>link}, inline(linktext, options) )
799
- end
800
- if stack.last
801
- stack.last << href
802
- else
803
- res << href
804
- end
805
- #All links should be catched before
806
- when %r{\[\[(.*)\]\]}
807
- options[:log].error("Lost link <#{el}>") if options[:log].error?
808
- #fixme: there are obsolete 2 additional spaces in the result.
809
- when /^http/ #implicit link
810
- #~ href = element(:a, {:href=>el.strip}, el.strip ) #This makes problems with TeX (unmasked _,%...)
811
- href = element(:url, {}, el.strip )
812
- el =~ /(\s|\Z)$/ #get the end-space/newline if available
813
- endspace = ( $1.empty? ? nil : $1 )
814
- if stack.last
815
- stack.last << href
816
- #~ stack.last << last_char #add again the
817
- else
818
- res << href
819
- #~ res << last_char #add again the end-space/newline
820
- end
821
- #No-wiki inline: {{{text}}}
822
- when /\{\{\{(.*)\}\}\}/
823
- if stack.last
824
- stack.last << element(:verb,{},$1)
825
- else
826
- res << element(:verb,{},$1)
827
- end
828
- #Inclusion
829
- #creole2doc implements a general inclusion.
830
- #Main usage are pictures/images ({{picname|alt}}),
831
- #but it can be more...
832
- #
833
- #Available inclusions are defined in Creole::Inclusions resp. Creole#inclusions,
834
- when /\{\{(.+?)(?:\|(.*))?\}\}/
835
- if stack.last
836
- stack.last << inclusion_or_plugin($1, $2, options[:inclusions])
837
- else
838
- res << inclusion_or_plugin($1, $2, options[:inclusions])
839
- end
840
- #Plugin
841
- #Used like Inclusions.
842
- #
843
- #available plugins are defined in Creole::Plugins resp. Creole#plugins
844
- when /<<(.+?)(?:\|(.*))?>>/
845
- if stack.last
846
- stack.last << inclusion_or_plugin($1, $2, options[:plugins])
847
- else
848
- res << inclusion_or_plugin($1, $2, options[:plugins])
849
- end
850
- #No special wiki command. The text is "normal" text.
851
- else #text to add
852
- #Replace characters.
853
- if CHARACTERS[el]
854
- insertion = CHARACTERS[el]
855
- startspace = endspace = nil
856
- else
857
- startspace = ( el[0,1] =~ /\s/ )
858
- endspace = ( el[-1,1] =~ /\s/ )
859
- insertion = word_wrap( el ) #wrap content
860
- end
861
- if stack.last
862
- stack.last << insertion
863
- #This adds some obsolete spaces in case of newlines at the end.
864
- #But if I compare with ' ', then words will be concatenated without separator.
865
- stack.last << ' ' if endspace
866
- else #Just some text without any format
867
- res << ' ' if startspace #Keep space
868
- res << insertion
869
- res << ' ' if endspace #Keep space
870
- end
871
- end
872
- }
873
- res
874
- end #inline
875
- =begin rdoc
876
- Inclusion or Plugin.
877
- creole2doc implements a general inclusion.
878
- Main usage are pictures/images ({{picname|alt}}),
879
- but it can be more...
880
-
881
- The last paramter contains a hash with the supported inclusions/plugins.
882
- =end
883
- def inclusion_or_plugin( link, p_additions, inclusions )
884
-
885
- addition, additions = nil
886
- #Splitt additions at |
887
- if p_additions
888
- addition, *additions = p_additions.split(/\|/)
889
- end
890
-
891
- inclusion = inclusions[link]
892
- #check inclusion.ancestors?
893
- #~ if inclusion.superclass != Creole_inclusion_and_plugin
894
- if inclusion.is_a?(Creole_inclusion_and_plugin)
895
- @log.error( "Wrong inclusion/plugin definition for #{link} (#{inclusion.inspect}, expected #{inclusions.default.superclass})") if @log.error?
896
- return nil
897
- end
898
- ip = inclusion.new( link, addition, additions, self )
899
- return ip
900
- end #inclusion
901
- =begin rdoc
902
- Check for links and pictures if the target exist.
903
-
904
- Absolute DOS-Pathes are detected (C:\...).
905
- Relative pathes are searched from @options[:targetdir] (default '.').
906
-
907
- Different locations are not supported (e.g. to implement LaTeXs \graphicspath)
908
- =end
909
- def check_link_existence( filename, log )
910
- case filename
911
- when /^.:/#absolute DOS-path (e.g. c:\...)
912
- path = filename.dup
913
- else #relative path
914
- path = "#{@options[:targetdir]}/#{filename}".sub(/^\//, '')
915
- end
916
- path.sub!(/(\.html?)#.*$/, '\1') #Don't check anchor inside html
917
- if ! File.exist?(path)
918
- log.warn("Reference not found: <#{filename}> (looking at <#{path}>)") if log.warn?
919
- #~ log.debug("Reference not found: <#{path}>") if log.debug?
920
- fpath = File.expand_path("#{Dir.pwd}/#{path}")
921
- log.debug("Reference not found: <#{fpath}>") if log.debug?
922
- end
923
- end #check_link_existence
924
-
925
- def inspect()
926
- "<#{self.class} (created #{@creation_caller})>"
927
- end
928
- end #Creole
929
- end #module Creole
930
- end #module Docgenerator
931
-
932
-
933
- if [__FILE__ ].include?($0)
934
-
935
- [
936
- :syntax,
937
- :creole,
938
- :wikimedia,
939
- :trippfall,
940
- :headings,
941
- :links,
942
- ].each{|key|
943
- puts '='*50
944
- puts Docgenerator::Creole::Creole.help(key)
945
- puts '='*50
946
- }
947
-
948
- creole = Docgenerator::Creole::Creole.new
949
- creole << 'x{{-}}y{{-}}z'
950
- creole << 'x{{shy}}y{{shy}}z'
951
- creole << ''
952
- creole << '{{../index.html#aa}}'
953
- puts creole.to_html
954
- end