docgenerator 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/examples/docgenerator_example.rb +34 -17
  2. data/examples/docgenerator_example_footnote.rb +82 -61
  3. data/examples/docgenerator_example_list.rb +24 -18
  4. data/examples/docgenerator_example_restrictions.rb +17 -27
  5. data/examples/docgenerator_example_tabular.rb +20 -20
  6. data/examples/docgenerator_example_tripfalls.rb +28 -20
  7. data/examples/results/readme +1 -0
  8. data/examples/results_expected/docgenerator_example.html +39 -0
  9. data/examples/results_expected/docgenerator_example.pdf +0 -0
  10. data/examples/results_expected/docgenerator_example.tex +56 -0
  11. data/examples/results_expected/docgenerator_example_footnote.html +40 -0
  12. data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
  13. data/examples/results_expected/docgenerator_example_footnote.tex +50 -0
  14. data/examples/results_expected/docgenerator_example_list.html +18 -0
  15. data/examples/results_expected/docgenerator_example_list.pdf +0 -0
  16. data/examples/results_expected/docgenerator_example_list.tex +46 -0
  17. data/examples/results_expected/docgenerator_example_restrictions.html +22 -0
  18. data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
  19. data/examples/results_expected/docgenerator_example_restrictions.tex +31 -0
  20. data/examples/results_expected/docgenerator_example_tabular.html +37 -0
  21. data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
  22. data/examples/results_expected/docgenerator_example_tabular.tex +41 -0
  23. data/examples/results_expected/docgenerator_example_tripfalls.html +27 -0
  24. data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
  25. data/examples/results_expected/docgenerator_example_tripfalls.tex +31 -0
  26. data/lib/creole/creole2doc.rb +291 -140
  27. data/lib/creole/creole_inclusion_and_plugins.rb +142 -39
  28. data/lib/creole/creole_placeholder.rb +92 -30
  29. data/lib/creole/creole_tabular.rb +119 -20
  30. data/lib/docgenerator.rb +209 -118
  31. data/lib/{docgenerator_attribute.rb → docgenerator/attribute.rb} +2 -1
  32. data/lib/{docgenerator_characters.rb → docgenerator/characters.rb} +75 -6
  33. data/lib/{docgenerator_css.rb → docgenerator/css.rb} +0 -0
  34. data/lib/docgenerator/document.rb +588 -0
  35. data/lib/{docgenerator_element.rb → docgenerator/element.rb} +52 -80
  36. data/lib/{docgenerator_elements.rb → docgenerator/elements.rb} +43 -17
  37. data/lib/{docgenerator_environments.rb → docgenerator/environments.rb} +20 -6
  38. data/lib/{docgenerator_footnote.rb → docgenerator/footnote.rb} +22 -18
  39. data/lib/{docgenerator_lists.rb → docgenerator/lists.rb} +17 -1
  40. data/lib/{docgenerator_sections.rb → docgenerator/sections.rb} +9 -1
  41. data/lib/docgenerator/standard.rb +81 -0
  42. data/lib/{docgenerator_tabular.rb → docgenerator/tabular.rb} +9 -5
  43. data/lib/packages/docgenerator_listings.rb +9 -5
  44. data/lib/packages/docgenerator_pdfpages.rb +17 -11
  45. data/lib/packages/docgenerator_url.rb +0 -2
  46. data/lib/templates/docgenerator_template.rb +66 -29
  47. data/lib/templates/docgenerator_template.yaml +18 -0
  48. data/lib/wiki2doc/wiki2docgenerator.rb +6 -2
  49. data/readme.rd +132 -0
  50. data/unittest/expected/test_document_usepackage_undefined.log +2 -0
  51. data/unittest/expected/test_enumerate.context +4 -0
  52. data/unittest/expected/test_footnote.html +4 -4
  53. data/unittest/expected/test_footnote.latex +4 -4
  54. data/unittest/expected/test_footnote_group.html +6 -6
  55. data/unittest/expected/test_footnote_group.latex +6 -6
  56. data/unittest/expected/test_href.html +2 -2
  57. data/unittest/expected/test_href.latex +2 -2
  58. data/unittest/expected/test_href.text +2 -2
  59. data/unittest/expected/test_itemize.context +4 -0
  60. data/unittest/expected/test_runtex.stdout +3 -0
  61. data/unittest/expected/test_runtex_2.stdout +3 -0
  62. data/unittest/expected/test_section.context +20 -0
  63. data/unittest/expected/test_tabular.html +2 -2
  64. data/unittest/expected/test_verbatim.html +3 -0
  65. data/unittest/expected/test_verbatim.latex +4 -0
  66. data/unittest/expected/test_verbatim_array.html +1 -0
  67. data/unittest/expected/test_verbatim_array.latex +2 -0
  68. data/unittest/expected_creole/test_creole_characters_all.html +12 -5
  69. data/unittest/expected_creole/test_creole_characters_all.latex +20 -6
  70. data/unittest/expected_creole/test_creole_comment.context +11 -0
  71. data/unittest/expected_creole/test_creole_comment.creole +12 -0
  72. data/unittest/expected_creole/test_creole_comment.html +9 -0
  73. data/unittest/expected_creole/test_creole_comment.latex +11 -0
  74. data/unittest/expected_creole/test_creole_creole1.0test.html +3 -3
  75. data/unittest/expected_creole/test_creole_creole1.0test.latex +3 -3
  76. data/unittest/expected_creole/test_creole_creole1.0test.text +4 -4
  77. data/unittest/expected_creole/test_creole_ignore.html +3 -0
  78. data/unittest/expected_creole/test_creole_ignore.latex +4 -0
  79. data/unittest/expected_creole/test_creole_ignore.text +2 -0
  80. data/unittest/expected_creole/test_creole_input.normsource +12 -12
  81. data/unittest/expected_creole/test_creole_input_file_simple.html +15 -0
  82. data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +15 -0
  83. data/unittest/expected_creole/test_creole_links_external_implicit.html +2 -2
  84. data/unittest/expected_creole/test_creole_links_external_implicit.latex +2 -2
  85. data/unittest/expected_creole/test_creole_links_external_implicit.text +2 -2
  86. data/unittest/expected_creole/test_creole_links_implicit_end.creole +4 -0
  87. data/unittest/expected_creole/test_creole_links_implicit_end.html +3 -0
  88. data/unittest/expected_creole/test_creole_links_implicit_end.latex +4 -0
  89. data/unittest/expected_creole/test_creole_list_ul.normsource +42 -42
  90. data/unittest/expected_creole/test_creole_mix_titles_list.html +10 -0
  91. data/unittest/expected_creole/test_creole_mix_titles_list.latex +18 -0
  92. data/unittest/expected_creole/test_creole_mix_titles_list.text +12 -0
  93. data/unittest/expected_creole/test_creole_paragraphs.normsource +15 -15
  94. data/unittest/expected_creole/test_creole_pictures_css.html +4 -1
  95. data/unittest/expected_creole/test_creole_pictures_css.latex +5 -1
  96. data/unittest/expected_creole/test_creole_pictures_longdesc.html +3 -0
  97. data/unittest/expected_creole/test_creole_pictures_width.html +3 -0
  98. data/unittest/expected_creole/test_creole_pictures_width.latex +4 -0
  99. data/unittest/expected_creole/test_creole_short_html.html +3 -0
  100. data/unittest/expected_creole/test_creole_short_html.latex +4 -0
  101. data/unittest/expected_creole/test_creole_short_html.text +2 -0
  102. data/unittest/expected_creole/test_creole_shy.creole +6 -0
  103. data/unittest/expected_creole/test_creole_shy.html +6 -0
  104. data/unittest/expected_creole/test_creole_shy.latex +8 -0
  105. data/unittest/expected_creole/test_creole_shy.text +4 -0
  106. data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +20 -0
  107. data/unittest/expected_creole/test_creole_toc.html +3 -1
  108. data/unittest/expected_creole/test_creole_toc.latex +1 -1
  109. data/unittest/expected_creole/test_creole_toc.text +1 -1
  110. data/unittest/expected_creole/test_creole_toc_level.html +7 -0
  111. data/unittest/expected_creole/test_creole_toc_level.latex +10 -0
  112. data/unittest/expected_creole/test_creole_toc_level.text +3 -0
  113. data/unittest/expected_creole/test_creole_toc_level_text.html +8 -0
  114. data/unittest/expected_creole/test_creole_toc_level_text.latex +9 -0
  115. data/unittest/expected_creole/test_creole_verbatim.html +1 -1
  116. data/unittest/expected_creole/test_creole_verbatim.latex +1 -1
  117. data/unittest/expected_creole/test_creole_verbatim.text +1 -1
  118. data/unittest/expected_creole/test_creole_verbatim_inline.html +1 -1
  119. data/unittest/expected_creole/test_creole_verbatim_inline.latex +1 -1
  120. data/unittest/expected_wiki/test_wiki_description.html +5 -5
  121. data/unittest/expected_wiki/test_wiki_description.latex +5 -5
  122. data/unittest/expected_wiki/test_wiki_description.text +5 -5
  123. data/unittest/expected_wiki/test_wiki_description.wiki +5 -5
  124. data/unittest/test_rakefile_docgenerator.rb +43 -0
  125. data/unittest/unittest_creole2doc.rb +415 -27
  126. data/unittest/unittest_docgenerator.rb +256 -23
  127. data/unittest/unittest_docgenerator_runtex.rb +83 -0
  128. data/unittest/unittest_versions.rb +44 -0
  129. data/unittest/unittest_wiki2doc.rb +28 -27
  130. metadata +473 -106
  131. data/lib/docgenerator_document.rb +0 -525
  132. data/lib/packages/docgenerator_beamer.rb +0 -253
  133. data/lib/yaml2presentation/yaml2presentation.rb +0 -1091
  134. data/unittest/expected/beamer_01_article.tex +0 -13
  135. data/unittest/expected/beamer_01_attachment.tex +0 -15
  136. data/unittest/expected/beamer_01_doc.html +0 -13
  137. data/unittest/expected/beamer_01_doc.tex +0 -18
  138. data/unittest/expected/beamer_01_notes_only.tex +0 -13
  139. data/unittest/expected/beamer_01_notes_onlyslideswithnotes.tex +0 -13
  140. data/unittest/expected/beamer_01_notes_show.tex +0 -13
  141. data/unittest/expected/beamer_01_presentation.tex +0 -13
  142. data/unittest/expected/beamer_02_doc.html +0 -29
  143. data/unittest/expected/beamer_02_doc.tex +0 -34
  144. data/unittest/expected/beamer_block.html +0 -1
  145. data/unittest/expected/beamer_block.latex +0 -1
  146. data/unittest/expected/beamer_doc_fragile_doc.tex +0 -33
  147. data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +0 -34
  148. data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +0 -34
  149. data/unittest/expected/beamer_doc_key_doc.html +0 -20
  150. data/unittest/expected/beamer_doc_key_doc.tex +0 -29
  151. data/unittest/expected/beamer_doc_note_doc.html +0 -30
  152. data/unittest/expected/beamer_doc_note_doc.tex +0 -37
  153. data/unittest/expected/beamer_doc_pic_bottom_doc.html +0 -24
  154. data/unittest/expected/beamer_doc_pic_doc.html +0 -24
  155. data/unittest/expected/beamer_doc_pic_doc.tex +0 -28
  156. data/unittest/expected/beamer_doc_pic_left_doc.html +0 -24
  157. data/unittest/expected/beamer_doc_pic_left_doc.tex +0 -28
  158. data/unittest/expected/beamer_doc_pic_ratio_doc.tex +0 -29
  159. data/unittest/expected/beamer_doc_pic_right_doc.html +0 -24
  160. data/unittest/expected/beamer_doc_pic_right_doc.tex +0 -28
  161. data/unittest/expected/beamer_doc_pic_top_doc.html +0 -24
  162. data/unittest/expected/beamer_frame.html +0 -5
  163. data/unittest/expected/beamer_frame.tex +0 -11
  164. data/unittest/expected/beamer_frame_fragile.tex +0 -7
  165. data/unittest/expected/beamer_frame_id.html +0 -1
  166. data/unittest/expected/beamer_frame_id.tex +0 -4
  167. data/unittest/expected/beamer_framepic.html +0 -5
  168. data/unittest/expected/beamer_framepic.latex +0 -1
  169. data/unittest/expected/beamer_framepic_link.html +0 -5
  170. data/unittest/expected/beamer_framepic_link.latex +0 -1
  171. data/unittest/expected/beamer_frametitle.html +0 -1
  172. data/unittest/expected/beamer_frametitle.latex +0 -1
  173. data/unittest/expected/beamer_note.html +0 -1
  174. data/unittest/expected/beamer_note.latex +0 -1
  175. data/unittest/expected_privat/test_creole_test_document.html +0 -6
  176. data/unittest/expected_wiki/test_wiki_amazon.html +0 -10
  177. data/unittest/expected_wiki/test_wiki_link.log +0 -3
  178. data/unittest/test_docgenerator.rb +0 -107
  179. data/unittest/unittest_yaml2pres.rb +0 -336
