docgenerator 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/docgenerator.rb +137 -0
- data/docgenerator_attribute.rb +142 -0
- data/docgenerator_characters.rb +171 -0
- data/docgenerator_css.rb +207 -0
- data/docgenerator_document.rb +374 -0
- data/docgenerator_element.rb +570 -0
- data/docgenerator_elements.rb +554 -0
- data/docgenerator_environments.rb +73 -0
- data/docgenerator_footnote.rb +106 -0
- data/docgenerator_lists.rb +163 -0
- data/docgenerator_sections.rb +88 -0
- data/docgenerator_tabular.rb +376 -0
- data/docgenerator_template.rb +103 -0
- data/examples/docgenerator_example.rb +185 -0
- data/packages/docgenerator_attachfile.rb +71 -0
- data/packages/docgenerator_beamer.rb +250 -0
- data/packages/docgenerator_caption.rb +43 -0
- data/packages/docgenerator_hyperref.rb +109 -0
- data/packages/docgenerator_listings.rb +100 -0
- data/packages/docgenerator_pdfpages.rb +18 -0
- data/packages/docgenerator_scrlettr2.rb +128 -0
- data/packages/docgenerator_scrpage2.rb +172 -0
- data/packages/docgenerator_url.rb +84 -0
- metadata +68 -0
@@ -0,0 +1,554 @@
|
|
1
|
+
#~ @attr = {:short=> 1}
|
2
|
+
#~ puts "\title#{"[#{@attr[:short]}]" if @attr[:short]}"
|
3
|
+
#~ __END__
|
4
|
+
|
5
|
+
#
|
6
|
+
#Definition of elements for DocGenerator.rb
|
7
|
+
#
|
8
|
+
if __FILE__ == $0
|
9
|
+
require 'DocGenerator'
|
10
|
+
else
|
11
|
+
#
|
12
|
+
#Definition of HTML-Tags (Sublasses of Element).
|
13
|
+
ATTR_LANG = Attribute.create( [ :html ], ['en', 'de'] )
|
14
|
+
#
|
15
|
+
HTML_ATTR_CORE = {
|
16
|
+
:id => Attribute.create( [ :html ] ),
|
17
|
+
:class => Attribute.create( [ :html ] ),
|
18
|
+
:style => Attribute.create( [ :html ], [CSS, String]), #fixm string raus
|
19
|
+
:title => Attribute.create( [ :html ] ) }
|
20
|
+
HTML_ATTR_I18N = {
|
21
|
+
:lang => ATTR_LANG,
|
22
|
+
:dir => Attribute.create( [ :html ], ['ltr', 'rtl'] )
|
23
|
+
}
|
24
|
+
HTML_ATTR_EVENTS = { :onclick => Attribute.create( [ :html ] ),
|
25
|
+
:ondblclick => Attribute.create( [ :html ] ),
|
26
|
+
:onmousedown => Attribute.create( [ :html ] ),
|
27
|
+
:onmouseup => Attribute.create( [ :html ] ),
|
28
|
+
:onmouseover => Attribute.create( [ :html ] ),
|
29
|
+
:onmousemove => Attribute.create( [ :html ] ),
|
30
|
+
:onmouseout => Attribute.create( [ :html ] ),
|
31
|
+
:onkeypress => Attribute.create( [ :html ] ),
|
32
|
+
:onkeyup => Attribute.create( [ :html ] ),
|
33
|
+
:onkeydown => Attribute.create( [ :html ] )
|
34
|
+
}
|
35
|
+
HTML_ATTR_ALL = {}
|
36
|
+
HTML_ATTR_ALL.update(HTML_ATTR_I18N)
|
37
|
+
HTML_ATTR_ALL.update(HTML_ATTR_EVENTS)
|
38
|
+
HTML_ATTR_ALL.update(HTML_ATTR_CORE)
|
39
|
+
|
40
|
+
HTML_ATTR_ALIGN = Attribute.create( [ :html ], ['left', 'center', 'right', 'justify', 'char'] )
|
41
|
+
HTML_ATTR_VALIGN = Attribute.create( [ :html ], ['bottom', 'top', 'middle', 'baseline'] )
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
#Main document control.
|
46
|
+
#
|
47
|
+
Element.create( [:head], {}, true,
|
48
|
+
{ :htmltag => 'head',
|
49
|
+
:latex => '#{@content}',
|
50
|
+
:text => '#{@content}',
|
51
|
+
:wiki => '<!-- #{@content} -->',
|
52
|
+
} )
|
53
|
+
Element.create( [:body], {
|
54
|
+
:bgcolor => Attribute.create( [ :html ] ),
|
55
|
+
:text => Attribute.create( [ :html ] ),
|
56
|
+
:link => Attribute.create( [ :html ] ),
|
57
|
+
:vlink => Attribute.create( [ :html ] ),
|
58
|
+
:alink => Attribute.create( [ :html ] ),
|
59
|
+
}.update(HTML_ATTR_CORE.dup.update(HTML_ATTR_I18N)),
|
60
|
+
true,
|
61
|
+
{ :htmltag => 'body',
|
62
|
+
:latex => '#{@content}',
|
63
|
+
:text => '#{@content}',
|
64
|
+
:wiki => '#{@content}',
|
65
|
+
} )
|
66
|
+
|
67
|
+
Element.create( [:latexdummy, :latexonly ], {},true,
|
68
|
+
{ :htmltag => nil,
|
69
|
+
:html => '',
|
70
|
+
:latex => '#{@content}'
|
71
|
+
} )
|
72
|
+
Element.create( [:htmldummy, :htmlonly ], {},true,
|
73
|
+
{ :html => '#{@content}',
|
74
|
+
:latex => ''
|
75
|
+
} )
|
76
|
+
|
77
|
+
|
78
|
+
#
|
79
|
+
#Titlepage
|
80
|
+
#
|
81
|
+
#This parameter are better set with Document.title.
|
82
|
+
#
|
83
|
+
class Title < Element
|
84
|
+
Element.add( [:title], Title)
|
85
|
+
add_attributes( {
|
86
|
+
:short => Attribute.create( [ :html ], nil, 1 )
|
87
|
+
}.update(HTML_ATTR_ALL)
|
88
|
+
)
|
89
|
+
#Unsaubere realisierung .. fixme
|
90
|
+
def shortoption()
|
91
|
+
@attr[:short].content.compact! #delete nils.
|
92
|
+
return nil if ! @attr[:short].filled?
|
93
|
+
@part_of_doc.each{|doc|
|
94
|
+
if doc.template[:latex].include?('Beamer')
|
95
|
+
return "[#{@attr[:short].content}]"
|
96
|
+
end
|
97
|
+
}
|
98
|
+
return nil
|
99
|
+
end
|
100
|
+
add_output( :latex, '#{linebreak(@crbefore)}\title#{shortoption}{#{@content}}#{linebreak(@crmid)}\hypersetup{pdftitle={#{@content}}}#{linebreak(@crafter)}')
|
101
|
+
#~ add_output( :latex, '#{linebreak(@crbefore)}\title{#{@content}}#{linebreak(@crmid)}\hypersetup{pdftitle={#{@content}}}#{linebreak(@crafter)}')
|
102
|
+
add_output( :html, '#{linebreak(@crbefore)}<title>#{@content}</title>#{linebreak(@crafter)}')
|
103
|
+
add_output( :text, "\n" + '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}' + "\n")
|
104
|
+
add_output( :wiki, '#{linebreak(@crbefore)}' + '=#{@content}=' + ' #{linebreak(@crafter)}')
|
105
|
+
end
|
106
|
+
Element.create( [:meta], {
|
107
|
+
:name => Attribute.create( [ :html, :required ], nil, 1 ),
|
108
|
+
:content => Attribute.create( [ :html, :required ], nil, 2 ),
|
109
|
+
}, ENDTAG,
|
110
|
+
{
|
111
|
+
:htmltag => 'meta',
|
112
|
+
#~ :html => '<meta name="#{@attr[:name]}" content="#{@attr[:content]}">',
|
113
|
+
:latex => '',
|
114
|
+
# :latex => '#{linebreak(@crbefore)}' + '\author{#{@content}}\hypersetup{pdfauthor={#{@content}}}' + ' #{linebreak(@crafter)}'
|
115
|
+
} )
|
116
|
+
#Like Meta, but not name...
|
117
|
+
Element.create( [:meta2], {
|
118
|
+
:'http-equiv' => Attribute.create( [ :html, :required ], nil, 1 ),
|
119
|
+
:content => Attribute.create( [ :html, :required ], nil, 2 ),
|
120
|
+
}, nil,
|
121
|
+
{
|
122
|
+
:htmltag => 'meta',
|
123
|
+
#~ :html => '<meta name="#{@attr[:name]}" content="#{@attr[:content]}">',
|
124
|
+
:latex => '',
|
125
|
+
# :latex => '#{linebreak(@crbefore)}' + '\author{#{@content}}\hypersetup{pdfauthor={#{@content}}}' + ' #{linebreak(@crafter)}'
|
126
|
+
} )
|
127
|
+
|
128
|
+
Element.create( [:author], {}, true,
|
129
|
+
{ :html => '<meta name="author" content="#{@content}">' + ' #{linebreak(@crafter)}',
|
130
|
+
:latex => '#{linebreak(@crbefore)}\author{#{@content}}#{linebreak(@crmid)}\hypersetup{pdfauthor={#{@content}}}#{linebreak(@crafter)}'
|
131
|
+
} )
|
132
|
+
Element.create( [:date], {}, true,
|
133
|
+
{ :html => '<meta name="creation-date" content="#{@content}">' + ' #{linebreak(@crafter)}',
|
134
|
+
:latex => '#{linebreak(@crbefore)}\date{#{@content}}#{linebreak(@crafter)}'
|
135
|
+
} )
|
136
|
+
Element.create( [:keywords], {}, true,
|
137
|
+
{ :html => '<meta name="keywords" content="#{@content}">' + ' #{linebreak(@crafter)}',
|
138
|
+
:latex => '#{linebreak(@crbefore)}\hypersetup{pdfkeywords={#{@content}}}#{linebreak(@crafter)}'
|
139
|
+
} )
|
140
|
+
Element.create( [:metadescription], {}, true,
|
141
|
+
{ :html => '<meta name="description" content="#{@content}">' + ' #{linebreak(@crafter)}',
|
142
|
+
:latex => '#{linebreak(@crbefore)}\hypersetup{pdfsubject={#{@content}}}#{linebreak(@crafter)}'
|
143
|
+
} )
|
144
|
+
Element.create( [:creator], {}, true,
|
145
|
+
{ :html => '<meta name="creator" content="#{@content}">' + ' #{linebreak(@crafter)}',
|
146
|
+
:latex => '#{linebreak(@crbefore)}\hypersetup{pdfcreator={#{@content}}}#{linebreak(@crafter)}'
|
147
|
+
} )
|
148
|
+
#~ Element.create( [:hypersetup], {}, true,
|
149
|
+
#~ { :html => '<meta name="description" content="#{@content}">',
|
150
|
+
#~ :latex => '#{linebreak(@crbefore)}' + '\pdfinfo{description=#{@content}}' + ' #{linebreak(@crafter)}'
|
151
|
+
#~ } )
|
152
|
+
|
153
|
+
Element.create( [:maketitle], {}, false,
|
154
|
+
{ :htmltag => 'span', #Empty span
|
155
|
+
:html => "<!-- maketitle -->\n",
|
156
|
+
:latex => '#{linebreak(@crbefore)}' + '\maketitle #{linebreak(@crafter)}'
|
157
|
+
} )
|
158
|
+
Element.create( [:tableofcontents], {}, false,
|
159
|
+
{ :htmltag => 'span', #Empty span
|
160
|
+
:html => "<!-- tableofcontents -->\n",
|
161
|
+
:latex => '#{linebreak(@crbefore)}' + '\tableofcontents ' + ' #{linebreak(@crafter)}'
|
162
|
+
} )
|
163
|
+
Element.create( [:addcontentsline], {
|
164
|
+
:file => Attribute.create( [ :latex, :required ], [ 'toc', 'lof', 'lot' ] ),
|
165
|
+
:depth => Attribute.create( [ :latex, :required ], [ -1, 0,1,2,3,4,5,6] ),
|
166
|
+
}, true,
|
167
|
+
{ #:htmltag => 'span', #Empty span
|
168
|
+
#:html => "<!-- tableofcontents -->\n",
|
169
|
+
:latex => '#{linebreak(@crbefore)}' + '\addcontentsline{#{@attr[:file]}}{#{@attr[:depth]}}{#{@content}}' + ' #{linebreak(@crafter)}'
|
170
|
+
} )
|
171
|
+
Element.create( [:addtocontents], {
|
172
|
+
:file => Attribute.create( [ :latex, :required ], [ 'toc', 'lof', 'lot' ] ),
|
173
|
+
}, true,
|
174
|
+
{ #:htmltag => 'span', #Empty span
|
175
|
+
#:html => "<!-- tableofcontents -->\n",
|
176
|
+
:latex => '#{linebreak(@crbefore)}' + '\addtocontents{#{@attr[:file]}}{#{@content}}' + ' #{linebreak(@crafter)}'
|
177
|
+
} )
|
178
|
+
|
179
|
+
#
|
180
|
+
#Generell paragraph handling.
|
181
|
+
#
|
182
|
+
Element.create( [:par, :p], HTML_ATTR_ALL, true,
|
183
|
+
{ :htmltag => 'p',
|
184
|
+
:latex => "\n\n" + '#{@content}' + "\n\n",
|
185
|
+
:text => "\n" + '#{@content}' + "\n", #siehe experimente/textformat.rb
|
186
|
+
:wiki => "\n" + '#{@content}' + "\n",
|
187
|
+
} )
|
188
|
+
#~ par.add_output( :html, '<p>#{@attr[:content]}</p>')
|
189
|
+
#~ par.add_output( :latex, '#{@content}\par')
|
190
|
+
|
191
|
+
Element.create( [:nobr], HTML_ATTR_ALL, true,
|
192
|
+
{ :htmltag => 'nobr',
|
193
|
+
:latex => '#{linebreak(@crbefore)}\mbox{#{@content}}#{linebreak(@crafter)}'
|
194
|
+
#~ :text => "\n" + '#{@content}' + "\n",
|
195
|
+
} )
|
196
|
+
|
197
|
+
Element.create( [:br, 'br/', 'br', :newline], {
|
198
|
+
:clear=> Attribute.create( [ :html ], ['all'] ),
|
199
|
+
},ENDTAG,
|
200
|
+
{ :htmltag => 'br',
|
201
|
+
:latex => '#{linebreak(@crbefore)}\newline' + ' #{linebreak(@crafter)}',
|
202
|
+
:text => "\n",
|
203
|
+
:wiki => '{{newline}}#{linebreak(@crafter)}',
|
204
|
+
} )
|
205
|
+
Element.create( [:hr, 'hr/', 'hr', :hrulefill], {
|
206
|
+
:clear=> Attribute.create( [ :html ], ['all'] ),
|
207
|
+
},ENDTAG,
|
208
|
+
{ :htmltag => 'hr',
|
209
|
+
:wiki => '----',
|
210
|
+
:text => '-' * 25,
|
211
|
+
:latex => '#{linebreak(@crbefore)}' + '\hrulefill' + ' #{linebreak(@crafter)}'
|
212
|
+
} )
|
213
|
+
|
214
|
+
Element.create( [:vfill], {},false,
|
215
|
+
{ :htmltag => nil,
|
216
|
+
:latex => '#{linebreak(@crbefore)}\vfill #{linebreak(@crafter)}'
|
217
|
+
} )
|
218
|
+
Element.create( [:hfill], {},false,
|
219
|
+
{ :htmltag => nil,
|
220
|
+
:latex => '#{linebreak(@crbefore)}\hfill #{linebreak(@crafter)}'
|
221
|
+
} )
|
222
|
+
|
223
|
+
Element.create( [:relax], {},false,
|
224
|
+
{ :htmltag => nil,
|
225
|
+
:latex => '#{linebreak(@crbefore)}\relax #{linebreak(@crafter)}'
|
226
|
+
} )
|
227
|
+
|
228
|
+
#
|
229
|
+
#Grouping
|
230
|
+
#
|
231
|
+
Element.create( [:span, :group], HTML_ATTR_CORE, true,
|
232
|
+
{ :htmltag => 'span',
|
233
|
+
:latex => '#{linebreak(@crbefore)}' +
|
234
|
+
'\bgroup ' + '#{linebreak(@crmid)}' +
|
235
|
+
'#{@content}' + '#{linebreak(@crmid)}' +
|
236
|
+
'\egroup ' + '#{linebreak(@crafter)}'
|
237
|
+
} )
|
238
|
+
|
239
|
+
divattr = { :align => HTML_ATTR_ALIGN}
|
240
|
+
divattr.update( HTML_ATTR_CORE )
|
241
|
+
Element.create( [:div, :Group], divattr, true,
|
242
|
+
{ :htmltag => 'div',
|
243
|
+
:latex => '#{linebreak(@crbefore)}' +
|
244
|
+
'\begingroup ' + '#{linebreak(@crmid)}' +
|
245
|
+
'#{@content}' + '#{linebreak(@crmid)}' +
|
246
|
+
'\endgroup ' + '#{linebreak(@crafter)}'
|
247
|
+
} )
|
248
|
+
|
249
|
+
|
250
|
+
#Make a separator lin in code
|
251
|
+
Element.create( [:sepline], {}, false,
|
252
|
+
{ :html => "\n<!--" + '-' * 50 + " -->\n",
|
253
|
+
:latex => "\n%" + '-' * 50 + "\n"
|
254
|
+
} )
|
255
|
+
#Make a comment in code
|
256
|
+
Element.create( [:comment], {}, true,
|
257
|
+
{ :htmltag => '<!-- #{@content} -->',
|
258
|
+
:latex => '#{linebreak(@crbefore)}' + '% ------- #{@content} -------' + ' #{linebreak(@crafter)}'
|
259
|
+
} )
|
260
|
+
|
261
|
+
#
|
262
|
+
#Links
|
263
|
+
#
|
264
|
+
#Better: \hypertarget, hyperlink (pdf)
|
265
|
+
Element.create( [ :url ],
|
266
|
+
HTML_ATTR_ALL,
|
267
|
+
true,
|
268
|
+
{
|
269
|
+
:html => '<a href="#{@content}">#{@content}</a>',
|
270
|
+
:latex => '\url{#{@content}}',
|
271
|
+
} )
|
272
|
+
|
273
|
+
Element.create( [ :ensuremath ],
|
274
|
+
{},
|
275
|
+
true,
|
276
|
+
{
|
277
|
+
:html => '#{@content}',
|
278
|
+
:latex => '\ensuremath{#{@content}}',
|
279
|
+
} )
|
280
|
+
|
281
|
+
#
|
282
|
+
#Internal reference
|
283
|
+
#The href-parameter is expected with a leading # (HTML)
|
284
|
+
#The corresponding label should be defined in the same document/file.
|
285
|
+
#
|
286
|
+
#For external links use :href.
|
287
|
+
class Href < Element
|
288
|
+
Element.add( [:a, :href], Href)
|
289
|
+
add_attributes( {
|
290
|
+
:href => Attribute.create( [ :html, :required ], [String], 1 ),
|
291
|
+
:hreflang => ATTR_LANG,
|
292
|
+
:alt => Attribute.create( [ :html ], [String], 2 ),
|
293
|
+
:name => Attribute.create( [ :html ], [String] ),
|
294
|
+
:longdesc => Attribute.create( [ :html ], [String] ),
|
295
|
+
:value => Attribute.create( [ :html ] ),
|
296
|
+
:shape => Attribute.create( [ :html ] ),
|
297
|
+
:coords => Attribute.create( [ :html ] ),
|
298
|
+
:target => Attribute.create( [ :html ], [ '_blank', '_parent', '_self', '_top' ] ),
|
299
|
+
}.update(HTML_ATTR_ALL)
|
300
|
+
)
|
301
|
+
def htmltag(); 'a'; end
|
302
|
+
def to_wiki( )
|
303
|
+
"[#{@attr[:href].to_s} #{@content}]"
|
304
|
+
end
|
305
|
+
def to_latex( )
|
306
|
+
reference = @attr[:href].to_s
|
307
|
+
if reference.sub!(/\#/, '') #Internal reference
|
308
|
+
return "\\hyperlink{#{reference}}{#{@content}}"
|
309
|
+
else #external reference
|
310
|
+
return "\\href{#{reference}}{#{@content}}"
|
311
|
+
end
|
312
|
+
end
|
313
|
+
def to_text( )
|
314
|
+
if @attr[:href].to_s == @content
|
315
|
+
@content
|
316
|
+
else
|
317
|
+
#~ "<#{@attr[:href].to_s} #{@content}>" --> Problem: Wird gerne als komplette URL interpreitert
|
318
|
+
"#{@content} (#{@attr[:href].to_s})"
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
#~ Element.create( [ :a, :href ],
|
324
|
+
#~ { :href => Attribute.create( [ :html, :required ], [String], 1 ),
|
325
|
+
#~ :hreflang => ATTR_LANG,
|
326
|
+
#~ :alt => Attribute.create( [ :html ], [String], 2 ),
|
327
|
+
#~ :name => Attribute.create( [ :html ], [String] ),
|
328
|
+
#~ :longdesc => Attribute.create( [ :html ], [String] ),
|
329
|
+
#~ :value => Attribute.create( [ :html ] ),
|
330
|
+
#~ :shape => Attribute.create( [ :html ] ),
|
331
|
+
#~ :coords => Attribute.create( [ :html ] ),
|
332
|
+
#~ :target => Attribute.create( [ :html ], [ '_blank', '_parent', '_self', '_top' ] ),
|
333
|
+
#~ }.update( HTML_ATTR_ALL ),
|
334
|
+
#~ true,
|
335
|
+
#~ {
|
336
|
+
#~ :htmltag => 'a',
|
337
|
+
#~ :latex => '\href{#{@attr[:href]}}{#{@content}}',
|
338
|
+
#~ } )
|
339
|
+
|
340
|
+
Element.create( [ :label ],
|
341
|
+
{ :name => Attribute.create( [ :html, :latex, :required ] ),
|
342
|
+
}.update( HTML_ATTR_ALL ),
|
343
|
+
true,
|
344
|
+
{
|
345
|
+
#~ :htmltag => 'a',
|
346
|
+
:html => '#{linebreak(@crbefore)}<a name="#{@attr[:name]}">#{linebreak(@crmid)}#{@content}</a>#{linebreak(@crafter)}',
|
347
|
+
:latex => '#{linebreak(@crbefore)}\label{#{@attr[:name]}}#{linebreak(@crmid)}\hypertarget{#{@attr[:name]}}{#{@content}}#{linebreak(@crafter)}',
|
348
|
+
} )
|
349
|
+
|
350
|
+
Element.create( [ :hypertarget ],
|
351
|
+
{ :href => Attribute.create( [ :html, :required ] ),
|
352
|
+
:alt => Attribute.create( [ :html ] ),
|
353
|
+
:longdesc => Attribute.create( [ :html ] ),
|
354
|
+
:value => Attribute.create( [ :html ] ),
|
355
|
+
:shape => Attribute.create( [ :html ] ),
|
356
|
+
:coords => Attribute.create( [ :html ] ),
|
357
|
+
}.update( HTML_ATTR_ALL ),
|
358
|
+
true,
|
359
|
+
{
|
360
|
+
#~ :htmltag => 'a',
|
361
|
+
:latex => '#{linebreak(@crbefore)}\hypertarget{#{@attr[:href]}}{#{@content}}#{linebreak(@crafter)}',
|
362
|
+
} )
|
363
|
+
|
364
|
+
Element.create( [ :link ],
|
365
|
+
{ :href => Attribute.create( [ :html, :required ], nil, 1 ),
|
366
|
+
:rel => Attribute.create( [ :html ], [String], 2 ),
|
367
|
+
:title => Attribute.create( [ :html ], nil, 3 ),
|
368
|
+
:type => Attribute.create( [ :html ], nil, 4 ),
|
369
|
+
}.update( HTML_ATTR_ALL ),
|
370
|
+
ENDTAG,
|
371
|
+
{
|
372
|
+
:htmltag => 'link',
|
373
|
+
#~ :latex => '',
|
374
|
+
} )
|
375
|
+
|
376
|
+
#
|
377
|
+
|
378
|
+
class Usepackage < Element
|
379
|
+
#Make the key known to the complete key-list of elements.
|
380
|
+
Element.add( [:usepackage], Usepackage)
|
381
|
+
#~ add_attributes( HTML_ATTR_ALL )
|
382
|
+
add_attributes( { :option => Attribute.create( ) } )
|
383
|
+
|
384
|
+
#With usepackage additional command my be defined.
|
385
|
+
#Here we load this special
|
386
|
+
def << ( content )
|
387
|
+
@content << content
|
388
|
+
#Load new makros
|
389
|
+
makrodefinitions = 'docgenerator_' + content + '.rb'
|
390
|
+
begin
|
391
|
+
require makrodefinitions
|
392
|
+
rescue LoadError
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
#Redefine standard output.
|
397
|
+
#Options are given, if an option is avalaible.
|
398
|
+
#~ add_output( :latex, '\usepackage[#{@attr[:option]}]{#{@content}}' )
|
399
|
+
def to_latex()
|
400
|
+
cmd = linebreak(@crbefore)
|
401
|
+
cmd << '\usepackage'
|
402
|
+
opt = @attr[:option].content
|
403
|
+
cmd << '[' + opt.join(',') + ']' if opt.size > 0
|
404
|
+
cmd << "{#{@content}}"
|
405
|
+
cmd << linebreak(@crafter)
|
406
|
+
return cmd
|
407
|
+
end
|
408
|
+
def to_html()
|
409
|
+
return ''
|
410
|
+
end
|
411
|
+
end #Usepackage
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
#~ :em => {}, #complete it
|
416
|
+
#~ :code => {}, #complete it
|
417
|
+
Element.create( [:font], {
|
418
|
+
:size => Attribute.create([:html], [ Fixnum ]),
|
419
|
+
},true,
|
420
|
+
{ :htmltag => 'font',
|
421
|
+
#~ :latex => '\tiny ' #+ ' #{linebreak(@crafter)}'
|
422
|
+
} )
|
423
|
+
#Fixme: Jeweils :tinytex f�r ungeklammerte
|
424
|
+
Element.create( [:tiny ], {},true,
|
425
|
+
{ :html => '<span style="font-size:xx-small">#{@content}</span>',
|
426
|
+
:latex => '#{linebreak(@crbefore)}{\tiny #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
427
|
+
} )
|
428
|
+
Element.create( [:scriptsize ], {},true,
|
429
|
+
{ :html => '<span style="font-size:x-small">#{@content}</span>',
|
430
|
+
:latex => '#{linebreak(@crbefore)}{\scriptsize #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
431
|
+
} )
|
432
|
+
Element.create( [:footnotesize ], {},true,
|
433
|
+
{ :html => '<span style="font-size:x-small">#{@content}</span>',
|
434
|
+
:latex => '#{linebreak(@crbefore)}{\footnotesize #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
435
|
+
} )
|
436
|
+
#fixme \small oder {\small ..}
|
437
|
+
Element.create( [:small ], {},true,
|
438
|
+
{ #:html => '<span style="font-size:small">#{@content}</span>',
|
439
|
+
:htmltag => 'small',
|
440
|
+
:latex => '#{linebreak(@crbefore)}{\small #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
441
|
+
} )
|
442
|
+
Element.create( [:normalsize ], {},true,
|
443
|
+
{ :html => '<span style="font-size:medium">#{@content}</span>',
|
444
|
+
:latex => '#{linebreak(@crbefore)}{\normalsize #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
445
|
+
} )
|
446
|
+
Element.create( [:large ], {},true,
|
447
|
+
{ :html => '<span style="font-size:large">#{@content}</span>',
|
448
|
+
:latex => '#{linebreak(@crbefore)}{\large #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
449
|
+
} )
|
450
|
+
Element.create( [:Large ], {},true,
|
451
|
+
{ :html => '<span style="font-size:x-large">#{@content}</span>',
|
452
|
+
:latex => '#{linebreak(@crbefore)}{\Large #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
453
|
+
} )
|
454
|
+
Element.create( [:huge ], {},true,
|
455
|
+
{ :html => '<span style="font-size:xx-large">#{@content}</span>',
|
456
|
+
:latex => '#{linebreak(@crbefore)}{\huge #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
457
|
+
} )
|
458
|
+
Element.create( [:Huge ], {},true,
|
459
|
+
{ :html => '<span style="font-size:xx-large">#{@content}</span>',
|
460
|
+
:latex => '#{linebreak(@crbefore)}{\Huge #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
461
|
+
} )
|
462
|
+
|
463
|
+
Element.create( [:textbf, :strong ], {},true,
|
464
|
+
{ :htmltag => 'strong',
|
465
|
+
:latex => '#{linebreak(@crbefore)}\textbf{#{@content}}#{linebreak(@crafter)}',
|
466
|
+
:wiki => %q|#{linebreak(@crbefore)}'''#{@content}'''#{linebreak(@crafter)}|,
|
467
|
+
:text => '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}',
|
468
|
+
} )
|
469
|
+
Element.create( [:emph ], {},true,
|
470
|
+
{ :htmltag => 'em',
|
471
|
+
:latex => '#{linebreak(@crbefore)}\emph{#{@content}}#{linebreak(@crafter)}',
|
472
|
+
:wiki => '#{linebreak(@crbefore)}''#{@content}''#{linebreak(@crafter)}',
|
473
|
+
:text => '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}',
|
474
|
+
} )
|
475
|
+
|
476
|
+
Element.create( [:stroke ], {},true,
|
477
|
+
{ #:html => '<span style="font-size:small">#{@content}</span>',
|
478
|
+
:htmltag => 's',
|
479
|
+
#~ :latex => '#{linebreak(@crbefore)}{\stroke #{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
480
|
+
} )
|
481
|
+
|
482
|
+
Element.create( [:underline ], {},true,
|
483
|
+
{ #:html => '<span style="font-size:small">#{@content}</span>',
|
484
|
+
:htmltag => 'undeline',
|
485
|
+
:latex => '#{linebreak(@crbefore)}{\underline#{@content}}#{linebreak(@crafter)}' #+ ' #{linebreak(@crafter)}'
|
486
|
+
} )
|
487
|
+
|
488
|
+
Element.create( [:sup, :textsuperscript ], {}.update(HTML_ATTR_ALL),true,
|
489
|
+
{ :htmltag => 'sup',
|
490
|
+
:latex => '#{linebreak(@crbefore)}\textsuperscript{#{@content}}#{linebreak(@crafter)}'
|
491
|
+
} )
|
492
|
+
|
493
|
+
#
|
494
|
+
#Math function: sup
|
495
|
+
#~ Element.create( [:latexsup ], {}.update(HTML_ATTR_ALL),false,
|
496
|
+
#~ { :html => 'sup',
|
497
|
+
#~ :latex => '#{linebreak(@crbefore)}\sup}#{linebreak(@crafter)}'
|
498
|
+
#~ } )
|
499
|
+
|
500
|
+
Element.create( [:sub ], {}.update(HTML_ATTR_ALL),true,
|
501
|
+
{ :htmltag => 'sub',
|
502
|
+
#:latex => '\emph{#{@content}}'
|
503
|
+
} )
|
504
|
+
|
505
|
+
|
506
|
+
Element.create( [:newpage ], {},false,
|
507
|
+
{ #:htmltag => '',
|
508
|
+
:latex => '#{linebreak(@crbefore)}\newpage #{linebreak(@crafter)}'
|
509
|
+
} )
|
510
|
+
Element.create( [:clearpage ], {},false,
|
511
|
+
{ #:htmltag => '',
|
512
|
+
:latex => '#{linebreak(@crbefore)}' + '\clearpage ' + ' #{linebreak(@crafter)}'
|
513
|
+
} )
|
514
|
+
Element.create( [:twocolumn ], {},false,
|
515
|
+
{ #:htmltag => '',
|
516
|
+
:latex => '#{linebreak(@crbefore)}' + '\twocolumn ' + ' #{linebreak(@crafter)}'
|
517
|
+
} )
|
518
|
+
#fixme: TeX kein content, HTML hat content
|
519
|
+
Element.create( [:centering ], {},false,
|
520
|
+
{ :htmltag => 'center',
|
521
|
+
:latex => '\centering ' + ' #{linebreak(@crafter)}'
|
522
|
+
} )
|
523
|
+
|
524
|
+
#~ :link => {}, #complete it
|
525
|
+
#~ :center => {}, #complete it
|
526
|
+
#~ :map => all.update({}), #complete it
|
527
|
+
#~ :area => all.update({}), #complete it
|
528
|
+
#~ :option=> {:value=>nil}, #complete it
|
529
|
+
#~ :select=> events.update({}), #complete it
|
530
|
+
|
531
|
+
Element.create( :input, {}, true )
|
532
|
+
Element.create( :include, {}, true )
|
533
|
+
|
534
|
+
|
535
|
+
Element.create( [:img, :includegraphics],
|
536
|
+
{
|
537
|
+
:src => Attribute.create([:html, :latex, :required], [ String ], 1),
|
538
|
+
:alt => Attribute.create([:html], [String], 2 ),
|
539
|
+
:style => Attribute.create([:html], [String] ),
|
540
|
+
:width => Attribute.create([:texkeyval], [Integer, String] ), #String for \textwidth... for HTML use CSS
|
541
|
+
:height => Attribute.create([:texkeyval], [Integer, String] ), #String for \textwidth... for HTML use CSS
|
542
|
+
:border => Attribute.create([:html], [Integer] ),
|
543
|
+
:longdesc => Attribute.create([:html], [String] ),
|
544
|
+
:usemap => Attribute.create([:html], [String] ),
|
545
|
+
:name => Attribute.create([:html], [String] ),
|
546
|
+
:angle => Attribute.create([:texkeyval], [Integer] ), #Rotation angle.
|
547
|
+
:align => HTML_ATTR_ALIGN,
|
548
|
+
}.update(HTML_ATTR_CORE), ENDTAG,
|
549
|
+
{ #:html => '<span style="font-size:xx-small">#{@content}</span>',
|
550
|
+
:htmltag => 'img',
|
551
|
+
:latex => '#{linebreak(@crbefore)}\includegraphics[#{texkeyval}]{#{@attr[:src]}}#{linebreak(@crafter)}'
|
552
|
+
}
|
553
|
+
)
|
554
|
+
|
@@ -0,0 +1,73 @@
|
|
1
|
+
class Environment < Element
|
2
|
+
#Parameters are given as a string (or anything what gives a String with to_s).
|
3
|
+
#It is difficult to make a generic parameter interface.
|
4
|
+
#If needed, redefine the method.
|
5
|
+
def to_latex_environment( environment, parameter = nil)
|
6
|
+
cmd = ''
|
7
|
+
cmd << "\n" if @crbefore
|
8
|
+
cmd << "\n\\begin{#{environment}}"
|
9
|
+
cmd << parameter.to_s if parameter
|
10
|
+
cmd << "\n" if @crmid
|
11
|
+
cmd << @content.to_s
|
12
|
+
cmd << "\n" if @crmid and cmd[-1,1] != "\n"
|
13
|
+
cmd << "\\end{#{environment}}\n"
|
14
|
+
cmd << "\n" if @crafter
|
15
|
+
return cmd
|
16
|
+
end
|
17
|
+
#~ def htmltag()
|
18
|
+
#~ return 'table'
|
19
|
+
#~ end
|
20
|
+
#~ def to_latex( )
|
21
|
+
#~ return to_latex_environment( 'itemize' )
|
22
|
+
#~ end
|
23
|
+
end
|
24
|
+
|
25
|
+
Element.create( [:minipage], { :width => Attribute.create( [ :latex, :html ], [ String ] ), },
|
26
|
+
true,
|
27
|
+
{ :htmltag => 'div',
|
28
|
+
:latex => '#{linebreak(@crbefore)}' +
|
29
|
+
'\begin{minipage}{#{@attr[:width]}}' + '#{linebreak(@crmid)}' +
|
30
|
+
'#{@content}' + '#{linebreak(@crmid)}' +
|
31
|
+
'\end{minipage}' + '#{linebreak(@crafter)}'
|
32
|
+
} )
|
33
|
+
|
34
|
+
Element.create( [:center ], HTML_ATTR_CORE, true,
|
35
|
+
{ :htmltag => 'center',
|
36
|
+
:latex => '#{linebreak(@crbefore)}\begin{center}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\\end{center}#{linebreak(@crafter)}'
|
37
|
+
} )
|
38
|
+
Element.create( [:quote, :blockquote ], HTML_ATTR_CORE, true,
|
39
|
+
{ :htmltag => 'blockquote',
|
40
|
+
:latex => '#{linebreak(@crbefore)}\begin{quote}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{quote}#{linebreak(@crafter)}'
|
41
|
+
} )
|
42
|
+
|
43
|
+
Element.create( [:landscape ], {}, true,
|
44
|
+
{ #:htmltag => 'center',
|
45
|
+
:latex => '#{linebreak(@crbefore)}\begin{landscape}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{landscape}#{linebreak(@crafter)}'
|
46
|
+
} )
|
47
|
+
|
48
|
+
Element.create( [:verb ], {}, true,
|
49
|
+
{ :htmltag => 'pre', #fixme
|
50
|
+
:latex => '#{linebreak(@crbefore)}\verb|#{@content}|#{linebreak(@crafter)}'
|
51
|
+
} )
|
52
|
+
class Verbatim < Environment
|
53
|
+
add_attributes( HTML_ATTR_ALL )
|
54
|
+
Element.add( [:verbatim, :pre], Verbatim)
|
55
|
+
def htmltag(); 'pre' end
|
56
|
+
def to_text(); "#{content}" end
|
57
|
+
def to_wiki(); " #{content}" end
|
58
|
+
def to_latex( )
|
59
|
+
return to_latex_environment( 'verbatim' )
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
class Figure < Environment
|
64
|
+
add_attributes( HTML_ATTR_ALL )
|
65
|
+
Element.add( [:figure], Figure)
|
66
|
+
def htmltag(); 'div'; end
|
67
|
+
def to_latex( )
|
68
|
+
return to_latex_environment( 'figure' )
|
69
|
+
end
|
70
|
+
end
|
71
|
+
Element.create( [:listoffigures], {},false, {
|
72
|
+
:latex => '#{linebreak(@crbefore)}\listoffigures #{linebreak(@crafter)}',
|
73
|
+
})
|