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,303 @@
1
+ module Docgenerator
2
+ =begin rdoc
3
+ ===Meta-methods
4
+ The Element-class contains meta functions to define the
5
+ behaviour of subclasses.
6
+
7
+ Details see
8
+ * Element.inherited
9
+ * Element.add_id
10
+ * Element.has_no_content
11
+ * Element.add_attribute
12
+ * Element.add_attributes
13
+ * Element.add_output
14
+ * Element.add_latex_output
15
+ * Element.add_html_output
16
+ * Element.add_context_output
17
+ * Element.add_creole_output
18
+ * Element.add_wiki_output
19
+ * Element.add_text_output
20
+ =end
21
+ class Element
22
+
23
+ #Hash with all ids and their corresponding classes.
24
+ @@ids = Hash.new( )
25
+
26
+ =begin rdoc
27
+ Meta-class for metaprogramming
28
+ =end
29
+ class << self #Meta-class Element
30
+ =begin rdoc
31
+ This method is called, when a subclass of this class is defined.
32
+
33
+ The class will be added to the element list with class name, converted to a symbol
34
+ (modules are extracted in adcance).
35
+ The element ma be created with element-method.
36
+ =end
37
+ def inherited( subclass )
38
+ DOCGENERATOR_LOGGER.info("New Element class: #{subclass}") if DOCGENERATOR_LOGGER.debug?
39
+ if subclass.name
40
+ subclass.add_id(subclass.name.split('::').last.downcase.to_sym)
41
+ else
42
+ DOCGENERATOR_LOGGER.warn("New Element class without name: #{subclass}") if DOCGENERATOR_LOGGER.warn?
43
+ end
44
+ end
45
+ =begin rdoc
46
+ Define meta/class accessor to element_ids.
47
+
48
+ @element_ids isd defined in Element.add_id
49
+
50
+ =end
51
+ def element_ids; @element_ids; end
52
+ =begin rdoc
53
+ Add a new element class or assign another name (synonym) for a class.
54
+ The initial call is made by Element.inherited.
55
+ =end
56
+ def add_id(id)
57
+ @element_ids ||= []
58
+ if @@ids[ id ] == nil
59
+ DOCGENERATOR_LOGGER.debug("Element id '#{id}' is new for #{self}") if DOCGENERATOR_LOGGER.debug?
60
+ #All new ids are collected
61
+ @@ids[ id ] = self
62
+ @element_ids << id
63
+ elsif @@ids[ id ] == self
64
+ DOCGENERATOR_LOGGER.warn("Element class '#{id}' is defined double: #{self}") if DOCGENERATOR_LOGGER.warn?
65
+ else
66
+ DOCGENERATOR_LOGGER.error("Error: ID '#{id}' is redefined #{@@ids[id]} -> #{self}") if DOCGENERATOR_LOGGER.error?
67
+ @@ids[id] = self
68
+ @element_ids << id
69
+ end
70
+ end
71
+ #Return a element class.
72
+ def get( name )
73
+ return @@ids[name]
74
+ end
75
+
76
+ =begin rdoc
77
+ Set flag, that the element does not support content.
78
+
79
+ See also Docgenerator::Element#content?
80
+ =end
81
+ def has_no_content(value = nil)
82
+ self.class_eval( "def content?(); #{value.inspect}; end" )
83
+ end
84
+
85
+ =begin rdoc
86
+ Add a attribute to the metaclass
87
+
88
+ Example:
89
+ class XX < Element
90
+ add_attribute :key, Attribute.create( ... )
91
+ }
92
+ end
93
+ =end
94
+ def add_attribute(id, attribute)
95
+ @attr = {} unless @attr
96
+ #~ if ! attribute.is_a?(Attribute)
97
+ #~ DOCGENERATOR_LOGGER.error("Attribute #{id} is no Docgenerator::Attribute but #{attribute.inspect}") if DOCGENERATOR_LOGGER.error?
98
+ #~ end
99
+ @attr[id] = attribute
100
+ end
101
+ =begin rdoc
102
+ Add possible attributes to an element class.
103
+
104
+ Attributes are defined in a hash, each key get a Attribute-instance.
105
+
106
+ Example:
107
+ class XX < Element
108
+ add_attributes {
109
+ :key => Attribute.create( ... ),
110
+ }
111
+ end
112
+ =end
113
+ def add_attributes( attr )
114
+ attr.each{ |k,a |
115
+ self.add_attribute(k,a)
116
+ }
117
+ end
118
+ =begin rdoc
119
+ Return the attributes for the metaclass.
120
+ =end
121
+ def attributes()
122
+ @attr || {}
123
+ end
124
+
125
+ =begin rdoc
126
+ Returns list of attributes.
127
+ Can be used for copying attributes from one class to another class.
128
+ =end
129
+ def get_attribute_list()
130
+ return self.attributes
131
+ end
132
+
133
+ =begin rdoc
134
+ Add an output routine.
135
+
136
+ Called by
137
+ * add_latex_output
138
+ * add_context_output
139
+ * add_html_output
140
+ * add_text_output
141
+ * add_wiki_output
142
+ * add_creole_output
143
+
144
+ The definition can be made in two ways:
145
+ * block
146
+ * result string
147
+
148
+
149
+ For very complex elements, it may be better to
150
+ use the block variant or to redefine to_latex, to_html ...
151
+
152
+
153
+ =Definition with block
154
+ Example:
155
+ add_output(:latex) {|options = {}|
156
+ o = set_option_defaults(options) #define logger
157
+ o[:log].debug("enter to_doc(#{target}) for #{self.inspect}") if o[:log].debug?
158
+ ...
159
+ }
160
+
161
+ The block must contain one optional parameter (default {}).
162
+
163
+
164
+ =Definition with result string
165
+ Example:
166
+ add_output( :latex, '\section{#{@content}}' )
167
+
168
+ The string contains the result.
169
+ The string will be interpreted, when the to_xxxx method is called.
170
+
171
+ Examples for string:
172
+ '#{linebreak(@crbefore)}\section{#{@content}}#{linebreak(@crafter)}'
173
+
174
+ =Some special helper to build the result:
175
+ ==linebreaks
176
+ linebreak(xx) will create a #linebreak, when xx is true.
177
+ xx may be @crbefore, @crmid, @crafter.
178
+ The variables can be influenced by #cr, #Cr, #cR, #CR.
179
+
180
+ ==recursive content
181
+ '@content}' will be replaced by '@content.to_doc( _target_ , o)}'
182
+
183
+ * If you define something like @content.to_html..., please give attention for the options.
184
+
185
+ ==Attributes
186
+ Attributes can be accessed with @attr[:key]
187
+
188
+ ===Key-val attributes
189
+ #texkeyval add all attributes with flag :texkeyval. (see Attribute#texkeyval?)
190
+
191
+ =end
192
+ def add_output( target, string = nil, &proc )
193
+
194
+ if ! [ :latex, :context, :html, :text, :wiki, :creole ].include?(target)
195
+ DOCGENERATOR_LOGGER.error("#{self}: Undefined target format #{target}") if DOCGENERATOR_LOGGER.error?
196
+ end
197
+
198
+ if block_given?
199
+ if string
200
+ DOCGENERATOR_LOGGER.error("add_output #{target} contains result string and block. Use the block definietion #{self.inspect}") if DOCGENERATOR_LOGGER.error?
201
+ end
202
+ #The (optional) parameter should be {} by default.
203
+ if proc.respond_to?(:parameters) #since ruby 1.9.2
204
+ if proc.parameters.size != 1 #Proc#parameters introduced with ruby 1.9.2
205
+ DOCGENERATOR_LOGGER.error("add_output #{target}: Arity of block not 1 but #{proc.parameters.inspect} #{self.inspect}") if DOCGENERATOR_LOGGER.error?
206
+ elsif proc.parameters.first.first != :opt
207
+ DOCGENERATOR_LOGGER.error("add_output #{target}: Block parameter is not optional #{proc.parameters.inspect} #{self.inspect}") if DOCGENERATOR_LOGGER.error?
208
+ #the optional parameter should have the default {}
209
+ #no way to test it, see http://forum.ruby-portal.de/viewtopic.php?f=22&t=12384
210
+ end
211
+ else #Proc#parameters not supported
212
+ if proc.arity > 1 #makes arity 0 also for optional parameters.
213
+ DOCGENERATOR_LOGGER.error("add_output #{target}: Arity of block not 1 but #{proc.arity} #{self.inspect}") if DOCGENERATOR_LOGGER.error?
214
+ end
215
+ end
216
+ #Define the method.
217
+ define_method( "to_#{target}".to_sym, &proc )
218
+ else #block_given?
219
+ =begin
220
+ Define the output routine, based on a string.
221
+ =end
222
+ if ! string.kind_of?( String )
223
+ DOCGENERATOR_LOGGER.error("<#{self.inspect}>#add_output: #{string.inspect} is no String")
224
+ end
225
+ cmd = <<-code
226
+ def to_#{target}(options = {})
227
+ o = set_option_defaults(options)
228
+ o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: \#{options.keys.inspect}") if o[:log].debug?
229
+ code
230
+ template = string.gsub(/\\/, '\\\\\\')
231
+ template.gsub!(/"/, '\"')
232
+ #define recursive to_doc for content.
233
+ #the closing \} is important. Else you replace '@content.to_latex' with @content.to_doc.to_latex'
234
+ template.gsub!(/@content\}/, "@content.to_doc(#{target.inspect}, o)}")
235
+ cmd << " \"#{template}\"\n"
236
+ cmd << "end\n"
237
+ class_eval( cmd )
238
+ cmd #return cmd for unit test
239
+ end #block_given?
240
+ end
241
+ =begin rdoc
242
+ Define the HTML-tag for the to_html method.
243
+ =end
244
+ def add_html_tag( tag )
245
+ self.class_eval( "def htmltag()\n'#{tag}'\nend" )
246
+ end
247
+ =begin rdoc
248
+ Define the output routine for html.
249
+ See Element.add_output for details.
250
+ =end
251
+ def add_html_output( output = nil, &cmd )
252
+ self.add_output(:html, output, &cmd )
253
+ end
254
+ =begin rdoc
255
+ Define the output routine for LaTeX.
256
+ See Element.add_output for details.
257
+ =end
258
+ def add_latex_output( output = nil, &cmd )
259
+ self.add_output(:latex, output, &cmd )
260
+ end
261
+ =begin rdoc
262
+ Define the output routine for conTeXt.
263
+ See Element.add_output for details.
264
+ =end
265
+ def add_context_output( output = nil, &cmd )
266
+ self.add_output(:context, output, &cmd )
267
+ end
268
+ =begin rdoc
269
+ Define the output routine for text.
270
+ See Element.add_output for details.
271
+ =end
272
+ def add_text_output( output = nil, &cmd )
273
+ self.add_output(:text, output, &cmd )
274
+ end
275
+ =begin rdoc
276
+ Define the output routine for wiki.
277
+ See Element.add_output for details.
278
+ =end
279
+ def add_wiki_output( output = nil, &cmd )
280
+ self.add_output(:wiki, output, &cmd )
281
+ end
282
+ =begin rdoc
283
+ Define the output routine for creole.
284
+ See Element.add_output for details.
285
+ =end
286
+ def add_creole_output( output = nil, &cmd )
287
+ self.add_output(:creole, output, &cmd )
288
+ end
289
+
290
+ end #Meta-class Element
291
+
292
+ =begin rdoc
293
+ Return all id's of the class.
294
+ The ids are filled via Element.add_id
295
+ =end
296
+ def element_ids()
297
+ #~ myids = []
298
+ #~ @@ids.each{|k,v| myids << k if v == self.class and k.class != Class }
299
+ return self.class.element_ids
300
+ end
301
+
302
+ end #Element
303
+ end #Docgenerator
@@ -1,74 +1,107 @@
1
- #~ @attr = {:short=> 1}
2
- #~ puts "\title#{"[#{@attr[:short]}]" if @attr[:short]}"
3
- #~ __END__
1
+ =begin rdoc
2
+ Definition of basic elements for docgenerator.rb
3
+ =end
4
4
 
