docgenerator 1.2.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (209) hide show
  1. data/build_test_and_doc.rb +505 -0
  2. data/examples/creole_example.rb +82 -0
  3. data/examples/creole_example_footnote.rb +67 -0
  4. data/examples/creole_example_placeholder.rb +77 -0
  5. data/examples/creole_example_rail.rb +154 -0
  6. data/examples/creole_example_rubycode.rb +144 -0
  7. data/examples/creole_example_struktex.rb +169 -0
  8. data/examples/docgenerator_example.rb +1 -1
  9. data/examples/docgenerator_example_footnote.rb +1 -0
  10. data/examples/docgenerator_example_list.rb +3 -0
  11. data/examples/docgenerator_example_restrictions.rb +1 -1
  12. data/examples/docgenerator_example_tabular.rb +1 -1
  13. data/examples/docgenerator_example_tripfalls.rb +2 -2
  14. data/examples/results/readme +2 -1
  15. data/examples/wiki2docgenerator_example.rb +61 -32
  16. data/lib/creole/creole2doc.rb +57 -58
  17. data/lib/creole/creole_characters.rb +56 -0
  18. data/lib/creole/creole_inclusion_and_plugins.rb +59 -284
  19. data/lib/creole/creole_inclusions.rb +142 -0
  20. data/lib/creole/creole_placeholder.rb +57 -23
  21. data/lib/creole/creole_plugins.rb +198 -0
  22. data/lib/creole/creole_tabular.rb +16 -8
  23. data/lib/creole/plugins/rail.rb +182 -0
  24. data/lib/creole/plugins/rubycode4creole.rb +136 -0
  25. data/lib/creole/plugins/struktex.rb +59 -0
  26. data/lib/creole/plugins/todonotes.rb +70 -0
  27. data/lib/docgenerator.rb +161 -71
  28. data/lib/docgenerator/attribute.rb +189 -156
  29. data/lib/docgenerator/characters.rb +824 -267
  30. data/lib/docgenerator/compatibility_v1.rb +249 -0
  31. data/lib/docgenerator/css.rb +53 -32
  32. data/lib/docgenerator/document.rb +119 -56
  33. data/lib/docgenerator/element.rb +304 -351
  34. data/lib/docgenerator/element_meta.rb +303 -0
  35. data/lib/docgenerator/elements.rb +1112 -481
  36. data/lib/docgenerator/environments.rb +153 -62
  37. data/lib/docgenerator/footnote.rb +30 -9
  38. data/lib/docgenerator/lists.rb +71 -47
  39. data/lib/docgenerator/packages/attachfile.rb +136 -0
  40. data/lib/{packages/docgenerator_caption.rb → docgenerator/packages/caption.rb} +28 -19
  41. data/lib/docgenerator/packages/hyperref.rb +194 -0
  42. data/lib/docgenerator/packages/listings.rb +179 -0
  43. data/lib/docgenerator/packages/pdfpages.rb +43 -0
  44. data/lib/docgenerator/packages/rubycode4doc.rb +227 -0
  45. data/lib/{packages/docgenerator_scrlettr2.rb → docgenerator/packages/scrlettr2.rb} +25 -16
  46. data/lib/docgenerator/packages/scrpage2.rb +410 -0
  47. data/lib/docgenerator/packages/struktex.rb +447 -0
  48. data/lib/docgenerator/packages/todonotes.rb +85 -0
  49. data/lib/{packages/docgenerator_url.rb → docgenerator/packages/url.rb} +7 -6
  50. data/lib/docgenerator/sections.rb +257 -83
  51. data/lib/docgenerator/standard.rb +19 -11
  52. data/lib/docgenerator/tabular.rb +234 -118
  53. data/lib/{templates → docgenerator/templates}/docgenerator_template.rb +52 -44
  54. data/lib/{templates → docgenerator/templates}/docgenerator_template.yaml +0 -0
  55. data/lib/{templates → docgenerator/templates}/docgenerator_template_css.rb +22 -16
  56. data/lib/wiki2doc/plugins/rubycode4wiki.rb +53 -0
  57. data/lib/wiki2doc/plugins/struktex.rb +12 -0
  58. data/lib/wiki2doc/wiki2docgenerator.rb +39 -38
  59. data/lib/wiki2doc/wikimedia_document.rb +24 -0
  60. data/manpage_elements.rb +10411 -0
  61. data/readme.rd +34 -24
  62. data/unittest/creole_testtext.creole +11 -0
  63. data/unittest/expected/test_document_usepackage_undefined.log +2 -2
  64. data/unittest/expected/test_runtex.stdout +0 -1
  65. data/unittest/expected/test_runtex_2.stdout +0 -1
  66. data/unittest/expected/toc_css.css +3 -2
  67. data/unittest/expected_creole/test_creole_characters_all.creole +28 -0
  68. data/unittest/expected_creole/test_creole_characters_all.html +15 -15
  69. data/unittest/expected_creole/test_creole_characters_all.latex +15 -15
  70. data/unittest/expected_creole/test_creole_footnotes_groupid.html +15 -0
  71. data/unittest/expected_creole/test_creole_links_file.html +2 -2
  72. data/unittest/expected_creole/test_creole_links_file.latex +2 -2
  73. data/unittest/expected_creole/test_creole_links_file.text +2 -2
  74. data/unittest/expected_creole/test_creole_picture_link.html +1 -1
  75. data/unittest/expected_creole_rail/test_rail_creole_object.tex +33 -0
  76. data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +40 -0
  77. data/unittest/expected_rubycode4doc/creole_complete.html +26 -0
  78. data/unittest/expected_rubycode4doc/creole_complete.tex +40 -0
  79. data/unittest/expected_rubycode4doc/creole_in_tab.html +4 -0
  80. data/unittest/expected_rubycode4doc/creole_in_tab.tex +6 -0
  81. data/unittest/expected_rubycode4doc/creole_inline_ruby.html +7 -0
  82. data/unittest/expected_rubycode4doc/creole_output.html +2 -0
  83. data/unittest/expected_rubycode4doc/creole_output.tex +4 -0
  84. data/unittest/expected_rubycode4doc/creole_rubycode.html +1 -0
  85. data/unittest/expected_rubycode4doc/creole_rubycode.tex +3 -0
  86. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +1 -0
  87. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +3 -0
  88. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +3 -0
  89. data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +5 -0
  90. data/unittest/expected_rubycode4doc/wiki_1.html +8 -0
  91. data/unittest/expected_rubycode4doc/wiki_2.html +8 -0
  92. data/unittest/expected_rubycode4doc/wiki_3.html +9 -0
  93. data/unittest/expected_rubycode4doc/wiki_immediate_1.html +5 -0
  94. data/unittest/expected_rubycode4doc/wiki_immediate_2.html +5 -0
  95. data/unittest/expected_rubycode4doc/wiki_immediate_3.html +8 -0
  96. data/unittest/expected_rubycode4doc/wiki_immediate_full.html +21 -0
  97. data/unittest/expected_struktex/test_struktex_krug.creole +15 -0
  98. data/unittest/expected_struktex/test_struktex_krug.tex +19 -0
  99. data/unittest/expected_struktex/test_struktex_krug.wiki +15 -0
  100. data/unittest/expected_struktex/test_struktex_statement.creole +7 -0
  101. data/unittest/expected_struktex/test_struktex_statement.tex +9 -0
  102. data/unittest/expected_struktex/test_struktex_statement.wiki +7 -0
  103. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.html +0 -0
  104. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.latex +0 -0
  105. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.text +0 -0
  106. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.wiki +0 -0
  107. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.html +1 -1
  108. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.latex +1 -1
  109. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.text +1 -1
  110. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.wiki +1 -1
  111. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.html +0 -0
  112. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.latex +0 -0
  113. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.text +0 -0
  114. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.wiki +0 -0
  115. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_2.html +0 -0
  116. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_groupid.html +0 -0
  117. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.html +0 -0
  118. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.latex +0 -0
  119. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.text +0 -0
  120. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.wiki +0 -0
  121. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.html +0 -0
  122. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.latex +0 -0
  123. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.text +0 -0
  124. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.wiki +0 -0
  125. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_label.html +0 -0
  126. data/unittest/expected_wikimedia/test_wiki_link.html +8 -0
  127. data/unittest/expected_wikimedia/test_wiki_link.latex +17 -0
  128. data/unittest/expected_wikimedia/test_wiki_link.wiki +11 -0
  129. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.html +0 -0
  130. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.latex +0 -0
  131. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.text +0 -0
  132. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.wiki +0 -0
  133. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.html +0 -0
  134. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.latex +0 -0
  135. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.text +0 -0
  136. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.wiki +0 -0
  137. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.html +0 -0
  138. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.latex +0 -0
  139. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.text +0 -0
  140. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.wiki +0 -0
  141. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.html +0 -0
  142. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.latex +0 -0
  143. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.text +0 -0
  144. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.wiki +0 -0
  145. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.html +0 -0
  146. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.latex +0 -0
  147. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.text +0 -0
  148. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.wiki +0 -0
  149. data/unittest/expected_wikimedia/test_wiki_picture.html +55 -0
  150. data/unittest/expected_wikimedia/test_wiki_picture.latex +76 -0
  151. data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +5 -0
  152. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.html +0 -0
  153. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.latex +0 -0
  154. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.wiki +0 -0
  155. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.html +0 -0
  156. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.latex +0 -0
  157. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.text +0 -0
  158. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.wiki +0 -0
  159. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.html +0 -0
  160. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.latex +0 -0
  161. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.text +0 -0
  162. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.wiki +0 -0
  163. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.html +0 -0
  164. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.latex +0 -0
  165. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.text +0 -0
  166. data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.wiki +0 -0
  167. data/unittest/{unittest_creole2doc.rb → unittest_creole.rb} +385 -476
  168. data/unittest/unittest_creole_placeholders.rb +272 -0
  169. data/unittest/unittest_creole_plugin_rail.rb +147 -0
  170. data/unittest/unittest_docgenerator.rb +206 -332
  171. data/unittest/unittest_docgenerator_characters.rb +650 -0
  172. data/unittest/unittest_docgenerator_runtex.rb +48 -20
  173. data/unittest/unittest_packages_struktex.rb +187 -0
  174. data/unittest/unittest_rubycode4doc.rb +275 -0
  175. data/unittest/unittest_wikimedia.rb +479 -0
  176. metadata +245 -172
  177. data/examples/results_expected/docgenerator_example.html +0 -39
  178. data/examples/results_expected/docgenerator_example.pdf +0 -0
  179. data/examples/results_expected/docgenerator_example.tex +0 -56
  180. data/examples/results_expected/docgenerator_example_footnote.html +0 -40
  181. data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
  182. data/examples/results_expected/docgenerator_example_footnote.tex +0 -50
  183. data/examples/results_expected/docgenerator_example_list.html +0 -18
  184. data/examples/results_expected/docgenerator_example_list.pdf +0 -0
  185. data/examples/results_expected/docgenerator_example_list.tex +0 -46
  186. data/examples/results_expected/docgenerator_example_restrictions.html +0 -22
  187. data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
  188. data/examples/results_expected/docgenerator_example_restrictions.tex +0 -31
  189. data/examples/results_expected/docgenerator_example_tabular.html +0 -37
  190. data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
  191. data/examples/results_expected/docgenerator_example_tabular.tex +0 -41
  192. data/examples/results_expected/docgenerator_example_tripfalls.html +0 -27
  193. data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
  194. data/examples/results_expected/docgenerator_example_tripfalls.tex +0 -31
  195. data/lib/packages/docgenerator_attachfile.rb +0 -71
  196. data/lib/packages/docgenerator_hyperref.rb +0 -109
  197. data/lib/packages/docgenerator_listings.rb +0 -103
  198. data/lib/packages/docgenerator_pdfpages.rb +0 -24
  199. data/lib/packages/docgenerator_scrpage2.rb +0 -172
  200. data/self_docgenerator.rb +0 -163
  201. data/unittest/expected_wiki/test_wiki_link.html +0 -8
  202. data/unittest/expected_wiki/test_wiki_link.latex +0 -17
  203. data/unittest/expected_wiki/test_wiki_link.wiki +0 -11
  204. data/unittest/expected_wiki/test_wiki_picture.html +0 -55
  205. data/unittest/expected_wiki/test_wiki_picture.latex +0 -76
  206. data/unittest/expected_wiki/test_wiki_picture_thumb.html +0 -5
  207. data/unittest/test_rakefile_docgenerator.rb +0 -43
  208. data/unittest/unittest_versions.rb +0 -44
  209. data/unittest/unittest_wiki2doc.rb +0 -464