@@ -16,23 +16,26 @@
16
16
  #
17
17
 
18
18
 
19
- #
20
- #Dummy class for all inclusions and plugins.
21
- #Used to check the correct definition.
22
- #
23
- #- Inclusions are used later with {{xx}}
24
- #- Plugins are used later with <<xx>>
25
- #
26
- #Derived classes (Inclusions):
27
- #- Creole_inclusion_img
28
- #- Creole_inclusion_footnote_group
29
- #- Creole_inclusion_footnote
30
- #Derived classes (Plugins):
31
- #- Creole_default_plugin
32
- #- Creole_plugin_ruby
33
- #- Creole_plugin_ruby_raw
34
- #More subclasses may be possible.
19
+ =begin rdoc
20
+ Dummy class for all inclusions and plugins.
21
+ Used to check the correct definition.
22
+
23
+ - Inclusions are used later with {{xx}}
24
+ - Plugins are used later with <<xx>>
25
+
26
+ Derived classes (Inclusions):
27
+ - Creole_inclusion_img
28
+ - Creole_inclusion_footnote_group
29
+ - Creole_inclusion_footnote
30
+ Derived classes (Plugins):
31
+ - Creole_default_plugin
32
+ - Creole_plugin_ruby
33
+ - Creole_plugin_ruby_raw
34
+ More subclasses may be possible.
35
+ =end
35
36
  class Creole_inclusion_and_plugin