5
5
  #
6
- #Definition of elements for DocGenerator.rb
7
- #
8
- #
6
+ module Docgenerator
7
+ =begin rdoc
8
+ Module to collect subclasses of class Element
9
+ =end
10
+ module Elements
9
11
 
10
12
  #
11
13
  #Main document control.
12
14
  #
13
- Element.create( [:head], {}, true,
14
- { :htmltag => 'head',
15
- :latex => '#{@content}',
16
- :context => '#{@content}',
17
- :text => '#{@content}',
18
- :wiki => '#{@content}',
19
- :creole => '#{@content}',
20
- } )
21
- Element.create( [:body], {
22
- :bgcolor => Attribute.create( [ :html ] ),
23
- :text => Attribute.create( [ :html ] ),
24
- :link => Attribute.create( [ :html ] ),
25
- :vlink => Attribute.create( [ :html ] ),
26
- :alink => Attribute.create( [ :html ] ),
27
- }.update(HTML_ATTR_CORE.dup.update(HTML_ATTR_I18N)),
28
- true,
29
- { :htmltag => 'body',
30
- :latex => '#{@content}',
31
- :context => '#{@content}',
32
- :text => '#{@content}',
33
- :wiki => '#{@content}',
34
- :creole => '#{@content}',
35
- } )
36
-
37
- Element.create( [:latexdummy, :latexonly ], {},true,
38
- { :htmltag => nil,
39
- :html => '',
40
- :latex => '#{@content}',
41
- :context => '',
42
- } )
43
- Element.create( [:htmldummy, :htmlonly ], {},true,
44
- { :html => '#{@content}',
45
- :latex => '',
46
- :context => '',
47
- } )
15
+
16
+ =begin rdoc
17
+ Define Element ':head'
18
+
19
+ Create an instance with
20
+ element( :head, [ attributes, [content]] )
21
+
22
+ Head.new( [ attributes, [content]] )
23
+ =end
24
+ class Head < Element
25
+ add_html_tag 'head'
26
+ add_latex_output '#{@content}'
27
+ add_context_output '#{@content}'
28
+ add_text_output '#{@content}'
29
+ add_wiki_output '#{@content}'
30
+ add_creole_output '#{@content}'
31
+ end #Head
32
+
33
+ =begin rdoc
34
+ Define Docgenerator::Element ':body'
35
+ =end
36
+ class Body < Element
37
+ add_attributes HTML_ATTR_CORE
38
+ add_attributes HTML_ATTR_I18N
39
+ add_attribute :lang, ATTR_LANG
40
+ add_attribute :bgcolor, Attribute.create( [ :html ] )
41
+ add_attribute :text, Attribute.create( [ :html ] )
42
+ add_attribute :link, Attribute.create( [ :html ] )
43
+ add_attribute :vlink, Attribute.create( [ :html ] )
44
+ add_attribute :alink, Attribute.create( [ :html ] )
45
+
46
+ add_html_tag 'body'
47
+ add_latex_output '#{@content}'
48
+ add_context_output '#{@content}'
49
+ add_text_output '#{@content}'
50
+ add_wiki_output '#{@content}'
51
+ add_creole_output '#{@content}'
52
+ end #Body
53
+
54
+ =begin rdoc
55
+ Define Element :latexdummy, :latexonly
56
+
57
+ Usefull, if you have LaTeX-only text in your document.
58
+ (e.g. \\newcommands in the header).
59
+ =end
60
+ class Latexdummy < Element
61
+ add_id :latexonly
62
+ add_html_output ''
63
+ add_latex_output '#{@content}'
64
+ add_context_output ''
65
+ add_text_output ''
66
+ add_wiki_output ''
67
+ add_creole_output ''
68
+ end #Latexdummy
69
+
70
+ =begin rdoc
71
+ Define Element :htmldummy, :htmlonly
72
+ =end
73
+ class Htmldummy < Element
74
+ add_id :htmlonly
75
+ add_html_output '#{@content}'
76
+ add_latex_output ''
77
+ add_context_output ''
78
+ add_text_output ''
79
+ add_wiki_output ''
80
+ add_creole_output ''
81
+ end #Htmldummy
48
82
 
49
83
 
50
84
  =begin rdoc
51
85
  Titlepage
52
86
 
53
- This parameter are better set with Document.title.
87
+ This parameter are better set with
88
+ Docgenerator::Document.new(
89
+ :title => 'title'
90
+ )
54
91
  =end
55
92
  class Title < Element
56
- Element.add( [:title], Title)
57
- add_attributes( {
58
- :short => Attribute.create( [ :html ], nil, 1 )
59
- }.update(HTML_ATTR_ALL)
60
- )
93
+ add_attributes HTML_ATTR_ALL
94
+ add_attribute :short, Attribute.create( [ :html ], nil, 1 )
95
+
61
96
  =begin rdoc
62
97
  Does the LaTeX-class support the shorttitle-option?
63
98
 
64
99
  beamer.sty does it, others not.
65
-
66
- #Unsaubere realisierung .. fixme
67
100
  =end
68
101
  def shortoption( options = {} )
69
102
  @attr[:short].content.compact! #delete nils.
70
103
  return nil if ! @attr[:short].filled?
71
- o = Docgenerator_logger.set_option_defaults(options)
104
+ o = set_option_defaults(options)
72
105
  o[:log].debug("enter shortoption") if o[:log].debug?
73
106
  if o[:document]
74
107
  #Check for known classes, which support the optional short title
@@ -83,100 +116,161 @@ beamer.sty does it, others not.
83
116
  end
84
117
  return nil
85
118
  end
86
- #Add shorttitle as a meta-tag.
87
- def shorttitle_html()
88
- return nil if ! @attr[:short].filled?
89
- return element( :meta, {:name => 'shorttitle', :content => @attr[:short].content }).to_html
119
+ =begin rdoc
120
+ Add shorttitle as a meta-tag., options should contain :log
121
+ =end
122
+ def shorttitle_html(options = {})
123
+ return nil unless @attr[:short].filled?
124
+ return element( :meta, {:name => 'shorttitle', :content => @attr[:short].content}).to_html(:log => options[:log])
90
125
  end
91
126
 
127
+ =begin rdoc
128
+ Define output routines.
129
+ =end
92
130
  add_output( :latex, '#{linebreak(@crbefore)}\title#{shortoption(o)}{#{@content}}#{linebreak(@crmid)}\hypersetup{pdftitle={#{@content}}}#{linebreak(@crafter)}')
93
131
  #~ add_output( :latex, '#{linebreak(@crbefore)}\title{#{@content}}#{linebreak(@crmid)}\hypersetup{pdftitle={#{@content}}}#{linebreak(@crafter)}')
94
- add_output( :html, '#{linebreak(@crbefore)}<title>#{@content}</title>#{linebreak(@crmid) if shorttitle_html}#{shorttitle_html}#{linebreak(@crafter)}')
132
+ add_output( :html, '#{linebreak(@crbefore)}<title>#{@content}</title>#{linebreak(@crmid) if shorttitle_html(o)}#{shorttitle_html(o)}#{linebreak(@crafter)}')
95
133
 
96
134
  add_output( :text, "\n" + '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}' + "\n")
97
135
  add_output( :wiki, '#{linebreak(@crbefore)}' + '=#{@content}=' + ' #{linebreak(@crafter)}')
98
136
  add_output( :creole, '#{linebreak(@crbefore)}' + '=#{@content}' + ' #{linebreak(@crafter)}')
99
137
  end #Title
100
138
 
