docgenerator 1.0.4 → 1.1.1

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 (231) hide show
  1. data/lib/creole/creole2doc.rb +777 -0
  2. data/lib/creole/creole_inclusion_and_plugins.rb +236 -0
  3. data/lib/creole/creole_placeholder.rb +74 -0
  4. data/lib/creole/creole_tabular.rb +170 -0
  5. data/lib/docgenerator.rb +15 -6
  6. data/lib/docgenerator_attribute.rb +2 -2
  7. data/lib/docgenerator_characters.rb +20 -4
  8. data/lib/docgenerator_document.rb +132 -42
  9. data/lib/docgenerator_element.rb +531 -524
  10. data/lib/docgenerator_elements.rb +408 -399
  11. data/lib/docgenerator_environments.rb +28 -2
  12. data/lib/docgenerator_footnote.rb +72 -79
  13. data/lib/docgenerator_sections.rb +1 -1
  14. data/lib/docgenerator_tabular.rb +8 -3
  15. data/lib/packages/docgenerator_beamer.rb +253 -0
  16. data/lib/packages/docgenerator_scrlettr2.rb +53 -9
  17. data/lib/templates/docgenerator_template_css.rb +4 -0
  18. data/lib/wiki2doc/wiki2docgenerator.rb +1087 -970
  19. data/lib/yaml2presentation/yaml2presentation.rb +1091 -0
  20. data/self_docgenerator.rb +8 -6
  21. data/unittest/Red_Flower.jpg +0 -0
  22. data/unittest/creole1.0test.txt +128 -0
  23. data/unittest/expected/beamer_01_doc.html +1 -1
  24. data/unittest/expected/beamer_02_doc.html +1 -1
  25. data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +34 -0
  26. data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +34 -0
  27. data/unittest/expected/beamer_doc_key_doc.html +1 -1
  28. data/unittest/expected/beamer_doc_note_doc.html +1 -1
  29. data/unittest/expected/beamer_doc_pic_bottom_doc.html +1 -1
  30. data/unittest/expected/beamer_doc_pic_doc.html +1 -1
  31. data/unittest/expected/beamer_doc_pic_left_doc.html +1 -1
  32. data/unittest/expected/beamer_doc_pic_right_doc.html +1 -1
  33. data/unittest/expected/beamer_doc_pic_top_doc.html +1 -1
  34. data/unittest/expected/test_footnote.html +2 -2
  35. data/unittest/expected/test_footnote.latex +1 -1
  36. data/unittest/expected/test_footnote_group.html +3 -3
  37. data/unittest/expected/test_footnote_group.latex +2 -2
  38. data/unittest/expected_creole/test_creole.html +3 -0
  39. data/unittest/expected_creole/test_creole_characters_all.html +10 -0
  40. data/unittest/expected_creole/test_creole_characters_all.latex +20 -0
  41. data/unittest/expected_creole/test_creole_characters_special.html +10 -0
  42. data/unittest/expected_creole/test_creole_characters_special.latex +18 -0
  43. data/unittest/expected_creole/test_creole_countdown.html +3 -0
  44. data/unittest/expected_creole/test_creole_countdown.latex +4 -0
  45. data/unittest/expected_creole/test_creole_creole1.0test.html +182 -0
  46. data/unittest/expected_creole/test_creole_creole1.0test.latex +253 -0
  47. data/unittest/expected_creole/test_creole_creole1.0test.text +160 -0
  48. data/unittest/expected_creole/test_creole_footnotes.html +9 -0
  49. data/unittest/expected_creole/test_creole_footnotes.latex +14 -0
  50. data/unittest/expected_creole/test_creole_footnotes_label.html +9 -0
  51. data/unittest/expected_creole/test_creole_headings.html +17 -0
  52. data/unittest/expected_creole/test_creole_headings.latex +19 -0
  53. data/unittest/expected_creole/test_creole_headings.text +48 -0
  54. data/unittest/expected_creole/test_creole_headings.wiki +37 -0
  55. data/unittest/expected_creole/test_creole_hr.html +7 -0
  56. data/unittest/expected_creole/test_creole_hr.latex +9 -0
  57. data/unittest/expected_creole/test_creole_hr.text +4 -0
  58. data/unittest/expected_creole/test_creole_inline.html +3 -0
  59. data/unittest/expected_creole/test_creole_inline.latex +4 -0
  60. data/unittest/expected_creole/test_creole_inline.text +2 -0
  61. data/unittest/expected_creole/test_creole_inline_ruby.html +12 -0
  62. data/unittest/expected_creole/test_creole_inline_ruby.latex +20 -0
  63. data/unittest/expected_creole/test_creole_inline_ruby_raw.html +6 -0
  64. data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +8 -0
  65. data/unittest/expected_creole/test_creole_input.normsource +23 -0
  66. data/unittest/expected_creole/test_creole_label.html +12 -0
  67. data/unittest/expected_creole/test_creole_label.latex +15 -0
  68. data/unittest/expected_creole/test_creole_line_break.html +6 -0
  69. data/unittest/expected_creole/test_creole_line_break.latex +8 -0
  70. data/unittest/expected_creole/test_creole_links_explicit_internal.html +6 -0
  71. data/unittest/expected_creole/test_creole_links_explicit_internal.text +4 -0
  72. data/unittest/expected_creole/test_creole_links_explicit_with_em.html +3 -0
  73. data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +4 -0
  74. data/unittest/expected_creole/test_creole_links_explicit_with_em.text +2 -0
  75. data/unittest/expected_creole/test_creole_links_external.html +6 -0
  76. data/unittest/expected_creole/test_creole_links_external.latex +8 -0
  77. data/unittest/expected_creole/test_creole_links_external.text +4 -0
  78. data/unittest/expected_creole/test_creole_links_external_implicit.html +9 -0
  79. data/unittest/expected_creole/test_creole_links_external_implicit.latex +12 -0
  80. data/unittest/expected_creole/test_creole_links_external_implicit.text +6 -0
  81. data/unittest/expected_creole/test_creole_links_file.html +6 -0
  82. data/unittest/expected_creole/test_creole_links_file.latex +8 -0
  83. data/unittest/expected_creole/test_creole_links_file.text +4 -0
  84. data/unittest/expected_creole/test_creole_list_ol.html +12 -0
  85. data/unittest/expected_creole/test_creole_list_ol.latex +22 -0
  86. data/unittest/expected_creole/test_creole_list_ol_after_ul.html +12 -0
  87. data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +20 -0
  88. data/unittest/expected_creole/test_creole_list_ol_after_ul.text +6 -0
  89. data/unittest/expected_creole/test_creole_list_ol_ul.html +15 -0
  90. data/unittest/expected_creole/test_creole_list_ol_ul.latex +26 -0
  91. data/unittest/expected_creole/test_creole_list_ul.html +22 -0
  92. data/unittest/expected_creole/test_creole_list_ul.latex +40 -0
  93. data/unittest/expected_creole/test_creole_list_ul.normsource +83 -0
  94. data/unittest/expected_creole/test_creole_list_ul_too_much.html +24 -0
  95. data/unittest/expected_creole/test_creole_list_ul_too_much.latex +44 -0
  96. data/unittest/expected_creole/test_creole_newline.html +9 -0
  97. data/unittest/expected_creole/test_creole_newline.latex +11 -0
  98. data/unittest/expected_creole/test_creole_newline.text +7 -0
  99. data/unittest/expected_creole/test_creole_paragraphs.html +6 -0
  100. data/unittest/expected_creole/test_creole_paragraphs.latex +8 -0
  101. data/unittest/expected_creole/test_creole_paragraphs.normsource +27 -0
  102. data/unittest/expected_creole/test_creole_paragraphs.text +4 -0
  103. data/unittest/expected_creole/test_creole_paragraphs.wiki +4 -0
  104. data/unittest/expected_creole/test_creole_paragraphs_wrap.html +5 -0
  105. data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +6 -0
  106. data/unittest/expected_creole/test_creole_paragraphs_wrap.text +4 -0
  107. data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +4 -0
  108. data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +9 -0
  109. data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +11 -0
  110. data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +7 -0
  111. data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +7 -0
  112. data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +5 -0
  113. data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +6 -0
  114. data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +4 -0
  115. data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +4 -0
  116. data/unittest/expected_creole/test_creole_picture_link.html +6 -0
  117. data/unittest/expected_creole/test_creole_pictures.html +10 -0
  118. data/unittest/expected_creole/test_creole_pictures.latex +13 -0
  119. data/unittest/expected_creole/test_creole_pictures_css.html +3 -0
  120. data/unittest/expected_creole/test_creole_pictures_css.latex +4 -0
  121. data/unittest/expected_creole/test_creole_pictures_imgclass.html +6 -0
  122. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +8 -0
  123. data/unittest/expected_creole/test_creole_placeholders_html.html +7 -0
  124. data/unittest/expected_creole/test_creole_placeholders_html.latex +8 -0
  125. data/unittest/expected_creole/test_creole_placeholders_html.text +4 -0
  126. data/unittest/expected_creole/test_creole_placeholders_latex.html +6 -0
  127. data/unittest/expected_creole/test_creole_placeholders_latex.latex +9 -0
  128. data/unittest/expected_creole/test_creole_placeholders_latex.text +4 -0
  129. data/unittest/expected_creole/test_creole_tabular.html +20 -0
  130. data/unittest/expected_creole/test_creole_tabular.latex +22 -0
  131. data/unittest/expected_creole/test_creole_tabular_creole.html +18 -0
  132. data/unittest/expected_creole/test_creole_tabular_creole.latex +19 -0
  133. data/unittest/expected_creole/test_creole_tabular_css.html +20 -0
  134. data/unittest/expected_creole/test_creole_tabular_css.latex +22 -0
  135. data/unittest/expected_creole/test_creole_toc.html +11 -0
  136. data/unittest/expected_creole/test_creole_toc.latex +22 -0
  137. data/unittest/expected_creole/test_creole_toc.text +4 -0
  138. data/unittest/expected_creole/test_creole_toc_text.html +5 -0
  139. data/unittest/expected_creole/test_creole_toc_text.latex +5 -0
  140. data/unittest/expected_creole/test_creole_ul_multiple_line.html +7 -0
  141. data/unittest/expected_creole/test_creole_ul_multiple_line.latex +14 -0
  142. data/unittest/expected_creole/test_creole_ul_with_blank.html +11 -0
  143. data/unittest/expected_creole/test_creole_ul_with_blank.latex +20 -0
  144. data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
  145. data/unittest/expected_creole/test_creole_ul_with_bold.html +11 -0
  146. data/unittest/expected_creole/test_creole_ul_with_bold.latex +18 -0
  147. data/unittest/expected_creole/test_creole_ul_with_bold.text +7 -0
  148. data/unittest/expected_creole/test_creole_verbatim.html +25 -0
  149. data/unittest/expected_creole/test_creole_verbatim.latex +33 -0
  150. data/unittest/expected_creole/test_creole_verbatim.text +17 -0
  151. data/unittest/expected_creole/test_creole_verbatim_inline.html +6 -0
  152. data/unittest/expected_creole/test_creole_verbatim_inline.latex +8 -0
  153. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +6 -0
  154. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +8 -0
  155. data/unittest/expected_privat/test_creole_test_document.html +6 -0
  156. data/unittest/{expected → expected_wiki}/test_wiki.html +0 -0
  157. data/unittest/{expected → expected_wiki}/test_wiki.latex +0 -0
  158. data/unittest/{expected → expected_wiki}/test_wiki.text +0 -0
  159. data/unittest/{expected → expected_wiki}/test_wiki.wiki +0 -0
  160. data/unittest/{expected → expected_wiki}/test_wiki_amazon.html +0 -0
  161. data/unittest/{expected → expected_wiki}/test_wiki_description.html +0 -0
  162. data/unittest/{expected → expected_wiki}/test_wiki_description.latex +0 -0
  163. data/unittest/{expected → expected_wiki}/test_wiki_description.text +0 -0
  164. data/unittest/{expected → expected_wiki}/test_wiki_description.wiki +0 -0
  165. data/unittest/expected_wiki/test_wiki_footnote.html +8 -0
  166. data/unittest/expected_wiki/test_wiki_footnote.latex +17 -0
  167. data/unittest/{expected → expected_wiki}/test_wiki_footnote.text +2 -4
  168. data/unittest/expected_wiki/test_wiki_footnote.wiki +10 -0
  169. data/unittest/expected_wiki/test_wiki_footnote_2.html +8 -0
  170. data/unittest/expected_wiki/test_wiki_footnote_groupid.html +21 -0
  171. data/unittest/{expected → expected_wiki}/test_wiki_html_code.html +0 -0
  172. data/unittest/{expected → expected_wiki}/test_wiki_html_code.latex +0 -0
  173. data/unittest/{expected → expected_wiki}/test_wiki_html_code.text +0 -0
  174. data/unittest/{expected → expected_wiki}/test_wiki_html_code.wiki +0 -0
  175. data/unittest/{expected → expected_wiki}/test_wiki_inline.html +0 -0
  176. data/unittest/{expected → expected_wiki}/test_wiki_inline.latex +0 -0
  177. data/unittest/{expected → expected_wiki}/test_wiki_inline.text +0 -0
  178. data/unittest/{expected → expected_wiki}/test_wiki_inline.wiki +0 -0
  179. data/unittest/{expected → expected_wiki}/test_wiki_label.html +0 -0
  180. data/unittest/{expected → expected_wiki}/test_wiki_link.html +0 -0
  181. data/unittest/{expected → expected_wiki}/test_wiki_link.latex +0 -0
  182. data/unittest/{expected → expected_wiki}/test_wiki_link.log +0 -0
  183. data/unittest/{expected → expected_wiki}/test_wiki_link.wiki +0 -0
  184. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.html +0 -0
  185. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.latex +0 -0
  186. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.text +0 -0
  187. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.wiki +0 -0
  188. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.html +0 -0
  189. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.latex +0 -0
  190. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.text +0 -0
  191. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.wiki +0 -0
  192. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.html +0 -0
  193. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.latex +0 -0
  194. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.text +0 -0
  195. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.wiki +0 -0
  196. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.html +0 -0
  197. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.latex +0 -0
  198. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.text +0 -0
  199. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.wiki +0 -0
  200. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.html +0 -0
  201. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.latex +0 -0
  202. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.text +0 -0
  203. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.wiki +0 -0
  204. data/unittest/{expected → expected_wiki}/test_wiki_picture.html +0 -0
  205. data/unittest/{expected → expected_wiki}/test_wiki_picture.latex +0 -0
  206. data/unittest/{expected → expected_wiki}/test_wiki_picture_thumb.html +0 -0
  207. data/unittest/{expected → expected_wiki}/test_wiki_tab1.html +0 -0
  208. data/unittest/{expected → expected_wiki}/test_wiki_tab1.latex +0 -0
  209. data/unittest/{expected → expected_wiki}/test_wiki_tab1.wiki +0 -0
  210. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.html +0 -0
  211. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.latex +0 -0
  212. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.text +0 -0
  213. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.wiki +0 -0
  214. data/unittest/{expected → expected_wiki}/test_wiki_toc.html +0 -0
  215. data/unittest/{expected → expected_wiki}/test_wiki_toc.latex +0 -0
  216. data/unittest/{expected → expected_wiki}/test_wiki_toc.text +0 -0
  217. data/unittest/{expected → expected_wiki}/test_wiki_toc.wiki +0 -0
  218. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.html +0 -0
  219. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.latex +0 -0
  220. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.text +0 -0
  221. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.wiki +0 -0
  222. data/unittest/test_docgenerator.rb +1 -2
  223. data/unittest/unittest_creole2doc.rb +1024 -0
  224. data/unittest/unittest_docgenerator.rb +17 -8
  225. data/unittest/unittest_wiki2doc.rb +92 -88
  226. data/unittest/unittest_yaml2pres.rb +336 -0
  227. metadata +202 -70
  228. data/unittest/expected/test_wiki_footnote.html +0 -8
  229. data/unittest/expected/test_wiki_footnote.latex +0 -15
  230. data/unittest/expected/test_wiki_footnote.wiki +0 -12
  231. data/unittest/expected/test_wiki_footnote_groupid.html +0 -21