@@ -0,0 +1,479 @@
1
+ # encoding: ASCII-8BIT
2
+ require 'test/unit'
3
+ require 'more_unit_test/assert_equal_filecontent.rb'
4
+
5
+
6
+ =begin
7
+ To make it better:
8
+
9
+ make more testclasses and create test data in setup.
10
+ eiach test in its own method.
11
+
12
+ =end
13
+ if $0 == __FILE__
14
+ $:.unshift("../lib")
15
+ #~ $:.unshift("../lib_privat")
16
+ end
17
+ require 'wiki2doc/wiki2docgenerator'
18
+ include Docgenerator
19
+ include Wikimedia
20
+ #~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
21
+
22
+ $fixmes = []
23
+
24
+ END { puts $fixmes }
25
+
26
+ class Testcase < Test::Unit::TestCase
27
+ def setup()
28
+ #Avoid warnings about missing logger in to_doc
29
+ @opt = { :log => DOCGENERATOR_DEFAULT_LOGGER }
30
+ end
31
+ def test_wiki()
32
+ wiki = Wikitext.new(:content => <<wiki
33
+ ==Titel 1==
34
+ Text
35
+ ===Titel 2===
36
+ Text unter Titel 2
37
+ wiki
38
+ )
39
+ assert_equal_filecontent( "expected_wikimedia/test_wiki.html", wiki.to_doc(:html, @opt))
40
+ assert_equal_filecontent( "expected_wikimedia/test_wiki.latex", wiki.to_doc(:latex, @opt))
41
+ assert_equal_filecontent( "expected_wikimedia/test_wiki.wiki", wiki.to_doc(:wiki, @opt))
42
+ assert_equal_filecontent( "expected_wikimedia/test_wiki.text", wiki.to_doc(:text, @opt))
43
+ end
44
+ #
45
+ #Including the definition of a label tor the toc.
46
+ def test_wiki_toc()
47
+ wiki = Wikitext.new(:content => <<wiki
48
+ ==Titel 1==
49
+ Text
50
+ ===Titel 2===
51
+ Text unter Titel 2
52
+ ===[2b]Titel 2b===
53
+ Text unter Titel 2b
54
+ wiki
55
+ )
56
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.html", wiki.to_doc(:html, @opt))
57
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.latex", wiki.to_doc(:latex, @opt))
58
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.wiki", wiki.to_doc(:wiki, @opt))
59
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.text", wiki.to_doc(:text, @opt))
60
+ end
61
+ def test_wiki_inline()
62
+ wiki = Wikitext.new(:content => <<wiki
63
+ Inline-Tags ''kursiv'', '''fett''', ''''kursiv und fett''''
64
+
65
+ ''kursiv'',
66
+ '''fett''',
67
+ ''''kursiv und fett''''
68
+ wiki
69
+ )
70
+ #fixme tex unklar. wie zwei dd-tags in tex nachbilden?
71
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.html", wiki.to_doc(:html, @opt))
72
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.latex", wiki.to_doc(:latex, @opt))
73
+ #~ bug! fixme
74
+ $fixmes << 'inline 2 wiki'
75
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.wiki", wiki.to_doc(:wiki))
76
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.text", wiki.to_doc(:text, @opt))
77
+ end
78
+
79
+ def test_wiki_textformatting()
80
+ #Clear in newline is used by HTML (needed to handle floats)
81
+ wiki = Wikitext.new(:content => <<wiki
82
+ vorher{{newline}}Nachher
83
+
84
+ vorher{{newline|clear}}Nachher
85
+ ----
86
+ Nach einer Trennlinie
87
+ wiki
88
+ )
89
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.html", wiki.to_doc(:html, @opt))
90
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.latex", wiki.to_doc(:latex, @opt))
91
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.wiki", wiki.to_doc(:wiki, @opt))
92
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.text", wiki.to_doc(:text, @opt))
93
+ end
94
+
95
+ def test_wiki_label()
96
+ wiki = Wikitext.new(:content => <<wiki
97
+ [[label:a]]
98
+
99
+ text text
100
+ [[#a|hier]]
101
+ [[#a|hier]]
102
+ wiki
103
+ )
104
+ #~ fixme: TeX href hyperlabel??
105
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_label.html", wiki.to_doc(:html, @opt))
106
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_label.latex", wiki.to_doc(:latex))
107
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_label.wiki", wiki.to_doc(:wiki)) #fixme
108
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_label.text", wiki.to_doc(:text))
109
+ end
110
+
111
+ def test_wiki_list_ul()
112
+ wiki = Wikitext.new(:content => <<wiki
113
+ Text before
114
+ *Listentry 1
115
+ *Listentry 2
116
+ **Listentry 2.1
117
+ **Listentry 2.2
118
+ *Listentry 3
119
+ Text afterwords
120
+ wiki
121
+ )
122
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.html", wiki.to_doc(:html, @opt))
123
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.latex", wiki.to_doc(:latex, @opt))
124
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.wiki", wiki.to_doc(:wiki, @opt))
125
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.text", wiki.to_doc(:text, @opt))
126
+ end
127
+ #It works fine here, but LaTeX will give you an error.
128
+ def test_wiki_list_ul_too_much()
129
+ wiki = Wikitext.new(:content => <<wiki
130
+ Text before
131
+ *Listentry 1
132
+ *Listentry 2
133
+ **Listentry 2.1
134
+ **Listentry 2.2
135
+ ***Listentry 2.2.1
136
+ ****Listentry 2.2.1.1
137
+ *****Listentry 2.2.1.1.1
138
+ *Listentry 3
139
+ Text afterwords
140
+ wiki
141
+ )
142
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.html", wiki.to_doc(:html, @opt))
143
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.latex", wiki.to_doc(:latex, @opt))
144
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.wiki", wiki.to_doc(:wiki, @opt))
145
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.text", wiki.to_doc(:text, @opt))
146
+ end
147
+ def test_wiki_list_ol()
148
+ wiki = Wikitext.new(:content => <<wiki
149
+ Text before
150
+ #Listentry 1
151
+ #Listentry 2
152
+ ##Listentry 2.1
153
+ ##Listentry 2.2
154
+ #Listentry 3
155
+ Text afterwords
156
+ wiki
157
+ )
158
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.html", wiki.to_doc(:html, @opt))
159
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.latex", wiki.to_doc(:latex, @opt))
160
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.wiki", wiki.to_doc(:wiki, @opt))
161
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.text", wiki.to_doc(:text, @opt))
162
+ end #ol
163
+
164
+ def test_wiki_list_ol_ul()
165
+ wiki = Wikitext.new(:content => <<wiki
166
+ Text before
167
+ #Listentry 1
168
+ #Listentry 2
169
+ #*Listentry 2.1
170
+ #*Listentry 2.2
171
+ #Listentry 3
172
+ Text afterwords
173
+ wiki
174
+ )
175
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.html", wiki.to_doc(:html, @opt))
176
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.latex", wiki.to_doc(:latex, @opt))
177
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.wiki", wiki.to_doc(:wiki, @opt))
178
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.text", wiki.to_doc(:text, @opt))
179
+ $fixmes << "nested lists/wiki: bug"
180
+ $fixmes << "nested lists/text: bug"
181
+ end
182
+
183
+ def test_wiki_list_ol_after_ul()
184
+ wiki = Wikitext.new(:content => <<wiki
185
+ Text before
186
+ *Listentry 1
187
+ #Listentry 2
188
+ Text afterwords
189
+ wiki
190
+ )
191
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.html", wiki.to_doc(:html, @opt))
192
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.latex", wiki.to_doc(:latex, @opt))
193
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.wiki", wiki.to_doc(:wiki, @opt))
194
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.text", wiki.to_doc(:text, @opt))
195
+ end
196
+
197
+ #Line breaks will be lost.
198
+ def test_wiki_ul_multiple_line()
199
+ wiki = Wikitext.new(:content => <<wiki
200
+ * vorher
201
+ * text
202
+ mehr text zum item
203
+ * nachher und vorher
204
+ * text
205
+ mehr text zum item
206
+
207
+ neuer Absatz im Item funktioniert auch.
208
+ * nachher
209
+ wiki
210
+ )
211
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.html", wiki.to_doc(:html, @opt))
212
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.latex", wiki.to_doc(:latex, @opt))
213
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.wiki", wiki.to_doc(:wiki, @opt))
214
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.text", wiki.to_doc(:text, @opt)) #fixme
215
+ end
216
+ def test_wiki_description()
217
+ wiki = Wikitext.new(:content => <<wiki
218
+ ;Something
219
+ :Now a long description of Something,
220
+ continued on a second line.
221
+ :Another entry
222
+ ;Something Else
223
+ :Definition of Something Else
224
+ wiki
225
+ )
226
+ #~ fixme - latex how to implement different <dd> values
227
+ # fixme UTF-fehler
228
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_description.html", wiki.to_doc(:html, @opt))
229
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_description.latex", wiki.to_doc(:latex, @opt))
230
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_description.wiki", wiki.to_doc(:wiki, @opt))
231
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_description.text", wiki.to_doc(:text, @opt))
232
+ end
233
+
234
+ #~ Die Syntax:
235
+ #~ *{| beginnt eine Tabelle. Hier k�nnen zus�tzliche Formatierungseigenschaften kommen.
236
+ #~ **Zumindest columns==__ sollte gesetzt sein
237
+ #~ *! beginnt eine neue Zelle einer Titelzeile
238
+ #~ *| beginnt eine neue Zelle
239
+ #~ *|format| z.B. rowspan...
240
+ #~ *|format|| Zwei || beenden die Parameter der Zelle.
241
+ #~ Dann sinnvoll, wenn im Text selbst ein | vorkommt
242
+ #~ (z.B. ein Macro verwendet wird)
243
+ #~ *|- trennt zwei Zeilen der Tabelle
244
+ #~ **hline: Zus�tzlicher Trennstrich �ber der Zeile
245
+ #~ **toprule, midrule, bottomrule: Zus�tzlicher Trennstrich �ber der Zeile (erfordert booktabs.sty)
246
+ #~ *|} beendet eine Tabelle
247
+
248
+
249
+ def mk_wiki_tab( columns, lines )
250
+ tab = [ "{|columns=#{columns.size}|columndescription=#{'c' * columns.size}" ]
251
+ tab << "|colspan=#{columns.size}|pos=c|Titel"
252
+ lines.each{|line|
253
+ tab << "|-"
254
+ columns.each{|column|
255
+ tab << "|#{line}#{column}"
256
+ }
257
+ }
258
+ tab << "|}"
259
+ return tab.join("\n")
260
+ end
261
+ def test_wiki_tab1()
262
+ wiki = Wikitext.new(:content => mk_wiki_tab(Array('A'..'D'), Array(1..5) ) )
263
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.html", wiki.to_doc(:html, @opt))
264
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.latex", wiki.to_doc(:latex, @opt))
265
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.wiki", wiki.to_doc(:wiki, @opt))
266
+ $fixmes << "text-output for tables"
267
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.text", wiki.to_doc(:text))
268
+ end
269
+
270
+ #With >>> you can call ''WikiCollector''
271
+ #This collector gets teh content between the start and <<<.
272
+ #
273
+ #Collectors must support the methods << and to_doc.
274
+ #
275
+ #One predefined collector is html. It takes the content as 'plain text'.
276
+ #
277
+ def test_wiki_html_code()
278
+ wiki = Wikitext.new(:content => <<wiki
279
+ Beispiel:
280
+ >>>html{}
281
+ <div style = "float: right; background-color: yellow">
282
+ <strong>Fett</strong>
283
+ <em>kursiv</em>
284
+ </div>
285
+ <<<
286
+ Ende Beispiel
287
+ wiki
288
+ )
289
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.html", wiki.to_doc(:html, @opt))
290
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.latex", wiki.to_doc(:latex, @opt))
291
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.wiki", wiki.to_doc(:wiki, @opt))
292
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.text", wiki.to_doc(:text, @opt))
293
+ end
294
+ #
295
+ #Add File as verbatimtext
296
+ def test_wiki_verbatimfile()
297
+ #
298
+ #This test uses the coding of the test itself.
299
+ #
300
+ wiki = Wikitext.new(:content => <<wiki
301
+ {{verbatimfile|#{__FILE__}}}
302
+ wiki
303
+ )
304
+
305
+ escaped_filecontent = File.read(__FILE__).gsub(/</, '&lt;').gsub(/>/, '&gt;')
306
+ #~ puts wiki.to_latex[1..50].inspect
307
+ #~ puts wiki.to_latex[-50..-1].inspect
308
+ assert_equal( "<p ><pre>#{escaped_filecontent}</pre></p>\n", wiki.to_doc(:html, @opt))
309
+ assert_equal( "\n\n\n\\begin{verbatim}#{File.read(__FILE__)}\\end{verbatim}\n\n\n", wiki.to_doc(:latex, @opt))
310
+
311
+ #Add some attributes to the pre-environment.
312
+ wiki = Wikitext.new(:content => <<wiki
313
+ {{verbatimfile|#{__FILE__}|class=cssklasse}}
314
+ wiki
315
+ )
316
+ assert_equal( "<p ><pre class = \"cssklasse\" >#{escaped_filecontent}</pre></p>\n",
317
+ wiki.to_doc(:html, @opt))
318
+ end
319
+ #Add File as verbatimtext
320
+ def test_wiki_filecontent()
321
+ #
322
+ #This test uses the coding of the test itself.
323
+ #
324
+ wiki = Wikitext.new(:content => <<wiki
325
+ {{filecontent|#{__FILE__}}}
326
+ wiki
327
+ )
328
+ #~ puts wiki.to_latex[1..50].inspect
329
+ assert_equal( "<p ><div >#{File.read(__FILE__)}</div></p>\n", wiki.to_doc(:html, @opt))
330
+ assert_equal( "\n\n\\begingroup #{File.read(__FILE__)}\\endgroup \n\n", wiki.to_doc(:latex, @opt))
331
+
332
+ #Add some attributes to the pre-environment.
333
+ wiki = Wikitext.new(:content => <<wiki
334
+ {{filecontent|#{__FILE__}|class=cssklasse}}
335
+ wiki
336
+ )
337
+ assert_equal( "<p ><div class = \"cssklasse\" >#{File.read(__FILE__)}</div></p>\n",
338
+ wiki.to_doc(:html, @opt))
339
+ end
340
+ def test_wiki_footnote()
341
+ wiki = Wikitext.new(:content => <<wiki
342
+ Here is a footnote{{footnote|some remarks}}, and
343
+ a second footnote{{footnote|more remarks}}.
344
+
345
+ ----
346
+ {{footnotes}}
347
+ wiki
348
+ )
349
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.html", wiki.to_doc(:html, @opt))
350
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_2.html", wiki.to_doc(:html, @opt))
351
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.latex", wiki.to_doc(:latex, @opt))
352
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.wiki", wiki.to_doc(:wiki, @opt))
353
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.text", wiki.to_doc(:text, @opt))
354
+ end
355
+ def test_wiki_footnote_groupid()
356
+ wiki = Wikitext.new(:content => <<wiki
357
+ There are normal footnotes{{footnote|Like this one}}. But:
358
+ Here is a footnote in group 1{{footnote[group1]some remarks}}, and
359
+ a second footnote{{footnote[group1]more remarks}}.
360
+ In another group{{footnote[group2]Each group gets a name}}, we can define further remarks.
361
+
362
+ ----
363
+ Normal Footnotes:
364
+ {{footnotes}}
365
+ ----
366
+ Footnote group 1:
367
+ {{footnotes|group1}}
368
+ ----
369
+ Footnote group 2:
370
+ {{footnotes|group2}}
371
+ wiki
372
+ )
373
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.html", wiki.to_doc(:html, @opt))
374
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.latex", wiki.to_doc(:latex, @opt))
375
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.wiki", wiki.to_doc(:wiki, @opt))
376
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.text", wiki.to_doc(:text, @opt))
377
+ end
378
+ #~ Bilder lassen sich mit [ [Bild:Dateiname|Beschreibung]] in Artikel einf�gen.
379
+ #~ Das Bild wird dann in Originalgr��e links im Artikel angezeigt.
380
+
381
+ #~ Parameter sind optional mit [ [Bild:Dateiname|parameter|Beschreibung]] anzugeben.
382
+ #~ Es sind beliebig viele, mit | getrennte Parameter m�glich.
383
+ def test_wiki_picture()
384
+ wiki = Wikitext.new(:content => <<wiki
385
+ [[Bild:Red_Flower.jpg]]
386
+
387
+ [[Bild:Red_Flower.jpg|alt=description]]
388
+ [[Bild:Red_Flower.jpg|alt=description|beforetitle=vorher]]
389
+ [[Bild:Red_Flower.jpg|alt=description|aftertitle=nachher]]
390
+
391
+ [[Bild:Red_Flower.jpg|href=http://ruby.lickert.net]]
392
+ [[Bild:Red_Flower.jpg|href=http://ruby.lickert.net|alt=test]]
393
+
394
+ [[Bild:Red_Flower.jpg|right]]
395
+ [[Bild:Red_Flower.jpg|left]]
396
+
397
+ [[Bild:Red_Flower.jpg|width=123px]]
398
+
399
+ [[Bild:Red_Flower.jpg|class=pictureclass]]
400
+ [[Bild:Red_Flower.jpg|imgclass=imgclass]]
401
+ [[Bild:Red_Flower.jpg|figureclass=imgclass]]
402
+ wiki
403
+ )
404
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.html", wiki.to_doc(:html, @opt))
405
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.latex", wiki.to_doc(:latex, @opt))
406
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.wiki", wiki.to_doc(:wiki, @opt))
407
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.text", wiki.to_doc(:text, @opt))
408
+
409
+ wiki = Wikitext.new(:content => <<wiki
410
+ [[Bild:Red_Flower.jpg|thumb=testthumb.jpg]]
411
+ wiki
412
+ )
413
+ wiki.log.level = Log4r::FATAL #Avoid warning for missing picture
414
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.html", wiki.to_doc(:html, @opt))
415
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.latex", wiki.to_doc(:latex, @opt))
416
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.wiki", wiki.to_doc(:wiki, @opt))
417
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.text", wiki.to_doc(:text, @opt))
418
+ end
419
+
420
+ #
421
+ #
422
+ def test_wiki_link()
423
+ #thisfile is needed to avoid different values of __FILE__
424
+ #(Running stand alone it's the filename, with require it's './<<filename>>'
425
+ thisfile = File.basename(__FILE__)
426
+
427
+ wiki = Wikitext.new(:content => <<wiki
428
+ text before [./#{thisfile} link to test] text after
429
+
430
+ text before
431
+ [./#{thisfile} link to test]
432
+ text after
433
+
434
+ [./unexisting_file.xx link with error]
435
+ wiki
436
+ )
437
+ wiki.log.level = Log4r::FATAL
438
+ #~ wiki.log.outputters = Log4r::FileOutputter.new('wiki_link', :filename => "expected_wikimedia/test_wiki_link.log")
439
+
440
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_link.html", wiki.to_doc(:html, @opt))
441
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_link.log", wiki.to_doc(:html, @opt))
442
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_link.latex", wiki.to_doc(:latex, @opt))
443
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_link.wiki", wiki.to_doc(:wiki, @opt))
444
+ #~ assert_equal_filecontent( "expected_wikimedia/test_wiki_link.text", wiki.to_doc(:text, @opt))
445
+ end
446
+ end #TestWiki
447
+
448
+ def newtest(text)
449
+ code = <<code
450
+ def test_wiki_??()
451
+ wiki = Wikitext.new(:content => <<wiki
452
+ ==Titel 1==
453
+ Text
454
+ wiki
455
+ )
456
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_??.html", wiki.to_doc(:html, @opt))
457
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_??.latex", wiki.to_doc(:latex, @opt))
458
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_??.wiki", wiki.to_doc(:wiki, @opt))
459
+ assert_equal_filecontent( "expected_wikimedia/test_wiki_??.text", wiki.to_doc(:text, @opt))
460
+ end
461
+ code
462
+ puts code.gsub(/\?\?/, text)
463
+ end
464
+ #~ newtest('link')
465
+
466
+ __END__
467
+ ==Wiki2docgenerator.rb==
468
+ ===Einr�ckungen===
469
+ Nicht realisiert, macht implizit Definitionsliste (fixme)
470
+ : Text macht implizit Definitionsliste (fixme)
471
+ :: Noch tiefer
472
+
473
+ ==Makros==
474
+ Makros sind eingeleitet mit {{.
475
+ nach dem Makronamen sind Parameter mit | getrennt.
476
+
477
+ ===Link ins ODP===
478
+ *{{dmoz|World/Deutsch}}
479
+ *{{dmoz|World/Deutsch|Deutschsprachige Inhalte}}