101
- Element.create( [:meta], {
102
- :name => Attribute.create( [ :html, :required ], nil, 1 ),
103
- :content => Attribute.create( [ :html, :required ], nil, 2 ),
104
- }, ENDTAG,
105
- {
106
- :htmltag => 'meta',
107
- #~ :html => '<meta name="#{@attr[:name]}" content="#{@attr[:content]}">',
108
- :latex => '',
109
- :context => '',
110
- # :latex => '#{linebreak(@crbefore)}' + '\author{#{@content}}\hypersetup{pdfauthor={#{@content}}}' + ' #{linebreak(@crafter)}'
111
- :wiki => '',
112
- :creole => '',
113
- :text => '',
114
- } )
115
- #Like Meta, but not name...
116
- Element.create( [:meta2], {
117
- :'http-equiv' => Attribute.create( [ :html, :required ], nil, 1 ),
118
- :content => Attribute.create( [ :html, :required ], nil, 2 ),
119
- }, nil,
120
- {
121
- :htmltag => 'meta',
122
- #~ :html => '<meta name="#{@attr[:name]}" content="#{@attr[:content]}">',
123
- :latex => '',
124
- # :latex => '#{linebreak(@crbefore)}' + '\author{#{@content}}\hypersetup{pdfauthor={#{@content}}}' + ' #{linebreak(@crafter)}'
125
- } )
126
-
127
- Element.create( [:author], {}, true,
128
- { :html => '<meta name="author" content="#{@content}">' + ' #{linebreak(@crafter)}',
129
- :latex => '#{linebreak(@crbefore)}\author{#{@content}}#{linebreak(@crmid)}\hypersetup{pdfauthor={#{@content}}}#{linebreak(@crafter)}'
130
- } )
131
- Element.create( [:date], {}, true,
132
- { :html => '<meta name="creation-date" content="#{@content}">' + ' #{linebreak(@crafter)}',
133
- :latex => '#{linebreak(@crbefore)}\date{#{@content}}#{linebreak(@crafter)}'
134
- } )
135
- Element.create( [:keywords], {}, true,
136
- { :html => '<meta name="keywords" content="#{@content}">' + ' #{linebreak(@crafter)}',
137
- :latex => '#{linebreak(@crbefore)}\hypersetup{pdfkeywords={#{@content}}}#{linebreak(@crafter)}'
138
- } )
139
- Element.create( [:metadescription], {}, true,
140
- { :html => '<meta name="description" content="#{@content}">' + ' #{linebreak(@crafter)}',
141
- :latex => '#{linebreak(@crbefore)}\hypersetup{pdfsubject={#{@content}}}#{linebreak(@crafter)}'
142
- } )
143
- Element.create( [:creator], {}, true,
144
- { :html => '<meta name="creator" content="#{@content}">' + ' #{linebreak(@crafter)}',
145
- :latex => '#{linebreak(@crbefore)}\hypersetup{pdfcreator={#{@content}}}#{linebreak(@crafter)}'
146
- } )
147
- #~ Element.create( [:hypersetup], {}, true,
148
- #~ { :html => '<meta name="description" content="#{@content}">',
149
- #~ :latex => '#{linebreak(@crbefore)}' + '\pdfinfo{description=#{@content}}' + ' #{linebreak(@crafter)}'
150
- #~ } )
151
-
152
- Element.create( [:maketitle], {}, false,
153
- { :htmltag => 'span', #Empty span
154
- :html => "<!-- maketitle -->\n",
155
- :latex => '#{linebreak(@crbefore)}' + '\maketitle #{linebreak(@crafter)}'
156
- } )
157
- #~ Element.create( [:tableofcontents], {}, false,
158
- #~ { :htmltag => 'span', #Empty span
159
- #~ :html => '#{linebreak(@crbefore)}<!-- tableofcontents -->#{linebreak(@crafter)}',
160
- #~ :latex => '#{linebreak(@crbefore)}' + '\tableofcontents ' + ' #{linebreak(@crafter)}'
161
- #~ } )
162
-
163
- #Build table of contents.
164
- #
165
- #This element requires a related document.
166
- #
167
- #For LaTeX \tableofcontents is created, with attribute :as_list you can create a list.
139
+ =begin rdoc
140
+ Define Element :meta
141
+ =end
142
+ class Meta < Element
143
+ has_no_content false
144
+ add_attribute :name, Attribute.create( [ :html, :required ], nil, 1 )
145
+ add_attribute :content, Attribute.create( [ :html, :required ], nil, 2 )
146
+ add_html_tag 'meta'
147
+ add_latex_output ''
148
+ add_context_output ''
149
+ add_wiki_output ''
150
+ add_creole_output ''
151
+ add_text_output ''
152
+ end #Meta
153
+
154
+ =begin rdoc
155
+ Define Element :meta2
156
+
157
+ Like Meta, but without name.
158
+ =end
159
+ class Meta2 < Element
160
+ has_no_content ENDTAG
161
+ add_attribute :"http-equiv", Attribute.create( [ :html, :required ], nil, 1 )
162
+ add_attribute :content, Attribute.create( [ :html, :required ], nil, 2 )
163
+ add_html_tag 'meta'
164
+ add_latex_output ''
165
+ end #Meta2
166
+
167
+ =begin rdoc
168
+ Define Element :author
169
+
170
+ Create an instance with
171
+ element( :author, [ attributes, [content]] )
172
+ or
173
+ Author.new( [ attributes, [content]] )
174
+
175
+ Attributes are not defined for this element.
176
+ =end
177
+ class Author < Element
178
+ add_html_output '<meta name="author" content="#{@content}"> #{linebreak(@crafter)}'
179
+ add_latex_output '#{linebreak(@crbefore)}\author{#{@content}}#{linebreak(@crmid)}\hypersetup{pdfauthor={#{@content}}}#{linebreak(@crafter)}'
180
+ end #Author
181
+
182
+ =begin rdoc
183
+ Define Element :date
184
+
185
+ Create an instance with
186
+ element( :date, [ attributes, [content]] )
187
+ or
188
+ Date.new( [ attributes, [content]] )
189
+ =end
190
+ class Date < Element
191
+ add_html_output '<meta name="creation-date" content="#{@content}"> #{linebreak(@crafter)}'
192
+ add_latex_output '#{linebreak(@crbefore)}\date{#{@content}}#{linebreak(@crafter)}'
193
+ end #Date
194
+
195
+ =begin rdoc
196
+ Define Element :keywords
197
+
198
+ Create an instance with
199
+ element( :keywords, [ attributes, [content]] )
200
+ or
201
+ Keywords.new( [ attributes, [content]] )
202
+
203
+ Attributes are not defined for this element.
204
+ =end
205
+ class Keywords < Element
206
+ add_html_output '<meta name="keywords" content="#{@content}"> #{linebreak(@crafter)}'
207
+ add_latex_output '#{linebreak(@crbefore)}\hypersetup{pdfkeywords={#{@content}}}#{linebreak(@crafter)}'
208
+ end #Keywords
209
+
210
+ =begin rdoc
211
+ Define Element :metadescription
212
+
213
+ Create an instance with
214
+ element( :metadescription, [ attributes, [content]] )
215
+ or
216
+ Metadescription.new( [ attributes, [content]] )
217
+
218
+ Attributes are not defined for this element.
219
+ =end
220
+ class Metadescription < Element
221
+ add_html_output '<meta name="description" content="#{@content}"> #{linebreak(@crafter)}'
222
+ add_latex_output '#{linebreak(@crbefore)}\hypersetup{pdfsubject={#{@content}}}#{linebreak(@crafter)}'
223
+ end #Metadescription
224
+
225
+ =begin rdoc
226
+ Define Element :creator
227
+
228
+ Create an instance with
229
+ element( :creator, [ attributes, [content]] )
230
+ or
231
+ Creator.new( [ attributes, [content]] )
232
+ Attributes are not defined for this element.
233
+ =end
234
+ class Creator < Element
235
+ add_html_output '<meta name="creator" content="#{@content}"> #{linebreak(@crafter)}'
236
+ add_latex_output '#{linebreak(@crbefore)}\hypersetup{pdfcreator={#{@content}}}#{linebreak(@crafter)}'
237
+ end #Creator
238
+
239
+ =begin rdoc
240
+ Define Element :maketitle
241
+
242
+ Create an instance with
243
+ element( :maketitle, [ attributes, [content]] )
244
+ or
245
+ Maketitle.new( [ attributes, [content]] )
246
+ Attributes are not defined for this element.
247
+ =end
248
+ class Maketitle < Element
249
+ has_no_content false
250
+ add_html_tag 'span'
251
+ add_html_output "<!-- maketitle -->\n"
252
+ add_latex_output '#{linebreak(@crbefore)}\maketitle #{linebreak(@crafter)}'
253
+ end #Maketitle
254
+
255
+ =begin rdoc
256
+ Build table of contents.
257
+
258
+ This element requires a related document.
259
+
260
+ For LaTeX \tableofcontents is created, with attribute :as_list you can create a list.
261
+ =end
168
262
  class Tableofcontents < Element
169
- Element.add( [:tableofcontents], Tableofcontents)
170
- add_attributes( {
171
- :level => Attribute.create( [ :html, :latex ], [Fixnum], 1 ),
172
- :pre => Attribute.create( [ :html, :latex ], nil, 2 ),
173
- :post => Attribute.create( [ :html, :latex ], nil, 2 ),
174
- :as_list => Attribute.create( [ :latex ], [true, false], 2 ),
175
- }.update(HTML_ATTR_ALL)
176
- )
177
- def content?(); return false; end
263
+
264
+ add_attributes HTML_ATTR_ALL
265
+ add_attribute :level , Attribute.create( [ :html, :latex ], [Fixnum], 1 )
266
+ add_attribute :pre , Attribute.create( [ :html, :latex ], nil, 2 )
267
+ add_attribute :post , Attribute.create( [ :html, :latex ], nil, 2 )
268
+ add_attribute :as_list , Attribute.create( [ :latex ], [true, false], 2 )
269
+
270
+ has_no_content false
271
+
178
272
  def to_doc( target, options = {} )
179
- o = Docgenerator_logger.set_option_defaults(options)
273
+ o = set_option_defaults(options)
180
274
  o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