@@ -0,0 +1,236 @@
1
+ #
2
+ #Creole inclusions and plugins
3
+ #
4
+ #
5
+ #This classes are defined to implement transclusions (http://en.wikipedia.org/wiki/Transclusion)
6
+ #
7
+ #- http://www.wikicreole.org/wiki/Inclusion
8
+ #- http://www.wikicreole.org/wiki/Plugin
9
+ #
10
+ #By default, Pictures are expected.
11
+ #
12
+ #You can extend Wikis with additional inclusions:
13
+ #
14
+ # wiki = Creole.new()
15
+ # wiki.inclusion['xxx'] = Creole_inclusion_xxx
16
+ #
17
+
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.
35
+ class Creole_inclusion_and_plugin
36
+ def initialize( inclusionname, description, options, wiki )
37
+ @inclusionname = inclusionname
38
+ @description = description
39
+ @options = options
40
+ @wiki = wiki
41
+
42
+ raise "Inclusion received no wiki but #{wiki.inspect}" unless wiki.is_a?(Creole)
43
+
44
+ end
45
+ #Reader for the wiki.
46
+ attr_reader :wiki
47
+ end #Creole_inclusion
48
+
49
+ #
50
+ #Default Plugin.
51
+ class Creole_default_plugin < Creole_inclusion_and_plugin
52
+ Creole::Plugins.default = self
53
+ def initialize( pluginname, description, options, wiki )
54
+ super
55
+ @wiki.log.warn("Use Default plugin - nothing special done.") if @wiki.log.warn?
56
+ end
57
+ end
58
+
59
+
60
+ #Include images.
61
+ #http://www.wikicreole.org/wiki/Images
62
+ #
63
+ #There are yet more features than in standard.
64
+ #
65
+ #This is also the default for inclusions.
66
+ class Creole_inclusion_img < Creole_inclusion_and_plugin
67
+ Creole::Inclusions.default = self
68
+
69
+ #Define an image.
70
+ #The existence of the picture is checked.
71
+ def initialize( picname, alt_text, options, wiki )
72
+ super
73
+ @img = element(:img,{ :src => @inclusionname })
74
+ @img[:alt] << alt_text if alt_text
75
+ #Check existence of Picture. Only possible if the related wiki is available.
76
+ wiki.check_link_existence( @inclusionname, wiki.log )
77
+
78
+ css = CSS.new( :log => wiki.log )
79
+
80
+ options.each{|option|
81
+ case option
82
+ when /^(img)?css\s*=\s*(.*)/
83
+ $2.split(/\s*;\s*/).each{|css_assignment|
84
+ css_assignment =~ /(.+?)\s*:\s*(.+)/
85
+ css[$1] = $2
86
+ }
87
+ when /^(img)?class\s*=\s*(.*)/
88
+ @img[:class] << $2
89
+ else
90
+ wiki.log.warn("Img: Undefined option #{option}") if wiki.log.warn?
91
+ end #case option
92
+ } if options
93
+ @img.attr[:style] << css
94
+
95
+ end
96
+ def to_doc(target, options = {})
97
+ @img.to_doc(target, options)
98
+ end
99
+ end #Creole_inclusion_img
100
+
101
+ #
102
+ #Collection of footnotes.
103
+ #
104
+ class Creole_footnote_group < Creole_inclusion_and_plugin
105
+ #
106
+ Creole::Plugins['footnotes'] = self
107
+ #~ Creole::Inclusions['footnotes'] = self
108
+
109
+ def initialize( inclusionname, description, options, wiki )
110
+ super
111
+ description = Footnotegroup::DEFAULTGROUPID unless description
112
+ @footnotesgroup = wiki.footnotegroups[description]
113
+ wiki.log.error("Footnotesgroup #{description.inspect} not found") if ! @footnotesgroup and wiki.log.error?
114
+ end
115
+ def to_doc(target, options = {})
116
+ @footnotesgroup.to_doc(target, options)
117
+ end
118
+ end #Creole_inclusion_footnote_group
119
+
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.
125
+ class Creole_footnote < Creole_inclusion_and_plugin
126
+ Creole::Plugins['footnote'] = self
127
+ #~ Creole::Inclusions['footnote'] = self
128
+ def initialize( inclusionname, description, options, wiki )
129
+ super
130
+
131
+ @groupid = Footnotegroup::DEFAULTGROUPID
132
+ label = nil
133
+
134
+ options.each{|option|
135
+ case option
136
+ when /label\s*=\s*(.*)/
137
+ label = $1
138
+ when /groupid\s*=\s*(.*)/
139
+ @groupid = $1
140
+ else
141
+ @wiki.log.warn("Footnote with unknown option #{option.inspect} not found") if @wiki.log.warn?
142
+ end
143
+ }
144
+
145
+ if ! wiki.footnotegroups[@groupid]
146
+ wiki.footnotegroups[@groupid] = Footnotegroup.new(@groupid)
147
+ end
148
+
149
+ group = wiki.footnotegroups[@groupid]
150
+
151
+ @footnote = element(:footnote,{
152
+ :group => group,
153
+ :label => label,
154
+ }, description )
155
+
156
+
157
+ end
158
+ def to_doc(target, options ={})
159
+ @footnote.to_doc(target, options)
160
+ end
161
+ end #Creole_inclusion_footnote
162
+
163
+ #
164
+ #Eval the given ruby-code and put it as "raw text".
165
+ #
166
+ #
167
+ #This is defined as a plugin.
168
+ class Creole_plugin_ruby_raw < Creole_inclusion_and_plugin
169
+ #~ Creole::Inclusions['ruby'] = self
170
+ Creole::Plugins['ruby_raw'] = self
171
+
172
+ def initialize( inclusionname, description, options, wiki )
173
+ #The ruby-code may contain | - so we have to ad it again
174
+ description << "|#{options.join('|')}" unless options.empty?
175
+ options = nil
176
+ super
177
+ @code = description
178
+ begin
179
+ @result = eval(@code)
180
+ rescue => bang
181
+ wiki.log.error("Plugin ruby_raw: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
182
+ end
183
+ end #initioliaze
184
+ def to_doc(target, options ={})
185
+ @result.to_s
186
+ end
187
+ def inspect()
188
+ "#<Creole_plugin_ruby_raw:#{@code}>"
189
+ end
190
+ end #Creole_plugin_ruby
191
+
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.
198
+ class Creole_plugin_ruby < Creole_inclusion_and_plugin
199
+ #~ Creole::Inclusions['ruby'] = self
200
+ Creole::Plugins['ruby'] = self
201
+ def initialize( inclusionname, description, options, wiki )
202
+ #The ruby-code may contain | - so we have to ad it again
203
+ description << "|#{options.join('|')}" unless options.empty?
204
+ options = nil
205
+ super
206
+
207
+ @code = description
208
+ begin
209
+ @result = eval(@code)
210
+ rescue => bang
211
+ wiki.log.error("Plugin ruby: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
212
+ end
213
+ end #initioliaze
214
+ def to_doc(target, options = {})
215
+ @wiki.normsource2elements(
216
+ @wiki.parse(@result.to_s ), options
217
+ ).to_doc(target, options )
218
+ end
219
+ def inspect()
220
+ "#<Creole_plugin_ruby:#{@code}>"
221
+ end
222
+ end #Creole_plugin_ruby
223
+
224
+ #~ if $0 == __FILE__
225
+ #~ require 'quicktest'
226
+ #~ end
227
+
228
+
229
+ __END__
230
+ Fixme for image:
231
+ pack it for a figure-environment (HTML: div/span + float)
232
+ {{test.jpg|description|beforetitle=vorher]]
233
+ {{test.jpg|description|aftertitle=nachher}}
234
+ {{test.jpg|description|figureclass=imgclass}}
235
+ description = caption
236
+
@@ -0,0 +1,74 @@
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
12
+ class Creole_placeholder
13
+
14
+ def initialize( wiki )
15
+ @wiki = wiki
16
+ @log = @wiki.log
17
+ end
18
+ def << (content)
19
+ @source = [] unless @source
20
+ @source << content
21
+ end
22
+ #
23
+ #possibility to analyse the content.
24
+ def close()
25
+ end
26
+ def to_doc( target, options = {})
27
+ @source.to_doc( target, options )
28
+ end
29
+ end #Creole_placeholder
30
+
31
+ #Just a dummy for wrong definitions.
32
+ #
33
+ #This class is used by Creole a default placeholder.
34
+ class Creole_dummy_placeholder < Creole_placeholder
35
+ Creole::Placeholders.default = self
36
+ end #Creole_dummy_placeholder
37
+
38
+ #
39
+ #Placeholder for pure HTML-output.
40
+ #This content is ignored in LaTeX, Wiki... documents.
41
+ class Creole_html < Creole_placeholder
42
+ Creole::Placeholders['html'] = self
43
+ #Return content only for html
44
+ def to_doc( target, options = {})
45
+ target == :html ? @source.to_doc( target, options ) : ''
46
+ end
47
+ end #Creole_html
48
+
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?
59
+ class Creole_latex < Creole_placeholder
60
+ Creole::Placeholders['latex'] = self
61
+ #Return content only for latex
62
+ def to_doc( target, options = {})
63
+ target == :latex ? @source.to_doc( target, options ) : ''
64
+ end
65
+ end #Creole_latex
66
+
67
+
68
+ __END__
69
+ To be done:
70
+ class Creole_rail
71
+ class Creole_struktogramm
72
+ rubycode (see plugin Creole_plugin_ruby )
73
+
74
+ Steuerparameter mit | nach plugin-name?
@@ -0,0 +1,170 @@
1
+ require 'creole2doc' if __FILE__ == $0
2
+
3
+ <<fixme
4
+ taboptions:
5
+ - border=: HTML
6
+ - .* = (.*): Used for CSS
7
+ newline-options
8
+ - toprule
9
+ - midrule
10
+ - hline
11
+ - .* = (.*): Used for CSS
12
+ lineoptions:
13
+ - colspan =
14
+ - pos
15
+ - .* = (.*): Used for CSS
16
+ fixme
17
+
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
32
+ class Creole_creoletab < Creole_placeholder
33
+ Creole::Placeholders['creole_tabular'] = self #original creole-tab definition
34
+ #Finish the tabular.
35
+ #Each cell is added left justified.
36
+ def close(options)
37
+ #~ @log.error("Standard creole tabulars not supported yet" )
38
+
39
+ step = 0 #start
40
+ head = []
41
+ content = []
42
+ @source.each{|line|
43
+ content << []
44
+ #delete trailing empty cells
45
+ line.chomp.gsub(/\|\s*$/,'').split(/\|/)[1..-1].each{|cell|
46
+ case cell
47
+ when /^=/
48
+ content.last << Cell.new(@wiki.inline($~.post_match.strip, options),:th)
49
+ else
50
+ content.last << Cell.new(@wiki.inline(cell.strip, options), :td)
51
+ end
52
+ }
53
+ }
54
+
55
+ max_size = 0
56
+ content.each{|line|
57
+ max_size = [max_size, line.size].max
58
+ }
59
+
60
+ @tab = element(:tabular, {#:style => tab_css,
61
+ :columns => max_size,
62
+ :columndescription => 'l' * max_size,
63
+ }).cR
64
+ content.each{|line|
65
+ @tab << row = element(:row).cr
66
+ line.each{|cell|
67
+ #fixme cell to wiki/creole
68
+ row << element(cell.type,{}, cell.content).cr
69
+ }
70
+ }
71
+ end
72
+ def to_doc( target, options = {})
73
+ self.close(options) unless @tab
74
+ @tab.to_doc( target, options )
75
+ end
76
+ end #Creole_tab
77
+
78
+ #
79
+ #Create tabulars analog to Wikimedia.
80
+ class Creole_tabular < Creole_placeholder
81
+ Creole::Placeholders['tabular'] = self
82
+ #Build the tabular.
83
+ def close()
84
+ #~ fixme:
85
+ #~ *CSS-format
86
+ #~ *generelle def
87
+
88
+ step = 0 #start
89
+ head = []
90
+ content = [[]]
91
+ options = {}
92
+ tab_css = CSS.new( :log => @log )
93
+ @source.each{|cell|
94
+ case cell
95
+ when /^\|!/ #generell cell definition
96
+ case $~.post_match().strip
97
+ when /columns\s*=\s*(.*)/
98
+ options[:columns] = $1.to_i
99
+ when /columndescription\s*=\s*(.*)/
100
+ options[:columndescription] = $1
101
+ when /css\s*=\s*(.*)\s*:\s*(.*)/
102
+ tab_css[$1] = $2
103
+ when '' #
104
+ else
105
+ @log.warn("#{self}: Unknown tabular option #{$1}") if @log.warn?
106
+ end
107
+ when /^\|-(.*)/ #new line
108
+ content << []
109
+ when /^\|=/ #header cell
110
+ content.last << Cell.new(@wiki.inline($~.post_match.strip, options), :th)
111
+ when /^\|/ #content of a cell
112
+ content.last << Cell.new(@wiki.inline($~.post_match.strip, options), :td)
113
+ else #error!
114
+ raise 'cell/log-warning'
115
+ end
116
+ }
117
+
118
+ max_size = 0
119
+ content.each{|line|
120
+ max_size = [max_size, line.size].max
121
+ }
122
+
123
+ if options[:columns] and options[:columns] < max_size
124
+ @log.warn("Creole-tabular: Defined size #{options[:columns]} < no of columns (#{max_size})") if @log.warn?
125
+ end
126
+
127
+ @tab = element(:tabular, { :style => tab_css,
128
+
129
+ }.merge(options) ).cR
130
+ content.each{|line|
131
+ @tab << row = element(:row).cr
132
+ line.each{|cell|
133
+ #fixme cell to wiki/creole
134
+ row << element(cell.type,{}, cell.content).cr
135
+ }
136
+ }
137
+ end
138
+ def to_doc( target, options = {})
139
+ @tab.to_doc( target, options )
140
+ end
141
+
142
+ end
143
+
144
+ __END__
145
+
146
+ class Creole_tabular_cvs
147
+ include Creole_placeholder
148
+ >>>tab
149
+ |! Tabdefinition crl
150
+ |! implizit columns
151
+ |= -> th
152
+ yy;yy;yy;
153
+ yy;yy;yy;
154
+ yy;yy;yy;
155
+ <<<
156
+
157
+
158
+ Die Syntax:
159
+ *{| beginnt eine Tabelle. Hier k�nnen zus�tzliche Formatierungseigenschaften kommen.
160
+ **Zumindest columns==__ sollte gesetzt sein
161
+ *! beginnt eine neue Zelle einer Titelzeile
162
+ *| beginnt eine neue Zelle
163
+ *|format| z.B. rowspan...
164
+ *|format|| Zwei || beenden die Parameter der Zelle.
165
+ Dann sinnvoll, wenn im Text selbst ein | vorkommt
166
+ (z.B. ein Macro verwendet wird)
167
+ *|- trennt zwei Zeilen der Tabelle
168
+ **hline: Zus�tzlicher Trennstrich �ber der Zeile
169
+ **toprule, midrule, bottomrule: Zus�tzlicher Trennstrich �ber der Zeile (erfordert booktabs.sty)
170
+ *|} beendet eine Tabelle
data/lib/docgenerator.rb CHANGED
@@ -3,8 +3,17 @@
3
3
  #Plain text and a Wiki-version exist also, but they are not well maintained.
4
4
  #
5
5
  #
6
+ #==Wiki
7
+ #Docgenerator is also the base for two Wiki-analyser.
8
+ #Both parse a wiki-source and build a docgenerator tree.
9
+ #In combination, you get a wiki to html and wiki to LaTeX converter.
10
+ #
11
+ #Details see
12
+ #- Creole (Creole-syntax)
13
+ #- Wikitext (Wikimedia-syntax, no longer supported.)
14
+ #
6
15
  #==Elements
7
- #A document is structured by elements.
16
+ #A document is structured by Element.
8
17
  #Each element contains attributes/parameters and content.
9
18
  #(Think of HTML-attributes and TeX-Parameters and the content of HTML-Tags and TeX-Environments.).
10
19
  #
@@ -17,7 +26,7 @@
17
26
  #Some elements (in fact, most of them) are generated dynamic,
18
27
  #so they will not occur in this generated documentation).
19
28
  #
20
- #== Examples
29
+ #=== Examples
21
30
  #A document with a paragraph:
22
31
  # doc = Document.new
23
32
  # doc.body << element(:p,{}, 'Content')
@@ -34,6 +43,7 @@
34
43
  #
35
44
  #See the unit tests and the examples-folder of the docgenerator distribution for more examples.
36
45
  #
46
+ #
37
47
  #== Known problems
38
48
  #This program is developed under Windows.
39
49
  #I expect encoding problems on other systems
@@ -60,12 +70,11 @@ require 'yaml' #needed by docgenerator_template.rb
60
70
  #How to handle the End-Tag for br/hr...
61
71
  #- false: set <br /> (XHTML)
62
72
  #- nil: set <br> (HTML)
73
+ #
63
74
  #Problem:
64
75
  #HTML may have no endtags, XHTML requires it.
65
- #~ Die Konstante ENDTAG macht es einstellbar.
66
- #~ Zu machen: Flag im Dokument ob HTML oder XHTML.
67
- #~ Aber woher weiss element in welches Dokument es geh�rt?
68
- #~ Gleiche Problem bei to_s, bzw. Document.target
76
+ #This constant defines it global.
77
+ #Fixme: Flag it in the HTML-template what you need.
69
78
  ENDTAG = false if ! defined?( ENDTAG )
70
79
 
71
80
 
@@ -39,7 +39,7 @@ class Attribute
39
39
  when :wiki
40
40
  attributeclass.class_eval('def wiki?(); true; end')
41
41
  else
42
- puts "Attribute: Unknown setting <#{setting.inspect}>"
42
+ DOCGENERATOR_LOGGER.error("Attribute: Unknown setting <#{setting.inspect}>") if DOCGENERATOR_LOGGER.error?
43
43
  end
44
44
  }
45
45
  if values
@@ -74,7 +74,7 @@ class Attribute
74
74
  #Sometimes the content of an attribute is needed directly.
75
75
  def content(); @attr_content; end
76
76
  #Check if content was added
77
- def filled?(); return @attr_content.size > 0; end
77
+ def filled?(); return @attr_content.compact.size > 0; end
78
78
  #Attribut is used for HTML.
79
79
  def html?(); false; end
80
80
  #Attribut is used for Text.
@@ -41,6 +41,11 @@ Element.create( [:percent, :'%'], {},false,
41
41
  :latex => '\%'
42
42
  } )
