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,53 +0,0 @@
1
- #
2
- #Obsolete script.
3
- #Replaced by creole/pplugins/rubycode4doc.rb
4
- #
5
- #This script is still in the distribution
6
- #
7
-
8
-
9
- #Only for quick tests
10
- $:.unshift("../../") if $0 == __FILE__
11
-
12
-
13
- require 'wiki2doc/wiki2docgenerator'
14
- require 'docgenerator/packages/rubycode4doc'
15
- #Example see examples/rubycode_wiki.rb
16
-
17
- #
18
- module Docgenerator
19
- module Wikimedia
20
-
21
- =begin rdoc
22
- Define a new Ruby-Type
23
- =end
24
- class Rubywiki < Wikitext
25
- def wiki_macro( macro, argv )
26
- case macro
27
- when 'rubycode'
28
- Rubycode::CodeTest[argv] ? Rubycode::CodeTest[argv].code : "Code '#{argv}' not defined"
29
- when 'rubycode_with_evaluation'
30
- Rubycode::CodeTest[argv] ? Rubycode::CodeTest[argv].code_evaluation_lstlisting : "Code '#{argv}' not defined"
31
- when 'rubycode_in_tab'
32
- Rubycode::CodeTest[argv] ? Rubycode::CodeTest[argv].code_in_tab : "Code '#{argv}' not defined"
33
- else
34
- super
35
- end
36
- end
37
- end
38
-
39
- #~ end
40
- end #module Wikimedia
41
-
42
- class Rubycode::CodeTest
43
- #If used as Wikicollector, just return nothing.
44
- #The Collector is just used to define the code
45
- def to_doc( target, options = {} ); ''; end
46
- end
47
- #if rubycode4wiki.rb is loaded add the class to the WikiCollectors.
48
- Wikimedia::WikiCollector.add(:rubycode, Rubycode::CodeTest)
49
-
50
- end #module Docgenerator
51
-
52
- __END__
53
- Example see examples/rubycode_wiki.rb
@@ -1,12 +0,0 @@
1
- =begin rdoc
2
- Add struktex-extension as WikiCollector.
3
- =end
4
-
5
- #~ $:.unshift('../..')
6
- require 'wiki2doc/wiki2docgenerator.rb'
7
- require 'docgenerator/packages/struktex.rb'
8
-
9
- #if wiki2docgenerator is loaded, add the class to the WikiCollectors.
10
- if defined?( Docgenerator::Wikimedia::WikiCollector)
11
- Docgenerator::Wikimedia::WikiCollector.add(:structogramm, Docgenerator::Packages::Struktex::Structogramm)
12
- end
@@ -1,1276 +0,0 @@
1
- =begin rdoc
2
- This small programm reads a text in Wiki-format and
3
- transform it to a "docgenerator"-object.
4
-
5
- This object can be saved as HTML or TeX (or Wiki again - in preparation).
6
-
7
- http://de.wikipedia.org/wiki/WikiSyntax
8
- http://de.wikipedia.org/wiki/Hilfe:Textgestaltung
9
-
10
- For usage: Check test.wiki.rb
11
- =end
12
-
13
- #
14
- #fixme:
15
- #-
16
- #- Textbaustein {{...}}
17
- #Standard: [[ legt Textbaustein an, {{ nutzt diesen
18
- # http://de.wikipedia.org/wiki/Wikipedia:Textbausteine/Schwesterprojekte
19
- #- http://de.wikipedia.org/wiki/Wikipedia:Textbausteine
20
-
21
- require 'docgenerator'
22
- require 'log4r'
23
- #~ begin
24
- #~ require 'privat/docgenerator_affiliate'
25
- #~ rescue LoadError
26
- #~ end
27
-
28
- #
29
- module Docgenerator
30
- =begin rdoc
31
- Collection of classes to handle texts in Wikimedia-Syntax.
32
- =end
33
- module Wikimedia
34
- #Struct for wiki-replacements.
35
- #The proc contains three block-parameter: The match-element, the Wikitext-object and the logger-object.
36
- Wikireg = Struct.new( 'WikiReg', :rule, :regex, :proc )
37
- class Wikireg
38
- @@give_message = true
39
- def self.give_message=(val); @@give_message = val; end
40
- def self.give_message?(); return @@give_message; end
41
- end
42
-
43
- #Constant with all Standard-replacemnts of Wikis.
44
- #Each replacement should also convert the part before and after the match.
45
- WIKI_INLINE_REPLACEMENTS = [
46
- #[[Bild:Dateiname|Zusatzinfos|Beschreibung]]
47
- #Zusatzinfos:
48
- # -left
49
- # -right
50
- Wikireg.new(:bild, /\[\[Bild:(.*?)\]\]/,
51
- Proc.new{|m, oo, log|
52
- parameter = m[1].split('|')
53
- [ oo.inline(m.pre_match, log),
54
- oo.wiki_bild( parameter.first, parameter[1..-1], log),
55
- oo.inline(m.post_match, log),
56
- ]
57
- } ),
58
- Wikireg.new(:file, /\[\[File:(.*)\]\]/,
59
- Proc.new{|m, oo, log|
60
- parameter = m[1].split('|')
61
- filename = parameter[0]
62
- if parameter.size > 1
63
- txt = "#{parameter.last}"
64
- else
65
- txt = File.basename(filename)
66
- end
67
- if Wikireg.give_message? and ! File.exist?(filename)
68
- log.warn( "Link to unexisting local file #{filename} (from #{Dir.pwd})" ) if log.warn?
69
- end
70
-
71
- css = CSS.new()
72
- parameter[1..-2].each{|p|
73
- case p
74
- when 'size'
75
- txt << " (#{File.size(filename)/1024}KB)" if File.exist?(filename)
76
- when /(.*)=>(.*)/
77
- css[$1] = $2
78
- else
79
- log.warn( "Wiki-File with unknown setting #{p}" ) if log.warn?
80
- end
81
- }
82
- #Result:
83
- [
84
- oo.inline(m.pre_match, log),
85
- element(:a, { :href => filename, :alt => txt, :style => css }, oo.inline(txt, log) ),
86
- oo.inline(m.post_match,log)
87
- ]} ),
88
- Wikireg.new(:label, %r{\[\[label:(.*)\]\]},
89
- Proc.new{|m, oo, log|
90
- [ oo.inline(m.pre_match, log),
91
- element(:label, { :name => m[1]} ),
92
- oo.inline(m.post_match, log)
93
- ]
94
- } ),
95
- Wikireg.new(:ref, %r{<ref>(.*)</ref>},
96
- Proc.new{|m, oo, log|
97
- puts "<ref> is obsolete, use {{footnote}}. To get footnotes set {{footnotes|ref}}"
98
- [ oo.inline(m.pre_match, log),
99
- element(:footnote, { :groupid => 'ref' }, oo.inline(m[1],log) ),
100
- oo.inline(m.post_match, log)
101
- ]
102
- } ),
103
- Wikireg.new(:bf_it, /''''(.*?)''''/,
104
- Proc.new{|m, oo, log| [ oo.inline(m.pre_match, log),
105
- element(:textbf, {}, element(:emph, {}, oo.inline(m[1], log) )),
106
- oo.inline(m.post_match, log)
107
- ]} ),
108
- Wikireg.new(:bf, /'''(.*?)'''/,
109
- Proc.new{|m, oo, log| [ oo.inline(m.pre_match, log),
110
- element(:textbf, {}, oo.inline(m[1], log)),
111
- oo.inline(m.post_match, log)
112
- ]} ),
113
- Wikireg.new(:it, /''(.*?)''/,
114
- Proc.new{|m, oo, log| [ oo.inline(m.pre_match, log),
115
- element(:emph, {}, oo.inline(m[1], log)),
116
- oo.inline(m.post_match, log)
117
- ]} ),
118
- #Soll in Wikipedia-Artikeln nicht verwendet werden.
119
- Wikireg.new(:small, %r{<small>(.*)</small>},
120
- Proc.new{|m, oo, log|
121
- [ oo.inline(m.pre_match, log),
122
- element(:small, {}, oo.inline(m[1], log )),
123
- oo.inline(m.post_match, log)
124
- ]
125
- } ),
126
- Wikireg.new(:stroke, %r{<s>(.*)</s>},
127
- Proc.new{|m, oo, log|
128
- [ oo.inline(m.pre_match, log),
129
- element(:stroke, {}, oo.inline(m[1], log )),
130
- oo.inline(m.post_match, log)
131
- ]
132
- } ),
133
- #- Textbaustein {{...}}
134
- #Standard: [[ legt Textbaustein an, {{ nutzt diesen
135
- # http://de.wikipedia.org/wiki/Wikipedia:Textbausteine/Schwesterprojekte
136
- #- http://de.wikipedia.org/wiki/Wikipedia:Textbausteine
137
- Wikireg.new(:wikidef, /\[\[(.+?):(.*?)\]\]/,
138
- Proc.new{|m, oo, log|
139
- puts "wikidef #{m[1].inspect} obsolete, please use macro {{..|"
140
- [ oo.inline(m.pre_match, log),
141
- oo.wikidef(m[1], m[2] ),
142
- oo.inline(m.post_match, log)
143
- ]}
144
- ),
145
- Wikireg.new(:wiki_macro, /\{\{(.+?)(\|(.*?))?\}\}/,
146
- Proc.new{|m, oo, log|
147
- [ oo.inline(m.pre_match, log),
148
- oo.wiki_macro(m[1], m[3] ),
149
- oo.inline(m.post_match, log)
150
- ].delete_if{|e| ! e or e.respond_to?(:to_str) and /\A\s*\Z/m =~ e}
151
- #[].delete(nil) may return nil -> use delete_if
152
- }
153
- ),
154
- #Problem: detect end of url without a end-character
155
- #[uri text]
156
- Wikireg.new(:url1, %r{\[\s*((?:https?://|\.|C:\\|C:\/|ftp:|mailto:|webcal://).*?)\s+(.*?)\s*\]},
157
- Proc.new{|m, oo, log|
158
- #Check local files, but without anchor
159
- if /\A\./ =~ m[1] #local file
160
- filename = oo.inputsource + m[1].split(/#/).first
161
- else
162
- filename = m[1].split(/#/).first
163
- end
164
- if Wikireg.give_message? and /\A(\.|\w:)/ =~ m[1] and ! File.exist?(filename)
165
- log.warn( "Link to unexisting local file #{filename} (from #{Dir.pwd})" ) if log.warn?
166
- end
167
- link_url = m[1]
168
- if /^\w:/ =~ link_url #local file with absolut path
169
- link_url = 'file://' + link_url
170
- end
171
- if m[2].size > 0
172
- linktext = m[2]
173
- else
174
- linktext = m[1].sub(/http:\/\//, '').sub(/\/$/, '')
175
- end
176
- [ oo.inline(m.pre_match, log),
177
- element(:a, {:href=> link_url }, oo.inline(linktext, log) ),
178
- oo.inline(m.post_match, log)
179
- ]
180
- }
181
- ),
182
- #uri http...
183
- Wikireg.new(:url2, %r{(https?://.*?)(\s|\Z)},
184
- Proc.new{|m, oo, log|
185
- [ oo.inline(m.pre_match, log),
186
- #~ element(:a, {:href=> m[1]}, m[1] ), #hier kein oo.inline
187
- element(:url, {}, m[1] ), #hier kein oo.inline
188
- m[2], #Space/CR
189
- oo.inline(m.post_match, log)
190
- ]} ),
191
- Wikireg.new(:wikilink, /\[\[(.+?)(\|(.*?))?\]\]/,
192
- #~ Wikireg.new(:wikilink, /\[\[(.+?)\]\]/,
193
- Proc.new{|m, oo, log|
194
- linktext = m[1]
195
- #m[2] includes the |
196
- if m[3]
197
- linktext = m[3]
198
- end
199
- [ oo.inline(m.pre_match, log),
200
- element(:a, {:href=> m[1]},
201
- oo.inline(linktext, log)
202
- ),
203
- oo.inline(m.post_match, log)
204
- ]
205
- } ),
206
- ]
207
-
208
- #require 'LotusNotes.rb'
209
- WIKI_INLINE_REPLACEMENT_NOTES =
210
- Wikireg.new(:notes, /(Notes:.*?)(\s|\Z)/, Proc.new{|m, oo, log|
211
- [
212
- oo.inline( m.pre_match, log),
213
- LN_Link.new( m[1] ).to_element,
214
- m[2],
215
- oo.inline( m.post_match, log ),
216
- ]})
217
-
218
- WIKI_INLINE_REPLACEMENTS_SYMBOLS = [
219
- #Problem: Native LaTeX with beamer and \only...
220
- Wikireg.new(:arrow, /->/,
221
- Proc.new{|m, oo, log|
222
- [ oo.inline(m.pre_match, log),
223
- element(:rightarrow),
224
- oo.inline(m.post_match, log),
225
- ]
226
- } ),
227
- Wikireg.new(:Arrow, /=>/,
228
- Proc.new{|m, oo, log|
229
- [ oo.inline(m.pre_match, log),
230
- element(:Rightarrow),
231
- oo.inline(m.post_match, log),
232
- ]
233
- } ),
234
- ]
235
-
236
- WIKI_INLINE_REPLACEMENTS_UNDERSCORE = Wikireg.new(:underscore, /_/,
237
- Proc.new{|m, oo, log|
238
- [ oo.inline(m.pre_match, log),
239
- "\\_",
240
- oo.inline(m.post_match, log),
241
- ]
242
- } )
243
-
244
- #require 'LotusNotes.rb'
245
- if defined? LN_Link
246
- WIKI_INLINE_REPLACEMENTS << WIKI_INLINE_REPLACEMENT_NOTES
247
- end
248
-
249
- module Wiki_helper
250
- #Transfer the input to a list.
251
- #input can be
252
- #-String
253
- #-List
254
- #-File (if .rb, then the part after __END__ is taken)
255
- #The method returns a list with lines, but no \n
256
- def get_input( input, lineoffset, close_it = false )
257
- inputlist = []
258
- if input.is_a?(String)
259
- #~ inputlist = input.split("\n")
260
- #Convert to Array, but keep the \n
261
- inputlist = input.split("\n")
262
- elsif input.is_a?(Array)
263
- inputlist = input.flatten.map{|l| l.nil? ? '' : l.chomp()}
264
- elsif input.is_a?(File)
265
- #If file is a ruby scriot, then the wiki-code in after __END__
266
- if /\.rb\Z/ =~ input.path and $0 != input.path
267
- line = input.readline while line != "__END__\n"
268
- end
269
- lineoffset = input.lineno
270
- inputlist << input.readlines.map{|l| l.chomp}
271
- input.close if close_it
272
- end
273
- return inputlist, lineoffset
274
- end
275
- end
276
- #
277
- #Struct for wiki elements.
278
- class Wikielements < Struct.new('Wikielements', :first, :l1,:l2,:l3,:l4, :tab, :row )
279
- #Clear all precesssors.
280
- def clear( element )
281
- if element.is_a?(Integer)
282
- element = self.members[element]
283
- end
284
- self.members.reverse.each{|i|
285
- break if i == element.to_s
286
- self[i] = nil
287
- }
288
- end
289
- end
290
-
291
- #
292
- #Get text in wiki-format and build a docgenerator-version.
293
- #
294
- class Wikitext
295
- include Docgenerator #get VERSION
296
-
297
- #
298
- #Make short description for the Wiki-syntax
299
- def self.help( version = :syntax)
300
- hlp = []
301
- hlp << "Wikitext.help #{version.inspect}"
302
- hlp << "-------------------------------------"
303
- case version
304
- when :syntax
305
- hlp << <<main
306
- Sections:
307
- ==title==
308
- ===subtitle===
309
- ====subsubtitle====
310
- Lists:
311
- * unordered
312
- # ordered
313
- description-like:
314
- ;key
315
- :entry
316
- Pictures:
317
- [[Bild:path|options]]
318
- For options use Wikitext.help(:img)
319
- Tabulars:
320
- Use Wikitext.help(:tab) for details
321
- Specials:
322
- ---- hrule
323
- main
324
- when :img
325
- hlp << <<main
326
- Pictures in Wikitext:
327
- [[Bild:path|options]]
328
- The complete command must be in one line.
329
- Options:
330
- - href=
331
- - alt=
332
- - imgclass=: Used for CSS-class (img)
333
- - figureclass=: Used for CSS-class (span/div)
334
- - left, right: CSS: float
335
- - aftertitle/beforetitle: Text before/after image
336
- - thumb: Add a thumb in the text and link to picture
337
- - \d*px: size/width
338
- - width=xx% define width for img/includegraphics
339
- - xx = : Used for CSS in img
340
- main
341
- when :tab
342
- hlp << <<tabhelp
343
- Tabulars in Wikitext:
344
- {|taboptions
345
- |[lineoptions|]
346
- |-[newline-options]
347
- |
348
- |}
349
- taboptions:
350
- - columns=: number of columns (required)
351
- - columndescription: For LaTeX
352
- - border=: HTML
353
- - .* = (.*): Used for CSS
354
- newline-options
355
- - toprule
356
- - midrule
357
- - hline
358
- - .* = (.*): Used for CSS
359
- lineoptions:
360
- - colspan =
361
- - pos
362
- - .* = (.*): Used for CSS
363
-
364
- Remark: If the text contains macros with | there is a bit confusion,
365
- what is a parameter of the cell and whats part of the macro.
366
-
367
- Solution: Define the end of cell parameters with ||
368
- tabhelp
369
- else
370
- hlp << "Sorry, option #{version.inspect} unknown"
371
- end
372
- return hlp.join("\n")
373
- end #help
374
- #Read text and convert it to a Document.
375
- def initialize(
376
- options = {}
377
- )
378
- #convert from old interface
379
- options = {
380
- :wiki_inline_replacements => options
381
- } if options.is_a?(Array)
382
- @options = {
383
- :wiki_inline_replacements => WIKI_INLINE_REPLACEMENTS + WIKI_INLINE_REPLACEMENTS_SYMBOLS,
384
- :log => Log4r::Logger.new('Wikitext', Log4r::INFO),
385
- :inputsource => './',
386
- :parsetest => false #Make an immediate test for parsing
387
- }.update(options)
388
- @source = []
389
- #Hash with all footnote groups
390
- @footnotegroups = {}
391
- #This rules can be extended via the accessors.
392
- @wiki_inline_replacements = @options[:wiki_inline_replacements]
393
- @lineoffset = 0 #for better debugging
394
- @inputsource = @options[:inputsource]
395
- @log = @options[:log]
396
- @log.outputters = Log4r::StdoutOutputter.new('log_stdout') if @log.outputters.empty?
397
- self << @options[:content] if @options[:content]
398
- @parent = self
399
- end
400
- #Line offset.
401
- #Is used as initial value in <<
402
- attr_writer :lineoffset
403
- #Used for relative filecheck
404
- attr_accessor :inputsource
405
- #Array with the rules for the inline elements (like text formatting...)
406
- #Can be extended/replaces by this accessor
407
- #
408
- #Don't include arrays. elements must be 'Wikireg'.
409
- attr_reader :wiki_inline_replacements
410
- #Logger
411
- attr_reader :log
412
- #Element, where the wiki test belongs to.
413
- #Can be used in the procs insiede a wikirule.
414
- attr_accessor :parent
415
- #Wiki-Code.
416
- #Source is an array
417
- attr_accessor :source
418
-
419
- include Wiki_helper
420
- #Add contents to Wiki-Text
421
- def <<( input )
422
- inputlist, lineoffset = get_input( input, @lineoffset )
423
- #The immediate parsing may help, when an error occurs.
424
- #The immediat parsing returns error messages with correct lineoffsets.
425
- #(On the other side, it may helt to see the @source itself)
426
- wiki2doc( inputlist.join("\n"), lineoffset ) if @options[:parsetest] == true
427
- @source.concat(inputlist)
428
- return self
429
- end
430
- #Prepare output for docgenerator.
431
- #
432
- #Attention! to_doc uses another logger then the wiki.
433
- #If it should be the same, it must be added at definition of the wiki.
434
- def to_doc( target, options = {} )
435
- o = set_option_defaults(options)
436
- o[:log].debug("enter to_doc for Wikitext #{self.inspect}") if o[:log].debug?
437
- @footnotegroups = {} #Avoid the multiple additions to groups (this makes parallel processing inpossible!)
438
- doc = wiki2doc( @source.join("\n") ) #return lists of element
439
- doc.to_doc(target, options )
440
- end #Wikitext.to_doc
441
-
442
- #
443
- #Method is called for wiki-structures like
444
- # [[key:value]]
445
- #This can be used to adapt the wiki for special usages.
446
- #
447
- #This is a inline replacement.
448
- #The return code is added at the location, where it is defined
449
- def wikidef( key, value )
450
- @log.warn("#{self.class}#wikidef #{key}: #{value} in line #{@lineno}" ) if log.warn?
451
- return value
452
- end
453
- #Include a picture
454
- # [[Bild:Dateiname|Zusatzinfos|Beschreibung]]
455
- #Zusatzinfos:
456
- # -left/right
457
- # -___px scale the pic. When used in combination with thumb, a pic "widht-picname) is searched.
458
- # -thumb (usefull in combination with href or width=50%)
459
- #figure_type:
460
- #The picture is framed by this value.
461
- #When you use :div, you can't make inline-Pics.
462
- #:span can be used also as float (HTML)
463
- #Correct LaTeX: figure (or not?
464
- def wiki_bild( picname, parameter, log, figure_type = :span)
465
- thumb = false #Use thumb instead
466
- href = false #make pic clickabe
467
- figure = element(figure_type, { :style => css_fig = CSS.new() }).cR
468
- css_img = CSS.new()
469
- option = { :src => picname, :style => css_img } #Options for img
470
- before_img = []
471
- after_img = []
472
-
473
- parameter.each{|p|
474
- case p
475
- when /href=(.*)/; href = $1
476
- when /alt=(.*)/; option[:alt] = $1
477
- when /imgclass=(.*)/; option[:class] = $1
478
- when /figureclass=(.*)/; figure[:class] << $1
479
- when /^class=(.*)/; option[:class] = $1 #old
480
- when 'left', 'right'
481
- css_fig[:float] = p
482
- when /aftertitle(=(.*))*/
483
- after_img << element(:br, { :clear => 'all' } ).cr
484
- after_img << $2
485
- when /beforetitle(=(.*))*/
486
- before_img << $2
487
- after_img << element(:br, { :clear => 'all' } ).cr
488
- when /thumb(=(.*))*/
489
- #Add a thumb in the text and link to picture
490
- thumb = true #look later for width-picname
491
- thumb = $2 if $2
492
- if File.exist?( @inputsource + picname ) and !href
493
- href = picname
494
- end
495
- when /\A\d*px\Z/ #size
496
- option[:width] = p
497
- when /(width)=(.*)/
498
- css_img[$1] = $2
499
- w = $2 #store it, $2 is replaced in next regex.
500
- case w
501
- when /100%/
502
- option[:width] = "\\textwidth"
503
- when /\A(\d+)%/
504
- option[:width] = "0.#{$1}\\textwidth"
505
- else
506
- option[:width] = w
507
- end
508
- when /(.*)=(.*)/
509
- css_img[$1] = $2
510
- else
511
- log.warn( "Wiki-Picture with unknown setting #{p}" ) if log.warn?
512
- end
513
- }
514
-
515
- bild = []
516
- bild = element(:a, {:href=>href }).cr if href
517
-
518
- figure << before_img if ! before_img.empty?
519
- figure << bild
520
- figure << after_img if ! after_img.empty?
521
-
522
- if thumb == true
523
- if File.exist?( "#{option[:width]}-#{option[:src]}" )
524
- thumb = "#{option[:width]}-#{option[:src]}"
525
- else
526
- thumb = picname
527
- end
528
- end
529
- option[:src] = thumb if thumb
530
-
531
- if /^(http|file|.:\/|\/)/ =~ option[:src]
532
- src = option[:src]
533
- else
534
- src = @inputsource + option[:src]
535
- end
536
- if /^http/ !~ src and ! File.exist?( (src).sub(%r{file:\/\/}, '') )
537
- log.warn( "Wikireg:bild: Picture #{option[:src]} not found (check from #{Dir.pwd} #{inputsource})" ) if log.warn?
538
- end
539
- if thumb and ! File.exist?( @inputsource + thumb )
540
- log.warn( "Wikireg:bild: Thumb #{thumb} not found (check from #{Dir.pwd} #{inputsource})" ) if log.warn?
541
- end
542
- if href and /^http:/!~ href and ! File.exist?( @inputsource + href )
543
- log.warn("Wikireg:bild: reference #{href} not found (check from #{Dir.pwd} #{inputsource})" ) if log.warn?
544
- #~ puts Dir.pwd
545
- #~ puts @inputsource.inspect
546
- #~ puts href
547
- #~ puts option[:src]
548
- #~ puts '-'*10
549
- end
550
-
551
- bild << element(:img, option )
552
- figure
553
- end #wiki_bild
554
-
555
- #
556
- #Analyses {{-Textmacros.
557
- #If it is redefined, but want to keep the standard method,
558
- #then you can call it via super in the else-branch of your case-command.
559
- def wiki_macro( key, value, log = @log )
560
- if value
561
- val = value.split('|')
562
- else
563
- val = []
564
- end
565
- case key
566
- when 'maketitle', 'author', 'title', 'date'
567
- val = val[0]
568
- return [
569
- element( key.to_sym,{},val ).cr,
570
- ]
571
- when 'Commons'
572
- return [
573
- element(:a, { :href => "http://commons.wikimedia.org/wiki/#{val[0]}" }, "Commons: #{val[0]}" ).cr,
574
- ]
575
- #~ when 'Wikibooks'
576
- #~ #fixme language?
577
- #~ return [
578
- #~ element(:a, { :href => "http://en.wikibooks.org/wiki/#{val[0]}" }, "Commons: #{val[0]}" ).cr,
579
- #~ ]
580
- when 'newline'
581
- if val.include?('clear')
582
- return element(:br, {:clear=>'all'})
583
- else
584
- return element(:br)
585
- end
586
- when 'dmoz'
587
- def dmoz_analyse(val)
588
- if val[1]
589
- catname = val[1]
590
- else
591
- catname = val[0].split(/\//).last.gsub(/_/, ' ')
592
- end
593
- cat = val[0].sub(%r{http://(www|editors)*.dmoz.org/}, '')
594
- cat << '/' if cat[-1,1] != '/'
595
- return cat, catname
596
- end
597
- cat, catname = dmoz_analyse(val)
598
- return [
599
- 'Weitere Links zum Thema ',
600
- element(:a, { :href => "http://dmoz.org/#{cat}" }, catname ),
601
- ' im Open Directory Project'
602
- ]
603
- when 'dmozed'
604
- #fixme: Umlaute
605
- cat, catname = dmoz_analyse(val)
606
- return [
607
- element(:a, { :href => "http://dmoz.org/#{cat}" }, catname ),
608
- ' ',
609
- element(:a, { :href => "http://editors.dmoz.org/editors/editcat.cgi?cat=#{cat}" },
610
- [ '(Edit)'])
611
- ]
612
- #footnotes|groupid
613
- when 'footnotes'
614
- #~ value = self.object_id if ! value
615
- value = Footnotegroup::DEFAULTGROUPID unless value
616
- return @footnotegroups[value]
617
- #footnote[groupid]
618
- when /footnote(\[(.*)\])*/
619
- groupid = $2 ? $2 : Footnotegroup::DEFAULTGROUPID
620
- if ! @footnotegroups[groupid]
621
- @footnotegroups[groupid] = Footnotegroup.new(groupid)
622
- end
623
- return [
624
- element(:footnote, { :group => @footnotegroups[groupid] }, self.inline(value, log) ),
625
- ]
626
- when 'html'
627
- return element(:htmlonly, {}, value )
628
- when 'rubycode', 'rubyvar' ##Pfui, eval
629
- log.warn( "#{self.class}#wiki_macro: eval in line #{@lineno} ('#{value}')" ) if log.warn?
630
- #~ return eval(value)
631
- return eval(value, binding, 'Wiki', @lineno)
632
- when 'verbatimfile'
633
- if File.exist?( val.first )
634
- return element(:verbatim,
635
- Hash[*val[1..-1].map{|v| kv = v.split(/=/); [kv[0].to_sym, kv[1]]}.flatten],
636
- File.read(val.first) )
637
- else
638
- log.warn( "#{self.class}#wiki_macro: File #{value} missing for verbatimfile in line #{@lineno}" ) if log.warn?
639
- end
640
- when 'filecontent'
641
- if File.exist?( val.first )
642
- text = File.read(val.first)
643
- #~ text.force_encoding(val[1] ) if val[1]
644
- return element(:div,
645
- Hash[*val[1..-1].map{|v| kv = v.split(/=/); [kv[0].to_sym, kv[1]]}.flatten],
646
- text )
647
- else
648
- log.error( "#{self.class}#wiki_macro: File #{value} missing for filecontent in line #{@lineno}" ) if log.error?
649
- end
650
- #A symbol. The corresponding element must be defined.
651
- when 'symbol'; return element(value.to_sym)
652
- when 'backslash'; return element(:backslash )
653
- when '^'; return element(:ensuremath, {}, element(:'^' ) )
654
- when '>'; return element(:gt)
655
- when '<'; return element(:lt)
656
- when '&'; return element(:'\&')
657
- when 'percent', '%'; return element(:percent )
658
- when 'rbrace'; return element(:rbrace )
659
- when '_'; return element(:underscore )
660
- when ' '; return element(:relax )
661
- when '...'; return element(:ldots )
662
- when 'lbrace'; return element(:lbrace )
663
- when 'tilde', 'sim'; return element(:sim )
664
- when 'math'; return element(:ensuremath,{}, value )
665
- #>>>requires privat/affiliate.rb
666
- when 'asin'
667
- return Amazon.new.asin_in_iframe( value ) if defined? JPC
668
- log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
669
- return ''
670
- when 'amazon' #~ {{amazon|produktlinie|keywords}}
671
- return Amazon.make_link(val) if defined? JPC
672
- log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
673
- return ''
674
- when 'jpc' #~ {{amazon|produktlinie|keywords}}
675
- return JPC.make_link(val) if defined? JPC
676
- log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
677
- return ''
678
- #<<<requires privat/affiliate.rb
679
- when 'fixme'
680
- log.info( "Fixme: #{value}" ) if log.info?
681
- return element(:comment, {}, [ 'Fixme: ', value ] )
682
- else
683
- log.error( "#{self.class}#wiki_macro Key '#{key}' unknown in line #{@lineno} ('#{value}')" ) if log.error?
684
- return value
685
- end
686
- end
687
-
688
-
689
- #Little structure for use in wiki2doc.
690
- Wiki_line = Struct.new('Wiki_line', :type, :content, :lineno, :indent, :add_info)
691
- #
692
- #Parse the text and creates the elements of it.
693
- #
694
- def wiki2doc( txt, lineoffset = 0, log = @log )
695
- (@wiki_inline_replacements ).each{|rule|
696
- if ! rule.is_a?(Wikireg)
697
- log.fatal( "Wikitext.wiki2doc: rule is no Wikireg #{rule.inspect}" ) if log.fatal?
698
- end
699
- }
700
-
701
- lines = []
702
- @lineno = lineoffset
703
- collector = nil #collect content for other application
704
- collectorline = nil #collect content for other application
705
-
706
- txt.each_line{|line|
707
-
708
- if line.gsub!( /#~.*/, '') #delete comments
709
- #skip processing, if the line is now empty.
710
- #Without this, empty paragraphs can be created.
711
- next if line == "\n"
712
- end
713
- @lineno += 1
714
-
715
- #if the content should be turned into new variant, do it here.
716
- if collector
717
- if /^<<</ =~ line #close the collector
718
- lines << Wiki_line.new(:collector, collector, collectorline )
719
- collector = nil
720
- else
721
- collector << line.chomp #collect content to collector
722
- end
723
- next
724
- end
725
- #Preparse. Detect line type and assign it
726
- case line.chomp
727
- #Example:
728
- #>>>structogramm{title;width;height}
729
- when /^>>>(.*)\{(.*)\}/
730
- args = []
731
- ctype = $1
732
- args = $2.split(/[;]/) if $2
733
- collector = WikiCollector.create(ctype, args )
734
- collectorline = @lineno
735
- if ! collector
736
- log.error( "#{__FILE__}##{__LINE__}: Undefined Collector #{ctype.inspect} used. Take Array instead (line #{@lineno})" ) if log.error?
737
- collector = []
738
- end
739
- #===[key]Titel===
740
- when /\A(=+)(?:\[(.*?)\])?(.+?)(=+)\s*/ #:h1, :h2, :h3, :h4, :h5, :h6
741
- #~ puts $1, $2, $3
742
- if $1.size != $4.size
743
- log.warn("#{__FILE__}: Heading problem #{$1} doesn't match <#{$3}> #{line.inspect}" ) if log.warn?
744
- end
745
- #Level starts with ==
746
- # =title= is not supported.
747
- h_level = "h#{$1.size - 1}".to_sym
748
- lines << Wiki_line.new(h_level, self.inline($3, log), @lineno, nil, $2)
749
- when /^\s*$/ #empty line
750
- lines << Wiki_line.new(:p, nil, @lineno)
751
- when /^((?:\*|\#)+)(\s*)/ #:li
752
- lines << Wiki_line.new(:li, self.inline($~.post_match, log), @lineno, $2.size, $1)
753
- #Experiment for items in description
754
- #~ when /^(:)?((?:\*|\#)+)(\s*)/ #:li
755
- #~ puts '>' * 15
756
- #~ puts line.inspect
757
- #~ puts $1.inspect
758
- #~ puts $2.inspect
759
- #~ puts $3.inspect
760
- #~ puts '<' * 15
761
- #~ lines << Wiki_line.new(:li, self.inline($~.post_match, log), @lineno, $3.size, $2)
762
- when /^;(\s*)/ #:dt
763
- lines << Wiki_line.new(:dt, self.inline($~.post_match, log), @lineno, $1.size)
764
- when /^:(\s*)/ #:dd
765
- lastline = lines.last
766
- if ! lastline
767
- log.warn( "#{__FILE__}: Use ':' at start of wiki text. #{@lineno}" ) if log.warn?
768
- lastline = Wiki_line.new() #Avoid error with method type
769
- end
770
- #If there was already an indent before, loo back.
771
- if lastline.type == :indent
772
- #find first line before indent
773
- lines.reverse.each{|line|
774
- lastline = line
775
- break if lastline.type != :indent
776
- }
777
- end
778
- if [:dt,:dd].include?(lastline.type)
779
- lines << Wiki_line.new(:dd, self.inline($~.post_match, log), @lineno, $1.size)
780
- else #-> quote
781
- lines << Wiki_line.new(:quote, self.inline($~.post_match, log), @lineno, $1.size)
782
- end
783
- when /^----$/ #:hr #line
784
- lines << Wiki_line.new(:hr,nil,@lineno)
785
- when /^(\s+)/ #:indent #can be: continuation of a list or a verbatim
786
- lines << Wiki_line.new(:indent, $~.post_match, @lineno, $1.size)
787
- when /^\{\|/ #:tab
788
- lines << Wiki_line.new(:tabular,$~.post_match,@lineno)
789
- when /^\|\}/ #:tabend
790
- lines << Wiki_line.new(:tabular_end,$~.post_match,@lineno)
791
- when /^\|-/ #:tabrow
792
- lines << Wiki_line.new(:tabular_row,$~.post_match,@lineno)
793
- when /^\|(.*\|)*(.*?)\s*$/ #:tabcell
794
- par = $1
795
- txt = $2
796
- #if the text contains macros with | there is a bit confusion,
797
- #what is a parameter of the cell and whats part of the macro.
798
- #
799
- #Solution:
800
- #Define the end of cell parameters with ||
801
- if par and par =~ /\|\|/
802
- par = $~.pre_match #parameters only before ||
803
- txt = $~.post_match + txt #txt all after ||
804
- end
805
- lines << Wiki_line.new(:tabular_cell ,self.inline(txt, log),@lineno,nil,par)
806
- else
807
- #~ puts "??\tUnknown line (#{__FILE__} line #{__LINE__})"
808
- #~ puts "??\tUnknown line: #{line.inspect}"
809
- #lines << Wiki_line.new(:text, self.inline(line, log), @lineno)
810
- #Insert space at end of line, but before \n.
811
- #Without, a line break results in HTML-Text without space between flow text
812
- lines << Wiki_line.new(:text, self.inline("#{line.chomp} \n", log), @lineno)
813
- end
814
- } #txt.each |line|
815
-
816
- if collector
817
- log.error( "#{__FILE__}##{__LINE__}: Content Collector not closed (start in line #{collectorline}" ) if log.error?
818
- end
819
-
820
- elements = [] #main container
821
- lists ={} #lists.
822
- lines.each{|line|
823
- case line.type
824
- when :h1, :h2, :h3, :h4, :h5, :h6
825
- elements << element( line.type,{},line.content).cr
826
- if line.add_info
827
- elements.last[:id] << line.add_info
828
- end
829
- #~ elements << element( line.type,{},self.inline(line.content, log)).cr
830
- when :p #new paragraph
831
- #fixme: how to detect new paragraph or continuation of item/pre/verbatim
832
- if ! elements.last #Start wiki
833
- elements << element( :p ).cr
834
- elsif elements.last.is_a?(:p) and elements.last.content.empty?
835
- #There is already an empty new par, we can use it.
836
- elsif elements.last.is_a?(Lists::ListEnvironment)
837
- #The next indent decides, if we need a new paragraph or continue in the last item.
838
- elements.last.content.last << nil #Add neutral flag for new paragraph
839
- else
840
- elements << element( :p ).cr
841
- end
842
- when :hr
843
- elements << element( :hr ).cr
844
- when :text
845
- if ! elements.last or ! elements.last.is_a?(:p)
846
- elements << element( :p ).cr
847
- end
848
- elements.last << line.content
849
- when :li
850
- if ! elements.last.is_a?(Lists::ListEnvironment) #ListEnvironment can be also a :dl
851
- lists = {} #delete all lists to start fresh
852
- end
853
- #~ puts "-----#{line.add_info}\t#{line.content.inspect}\t#{lists.keys.inspect}"
854
- listtype = ''
855
- loclist = {} #temporary list of lists. will be stored in 'lists'
856
- 1.upto(line.add_info.size){|level|
857
- leveltyp = line.add_info[0..level-1] #typ of listhirarchie
858
- if lists[leveltyp] #list already defined
859
- loclist[leveltyp] = lists[leveltyp]
860
- loclist[leveltyp] << element(:li,{}, line.content).cR if leveltyp == line.add_info
861
- else #create new list
862
- case line.add_info[-1,1]
863
- when '*'
864
- list_type = :ul
865
- when '#'
866
- list_type = :ol
867
- else
868
- log.error( "#{self.class}#wiki2doc: Unknown list type #{v}" ) if log.error?
869
- end
870
- loclist[leveltyp] = element( list_type ).CR
871
- #include first item in list
872
- loclist[leveltyp] << li = element(:li,{}).cR #add first item line
873
- li << line.content if leveltyp == line.add_info #add content to item line
874
- #Include list
875
- if level == 1 #Add first list to element-list
876
- elements << loclist[leveltyp]
877
- elsif leveltyp == line.add_info #add new list to previous list
878
- loclist[line.add_info[0,level-1]].content.last << loclist[leveltyp]
879
- end
880
- end
881
- }
882
- #copy lists and delete all other lists (so we get level changes)
883
- lists = loclist
884
- when :dt
885
- #~ lists = {} #mixture dl and ul/ol not possible actual
886
- if ! elements.last.is_a?(:dl)
887
- elements << element(:dl).cR
888
- lists[':'] = elements.last
889
- end
890
- elements.last << element(:dt,{},line.content ).cr
891
- when :dd
892
- if ! elements.last.is_a?(:dl)
893
- log.warn( "#{self.class}#wiki2doc(#{line.lineno}: :dl without :dt (#{line.content.strip})" ) if log.warn?
894
- elements << element(:dl).cr
895
- end
896
- elements.last << element(:dd,{},line.content).cr
897
- when :quote
898
- if ! elements.last.is_a?(:quote)
899
- elements << element(:quote).cR
900
- end
901
- if line.content =~ /^\s*$/ #Empty line
902
- elements.last << element(:newline).cR
903
- else
904
- elements.last << line.content
905
- elements.last << ' '
906
- end
907
- when :indent
908
- #~ puts "#{self.class}#wiki2doc(#{line.lineno}: indent: #{line.indent}\t#{line.add_info}\t#{line.content}"
909
- #Check if the indent is part of a list item
910
- if elements.last.is_a?(Lists::ListEnvironment)
911
- lastlist = lists[lists.keys.max] #Get last (deepest) list
912
- lastitem = lastlist.content.last
913
-
914
- case lastitem.content.last
915
- when nil #new paragraph
916
- lastitem << element(:p, {}, self.inline(line.content, log)).cr
917
- when Element #add content to last element
918
- lastitem.content.last << self.inline(line.content, log)
919
- else #add content to item line
920
- lastitem << ' '
921
- lastitem << self.inline(line.content, log)
922
- end
923
- elsif elements.last.is_a?(:dl)
924
- lastitem << self.inline(line.content, log)
925
- elsif ! elements.last.is_a?(:pre)
926
- elements << element(:pre).cR
927
- end
928
- if elements.last.is_a?(:pre)
929
- elements.last << (' ' * (line.indent - 1 )) + line.content + "\n"
930
- end
931
- when :tabular
932
- if /longtable/ =~ line.content
933
- elements << tab = element(:longtable, {:style=>CSS.new()}).CR
934
- else
935
- elements << tab = element(:tabular, {:style=>CSS.new()}).CR
936
- end
937
- if line.content #options
938
- options = line.content.split('|')
939
- options.each{|opt|
940
- case opt
941
- when /columndescription\s*=\s*(.*)/
942
- tab[:columndescription] << $1.gsub(/!/, '|') #TeX-Format
943
- when /columns\s*=\s*(.*)/
944
- tab[:columns] << $1.to_i
945
- when /border\s*=\s*(.*)/
946
- tab[:border] << $1.to_i
947
- when /(.*)\s*=\s*(.*)/
948
- #~ puts "#{__FILE__}##{__LINE__}: #{opt}" if ! tab[:style].content.first
949
- tab[:style].content.first[$1] = $2
950
- else
951
- log.warn( "#{self.class}#wiki2doc(#{line.lineno}: options for table unknown: #{opt}" ) if log.warn?
952
- end
953
- }
954
- end
955
- #Add first row
956
- elements.last << element(:tr, {} ).cr
957
- when :tabular_end
958
- elements << nil
959
- when :tabular_row
960
- if ! elements.last.is_a?(:tabular)
961
- log.warn( "#{self.class}#wiki2doc(#{line.lineno}: Add row to non-tabular" ) if log.warn?
962
- end
963
- prev_row = elements.last.content.last
964
- rowcss = CSS.new()
965
- elements.last << element(:tr, { :style => rowcss } ).cr
966
- if line.content #options
967
- options = line.content.split('|')
968
- #~ puts options.inspect
969
- options.each{|opt|
970
- case opt
971
- when 'toprule'; prev_row.toprule
972
- when 'midrule'; prev_row.midrule
973
- when 'hline'; prev_row.hline
974
- when /(.+)=(.+)/ #CSS?
975
- rowcss[$1] = $2
976
- when /\A\s*\Z/ #empty option
977
- else
978
- log.warn( "#{self.class}#wiki2doc(#{line.lineno}): Unknown line option #{opt.inspect}" ) if log.warn?
979
- end
980
- }
981
- end
982
- when :tabular_cell
983
- cellcss = CSS.new()
984
- colspan = 1
985
- pos = 'c'
986
- if line.add_info #options
987
- #fixme: Tabelle mit verschiedenen Optionen??
988
- options = line.add_info.split('|')
989
- options.each{|opt|
990
- case opt
991
- when /colspan\s*=\s*(.*)/
992
- colspan = $1.to_i
993
- when /pos\s*=\s*(.*)/
994
- pos = $1
995
- when /(.*?)\s*=\s*(.*)/
996
- cellcss[$1] = $2
997
- else
998
- log.warn( "options for table cell unknown: #{opt} (line #{line.lineno})" ) if log.warn?
999
- end
1000
- }
1001
- end
1002
- row = elements.last.content.last
1003
- if colspan > 1
1004
- row << element(:multicolumn, { :colspan => colspan, :style => cellcss, :pos => pos }, line.content).cr
1005
- else
1006
- row << element(:td, { :style => cellcss }, line.content).cr
1007
- end
1008
- when :collector
1009
- #~ if line.content.respond_to? :to_doc
1010
- #~ elements << line.content.to_element
1011
- #~ else
1012
- elements << line.content
1013
- #~ end
1014
- else
1015
- log.error("#{self.class}#wiki2doc(#{line.lineno}): New line type #{line.type.inspect} (#{line.content.inspect})" ) if log.error?
1016
- elements << element( line.type,{},self.inline(line.content, log)).cr
1017
- end
1018
- }
1019
-
1020
- #Delete empty paragraphs
1021
- elements.map!{|element|
1022
- if element.is_a?(:p) and element.content.empty?
1023
- nil #Delete empty paragraphs
1024
- else
1025
- element
1026
- end
1027
- }
1028
-
1029
- return elements
1030
- end #wiki2doc
1031
- #Translate text for inline tags.
1032
- def inline( intext, log, subs = @wiki_inline_replacements )
1033
- return Wikitext.inline( intext, log, subs, self )
1034
- end
1035
- #Translate text for inline tags.
1036
- #
1037
- #This can also be used from "outside" to translate single lines.
1038
- #To keep the same environment if called via an object, the object is given in oo.
1039
- def self.inline( intext, log, subs = WIKI_INLINE_REPLACEMENTS,
1040
- oo = self)
1041
- subs.each{|rule|
1042
- if rule.regex =~ intext
1043
- if rule.proc.is_a?( Proc )
1044
- return rule.proc.call($~, oo, log)
1045
- else
1046
- return rule.proc
1047
- end
1048
- end
1049
- }
1050
- return intext
1051
- end
1052
- #Obsolete method -don't use.
1053
- def toccss()
1054
- @log.error("Usage of obsolete toccss, use CSS_collection[:toc]") if @log.error?
1055
- return CSS_collection[:toc].style.to_html
1056
- end
1057
- #Make a table of contents
1058
- #
1059
- #Options:
1060
- #- listtype: :ul or :ol
1061
- #- addlinks: Set label for each header.
1062
- def toc( i_options = {} )
1063
- options = {
1064
- :listtype => :ul,
1065
- :level => 4,
1066
- :startlevel => 1,
1067
- :addlinks => true,
1068
- :tocclass => 'toc',
1069
- }.update(i_options)
1070
- uls = {}
1071
- uls[options[:startlevel]] = element(options[:listtype])
1072
- @source.flatten.each{|line|
1073
- if /\A(=+)(?:\[(.*?)\])?(.+?)(=+)\s*\z/ =~ line #:h1, :h2, :h3, :h4, :h5, :h6
1074
- level = $1.size.to_i - 1
1075
- anker = $2
1076
- titletext = $3
1077
- #Entfernen von Wiki-Links im Titel.
1078
- titletext.sub!(/\[\..*\s+(.*)\]/, '\1')
1079
-
1080
- next if level > options[:level]
1081
- if level < options[:startlevel]
1082
- log.warn( "#{self.class}#toc: TOC starts not at #{options[:startlevel]}, but level #{level} defined at #{line}" ) if log.warn?
1083
- next
1084
- end
1085
- if anker
1086
- titel = element(:a, {:href=>"##{anker}"}, titletext)
1087
- elsif options[:addlinks]
1088
- #Build label for toc
1089
- toclabel = []
1090
- 1.upto(level){|i|
1091
- if uls[i]
1092
- if i == level #same level - add one for actual element
1093
- toclabel << uls[i].content.size + 1
1094
- else #Previous level - use size
1095
- toclabel << uls[i].content.size
1096
- end
1097
- else #First element on this level
1098
- toclabel << 1
1099
- end
1100
- }
1101
- #~ puts "toclabel <#{$3}>\t#{toclabel.inspect}\t#{toclabel.join('-')}"
1102
- titel = element(:a, {:href=>"##{toclabel.join('-')}"}, titletext)
1103
- line.sub!(/^(=+)/, "\\1[#{toclabel.join('-')}]")
1104
- else
1105
- titel = titletext
1106
- end
1107
- options[:startlevel].upto(6){|i|
1108
- #Create 'higher' sections (indicates a problem in the text)
1109
- if i < level
1110
- if ! uls[i]
1111
- log.warn( "#{self.class}#toc: Sectioning jumps over level #{i} at #{line}" ) if log.warn?
1112
- uls[i-1].content.last << uls[i] = element(options[:listtype] ).Cr if uls[i-1]
1113
- end
1114
- if ! uls[i].content.last
1115
- uls[i] << element(:li,{}, '' ).cr
1116
- end
1117
- elsif i == level
1118
- #Create new level if necessary
1119
- if ! uls[level]
1120
- uls[level-1].content.last << uls[level] = element(options[:listtype] ).Cr
1121
- end
1122
- #Add section title
1123
- uls[level] << element(:li,{}, titel ).cr
1124
- else
1125
- #delete lower levels of previous topic
1126
- uls[i] = nil
1127
- end
1128
- }
1129
- end
1130
- }
1131
- return element(:div, { :class => options[:tocclass] }, uls[options[:startlevel]] ).CR
1132
- end
1133
- def footnotes()
1134
- footnotes = Footnotegroup[self.object_id]
1135
- return footnotes
1136
- end
1137
- end
1138
-
1139
- #Wiki-Collector is a hash with collectors.
1140
- #
1141
- #A WikiCollector give you the possibility to define
1142
- #'customized exits' in the wiki code.
1143
- #
1144
- #Usage example: see code2structogramm
1145
- class WikiCollector
1146
- @@variants = {}
1147
- #Add a new collector type.
1148
- #
1149
- #Each collector must implement the following methods:
1150
- #-new without parameters.
1151
- #-<< get lines of wiki-source
1152
- #-to_doc return the result
1153
- #See the two examples
1154
- #- WikiCollectorHTML
1155
- #- WikiCollectorFilecontent
1156
- #
1157
- def self.add(key, classtype)
1158
- if @@variants[key]
1159
- puts "WikiCollector: Double assignment #{key.inspect}, #{classtype}"
1160
- end
1161
- if ! classtype.method_defined?(:'<<')
1162
- puts "WikiCollector: Collector <#{key.inspect}> doesn't support <<"
1163
- return false
1164
- end
1165
- if ! classtype.method_defined?(:to_doc)
1166
- puts "WikiCollector: Collector <#{key.inspect}> doesn't support to_doc"
1167
- return false
1168
- end
1169
- @@variants[key] = classtype
1170
- end
1171
- #Get an instance of the requested collector.
1172
- def self.create(key, arguments = [] )
1173
- #~ puts "WikiCollector: request #{key.inspect}"
1174
- if @@variants[key.to_sym]
1175
- begin
1176
- return @@variants[key.to_sym].new(*arguments)
1177
- rescue ArgumentError
1178
- puts "WikiCollector: Collector <#{key.inspect}> get wrong parameters"
1179
- return false
1180
- end
1181
- else
1182
- puts "WikiCollector: Collector <#{key}> not found (available: #{@@variants.keys.inspect})"
1183
- return nil
1184
- end
1185
- end
1186
- end #WikiCollector
1187
- =begin rdoc
1188
- A little collector of "Plain-HTML".
1189
-
1190
- Can be called in a Wiki with:
1191
- >>>html{}
1192
- here you can add plain HTML
1193
- <<<
1194
- =end
1195
- class WikiCollectorHTML < Element
1196
- #Return the content 'as is', but only for HTML
1197
- def to_doc( target, options = {} )
1198
- case target
1199
- when :html
1200
- @content.join("\n")
1201
- else
1202
- ''
1203
- end
1204
- #~ return element(:onlyhtml,{},@htmlcode).restrict_to(:html).to_doc(target)
1205
- end
1206
- #~ def to_html()
1207
- #~ return @htmlcode
1208
- #~ end
1209
- #~ def to_latex(); ''; end
1210
- #~ def to_wiki(); ''; end
1211
- #~ def to_text(); ''; end
1212
- end
1213
- WikiCollector.add(:html, WikiCollectorHTML )
1214
- end #module Wikimedia
1215
- end #module Docgenerator
1216
-
1217
-
1218
- if __FILE__ == $0
1219
-
1220
- puts 'Use the unit test for complete test'
1221
-
1222
- puts Wikitext.help
1223
- puts Wikitext.help(:img)
1224
- puts Wikitext.help(:tab)
1225
-
1226
- #~ wiki = Wikitext.new(:content => <<wiki
1227
- #~ There are normal footnotes{{footnote|Like this one}}. But:
1228
- #~ Here is a footnote in group 1{{footnote[group1]some remarks}}, and
1229
- #~ a second footnote{{footnote[group1]more remarks}}.
1230
- #~ In another group{{footnote[group2]Each group gets a name}}, we can define further remarks.
1231
-
1232
- #~ ----
1233
- #~ Normal Footnotes:
1234
- #~ {{footnotes}}
1235
- #~ ----
1236
- #~ Footnote group 1:
1237
- #~ {{footnotes|group1}}
1238
- #~ ----
1239
- #~ Footnote group 2:
1240
- #~ {{footnotes|group2}}
1241
- #~ wiki
1242
- #~ )
1243
- wiki = Wikitext.new(:content => <<wiki
1244
- vorher
1245
-
1246
- nachher
1247
- nachher2
1248
-
1249
- ==test==
1250
- drei
1251
- wiki
1252
- )
1253
- puts '---------------------'
1254
-
1255
-
1256
- #~ puts wiki.toc.inspect
1257
- #~ puts wiki.toc.to_html
1258
- #~ puts wiki.toc.to_wiki
1259
- #~ puts '--------HTML-------------'
1260
- puts wiki.to_html
1261
- #~ puts '--------HTML-------------'
1262
- #~ puts wiki.to_html
1263
- #~ puts '--------LaTeX-------------'
1264
- #~ puts wiki.to_latex
1265
- #~ puts '--------Wiki-------------'
1266
- #~ puts wiki.to_wiki
1267
- #~ puts '--------Text-------------'
1268
- #~ puts wiki.to_text
1269
-
1270
- doc = Document.new()
1271
- doc.body << wiki
1272
- doc.save('test.html')
1273
- end
1274
-
1275
-
1276
- __END__