181
275
  tocoptions = {
182
276
  :level => @attr[:level].content.first,
@@ -210,7 +304,7 @@ class Tableofcontents < Element
210
304
  end
211
305
  #Build toc, if there is a related document.
212
306
  def to_html( options = {} )
213
- o = Docgenerator_logger.set_option_defaults(options)
307
+ o = set_option_defaults(options)
214
308
  o[:log].debug("enter to_html for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
215
309
  if o[:document]
216
310
  return o[:document].toc(options).to_html(options)
@@ -220,149 +314,376 @@ class Tableofcontents < Element
220
314
  end
221
315
  end
222
316
  end
223
- Element.create( [:addcontentsline], {
224
- :file => Attribute.create( [ :latex, :required ], [ 'toc', 'lof', 'lot' ] ),
225
- :depth => Attribute.create( [ :latex, :required ], [ -1, 0,1,2,3,4,5,6] ),
226
- }, true,
227
- { #:htmltag => 'span', #Empty span
228
- #:html => "<!-- tableofcontents -->\n",
229
- :latex => '#{linebreak(@crbefore)}' + '\addcontentsline{#{@attr[:file]}}{#{@attr[:depth]}}{#{@content}}' + ' #{linebreak(@crafter)}'
230
- } )
231
- Element.create( [:addtocontents], {
232
- :file => Attribute.create( [ :latex, :required ], [ 'toc', 'lof', 'lot' ] ),
233
- }, true,
234
- { #:htmltag => 'span', #Empty span
235
- #:html => "<!-- tableofcontents -->\n",
236
- :latex => '#{linebreak(@crbefore)}' + '\addtocontents{#{@attr[:file]}}{#{@content}}' + ' #{linebreak(@crafter)}'
237
- } )
238
317
 
239
- #
240
- #Generell paragraph handling.
241
- #
242
- Element.create( [:par, :p], HTML_ATTR_ALL, true,
243
- { :htmltag => 'p',
244
- :latex => "\n\n" + '#{@content}' + "\n\n",
245
- :context => "\n\n" + '#{@content}' + "\n\n",
246
- :text => "\n" + '#{@content}' + "\n", #siehe experimente/textformat.rb
247
- :wiki => "\n" + '#{@content}' + "\n", #
248
- :creole => "\n" + '#{@content}' + "\n\n",
249
- } )
250
- #~ par.add_output( :html, '<p>#{@attr[:content]}</p>')
251
- #~ par.add_output( :latex, '#{@content}\par')
252
-
253
- Element.create( [:nobr], HTML_ATTR_ALL, true,
254
- { :htmltag => 'nobr',
255
- :latex => '#{linebreak(@crbefore)}\mbox{#{@content}}#{linebreak(@crafter)}'
256
- #~ :text => "\n" + '#{@content}' + "\n",
257
- } )
258
-
259
- Element.create( [:br, 'br/', 'br', :newline], {
260
- :clear=> Attribute.create( [ :html ], ['all'] ),
261
- },ENDTAG,
262
- { :htmltag => 'br',
263
- :latex => '#{linebreak(@crbefore)}\newline' + ' #{linebreak(@crafter)}',
264
- :text => "\n",
265
- :wiki => '{{newline}}#{linebreak(@crafter)}',
266
- } )
267
- Element.create( [:hr, 'hr/', 'hr', :hrulefill], {
268
- :clear=> Attribute.create( [ :html ], ['all'] ),
269
- },ENDTAG,
270
- { :htmltag => 'hr',
271
- :wiki => '----',
272
- :text => '-' * 25,
273
- :latex => '#{linebreak(@crbefore)}' + '\hrulefill' + ' #{linebreak(@crafter)}'
274
- } )
275
-
276
- Element.create( [:vfill], {},false,
277
- { :htmltag => nil,
278
- :latex => '#{linebreak(@crbefore)}\vfill #{linebreak(@crafter)}'
279
- } )
280
- Element.create( [:hfill], {},false,
281
- { :htmltag => nil,
282
- :latex => '#{linebreak(@crbefore)}\hfill #{linebreak(@crafter)}'
283
- } )
284
-
285
- Element.create( [:relax], {},false,
286
- { :htmltag => nil,
287
- :latex => '#{linebreak(@crbefore)}\relax #{linebreak(@crafter)}'
288
- } )
318
+ =begin rdoc
319
+ Define Element :listoffigures
289
320
 
290
- #
291
- #Grouping
292
- #
293
- Element.create( [:span, :group], HTML_ATTR_CORE, true,
294
- { :htmltag => 'span',
295
- :latex => '#{linebreak(@crbefore)}' +
296
- '\bgroup ' + '#{linebreak(@crmid)}' +
297
- '#{@content}' + '#{linebreak(@crmid)}' +
298
- '\egroup ' + '#{linebreak(@crafter)}'
299
- } )
300
-
301
- divattr = { :align => HTML_ATTR_ALIGN}
302
- divattr.update( HTML_ATTR_CORE )
303
- Element.create( [:div, :Group], divattr, true,
304
- { :htmltag => 'div',
305
- :latex => '#{linebreak(@crbefore)}' +
306
- '\begingroup ' + '#{linebreak(@crmid)}' +
307
- '#{@content}' + '#{linebreak(@crmid)}' +
308
- '\endgroup ' + '#{linebreak(@crafter)}',
309
- :text => '#{@content}',
310
- :wiki => '#{@content}',
311
- } )
312
-
313
-
314
- #Make a separator lin in code
315
- Element.create( [:sepline], {}, false,
316
- { :html => "\n<!--" + '-' * 50 + " -->\n",
317
- :latex => "\n%" + '-' * 50 + "\n"
318
- } )
319
- #Make a comment in code
320
- Element.create( [:comment], {}, true,
321
- { :htmltag => '<!-- #{@content} -->',
322
- :latex => '#{linebreak(@crbefore)}' + '% ------- #{@content} -------' + ' #{linebreak(@crafter)}'
323
- } )
321
+ Create an instance with
322
+ element( :listoffigures, [ attributes, [content]] )
323
+ or
324
+ Listoffigures.new( [ attributes, [content]] )
325
+ Attributes are not defined for this element.
326
+ =end
327
+ class Listoffigures < Element
328
+ has_no_content false
329
+ add_latex_output '#{linebreak(@crbefore)}\listoffigures #{linebreak(@crafter)}'
330
+ end #Listoffigures
324
331
 
325
- #
326
- #Links
327
- #
328
- #Better: \hypertarget, hyperlink (pdf)
329
- Element.create( [ :url ],
330
- HTML_ATTR_ALL,
331
- true,
332
- {
333
- :html => '#{linebreak(@crbefore)}<a href="#{@content}">#{@content}</a>#{linebreak(@crafter)}',
334
- :latex => '#{linebreak(@crbefore)}\url{#{@content}}#{linebreak(@crafter)}',
335
- } )
336
-
337
- Element.create( [ :ensuremath ],
338
- {},
339
- true,
340
- {
341
- :html => '#{@content}',
342
- :latex => '\ensuremath{#{@content}}',
343
- } )
344
332
 
345
- #
346
- #Internal reference
347
- #The href-parameter is expected with a leading # (HTML)
348
- #The corresponding label should be defined in the same document/file.
349
- #
350
- #For external links use :href.
333
+ =begin rdoc
334
+ Define Element :addcontentsline
335
+
336
+ Create an instance with
337
+ element( :addcontentsline, [ attributes, [content]] )
338
+ or
339
+ Addcontentsline.new( [ attributes, [content]] )
340
+ Attributes may be:
341
+ * :file: [ 'toc', 'lof', 'lot' ]
342
+ * :depth: [ -1, 0,1,2,3,4,5,6]
343
+ =end
344
+ class Addcontentsline < Element
345
+ add_attribute :file, Attribute.create( [ :latex, :required ], [ 'toc', 'lof', 'lot' ] )
346
+ add_attribute :depth, Attribute.create( [ :latex, :required ], [ -1, 0,1,2,3,4,5,6] )
347
+ add_latex_output '#{linebreak(@crbefore)}\addcontentsline{#{@attr[:file]}}{#{@attr[:depth]}}{#{@content}} #{linebreak(@crafter)}'
348
+ end #Addcontentsline
349
+
350
+ =begin rdoc
351
+ Define Element :addtocontents
352
+
353
+ Create an instance with
354
+ element( :addtocontents, [ attributes, [content]] )
355
+ or
356
+ Addtocontents.new( [ attributes, [content]] )
357
+ Attributes may be:
358
+ * :file: [ 'toc', 'lof', 'lot' ]
359
+ =end
360
+ class Addtocontents < Element
361
+ add_attribute :file, Attribute.create( [ :latex, :required ], [ 'toc', 'lof', 'lot' ] )
362
+ add_latex_output '#{linebreak(@crbefore)}\addtocontents{#{@attr[:file]}}{#{@content}} #{linebreak(@crafter)}'
363
+ end #Addtocontents
364
+
365
+ =begin rdoc
366
+ Define Element :par, :p
367
+
368
+ Generell paragraph handling.
369
+
370
+ Create an instance with
371
+ element( :par, [ attributes, [content]] )
372
+ element( :p, [ attributes, [content]] )
373
+ or
374
+ Par.new( [ attributes, [content]] )
375
+ Attributes may be:
376
+ * HTML_ATTR_CORE
377
+ * HTML_ATTR_I18N
378
+ * HTML_ATTR_EVENTS
379
+ * :lang, ATTR_LANG
380
+ =end
381
+ class Par < Element
382
+ add_id :p
383
+ add_attributes HTML_ATTR_CORE
384
+ add_attributes HTML_ATTR_I18N
385
+ add_attributes HTML_ATTR_EVENTS
386
+ add_attribute :lang, ATTR_LANG
387
+ add_html_tag 'p'
388
+ add_latex_output "\n\n" + '#{@content}' + "\n\n"
389
+ add_context_output "\n\n" + '#{@content}' + "\n\n"
390
+ add_text_output "\n" + '#{@content}' + "\n"
391
+ add_wiki_output "\n" + '#{@content}' + "\n"
392
+ add_creole_output "\n" + '#{@content}' + "\n\n"
393
+ end #Par
394
+
395
+ =begin rdoc
396
+ Define Element :nobr
397
+
398
+ Create an instance with
399
+ element( :nobr, [ attributes, [content]] )
400
+ or
401
+ Nobr.new( [ attributes, [content]] )
402
+ Attributes may be:
403
+ * HTML_ATTR_CORE
404
+ * HTML_ATTR_I18N
405
+ * HTML_ATTR_EVENTS
406
+ * :lang, ATTR_LANG
407
+ =end
408
+ class Nobr < Element
409
+ add_attributes HTML_ATTR_CORE
410
+ add_attributes HTML_ATTR_I18N
411
+ add_attributes HTML_ATTR_EVENTS
412
+ add_attribute :lang, ATTR_LANG
413
+ add_html_tag 'nobr'
414
+ add_latex_output '#{linebreak(@crbefore)}\mbox{#{@content}}#{linebreak(@crafter)}'
415
+ end #Nobr
416
+
417
+ =begin rdoc
418
+ Define Element :br, "br/", "br", :newline
419
+
420
+ Create an instance with
421
+ element( :br, [ attributes, [content]] )
422
+ element( "br/", [ attributes, [content]] )
423
+ element( "br", [ attributes, [content]] )
424
+ element( :newline, [ attributes, [content]] )
425
+ or
426
+ Br.new( [ attributes, [content]] )
427
+ Attributes may be:
428
+ * :clear: ['all']
429
+ =end
430
+ class Newline < Element
431
+ add_id "br/"
432
+ add_id "br"
433
+ add_id :br
434
+ has_no_content ENDTAG
435
+ add_attribute :clear, Attribute.create( [ :html ], ['all'] )
436
+ add_html_tag 'br'
437
+ add_latex_output '#{linebreak(@crbefore)}\newline #{linebreak(@crafter)}'
438
+ add_text_output "\n"
439
+ add_wiki_output '{{newline}}#{linebreak(@crafter)}'
440
+ add_creole_output '\\\\#{linebreak(@crafter)}'
441
+ end #Br
442
+
443
+ =begin rdoc
444
+ Define Element :hr, "hr/", "hr", :hrulefill
445
+
446
+ Create an instance with
447
+ element( :hr, [ attributes, [content]] )
448
+ element( "hr/", [ attributes, [content]] )
449
+ element( "hr", [ attributes, [content]] )
450
+ element( :hrulefill, [ attributes, [content]] )
451
+ or
452
+ Hrulefill.new( [ attributes, [content]] )
453
+ Attributes may be:
454
+ * :clear:
455
+ =end
456
+ class Hrulefill < Element
457
+ add_id "hr/"
458
+ add_id "hr"
459
+ add_id :hr
460
+ has_no_content ENDTAG
461
+ add_attribute :clear, Attribute.create( [ :html ], ['all'] )
462
+ add_html_tag 'hr'
463
+ add_wiki_output '----'
464
+ add_text_output '-------------------------'
465
+ add_latex_output '#{linebreak(@crbefore)}\hrulefill #{linebreak(@crafter)}'
466
+ end #Hr
467
+
468
+ =begin rdoc
469
+ Define Element :vspace
470
+
471
+ Create an instance with
472
+ element( :vspace, [ attributes, [content]] )
473
+ or
474
+ Vspace.new( [ attributes, [content]] )
475
+ Attributes are not defined for this element.
476
+ =end
477
+ class Vspace < Element
478
+ add_latex_output '#{linebreak(@crbefore)}\vspace{#{@content}} #{linebreak(@crafter)}'
479
+ #:htmltag => 'hr',
480
+ #~ :wiki => '----',
481
+ #~ :text => '-' * 25,
482
+ end #Vspace
483
+
484
+ =begin rdoc
485
+ Define Element :hspace
486
+
487
+ Create an instance with
488
+ element( :hspace, [ attributes, [content]] )
489
+ or
490
+ Hspace.new( [ attributes, [content]] )
491
+ Attributes are not defined for this element.
492
+
493
+ Only for LaTeX
494
+ =end
495
+ class Hspace < Element
496
+ add_latex_output '#{linebreak(@crbefore)}\hspace{#{@content}} #{linebreak(@crafter)}'
497
+ end #Hspace
498
+
499
+ =begin rdoc
500
+ Define Element :vfill
501
+
502
+ Create an instance with
503
+ element( :vfill, [ attributes, [content]] )
504
+ or
505
+ Vfill.new( [ attributes, [content]] )
506
+ Attributes are not defined for this element.
507
+
508
+ Only for LaTeX
509
+ =end
510
+ class Vfill < Element
511
+ has_no_content
512
+ add_latex_output '#{linebreak(@crbefore)}\vfill #{linebreak(@crafter)}'
513
+ end #Vfill
514
+
515
+ =begin rdoc
516
+ Define Element :hfill
517
+
518
+ Create an instance with
519
+ element( :hfill, [ attributes, [content]] )
520
+ or
521
+ Hfill.new( [ attributes, [content]] )
522
+ Attributes are not defined for this element.
523
+
524
+ Only for LaTeX
525
+ =end
526
+ class Hfill < Element
527
+ has_no_content false
528
+ add_latex_output '#{linebreak(@crbefore)}\hfill #{linebreak(@crafter)}'
529
+ end #Hfill
530
+
531
+ =begin rdoc
532
+ Define Element :relax
533
+
534
+ Create an instance with
535
+ element( :relax, [ attributes, [content]] )
536
+ or
537
+ Relax.new( [ attributes, [content]] )
538
+ Attributes are not defined for this element.
539
+ =end
540
+ class Relax < Element
541
+ has_no_content
542
+ add_html_tag nil
543
+ add_latex_output '#{linebreak(@crbefore)}\relax #{linebreak(@crafter)}'
544
+ end #Relax
545
+
546
+
547
+ =begin rdoc
548
+ Define Element :span, :group
549
+
550
+ Can be used to group something.
551
+
552
+ Create an instance with
553
+ element( :span, [ attributes, [content]] )
554
+ element( :group, [ attributes, [content]] )
555
+ or
556
+ Span.new( [ attributes, [content]] )
557
+ Attributes may be:
558
+ * HTML_ATTR_CORE
559
+ =end
560
+ class Span < Element
561
+ add_id :group
562
+ add_attributes HTML_ATTR_CORE
563
+ add_html_tag 'span'
564
+ add_latex_output '#{linebreak(@crbefore)}\bgroup #{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\egroup #{linebreak(@crafter)}'
565
+ end #Span
566
+
567
+ =begin rdoc
568
+ Define Element :div, :Group
569
+
570
+ Create an instance with
571
+ element( :div, [ attributes, [content]] )
572
+ element( :Group, [ attributes, [content]] )
573
+ or
574
+ Div.new( [ attributes, [content]] )
575
+ Attributes may be:
576
+ * :align:
577
+ * :id:
578
+ * :class:
579
+ * :style:
580
+ * :title:
581
+ =end
582
+ class Div < Element
583
+ add_id :Group
584
+ add_attributes HTML_ATTR_CORE
585
+ add_attribute :align, HTML_ATTR_ALIGN
586
+ add_html_tag 'div'
587
+ add_latex_output '#{linebreak(@crbefore)}\begingroup #{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\endgroup #{linebreak(@crafter)}'
588
+ add_text_output '#{@content}'
589
+ add_wiki_output '#{@content}'
590
+ end #Div
591
+
592
+
593
+ =begin rdoc
594
+ Define Element :sepline
595
+
596
+ Make a separator line in code
597
+
598
+ Create an instance with
599
+ element( :sepline, [ attributes, [content]] )
600
+ or
601
+ Sepline.new( [ attributes, [content]] )
602
+ Attributes are not defined for this element.
603
+ =end
604
+ class Sepline < Element
605
+ has_no_content false
606
+ add_html_output "\n<!--" + '-' * 50 + " -->\n"
607
+ add_latex_output "\n%" + '-' * 50 + "\n"
608
+ end #Sepline
609
+
610
+ =begin rdoc
611
+ Define Element :comment
612
+
613
+ Make a comment in code
614
+
615
+ Create an instance with
616
+ element( :comment, [ attributes, [content]] )
617
+ or
618
+ Comment.new( [ attributes, [content]] )
619
+ Attributes are not defined for this element.
620
+ =end
621
+ class Comment < Element
622
+ add_html_tag '<!-- #{@content} -->'
623
+ add_latex_output '#{linebreak(@crbefore)}% ------- #{@content} ------- #{linebreak(@crafter)}'
624
+ end #Comment
625
+
626
+ =begin rdoc
627
+ Define Element :url
628
+
629
+ Links
630
+
631
+ Better: \hypertarget, hyperlink (pdf)
632
+
633
+ Create an instance with
634
+ element( :url, [ attributes, [content]] )
635
+ or
636
+ Url.new( [ attributes, [content]] )
637
+ Attributes may be:
638
+ * HTML_ATTR_CORE
639
+ * HTML_ATTR_I18N
640
+ * HTML_ATTR_EVENTS
641
+ * ATTR_LANG
642
+ =end
643
+ class Url < Element
644
+ add_attributes HTML_ATTR_CORE
645
+ add_attributes HTML_ATTR_I18N
646
+ add_attributes HTML_ATTR_EVENTS
647
+ add_attribute :lang, ATTR_LANG
648
+ add_html_output '#{linebreak(@crbefore)}<a href="#{@content}">#{@content}</a>#{linebreak(@crafter)}'
649
+ add_latex_output '#{linebreak(@crbefore)}\url{#{@content}}#{linebreak(@crafter)}'
650
+ end #Url
651
+
652
+ =begin rdoc
653
+ Define Element :ensuremath
654
+
655
+ Create an instance with
656
+ element( :ensuremath, [ attributes, [content]] )
657
+ or
658
+ Ensuremath.new( [ attributes, [content]] )
659
+ Attributes are not defined for this element.
660
+ =end
661
+ class Ensuremath < Element
662
+ add_html_output '#{@content}'
663
+ add_latex_output '\ensuremath{#{@content}}'
664
+ add_context_output '\math{#{@content}}' #http://www.ntg.nl/pipermail/ntg-context/2010/051451.html
665
+ end #Ensuremath
666
+
667
+ =begin rdoc
668
+ Internal reference
669
+ The href-parameter is expected with a leading # (HTML)
670
+ The corresponding label should be defined in the same document/file.
671
+
672
+ For external links use :href.
673
+ =end
351
674
  class Href < Element
352
- Element.add( [:a, :href], Href)
353
- add_attributes( {
354
- :href => Attribute.create( [ :html, :required ], [String], 1 ),
355
- :hreflang => ATTR_LANG,
356
- :alt => Attribute.create( [ :html ], [String], 2 ),
357
- :name => Attribute.create( [ :html ], [String] ),
358
- :longdesc => Attribute.create( [ :html ], [String] ),
359
- :value => Attribute.create( [ :html ] ),
360
- :shape => Attribute.create( [ :html ] ),
361
- :coords => Attribute.create( [ :html ] ),
362
- :target => Attribute.create( [ :html ], [ '_blank', '_parent', '_self', '_top' ] ),
363
- }.update(HTML_ATTR_ALL)
364
- )
365
- def htmltag(); 'a'; end
675
+ add_id :a
676
+ add_attribute :href, Attribute.create( [ :html, :required ], [String], 1 )
677
+ add_attribute :hreflang, ATTR_LANG
678
+ add_attribute :alt, Attribute.create( [ :html ], [String], 2 )
679
+ add_attribute :name, Attribute.create( [ :html ], [String] )
680
+ add_attribute :longdesc, Attribute.create( [ :html ], [String] )
681
+ add_attribute :value, Attribute.create( [ :html ] )
682
+ add_attribute :shape, Attribute.create( [ :html ] )
683
+ add_attribute :coords,Attribute.create( [ :html ] )
684
+ add_attribute :target, Attribute.create( [ :html ], [ '_blank', '_parent', '_self', '_top' ] )
685
+ add_attributes HTML_ATTR_ALL
686
+ add_html_tag 'a'
366
687
  def to_wiki( options = {} )
367
688
  "[#{@attr[:href].to_s} #{@content.to_doc(:wiki, options)}]"
368
689
  end
@@ -387,82 +708,118 @@ class Href < Element
387
708
  end
388
709
  end
389
710
 
390
- #~ Element.create( [ :a, :href ],
391
- #~ { :href => Attribute.create( [ :html, :required ], [String], 1 ),
392
- #~ :hreflang => ATTR_LANG,
393
- #~ :alt => Attribute.create( [ :html ], [String], 2 ),
394
- #~ :name => Attribute.create( [ :html ], [String] ),
395
- #~ :longdesc => Attribute.create( [ :html ], [String] ),
396
- #~ :value => Attribute.create( [ :html ] ),
397
- #~ :shape => Attribute.create( [ :html ] ),
398
- #~ :coords => Attribute.create( [ :html ] ),
399
- #~ :target => Attribute.create( [ :html ], [ '_blank', '_parent', '_self', '_top' ] ),
400
- #~ }.update( HTML_ATTR_ALL ),
401
- #~ true,
402
- #~ {
403
- #~ :htmltag => 'a',
404
- #~ :latex => '\href{#{@attr[:href]}}{#{@content}}',
405
- #~ } )
406
-
407
- Element.create( [ :label ],
408
- {
409
- :name => Attribute.create( [ :html, :latex, :required ] ),
410
- }.update( HTML_ATTR_ALL ),
411
- true,
412
- {
413
- #~ :htmltag => 'a',
414
- :html => '#{linebreak(@crbefore)}<a name="#{@attr[:name]}">#{linebreak(@crmid)}#{@content}</a>#{linebreak(@crafter)}',
415
- :latex => '#{linebreak(@crbefore)}\label{#{@attr[:name]}}#{linebreak(@crmid)}\hypertarget{#{@attr[:name]}}{#{@content}}#{linebreak(@crafter)}',
416
- :text => '(#{@attr[:name]}) #{@content}',
417
- :wiki => '#{linebreak(@crbefore)}[[??#{@attr[:name]}]]#{@content}#{linebreak(@crafter)}', #fixme wrong
418
- } )
419
-
420
- Element.create( [ :hypertarget ],
421
- { :href => Attribute.create( [ :html, :required ] ),
422
- :alt => Attribute.create( [ :html ] ),
423
- :longdesc => Attribute.create( [ :html ] ),
424
- :value => Attribute.create( [ :html ] ),
425
- :shape => Attribute.create( [ :html ] ),
426
- :coords => Attribute.create( [ :html ] ),
427
- }.update( HTML_ATTR_ALL ),
428
- true,
429
- {
430
- #~ :htmltag => 'a',
431
- :latex => '#{linebreak(@crbefore)}\hypertarget{#{@attr[:href]}}{#{@content}}#{linebreak(@crafter)}',
432
- } )
433
-
434
- Element.create( [ :link ],
435
- { :href => Attribute.create( [ :html, :required ], nil, 1 ),
436
- :rel => Attribute.create( [ :html ], [String], 2 ),
437
- :title => Attribute.create( [ :html ], nil, 3 ),
438
- :type => Attribute.create( [ :html ], nil, 4 ),
439
- }.update( HTML_ATTR_ALL ),
440
- ENDTAG,
441
- {
442
- :htmltag => 'link',
443
- #~ :latex => '',
444
- } )
711
+ =begin rdoc
712
+ Define Element :label
445
713
 
446
- #
714
+ Create an instance with
715
+ element( :label, [ attributes, [content]] )
716
+ or
717
+ Label.new( [ attributes, [content]] )
718
+ Attributes may be:
719
+ * :name:
720
+ * HTML_ATTR_CORE
721
+ * HTML_ATTR_I18N
722
+ * HTML_ATTR_EVENTS
723
+ * ATTR_LANG
724
+ =end
725
+ class Label < Element
726
+ add_attributes HTML_ATTR_CORE
727
+ add_attributes HTML_ATTR_I18N
728
+ add_attributes HTML_ATTR_EVENTS
729
+ add_attribute :lang, ATTR_LANG
730
+ add_attribute :name, Attribute.create( [ :html, :latex, :required ] )
731
+ add_html_output '#{linebreak(@crbefore)}<a name="#{@attr[:name]}">#{linebreak(@crmid)}#{@content}</a>#{linebreak(@crafter)}'
732
+ add_latex_output '#{linebreak(@crbefore)}\label{#{@attr[:name]}}#{linebreak(@crmid)}\hypertarget{#{@attr[:name]}}{#{@content}}#{linebreak(@crafter)}'
733
+ add_text_output '(#{@attr[:name]}) #{@content}'
734
+ add_wiki_output '#{linebreak(@crbefore)}[[??#{@attr[:name]}]]#{@content}#{linebreak(@crafter)}'
735
+ end #Label
736
+
737
+ =begin rdoc
738
+ Define Element :hypertarget
739
+
740
+ Create an instance with
741
+ element( :hypertarget, [ attributes, [content]] )
742
+ or
743
+ Hypertarget.new( [ attributes, [content]] )
744
+ Attributes may be:
745
+ * :href:
746
+ * :alt:
747
+ * :longdesc:
748
+ * :value:
749
+ * :shape:
750
+ * :coords:
751
+ * HTML_ATTR_CORE
752
+ * HTML_ATTR_I18N
753
+ * HTML_ATTR_EVENTS
754
+ * ATTR_LANG
755
+ =end
756
+ class Hypertarget < Element
757
+ add_attributes HTML_ATTR_CORE
758
+ add_attributes HTML_ATTR_I18N
759
+ add_attributes HTML_ATTR_EVENTS
760
+ add_attribute :lang, ATTR_LANG
761
+ add_attribute :href, Attribute.create( [ :html, :required ] )
762
+ add_attribute :alt, Attribute.create( [ :html ] )
763
+ add_attribute :longdesc, Attribute.create( [ :html ] )
764
+ add_attribute :value, Attribute.create( [ :html ] )
765
+ add_attribute :shape, Attribute.create( [ :html ] )
766
+ add_attribute :coords, Attribute.create( [ :html ] )
767
+ add_latex_output '#{linebreak(@crbefore)}\hypertarget{#{@attr[:href]}}{#{@content}}#{linebreak(@crafter)}'
768
+ end #Hypertarget
769
+
770
+
771
+ =begin rdoc
772
+ Define Element :link
773
+
774
+ Create an instance with
775
+ element( :link, [ attributes, [content]] )
776
+ or
777
+ Link.new( [ attributes, [content]] )
778
+ Attributes may be:
779
+ * :href:
780
+ * :rel:
781
+ * :title:
782
+ * :type:
783
+ * :lang:
784
+ * HTML_ATTR_CORE
785
+ * HTML_ATTR_I18N
786
+ * HTML_ATTR_EVENTS
787
+ * ATTR_LANG
788
+ =end
789
+ class Link < Element
790
+ has_no_content
791
+ add_attributes HTML_ATTR_CORE
792
+ add_attributes HTML_ATTR_I18N
793
+ add_attributes HTML_ATTR_EVENTS
794
+ add_attribute :lang, ATTR_LANG
795
+ add_attribute :href, Attribute.create( [ :html, :required ], nil, 1 )
796
+ add_attribute :rel, Attribute.create( [ :html ], [String], 2 )
797
+ add_attribute :title, Attribute.create( [ :html ], nil, 3 )
798
+ add_attribute :type, Attribute.create( [ :html ], nil, 4 )
799
+ add_html_tag 'link'
800
+ end #Link
447
801
 
448
802
  #
449
- #Add a TeX-Makro usepackage.
450
- #
451
- #This method tries to load the package specific definitions in a file
452
- # docgenerator_<<packagename>>
453
- #
803
+
804
+ =begin rdoc
805
+ Add a TeX-Makro usepackage.
806
+
807
+ This method tries to load the package specific definitions in a file
808
+ docgenerator_<<packagename>>
809
+ =end
454
810
  class Usepackage < Element
455
- #Make the key known to the complete key-list of elements.
456
- Element.add( [:usepackage], Usepackage)
457
811
  #~ add_attributes( HTML_ATTR_ALL )
458
- add_attributes( { :option => Attribute.create( ) } )
812
+ add_attribute :option, Attribute.create( )
459
813
 
460
- #With usepackage additional command may be defined.
461
- #Here we load this special commands/elements if available.
814
+ =begin rdoc
815
+ With usepackage additional command may be defined.
816
+
817
+ Here we load this special commands/elements if available.
818
+ =end
462
819
  def << ( content )
463
820
  @content << content
464
821
  #Load new additionals makros if available
465
- makrodefinitions = 'packages/docgenerator_' + content + '.rb'
822
+ makrodefinitions = 'docgenerator/packages/' + content + '.rb'
466
823
  begin
467
824
  @log.debug("usepackage: Try to load #{makrodefinitions}") if @log.debug?
468
825
  require makrodefinitions
@@ -471,9 +828,11 @@ class Usepackage < Element
471
828
  end
472
829
  end
473
830
 
474
- #Redefine standard output.
475
- #Options are given, if an option is available.
476
- #~ add_output( :latex, '\usepackage[#{@attr[:option]}]{#{@content}}' )
831
+ =begin rdoc
832
+ Redefine standard output.
833
+ Options are given, if an option is available.
834
+ =end
835
+ #~ add_latex_output '\usepackage[#{@attr[:option]}]{#{@content}}'
477
836
  def to_latex( options = {} )
478
837
  cmd = linebreak(@crbefore)
479
838
  cmd << '\usepackage'
@@ -483,6 +842,9 @@ class Usepackage < Element
483
842
  cmd << linebreak(@crafter)
484
843
  return cmd
485
844
  end
845
+ =begin rdoc
846
+ Not used in HTML
847
+ =end
486
848
  def to_html( options = {} )
487
849
  return ''
488
850
  end
@@ -492,147 +854,416 @@ end #Usepackage
492
854
 
493
855
  #~ :em => {}, #complete it
494
856
  #~ :code => {}, #complete it
495
- Element.create( [:font], {
496
- :size => Attribute.create([:html], [ Fixnum ]),
497
- },true,
498
- { :htmltag => 'font',
499
- #~ :latex => '\tiny ' #+ ' #{linebreak(@crafter)}'
500
- } )
501
- #Fixme: Jeweils :tinytex f�r ungeklammerte
502
- Element.create( [:tiny ], {},true,
503
- { :html => '<span style="font-size:xx-small">#{@content}</span>',
504
- :latex => '#{linebreak(@crbefore)}{\tiny #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
505
- } )
506
- Element.create( [:scriptsize ], {},true,
507
- { :html => '<span style="font-size:x-small">#{@content}</span>',
508
- :latex => '#{linebreak(@crbefore)}{\scriptsize #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
509
- } )
510
- Element.create( [:footnotesize ], {},true,
511
- { :html => '<span style="font-size:x-small">#{@content}</span>',
512
- :latex => '#{linebreak(@crbefore)}{\footnotesize #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
513
- } )
514
- #fixme \small oder {\small ..}
515
- Element.create( [:small ], {},true,
516
- { #:html => '<span style="font-size:small">#{@content}</span>',
517
- :htmltag => 'small',
518
- :latex => '#{linebreak(@crbefore)}{\small #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
519
- } )
520
- Element.create( [:normalsize ], {},true,
521
- { :html => '<span style="font-size:medium">#{@content}</span>',
522
- :latex => '#{linebreak(@crbefore)}{\normalsize #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
523
- } )
524
- Element.create( [:large ], {},true,
525
- { :html => '<span style="font-size:large">#{@content}</span>',
526
- :latex => '#{linebreak(@crbefore)}{\large #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
527
- } )
528
- Element.create( [:Large ], {},true,
529
- { :html => '<span style="font-size:x-large">#{@content}</span>',
530
- :latex => '#{linebreak(@crbefore)}{\Large #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
531
- } )
532
- Element.create( [:huge ], {},true,
533
- { :html => '<span style="font-size:xx-large">#{@content}</span>',
534
- :latex => '#{linebreak(@crbefore)}{\huge #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
535
- } )
536
- Element.create( [:Huge ], {},true,
537
- { :html => '<span style="font-size:xx-large">#{@content}</span>',
538
- :latex => '#{linebreak(@crbefore)}{\Huge #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
539
- } )
540
-
541
- Element.create( [:textbf, :strong ], {},true,
542
- { :htmltag => 'strong',
543
- :latex => '#{linebreak(@crbefore)}\textbf{#{@content}}#{linebreak(@crafter)}',
544
- :wiki => %q|#{linebreak(@crbefore)}'''#{@content}'''#{linebreak(@crafter)}|,
545
- :text => '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}',
546
- } )
547
- Element.create( [:emph ], {},true,
548
- { :htmltag => 'em',
549
- :latex => '#{linebreak(@crbefore)}\emph{#{@content}}#{linebreak(@crafter)}',
550
- :wiki => '#{linebreak(@crbefore)}''#{@content}''#{linebreak(@crafter)}',
551
- :text => '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}',
552
- } )
553
-
554
- Element.create( [:stroke ], {},true,
555
- { #:html => '<span style="font-size:small">#{@content}</span>',
556
- :htmltag => 's',
557
- #~ :latex => '#{linebreak(@crbefore)}{\stroke #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
558
- } )
559
-
560
- Element.create( [:underline ], {},true,
561
- { #:html => '<span style="font-size:small">#{@content}</span>',
562
- :htmltag => 'undeline',
563
- :latex => '#{linebreak(@crbefore)}{\underline#{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
564
- } )
565
-
566
- Element.create( [:sup, :textsuperscript ], {}.update(HTML_ATTR_ALL),true,
567
- { :htmltag => 'sup',
568
- :latex => '#{linebreak(@crbefore)}\textsuperscript{#{@content}}#{linebreak(@crafter)}',
569
- :wiki => '#{linebreak(@crbefore)}^#{@content}^#{linebreak(@crafter)}',
570
- :text => '#{linebreak(@crbefore)}^#{@content}^#{linebreak(@crafter)}'
571
- } )
572
857
 
573
- #
574
- #Math function: sup
575
- #~ Element.create( [:latexsup ], {}.update(HTML_ATTR_ALL),false,
576
- #~ { :html => 'sup',
577
- #~ :latex => '#{linebreak(@crbefore)}\sup}#{linebreak(@crafter)}'
578
- #~ } )
858
+ =begin rdoc
859
+ Define Element :font
860
+
861
+ Create an instance with
862
+ element( :font, [ attributes, [content]] )
863
+ or
864
+ Font.new( [ attributes, [content]] )
865
+ Attributes may be:
866
+ * :size:
867
+ =end
868
+ class Font < Element
869
+ add_attribute :size, Attribute.create([:html], [ Fixnum ])
870
+ add_html_tag 'font'
871
+ end #Font
872
+
873
+ =begin rdoc
874
+ Define Element :tiny
875
+
876
+ Create an instance with
877
+ element( :tiny, [ attributes, [content]] )
878
+ or
879
+ Tiny.new( [ attributes, [content]] )
880
+ Attributes are not defined for this element.
881
+ =end
882
+ class Tiny < Element
883
+ add_html_output '<span style="font-size:xx-small">#{@content}</span>'
884
+ add_latex_output '#{linebreak(@crbefore)}{\tiny #{@content}}#{linebreak(@crafter)}'
885
+ end #Tiny
886
+
887
+ =begin rdoc
888
+ Define Element :scriptsize
889
+
890
+ Create an instance with
891
+ element( :scriptsize, [ attributes, [content]] )
892
+ or
893
+ Scriptsize.new( [ attributes, [content]] )
894
+ Attributes are not defined for this element.
895
+ =end
896
+ class Scriptsize < Element
897
+ add_html_output '<span style="font-size:x-small">#{@content}</span>'
898
+ add_latex_output '#{linebreak(@crbefore)}{\scriptsize #{@content}}#{linebreak(@crafter)}'
899
+ end #Scriptsize
900
+
901
+ =begin rdoc
902
+ Define Element :footnotesize
903
+
904
+ Create an instance with
905
+ element( :footnotesize, [ attributes, [content]] )
906
+ or
907
+ Footnotesize.new( [ attributes, [content]] )
908
+ Attributes are not defined for this element.
909
+ =end
910
+ class Footnotesize < Element
911
+ add_html_output '<span style="font-size:x-small">#{@content}</span>'
912
+ add_latex_output '#{linebreak(@crbefore)}{\footnotesize #{@content}}#{linebreak(@crafter)}'
913
+ end #Footnotesize
914
+
915
+ =begin rdoc
916
+ Define Element :small
917
+
918
+ Create an instance with
919
+ element( :small, [ attributes, [content]] )
920
+ or
921
+ Small.new( [ attributes, [content]] )
922
+ Attributes are not defined for this element.
923
+ =end
924
+ class Small < Element
925
+ add_html_tag 'small'
926
+ add_latex_output '#{linebreak(@crbefore)}{\small #{@content}}#{linebreak(@crafter)}'
927
+ end #Small
928
+
929
+ =begin rdoc
930
+ Define Element :normalsize
931
+
932
+ Create an instance with
933
+ element( :normalsize, [ attributes, [content]] )
934
+ or
935
+ Normalsize.new( [ attributes, [content]] )
936
+ Attributes are not defined for this element.
937
+ =end
938
+ class Normalsize < Element
939
+ add_html_output '<span style="font-size:medium">#{@content}</span>'
940
+ add_latex_output '#{linebreak(@crbefore)}{\normalsize #{@content}}#{linebreak(@crafter)}'
941
+ end #Normalsize
942
+
943
+ =begin rdoc
944
+ Define Element :large
945
+
946
+ Create an instance with
947
+ element( :large, [ attributes, [content]] )
948
+ or
949
+ Large.new( [ attributes, [content]] )
950
+ Attributes are not defined for this element.
951
+ =end
952
+ class Large < Element
953
+ add_html_output '<span style="font-size:large">#{@content}</span>'
954
+ add_latex_output '#{linebreak(@crbefore)}{\large #{@content}}#{linebreak(@crafter)}'
955
+ end #Large
956
+
957
+ =begin rdoc
958
+ Define Element :Large
959
+
960
+ Create an instance with
961
+ element( :Large, [ attributes, [content]] )
962
+ or
963
+ LLarge.new( [ attributes, [content]] )
964
+ Attributes are not defined for this element.
965
+ =end
966
+ class LLarge < Element
967
+ add_id :Large
968
+ add_html_output '<span style="font-size:x-large">#{@content}</span>'
969
+ add_latex_output '#{linebreak(@crbefore)}{\Large #{@content}}#{linebreak(@crafter)}'
970
+ end #Large
971
+
972
+ =begin rdoc
973
+ Define Element :huge
974
+
975
+ Create an instance with
976
+ element( :huge, [ attributes, [content]] )
977
+ or
978
+ Huge.new( [ attributes, [content]] )
979
+ Attributes are not defined for this element.
980
+ =end
981
+ class Huge < Element
982
+ add_html_output '<span style="font-size:xx-large">#{@content}</span>'
983
+ add_latex_output '#{linebreak(@crbefore)}{\huge #{@content}}#{linebreak(@crafter)}'
984
+ end #Huge
985
+
986
+ =begin rdoc
987
+ Define Element :Huge
988
+
989
+ Create an instance with
990
+ element( :Huge, [ attributes, [content]] )
991
+ or
992
+ Huge.new( [ attributes, [content]] )
993
+ Attributes are not defined for this element.
994
+ =end
995
+ class HHuge < Element
996
+ add_id :Huge
997
+ add_html_output '<span style="font-size:xx-large">#{@content}</span>'
998
+ add_latex_output '#{linebreak(@crbefore)}{\Huge #{@content}}#{linebreak(@crafter)}'
999
+ end #Huge
1000
+
1001
+ =begin rdoc
1002
+ Define Element :textbf, :strong
1003
+
1004
+ Create an instance with
1005
+ element( :textbf, [ attributes, [content]] )
1006
+ element( :strong, [ attributes, [content]] )
1007
+ or
1008
+ Textbf.new( [ attributes, [content]] )
1009
+ Attributes are not defined for this element.
1010
+ =end
1011
+ class Textbf < Element
1012
+ add_id :strong
1013
+ add_html_tag 'strong'
1014
+ add_latex_output '#{linebreak(@crbefore)}\textbf{#{@content}}#{linebreak(@crafter)}'
1015
+ add_wiki_output '#{linebreak(@crbefore)}'''#{@content}'''#{linebreak(@crafter)}'
1016
+ add_text_output '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}'
1017
+ end #Textbf
1018
+
1019
+ =begin rdoc
1020
+ Define Element :emph
1021
+
1022
+ Create an instance with
1023
+ element( :emph, [ attributes, [content]] )
1024
+ or
1025
+ Emph.new( [ attributes, [content]] )
1026
+ Attributes are not defined for this element.
1027
+ =end
1028
+ class Emph < Element
1029
+ add_html_tag 'em'
1030
+ add_latex_output '#{linebreak(@crbefore)}\emph{#{@content}}#{linebreak(@crafter)}'
1031
+ add_wiki_output '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}'
1032
+ add_text_output '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}'
1033
+ end #Emph
1034
+
1035
+ =begin rdoc
1036
+ Define Element :stroke
1037
+
1038
+ Create an instance with
1039
+ element( :stroke, [ attributes, [content]] )
1040
+ or
1041
+ Stroke.new( [ attributes, [content]] )
1042
+ Attributes are not defined for this element.
1043
+
1044
+ Not defined for LaTeX (use of xout-package?)
1045
+ =end
1046
+ class Stroke < Element
1047
+ add_html_tag 's'
1048
+ end #Stroke
1049
+
1050
+ =begin rdoc
1051
+ Define Element :underline
1052
+
1053
+ Create an instance with
1054
+ element( :underline, [ attributes, [content]] )
1055
+ or
1056
+ Underline.new( [ attributes, [content]] )
1057
+ Attributes are not defined for this element.
1058
+ =end
1059
+ class Underline < Element
1060
+ add_html_tag 'u'
1061
+ add_latex_output '#{linebreak(@crbefore)}\underline{#{@content}}#{linebreak(@crafter)}'
1062
+ end #Underline
1063
+
1064
+ =begin rdoc
1065
+ Define Element :sup, :textsuperscript
1066
+
1067
+ Create an instance with
1068
+ element( :sup, [ attributes, [content]] )
1069
+ element( :textsuperscript, [ attributes, [content]] )
1070
+ or
1071
+ Sup.new( [ attributes, [content]] )
1072
+ Attributes may be:
1073
+ * :lang:
1074
+ * HTML_ATTR_CORE, HTML_ATTR_I18N, HTML_ATTR_EVENTS
1075
+ =end
1076
+ class Sup < Element
1077
+ add_id :textsuperscript
1078
+ add_attributes HTML_ATTR_CORE
1079
+ add_attributes HTML_ATTR_I18N
1080
+ add_attributes HTML_ATTR_EVENTS
1081
+ add_attribute :lang, ATTR_LANG
1082
+ add_html_tag 'sup'
1083
+ add_latex_output '#{linebreak(@crbefore)}\textsuperscript{#{@content}}#{linebreak(@crafter)}'
1084
+ add_wiki_output '#{linebreak(@crbefore)}^#{@content}^#{linebreak(@crafter)}'
1085
+ add_text_output '#{linebreak(@crbefore)}^#{@content}^#{linebreak(@crafter)}'
1086
+ end #Sup
1087
+ =begin rdoc
1088
+ Define Element :sub
1089
+
1090
+ Create an instance with
1091
+ element( :sub, [ attributes, [content]] )
1092
+ or
1093
+ Sub.new( [ attributes, [content]] )
1094
+ Attributes may be:
1095
+ * :lang:
1096
+ * HTML_ATTR_CORE, HTML_ATTR_I18N, HTML_ATTR_EVENTS
1097
+ =end
1098
+ class Sub < Element
1099
+ add_attributes HTML_ATTR_CORE
1100
+ add_attributes HTML_ATTR_I18N
1101
+ add_attributes HTML_ATTR_EVENTS
1102
+ add_attribute :lang, ATTR_LANG
1103
+ add_html_tag 'sub'
1104
+ end #Sub
1105
+
1106
+ =begin rdoc
1107
+ Define Element :newpage
1108
+
1109
+ Create an instance with
1110
+ element( :newpage, [ attributes, [content]] )
1111
+ or
1112
+ Newpage.new( [ attributes, [content]] )
1113
+ Attributes are not defined for this element.
1114
+ =end
1115
+ class Newpage < Element
1116
+ has_no_content
1117
+ add_latex_output '#{linebreak(@crbefore)}\newpage #{linebreak(@crafter)}'
1118
+ end #Newpage
1119
+
1120
+ =begin rdoc
1121
+ Define Element :clearpage
1122
+
1123
+ Create an instance with
1124
+ element( :clearpage, [ attributes, [content]] )
1125
+ or
1126
+ Clearpage.new( [ attributes, [content]] )
1127
+ Attributes are not defined for this element.
1128
+ =end
1129
+ class Clearpage < Element
1130
+ has_no_content
1131
+ add_latex_output '#{linebreak(@crbefore)}\clearpage #{linebreak(@crafter)}'
1132
+ end #Clearpage
1133
+
1134
+ =begin rdoc
1135
+ Define Element :twocolumn
1136
+
1137
+ Create an instance with
1138
+ element( :twocolumn, [ attributes, [content]] )
1139
+ or
1140
+ Twocolumn.new( [ attributes, [content]] )
1141
+ Attributes are not defined for this element.
1142
+ =end
1143
+ class Twocolumn < Element
1144
+ has_no_content
1145
+ add_latex_output '#{linebreak(@crbefore)}\twocolumn #{linebreak(@crafter)}'
1146
+ end #Twocolumn
1147
+
1148
+ =begin rdoc
1149
+ Define Element :centering
1150
+
1151
+ Please check also Center.
1152
+ Maybe, thats the better soultion.
1153
+
1154
+ Create an instance with
1155
+ element( :centering, [ attributes, [content]] )
1156
+ or
1157
+ Centering.new( [ attributes, [content]] )
1158
+ Attributes are not defined for this element.
1159
+
1160
+
1161
+ fixme: TeX kein content, HTML hat content
1162
+ =end
1163
+ class Centering < Element
1164
+ has_no_content false
1165
+ add_html_tag 'center'
1166
+ add_latex_output '\centering #{linebreak(@crafter)}'
1167
+ end #Centering
1168
+
1169
+
1170
+ =begin rdoc
1171
+ Define Element :input
1172
+
1173
+ Only LaTeX
1174
+
1175
+ Create an instance with
1176
+ element( :input, [ attributes, [content]] )
1177
+ or
1178
+ Input.new( [ attributes, [content]] )
1179
+ Attributes are not defined for this element.
1180
+ =end
1181
+ class Input < Element
1182
+ add_latex_output '#{linebreak(@crbefore)}\input{#{@content}}#{linebreak(@crafter)}'
1183
+ end #Input
1184
+
1185
+ =begin rdoc
1186
+ Define Element :include
1187
+
1188
+ Create an instance with
1189
+ element( :include, [ attributes, [content]] )
1190
+ or
1191
+ Include.new( [ attributes, [content]] )
1192
+ Attributes are not defined for this element.
1193
+ =end
1194
+ class Include < Element
1195
+ add_latex_output '#{linebreak(@crbefore)}\include{#{@content}}#{linebreak(@crafter)}'
1196
+ end #Include
1197
+
1198
+ =begin rdoc
1199
+ Define Element :img, :includegraphics
1200
+
1201
+ Create an instance with
1202
+ element( :img, [ attributes, [content]] )
1203
+ element( :includegraphics, [ attributes, [content]] )
1204
+ or
1205
+ Img.new( [ attributes, [content]] )
1206
+ Attributes may be:
1207
+ * :src:
1208
+ * :alt:
1209
+ * :width: String for \textwidth... for HTML use CSS
1210
+ * :height: String for \textwidth... for HTML use CSS
1211
+ * :border:
1212
+ * :longdesc:
1213
+ * :usemap:
1214
+ * :name:
1215
+ * :angle:
1216
+ * :align:
1217
+ * :id:
1218
+ * :class:
1219
+ * :title:
1220
+ * HTML_ATTR_CORE
1221
+ =end
1222
+ class Img < Element
1223
+ add_id :includegraphics
1224
+ has_no_content ENDTAG
1225
+ add_attributes HTML_ATTR_CORE
1226
+ add_attribute :align, HTML_ATTR_ALIGN
1227
+ add_attribute :src, Attribute.create([:html, :latex, :required], [ String ], 1)
1228
+ add_attribute :alt, Attribute.create([:html], [String], 2 )
1229
+ add_attribute :width, Attribute.create([:texkeyval], [Integer, String] )#String for \textwidth... for HTML use CSS
1230
+ add_attribute :height, Attribute.create([:texkeyval], [Integer, String] )
1231
+ add_attribute :border, Attribute.create([:html], [Integer] )
1232
+ add_attribute :longdesc, Attribute.create([:html], [String] )
1233
+ add_attribute :usemap, Attribute.create([:html], [String] )
1234
+ add_attribute :name, Attribute.create([:html], [String] )
1235
+ add_attribute :angle, Attribute.create([:texkeyval], [Integer] )
1236
+ add_attribute :align, HTML_ATTR_ALIGN
1237
+ add_html_tag 'img'
1238
+ add_latex_output '#{linebreak(@crbefore)}\includegraphics[#{texkeyval}]{#{@attr[:src]}}#{linebreak(@crafter)}'
1239
+ end #Img
1240
+
1241
+ =begin rdoc
1242
+ Define Element :verb
1243
+
1244
+ Create an instance with
1245
+ element( :verb, [ attributes, [content]] )
1246
+ or
1247
+ Verb.new( [ attributes, [content]] )
1248
+ Attributes may be:
1249
+ * HTML_ATTR_CORE
1250
+
1251
+ See also Environments::Verbatim
1252
+ =end
1253
+ class Verb < Element
1254
+ add_attributes HTML_ATTR_CORE
1255
+ #This builds a new block
1256
+ #~ :htmltag => 'pre',
1257
+ #With "display: inline" the element is continued correct, but <pre starts on new line.
1258
+ #~ :html => '#{linebreak(@crbefore)}<pre style = "display: inline">#{@content}</pre>#{linebreak(@crafter)}',
1259
+ #fixme font tt
1260
+ #~ :html => '#{linebreak(@crbefore)}<span style = "display: inline;white-space:pre;font-family:monospace">#{@content}</span>#{linebreak(@crafter)}',
1261
+ add_html_output '#{linebreak(@crbefore)}<span style = "display: inline;white-space:pre;font-family:monospace">#{@content.join.gsub(/</, \'&lt;\').gsub(/>/, \'&gt;\')}</span>#{linebreak(@crafter)}'
1262
+ add_latex_output '#{linebreak(@crbefore)}\verb|#{@content}|#{linebreak(@crafter)}'
1263
+ add_text_output '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}'
1264
+ end #Verb
579
1265
 
580
- Element.create( [:sub ], {}.update(HTML_ATTR_ALL),true,
581
- { :htmltag => 'sub',
582
- #:latex => '\emph{#{@content}}'
583
- } )
584
1266
 
585
-
586
- Element.create( [:newpage ], {},false,
587
- { #:htmltag => '',
588
- :latex => '#{linebreak(@crbefore)}\newpage #{linebreak(@crafter)}'
589
- } )
590
- Element.create( [:clearpage ], {},false,
591
- { #:htmltag => '',
592
- :latex => '#{linebreak(@crbefore)}' + '\clearpage ' + ' #{linebreak(@crafter)}'
593
- } )
594
- Element.create( [:twocolumn ], {},false,
595
- { #:htmltag => '',
596
- :latex => '#{linebreak(@crbefore)}' + '\twocolumn ' + ' #{linebreak(@crafter)}'
597
- } )
598
- #fixme: TeX kein content, HTML hat content
599
- Element.create( [:centering ], {},false,
600
- { :htmltag => 'center',
601
- :latex => '\centering ' + ' #{linebreak(@crafter)}'
602
- } )
603
-
604
- #~ :link => {}, #complete it
605
- #~ :center => {}, #complete it
606
- #~ :map => all.update({}), #complete it
607
- #~ :area => all.update({}), #complete it
608
- #~ :option=> {:value=>nil}, #complete it
609
- #~ :select=> events.update({}), #complete it
610
-
611
- Element.create( :input, {}, true, {
612
- :latex => '#{linebreak(@crbefore)}\input{#{@content}}#{linebreak(@crafter)}'
613
- } )
614
- Element.create( :include, {}, true, {
615
- :latex => '#{linebreak(@crbefore)}\include{#{@content}}#{linebreak(@crafter)}'
616
- } )
617
-
618
-
619
- Element.create( [:img, :includegraphics],
620
- {
621
- :src => Attribute.create([:html, :latex, :required], [ String ], 1),
622
- :alt => Attribute.create([:html], [String], 2 ),
623
- :style => Attribute.create([:html], [String] ),
624
- :width => Attribute.create([:texkeyval], [Integer, String] ), #String for \textwidth... for HTML use CSS
625
- :height => Attribute.create([:texkeyval], [Integer, String] ), #String for \textwidth... for HTML use CSS
626
- :border => Attribute.create([:html], [Integer] ),
627
- :longdesc => Attribute.create([:html], [String] ),
628
- :usemap => Attribute.create([:html], [String] ),
629
- :name => Attribute.create([:html], [String] ),
630
- :angle => Attribute.create([:texkeyval], [Integer] ), #Rotation angle.
631
- :align => HTML_ATTR_ALIGN,
632
- }.update(HTML_ATTR_CORE), ENDTAG,
633
- { #:html => '<span style="font-size:xx-small">#{@content}</span>',
634
- :htmltag => 'img',
635
- :latex => '#{linebreak(@crbefore)}\includegraphics[#{texkeyval}]{#{@attr[:src]}}#{linebreak(@crafter)}'
636
- }
637
- )
638
1267
 
1268
+ end #module Elements
1269
+ end #module Docgenerator