43
43
 
44
+ Element.create( [:dollar, :'$'], {},false,
45
+ { :html => '$',
46
+ :latex => '\$'
47
+ } )
48
+
44
49
  Element.create( [:'^'], {},false,
45
50
  { :html => '^',
46
51
  :latex => '\hat{}'
@@ -78,21 +83,25 @@ Element.create( [:radic], {},false,
78
83
 
79
84
  Element.create( [:rarr, :rightarrow, :'->'], {},false,
80
85
  { :html => '&rarr;',
81
- :latex => '\ensuremath{\rightarrow}'
86
+ :latex => '\ensuremath{\rightarrow}',
87
+ :text => '->',
82
88
  } )
83
89
 
84
90
  Element.create( [:rArr, :Rightarrow, :'=>'], {},false,
85
91
  { :html => '&rArr;',
86
- :latex => '\ensuremath{\Rightarrow}'
92
+ :latex => '\ensuremath{\Rightarrow}',
93
+ :text => '=>',
87
94
  } )
88
95
  Element.create( [:larr, :leftarrow, :'<-'], {},false,
89
96
  { :html => '&larr;',
90
- :latex => '\ensuremath{\leftarrow}'
97
+ :latex => '\ensuremath{\leftarrow}',
98
+ :text => '<-',
91
99
  } )
92
100
 
93
101
  Element.create( [:lArr, :Leftarrow, :'<='], {},false,
94
102
  { :html => '&lArr;',
95
- :latex => '\ensuremath{\Lefttarrow}'
103
+ :latex => '\ensuremath{\Lefttarrow}',
104
+ :text => '<=',
96
105
  } )
97
106
 
98
107
  Element.create( [:uArr, :Uparrow ], {},false,
@@ -164,8 +173,15 @@ Element.create( [:empty], {},false,
164
173
  Element.create( [:'_', :underscore], {},false,
165
174
  { :html => '_',
166
175
  :latex => '\_',
176
+ :wiki => '_',
177
+ :text => '_',
167
178
  } )
168
179
 
180
+ Element.create( [:'...', :ldots], {},false,
181
+ { :html => '&hellip;',
182
+ :latex => '\ldots ',
183
+ } )
184
+
169
185
  Element.create( [:bullet], {},false,
170
186
  { :html => '&#149;',
171
187
  :latex => '\ensuremath{\bullet}'