37
+ include Docgenerator #get VERSION
38
+
36
39
  def initialize( inclusionname, description, options, wiki )
37
40
  @inclusionname = inclusionname
38
41
  @description = description
@@ -52,22 +55,67 @@ class Creole_default_plugin < Creole_inclusion_and_plugin
52
55
  Creole::Plugins.default = self
53
56
  def initialize( pluginname, description, options, wiki )
54
57
  super
55
- @wiki.log.warn("Use Default plugin - nothing special done.") if @wiki.log.warn?
58
+ @wiki.log.warn("Use Default plugin instead requested #{pluginname}- nothing special done.") if @wiki.log.warn?
56
59
  end
57
60
  end
58
61
 
59
62
 
60
- #Include images.
61
- #http://www.wikicreole.org/wiki/Images
62
63
  #
63
- #There are yet more features than in standard.
64
+ #Define a 'shy' as {{shy}}
65
+ #
66
+ class Creole_shy < Creole_inclusion_and_plugin
67
+ #
68
+ #~ Creole::Plugins['-'] = self
69
+ Creole::Inclusions['-'] = self
70
+ Creole::Inclusions['shy'] = self
71
+
72
+ def to_doc(target, options = {})
73
+ element(:shy).to_doc(target, options)
74
+ end
75
+ end #Creole_inclusion_footnote_group
76
+
64
77
  #
65
- #This is also the default for inclusions.
78
+ #Define a 'nil' as {{nil}}
79
+ #
80
+ class Creole_nil < Creole_inclusion_and_plugin
81
+ #
82
+ #~ Creole::Plugins['-'] = self
83
+ #~ Creole::Inclusions['-'] = self
84
+ Creole::Inclusions['nil'] = self
85
+
86
+ def to_doc(target, options = {})
87
+ ''
88
+ end
89
+ end #Creole_inclusion_footnote_group
90
+
91
+
92
+ =begin rdoc
93
+ Include images.
94
+ http://www.wikicreole.org/wiki/Images
95
+
96
+ There are yet more features than in standard.
97
+
98
+ This is also the default for inclusions.
99
+
100
+ Usage:
101
+ {{picurl.jpg|Alternate text|class=cc}}
102
+ {{picurl.jpg|Alternate text|css=width:50%}}
103
+
104
+ =end
66
105
  class Creole_inclusion_img < Creole_inclusion_and_plugin
67
106
  Creole::Inclusions.default = self
107
+ =begin rdoc
108
+ Define an image.
109
+ The existence of the picture is checked.
110
+
111
+ Supported options:
112
+ * alt (2nd parameter of {{picsrc|...}}
113
+ * css or imgcss
114
+ * class or imgclass
115
+ * longdesc (can take a url, at leas opera offers to call the description)
116
+ * width (only LaTeX. For HTML, use css-option).
68
117
 
69
- #Define an image.
70
- #The existence of the picture is checked.
118
+ =end
71
119
  def initialize( picname, alt_text, options, wiki )
72
120
  super
73
121
  @img = element(:img,{ :src => @inclusionname })
@@ -77,6 +125,16 @@ class Creole_inclusion_img < Creole_inclusion_and_plugin
77
125
 
78
126
  css = CSS.new( :log => wiki.log )
79
127
 
128
+ #
129
+ #Check for options
130
+ #
131
+ #Missing options:
132
+ #* align
133
+ #* border
134
+ #* height
135
+ #* hspace
136
+ #* name
137
+ #* vspace
80
138
  options.each{|option|
81
139
  case option
82
140
  when /^(img)?css\s*=\s*(.*)/
@@ -86,6 +144,10 @@ class Creole_inclusion_img < Creole_inclusion_and_plugin
86
144
  }
87
145
  when /^(img)?class\s*=\s*(.*)/
88
146
  @img[:class] << $2
147
+ when /^width\s*=\s*(.*)/
148
+ @img[:width] << $1
149
+ when /^longdesc\s*=\s*(.*)/ #gibt einen URI (nach RFC 2396) an, wo eine Langbeschreibung der Grafik zu finden ist
150
+ @img[:longdesc] << $1
89
151
  else
90
152
  wiki.log.warn("Img: Undefined option #{option}") if wiki.log.warn?
91
153
  end #case option
@@ -117,11 +179,15 @@ class Creole_footnote_group < Creole_inclusion_and_plugin
117
179
  end
118
180
  end #Creole_inclusion_footnote_group
119
181
 
120
- #
121
- #One footnote
122
- #
123
- #Bug: If you create more documents, you get a common footnote counting.
124
- #Has to be repaired one day.
182
+ =begin rdoc
183
+ One footnote
184
+
185
+ Usage:
186
+ <<footnote|text>>
187
+
188
+ Bug: If you create more documents, you get a common footnote counting.
189
+ Has to be repaired one day.
190
+ =end
125
191
  class Creole_footnote < Creole_inclusion_and_plugin
126
192
  Creole::Plugins['footnote'] = self
127
193
  #~ Creole::Inclusions['footnote'] = self
@@ -160,11 +226,47 @@ class Creole_footnote < Creole_inclusion_and_plugin
160
226
  end
161
227
  end #Creole_inclusion_footnote
162
228
 
163
- #
164
- #Eval the given ruby-code and put it as "raw text".
165
- #
166
- #
167
- #This is defined as a plugin.
229
+ =begin rdoc
230
+ Some short html
231
+
232
+ Usage:
233
+ {{html|code}}
234
+
235
+ Note:
236
+ There is also a placeholder for larger html:
237
+ <<<html
238
+ content
239
+ >>>
240
+ =end
241
+ class Creole_short_html < Creole_inclusion_and_plugin
242
+ #We don't use it as plugin. Closing > from html may e confusing as in:
243
+ # <<html|<em>kursuiv</em>>>
244
+ #~ Creole::Plugins['html'] = self
245
+ Creole::Inclusions['html'] = self
246
+ #~ Creole::Inclusions['footnote'] = self
247
+ def initialize( inclusionname, description, options, wiki )
248
+ super
249
+ options.each{|option|
250
+ #~ case option
251
+ #~ else
252
+ @wiki.log.warn("HTML with unknown option #{option.inspect} not found") if @wiki.log.warn?
253
+ #~ end
254
+ }
255
+ @source = description
256
+
257
+ end
258
+ #Return content only for html
259
+ def to_doc( target, options = {})
260
+ target == :html ? @source.to_doc( target, options ) : ''
261
+ end
262
+ end #Creole_inclusion_html
263
+
264
+ =begin rdoc
265
+ Eval the given ruby-code and put it as "raw text".
266
+
267
+
268
+ This is defined as a plugin.
269
+ =end
168
270
  class Creole_plugin_ruby_raw < Creole_inclusion_and_plugin
169
271
  #~ Creole::Inclusions['ruby'] = self
170
272
  Creole::Plugins['ruby_raw'] = self
@@ -189,12 +291,13 @@ class Creole_plugin_ruby_raw < Creole_inclusion_and_plugin
189
291
  end
190
292
  end #Creole_plugin_ruby
191
293
 
192
- #
193
- #Eval the given ruby-code and add it as a interpreted code.
194
- #
195
- #This is defined as a plugin.
196
- #
197
- #Ideas for further development: eval later, at doc generation.
294
+ =begin rdoc
295
+ Eval the given ruby-code and add it as a interpreted code.
296
+
297
+ This is defined as a plugin.
298
+
299
+ Ideas for further development: eval later, at doc generation.
300
+ =end
198
301
  class Creole_plugin_ruby < Creole_inclusion_and_plugin
199
302
  #~ Creole::Inclusions['ruby'] = self
200
303
  Creole::Plugins['ruby'] = self
@@ -1,43 +1,76 @@
1
- #
2
- #Placeholder are defined in Creole-Syntax via <<< >>>
3
- #
4
- #Placeholders collect the content between <<< and >>>.
5
- #
6
- #Derived classes are:
7
- #- Creole_dummy_placeholder
8
- #- Creole_html
9
- #- Creole_latex
10
- #- Creole_tabular
11
- #- Creole_creoletab
1
+ =begin rdoc
2
+ Placeholder are defined in Creole-Syntax via <<< >>>
3
+
4
+ Placeholders get a name and optional parameters:
5
+ <<<name|parameter
6
+
7
+ Placeholders collect the content between <<< and >>>.
8
+
9
+ Derived classes are:
10
+ - Creole_dummy_placeholder
11
+ - Creole_html
12
+ - Creole_latex
13
+ - Creole_tabular
14
+ - Creole_creoletab
15
+ =end
12
16
  class Creole_placeholder
13
-
14
- def initialize( wiki )
17
+ include Docgenerator #get VERSION
18
+ =begin rdoc
19
+ Each placeholder get the wiki where it belongs to.
20
+
21
+ Parameters are optional.
22
+
23
+ Definition inside the wiki:
24
+ <<<name|parameters
25
+ content
26
+ >>>
27
+ Placeholders collect the content between <<< and >>>.
28
+ =end
29
+ def initialize( wiki, parameters = nil )
15
30
  @wiki = wiki
31
+ #
32
+ @parameters = parameters
16
33
  @log = @wiki.log
17
34
  end
35
+ #
36
+ #Add the content between <<< and >>>.
18
37
  def << (content)
19
38
  @source = [] unless @source
20
39
  @source << content
21
40
  end
22
41
  #
23
- #possibility to analyse the content.
42
+ #Possibility to analyse the content.
24
43
  def close()
44
+ @source.freeze
25
45
  end
46
+ #Export it. Should be redefined by sub classes.
26
47
  def to_doc( target, options = {})
27
48
  @source.to_doc( target, options )
28
49
  end
29
50
  end #Creole_placeholder
30
51
 
31
- #Just a dummy for wrong definitions.
32
- #
33
- #This class is used by Creole a default placeholder.
52
+ =begin rdoc
53
+ Just a dummy for wrong definitions.
54
+
55
+ This class is used by Creole a default placeholder.
56
+ =end
34
57
  class Creole_dummy_placeholder < Creole_placeholder
35
58
  Creole::Placeholders.default = self
36
59
  end #Creole_dummy_placeholder
37
60
 
38
- #
39
- #Placeholder for pure HTML-output.
40
- #This content is ignored in LaTeX, Wiki... documents.
61
+ =begin rdoc
62
+ Placeholder for pure HTML-output.
63
+ This content is ignored in LaTeX, Wiki... documents.
64
+
65
+ Usage:
66
+ <<<html
67
+ content
68
+ >>>
69
+
70
+ Note:
71
+ There is also a plugin for short html:
72
+ {{html|code}}
73
+ =end
41
74
  class Creole_html < Creole_placeholder
42
75
  Creole::Placeholders['html'] = self
43
76
  #Return content only for html
@@ -46,16 +79,17 @@ class Creole_html < Creole_placeholder
46
79
  end
47
80
  end #Creole_html
48
81
 
49
- #
50
- #Placeholder for pure LaTeX-output.
51
- #This content is ignored in HTML, Wiki... documents.
52
- #
53
- #Idea for option: Parse the content by the wiki.
54
- #
55
- #Pro:
56
- #-allows the usage of <<ruby|...
57
- #Cons:
58
- #-unexpected conversions?
82
+ =begin
83
+ Placeholder for pure LaTeX-output.
84
+ This content is ignored in HTML, Wiki... documents.
85
+
86
+ Idea for option: Parse the content by the wiki.
87
+
88
+ Pro:
89
+ -allows the usage of <<ruby|...
90
+ Cons:
91
+ -unexpected conversions?
92
+ =end
59
93
  class Creole_latex < Creole_placeholder
60
94
  Creole::Placeholders['latex'] = self
61
95
  #Return content only for latex
@@ -64,6 +98,34 @@ class Creole_latex < Creole_placeholder
64
98
  end
65
99
  end #Creole_latex
66
100
 
101
+ #
102
+ #Collect
103
+ #
104
+ class Creole_comment < Creole_placeholder
105
+ Creole::Placeholders['comment'] = self
106
+ #Return content as a comment
107
+ def to_doc( target, options = {})
108
+ case target
109
+ when :html; to_html( options )
110
+ when :latex; to_latex( options )
111
+ when :context; to_latex( options )
112
+ when :creole; to_creole( options )
113
+ else
114
+ @log.error("Creole_comment not supported for target #{target.inspect}") if @log.error?
115
+ end
116
+ end
117
+ def to_html(options = {})
118
+ return "<!-- #{@source.join} -->"
119
+ end
120
+ alias :to_context :to_latex
121
+ def to_latex(options = {})
122
+ return @source.map{|l| "%#{l}" }.join
123
+ end
124
+ def to_creole(options = {})
125
+ return "<<<comment\n#{@source.join}>>>"
126
+ end
127
+ end #Creole_html
128
+
67
129
 
68
130
  __END__
69
131
  To be done:
@@ -16,21 +16,29 @@ lineoptions:
16
16
  fixme
17
17
 
18
18
 
19
- #
20
- #Extend the class by a little structure
21
- class Creole_placeholder
22
- Cell = Struct.new('Cell', :content, :type )
23
- end #Creole_placeholder
24
-
25
- #
26
- #"Original" creole tab.
27
- #
28
- #Defined as a collector, so we can collect the content first and
29
- #build the tabular later.
30
- #
31
- #Details see http://www.wikicreole.org/wiki/Tables
19
+
20
+ =begin
21
+ "Original" creole tab.
22
+
23
+ Defined as a collector, so we can collect the content first and
24
+ build the tabular later.
25
+
26
+ Details see http://www.wikicreole.org/wiki/Tables
27
+
28
+ Usage:
29
+ Tables are done like this:
30
+ |=header col1|=header col2|
31
+ |col1|col2|
32
+ |you |can |
33
+ |also |align\\ it. |
34
+
35
+ =end
32
36
  class Creole_creoletab < Creole_placeholder
33
37
  Creole::Placeholders['creole_tabular'] = self #original creole-tab definition
38
+
39
+ #Extend the class by a little structure
40
+ Cell = Struct.new('Cell', :content, :type )
41
+
34
42
  #Finish the tabular.
35
43
  #Each cell is added left justified.
36
44
  def close(options)
@@ -75,10 +83,78 @@ class Creole_creoletab < Creole_placeholder
75
83
  end
76
84
  end #Creole_tab
77
85
 
78
- #
79
- #Create tabulars analog to Wikimedia.
86
+ =begin rdoc
87
+ Create tabulars analog to Wikimedia.
88
+
89
+ Usage:
90
+ before
91
+ <<<tabular
92
+ |!columns=3
93
+ |!columndescription=ccc
94
+ |=1
95
+ |=2
96
+ |=3
97
+ |-
98
+ |eins
99
+ |zwei
100
+ |drei
101
+ |-
102
+ |one
103
+ |two
104
+ |three
105
+ >>>
106
+ after
107
+
108
+ You can add additional settings to cells:
109
+ <<<tabular
110
+ |!columns=3
111
+ |eins||css=color: red
112
+ |css = zwei
113
+ |||class=empty
114
+ >>>
115
+ =end
80
116
  class Creole_tabular < Creole_placeholder
81
117
  Creole::Placeholders['tabular'] = self
118
+
119
+ #Extend the class by a little structure
120
+ class Cell
121
+ =begin rdoc
122
+ The content of a cell is separated from settings by two ||
123
+
124
+ If you have an empty cell with additional setting, you must write three |
125
+
126
+ Supported additional settings:
127
+ * css= define css-style options
128
+ * class= define HTML-class
129
+ * title= define a title (results in popup during mouse-over)
130
+ =end
131
+ def initialize( content, type, wiki, local_options )
132
+ @content, options = content.split(/\|\|/,2)
133
+ @content = '' unless @content #just in case of empty content
134
+ @options = {}
135
+ options.split(/\|/).each{|option|
136
+ case option
137
+ when /class\s*=\s*/
138
+ @options[:class] = $~.post_match
139
+ when /css\s*=\s*/
140
+ @options[:style] = $~.post_match
141
+ when /title\s*=\s*/
142
+ @options[:title] = $~.post_match
143
+ when '' #ignore them
144
+ else
145
+ wiki.log.warn("Creole_tabular::Cell: Undefined option #{option.inspect}")
146
+ end
147
+ } if options
148
+ @type = type #:td or :th
149
+ @wiki = wiki
150
+ @local_options = local_options
151
+ end
152
+ #Return the content as a element.
153
+ def cell_element()
154
+ element(@type,@options, @wiki.inline(@content, @local_options)).cr
155
+ end
156
+ end
157
+
82
158
  #Build the tabular.
83
159
  def close()
84
160
  #~ fixme:
@@ -88,7 +164,17 @@ class Creole_tabular < Creole_placeholder
88
164
  step = 0 #start
89
165
  head = []
90
166
  content = [[]]
91
- options = {}
167
+
168
+ options = { :log => @log }
169
+ local_options = {
170
+ :log => @log,
171
+ :inclusions => @wiki.inclusions,
172
+ :plugins => @wiki.plugins.dup
173
+ }
174
+ #No footnotes inside tabulars
175
+ local_options[:plugins].delete('footnote')
176
+ local_options[:plugins].delete('footnotes')
177
+
92
178
  tab_css = CSS.new( :log => @log )
93
179
  @source.each{|cell|
94
180
  case cell
@@ -107,9 +193,11 @@ class Creole_tabular < Creole_placeholder
107
193
  when /^\|-(.*)/ #new line
108
194
  content << []
109
195
  when /^\|=/ #header cell
110
- content.last << Cell.new(@wiki.inline($~.post_match.strip, options), :th)
196
+ #~ content.last << Cell.new(@wiki.inline($~.post_match.strip, local_options), :th)
197
+ content.last << Cell.new($~.post_match.strip, :th, @wiki, local_options)
111
198
  when /^\|/ #content of a cell
112
- content.last << Cell.new(@wiki.inline($~.post_match.strip, options), :td)
199
+ #~ content.last << Cell.new(@wiki.inline($~.post_match.strip, local_options), :td)
200
+ content.last << Cell.new($~.post_match.strip, :td, @wiki, local_options)
113
201
  else #error!
114
202
  raise 'cell/log-warning'
115
203
  end
@@ -130,8 +218,7 @@ class Creole_tabular < Creole_placeholder
130
218
  content.each{|line|
131
219
  @tab << row = element(:row).cr
132
220
  line.each{|cell|
133
- #fixme cell to wiki/creole
134
- row << element(cell.type,{}, cell.content).cr
221
+ row << cell.cell_element.cr
135
222
  }
136
223
  }
137
224
  end
@@ -141,6 +228,18 @@ class Creole_tabular < Creole_placeholder
141
228
 
142
229
  end
143
230
 
231
+
232
+ if $0 == __FILE__
233
+ creole = Creole.new(
234
+ :name => 'tabular_creole',
235
+ :content => <<'creole'
236
+ <<<tabular
237
+ |
238
+ >>>
239
+ creole
240
+ )
241
+ puts creole.to_html
242
+ end
144
243
  __END__
145
244
 
146
245
  class Creole_tabular_cvs