docgenerator 0.1.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/examples/docgenerator_example.rb +76 -160
  2. data/examples/docgenerator_example_footnote.rb +98 -0
  3. data/examples/docgenerator_example_list.rb +62 -0
  4. data/examples/docgenerator_example_restrictions.rb +59 -0
  5. data/examples/docgenerator_example_tabular.rb +68 -0
  6. data/examples/docgenerator_example_tripfalls.rb +57 -0
  7. data/examples/wiki2docgenerator_example.rb +270 -0
  8. data/lib/docgenerator.rb +159 -0
  9. data/{docgenerator_attribute.rb → lib/docgenerator_attribute.rb} +32 -7
  10. data/{docgenerator_characters.rb → lib/docgenerator_characters.rb} +15 -0
  11. data/{docgenerator_css.rb → lib/docgenerator_css.rb} +6 -1
  12. data/{docgenerator_document.rb → lib/docgenerator_document.rb} +92 -93
  13. data/{docgenerator_element.rb → lib/docgenerator_element.rb} +125 -51
  14. data/{docgenerator_elements.rb → lib/docgenerator_elements.rb} +40 -56
  15. data/{docgenerator_environments.rb → lib/docgenerator_environments.rb} +16 -10
  16. data/{docgenerator_footnote.rb → lib/docgenerator_footnote.rb} +44 -22
  17. data/{docgenerator_lists.rb → lib/docgenerator_lists.rb} +44 -39
  18. data/{docgenerator_sections.rb → lib/docgenerator_sections.rb} +2 -2
  19. data/{docgenerator_tabular.rb → lib/docgenerator_tabular.rb} +71 -39
  20. data/{packages → lib/packages}/docgenerator_attachfile.rb +0 -0
  21. data/{packages → lib/packages}/docgenerator_caption.rb +0 -0
  22. data/{packages → lib/packages}/docgenerator_hyperref.rb +0 -0
  23. data/{packages → lib/packages}/docgenerator_listings.rb +1 -2
  24. data/{packages → lib/packages}/docgenerator_pdfpages.rb +0 -0
  25. data/{packages → lib/packages}/docgenerator_scrlettr2.rb +2 -2
  26. data/{packages → lib/packages}/docgenerator_scrpage2.rb +0 -0
  27. data/{packages → lib/packages}/docgenerator_url.rb +0 -0
  28. data/lib/templates/docgenerator_template.rb +176 -0
  29. data/lib/templates/docgenerator_template.yaml +105 -0
  30. data/lib/wiki2doc/wiki2docgenerator.rb +1161 -0
  31. data/self_docgenerator.rb +161 -0
  32. data/unittest/expected/test_beamer_note.html +1 -0
  33. data/unittest/expected/test_beamer_note.latex +1 -0
  34. data/unittest/expected/test_beamer_note.text +1 -0
  35. data/unittest/expected/test_beamer_note.wiki +1 -0
  36. data/unittest/expected/test_block.html +1 -0
  37. data/unittest/expected/test_block.latex +1 -0
  38. data/unittest/expected/test_block.text +1 -0
  39. data/unittest/expected/test_block.wiki +2 -0
  40. data/unittest/expected/test_css.css +1 -0
  41. data/unittest/expected/test_css2.css +1 -0
  42. data/unittest/expected/test_description.html +1 -0
  43. data/unittest/expected/test_description.latex +3 -0
  44. data/unittest/expected/test_description.text +3 -0
  45. data/unittest/expected/test_description.wiki +3 -0
  46. data/unittest/expected/test_document_article.latex +23 -0
  47. data/unittest/expected/test_document_html.html +14 -0
  48. data/unittest/expected/test_document_replacement_article.latex +23 -0
  49. data/unittest/expected/test_document_replacement_html.html +14 -0
  50. data/unittest/expected/test_document_replacement_text.text +5 -0
  51. data/unittest/expected/test_document_replacement_wiki.wiki +5 -0
  52. data/unittest/expected/test_document_text.text +5 -0
  53. data/unittest/expected/test_document_wiki.wiki +5 -0
  54. data/unittest/expected/test_enumerate.html +1 -0
  55. data/unittest/expected/test_enumerate.latex +3 -0
  56. data/unittest/expected/test_enumerate.text +1 -0
  57. data/unittest/expected/test_enumerate.wiki +2 -0
  58. data/unittest/expected/test_footnote.html +5 -0
  59. data/unittest/expected/test_footnote.latex +11 -0
  60. data/unittest/expected/test_footnote.text +13 -0
  61. data/unittest/expected/test_footnote.wiki +11 -0
  62. data/unittest/expected/test_footnote_group.html +8 -0
  63. data/unittest/expected/test_footnote_group.latex +17 -0
  64. data/unittest/expected/test_footnote_group.wiki +17 -0
  65. data/unittest/expected/test_href.html +2 -0
  66. data/unittest/expected/test_href.latex +8 -0
  67. data/unittest/expected/test_href.text +4 -0
  68. data/unittest/expected/test_html_css.html +1 -0
  69. data/unittest/expected/test_itemize.html +1 -0
  70. data/unittest/expected/test_itemize.latex +3 -0
  71. data/unittest/expected/test_itemize.text +1 -0
  72. data/unittest/expected/test_itemize.wiki +2 -0
  73. data/unittest/expected/test_section.html +8 -0
  74. data/unittest/expected/test_section.latex +20 -0
  75. data/unittest/expected/test_section.text +24 -0
  76. data/unittest/expected/test_section.wiki +20 -0
  77. data/unittest/expected/test_tabular.html +10 -0
  78. data/unittest/expected/test_tabular.latex +10 -0
  79. data/unittest/expected/test_tabular.wiki +31 -0
  80. data/unittest/expected/test_tabular_doc.latex +22 -0
  81. data/unittest/expected/test_wiki.html +6 -0
  82. data/unittest/expected/test_wiki.latex +12 -0
  83. data/unittest/expected/test_wiki.text +14 -0
  84. data/unittest/expected/test_wiki.wiki +12 -0
  85. data/unittest/expected/test_wiki_amazon.html +10 -0
  86. data/unittest/expected/test_wiki_description.html +7 -0
  87. data/unittest/expected/test_wiki_description.latex +11 -0
  88. data/unittest/expected/test_wiki_description.text +6 -0
  89. data/unittest/expected/test_wiki_description.wiki +6 -0
  90. data/unittest/expected/test_wiki_footnote.html +8 -0
  91. data/unittest/expected/test_wiki_footnote.latex +15 -0
  92. data/unittest/expected/test_wiki_footnote.text +12 -0
  93. data/unittest/expected/test_wiki_footnote.wiki +12 -0
  94. data/unittest/expected/test_wiki_footnote_groupid.html +21 -0
  95. data/unittest/expected/test_wiki_html_code.html +7 -0
  96. data/unittest/expected/test_wiki_html_code.latex +10 -0
  97. data/unittest/expected/test_wiki_html_code.text +6 -0
  98. data/unittest/expected/test_wiki_html_code.wiki +6 -0
  99. data/unittest/expected/test_wiki_inline.html +6 -0
  100. data/unittest/expected/test_wiki_inline.latex +12 -0
  101. data/unittest/expected/test_wiki_inline.text +8 -0
  102. data/unittest/expected/test_wiki_inline.wiki +8 -0
  103. data/unittest/expected/test_wiki_label.html +6 -0
  104. data/unittest/expected/test_wiki_link.html +8 -0
  105. data/unittest/expected/test_wiki_link.latex +14 -0
  106. data/unittest/expected/test_wiki_link.log +3 -0
  107. data/unittest/expected/test_wiki_link.wiki +6 -0
  108. data/unittest/expected/test_wiki_list_ol.html +24 -0
  109. data/unittest/expected/test_wiki_list_ol.latex +30 -0
  110. data/unittest/expected/test_wiki_list_ol.text +10 -0
  111. data/unittest/expected/test_wiki_list_ol.wiki +12 -0
  112. data/unittest/expected/test_wiki_list_ol_after_ul.html +16 -0
  113. data/unittest/expected/test_wiki_list_ol_after_ul.latex +24 -0
  114. data/unittest/expected/test_wiki_list_ol_after_ul.text +8 -0
  115. data/unittest/expected/test_wiki_list_ol_after_ul.wiki +10 -0
  116. data/unittest/expected/test_wiki_list_ol_ul.html +24 -0
  117. data/unittest/expected/test_wiki_list_ol_ul.latex +30 -0
  118. data/unittest/expected/test_wiki_list_ol_ul.text +10 -0
  119. data/unittest/expected/test_wiki_list_ol_ul.wiki +12 -0
  120. data/unittest/expected/test_wiki_list_ul.html +24 -0
  121. data/unittest/expected/test_wiki_list_ul.latex +30 -0
  122. data/unittest/expected/test_wiki_list_ul.text +10 -0
  123. data/unittest/expected/test_wiki_list_ul.wiki +12 -0
  124. data/unittest/expected/test_wiki_list_ul_too_much.html +39 -0
  125. data/unittest/expected/test_wiki_list_ul_too_much.latex +51 -0
  126. data/unittest/expected/test_wiki_list_ul_too_much.text +11 -0
  127. data/unittest/expected/test_wiki_list_ul_too_much.wiki +15 -0
  128. data/unittest/expected/test_wiki_picture.html +55 -0
  129. data/unittest/expected/test_wiki_picture.latex +76 -0
  130. data/unittest/expected/test_wiki_picture_thumb.html +5 -0
  131. data/unittest/expected/test_wiki_tab1.html +30 -0
  132. data/unittest/expected/test_wiki_tab1.latex +30 -0
  133. data/unittest/expected/test_wiki_tab1.wiki +29 -0
  134. data/unittest/expected/test_wiki_textformatting.html +7 -0
  135. data/unittest/expected/test_wiki_textformatting.latex +16 -0
  136. data/unittest/expected/test_wiki_textformatting.text +11 -0
  137. data/unittest/expected/test_wiki_textformatting.wiki +9 -0
  138. data/unittest/expected/test_wiki_toc.html +9 -0
  139. data/unittest/expected/test_wiki_toc.latex +18 -0
  140. data/unittest/expected/test_wiki_toc.text +21 -0
  141. data/unittest/expected/test_wiki_toc.wiki +18 -0
  142. data/unittest/expected/test_wiki_ul_multiple_line.html +18 -0
  143. data/unittest/expected/test_wiki_ul_multiple_line.latex +19 -0
  144. data/unittest/expected/test_wiki_ul_multiple_line.text +6 -0
  145. data/unittest/expected/test_wiki_ul_multiple_line.wiki +7 -0
  146. data/unittest/test_docgenerator.rb +85 -0
  147. data/unittest/unittest_docgenerator.rb +454 -0
  148. data/unittest/unittest_wiki2doc.rb +451 -0
  149. metadata +155 -31
  150. data/docgenerator.rb +0 -137
  151. data/docgenerator_template.rb +0 -103
  152. data/packages/docgenerator_beamer.rb +0 -250
@@ -5,41 +5,7 @@
5
5
  #
6
6
  #Definition of elements for DocGenerator.rb
7
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
8
+ #
43
9
 
44
10
  #
45
11
  #Main document control.
@@ -91,7 +57,7 @@ class Title < Element
91
57
  @attr[:short].content.compact! #delete nils.
92
58
  return nil if ! @attr[:short].filled?
93
59
  @part_of_doc.each{|doc|
94
- if doc.template[:latex].include?('Beamer')
60
+ if doc.template[:latex].template.include?('Beamer')
95
61
  return "[#{@attr[:short].content}]"
96
62
  end
97
63
  }
@@ -243,7 +209,9 @@ Element.create( [:div, :Group], divattr, true,
243
209
  :latex => '#{linebreak(@crbefore)}' +
244
210
  '\begingroup ' + '#{linebreak(@crmid)}' +
245
211
  '#{@content}' + '#{linebreak(@crmid)}' +
246
- '\endgroup ' + '#{linebreak(@crafter)}'
212
+ '\endgroup ' + '#{linebreak(@crafter)}',
213
+ :text => '#{@content}',
214
+ :wiki => '#{@content}',
247
215
  } )
248
216
 
249
217
 
@@ -266,8 +234,8 @@ Element.create( [ :url ],
266
234
  HTML_ATTR_ALL,
267
235
  true,
268
236
  {
269
- :html => '<a href="#{@content}">#{@content}</a>',
270
- :latex => '\url{#{@content}}',
237
+ :html => '#{linebreak(@crbefore)}<a href="#{@content}">#{@content}</a>#{linebreak(@crafter)}',
238
+ :latex => '#{linebreak(@crbefore)}\url{#{@content}}#{linebreak(@crafter)}',
271
239
  } )
272
240
 
273
241
  Element.create( [ :ensuremath ],
@@ -299,23 +267,26 @@ class Href < Element
299
267
  }.update(HTML_ATTR_ALL)
300
268
  )
301
269
  def htmltag(); 'a'; end
302
- def to_wiki( )
303
- "[#{@attr[:href].to_s} #{@content}]"
270
+ def to_wiki( options = {} )
271
+ "[#{@attr[:href].to_s} #{@content.to_doc(:wiki, options)}]"
304
272
  end
305
- def to_latex( )
273
+ def to_latex( options = {} )
274
+ cmd = linebreak(@crbefore)
306
275
  reference = @attr[:href].to_s
307
276
  if reference.sub!(/\#/, '') #Internal reference
308
- return "\\hyperlink{#{reference}}{#{@content}}"
277
+ cmd << "\\hyperlink{#{reference}}{#{@content.to_doc(:latex, options)}}"
309
278
  else #external reference
310
- return "\\href{#{reference}}{#{@content}}"
279
+ cmd << "\\href{#{reference}}{#{@content.to_doc(:latex, options)}}"
311
280
  end
281
+ cmd << linebreak(@crafter)
282
+ cmd
312
283
  end
313
- def to_text( )
284
+ def to_text( options = {} )
314
285
  if @attr[:href].to_s == @content
315
- @content
286
+ @content.to_doc(:text, options)
316
287
  else
317
288
  #~ "<#{@attr[:href].to_s} #{@content}>" --> Problem: Wird gerne als komplette URL interpreitert
318
- "#{@content} (#{@attr[:href].to_s})"
289
+ "#{@content.to_doc(:text, options)} (#{@attr[:href].to_s})"
319
290
  end
320
291
  end
321
292
  end
@@ -338,13 +309,16 @@ end
338
309
  #~ } )
339
310
 
340
311
  Element.create( [ :label ],
341
- { :name => Attribute.create( [ :html, :latex, :required ] ),
312
+ {
313
+ :name => Attribute.create( [ :html, :latex, :required ] ),
342
314
  }.update( HTML_ATTR_ALL ),
343
315
  true,
344
316
  {
345
317
  #~ :htmltag => 'a',
346
318
  :html => '#{linebreak(@crbefore)}<a name="#{@attr[:name]}">#{linebreak(@crmid)}#{@content}</a>#{linebreak(@crafter)}',
347
319
  :latex => '#{linebreak(@crbefore)}\label{#{@attr[:name]}}#{linebreak(@crmid)}\hypertarget{#{@attr[:name]}}{#{@content}}#{linebreak(@crafter)}',
320
+ :text => '(#{@attr[:name]}) #{@content}',
321
+ :wiki => '#{linebreak(@crbefore)}[[??#{@attr[:name]}]]#{@content}#{linebreak(@crafter)}', #fixme wrong
348
322
  } )
349
323
 
350
324
  Element.create( [ :hypertarget ],
@@ -375,14 +349,18 @@ Element.create( [ :link ],
375
349
 
376
350
  #
377
351
 
352
+ #
353
+ #TeX-Makro usepackage.
354
+ # Trys to load element definitions
355
+ #
378
356
  class Usepackage < Element
379
357
  #Make the key known to the complete key-list of elements.
380
358
  Element.add( [:usepackage], Usepackage)
381
359
  #~ add_attributes( HTML_ATTR_ALL )
382
360
  add_attributes( { :option => Attribute.create( ) } )
383
361
 
384
- #With usepackage additional command my be defined.
385
- #Here we load this special
362
+ #With usepackage additional command may be defined.
363
+ #Here we load this special commands/elements if available.
386
364
  def << ( content )
387
365
  @content << content
388
366
  #Load new makros
@@ -394,9 +372,9 @@ class Usepackage < Element
394
372
  end
395
373
 
396
374
  #Redefine standard output.
397
- #Options are given, if an option is avalaible.
375
+ #Options are given, if an option is available.
398
376
  #~ add_output( :latex, '\usepackage[#{@attr[:option]}]{#{@content}}' )
399
- def to_latex()
377
+ def to_latex( options = {} )
400
378
  cmd = linebreak(@crbefore)
401
379
  cmd << '\usepackage'
402
380
  opt = @attr[:option].content
@@ -405,7 +383,7 @@ class Usepackage < Element
405
383
  cmd << linebreak(@crafter)
406
384
  return cmd
407
385
  end
408
- def to_html()
386
+ def to_html( options = {} )
409
387
  return ''
410
388
  end
411
389
  end #Usepackage
@@ -487,7 +465,9 @@ Element.create( [:underline ], {},true,
487
465
 
488
466
  Element.create( [:sup, :textsuperscript ], {}.update(HTML_ATTR_ALL),true,
489
467
  { :htmltag => 'sup',
490
- :latex => '#{linebreak(@crbefore)}\textsuperscript{#{@content}}#{linebreak(@crafter)}'
468
+ :latex => '#{linebreak(@crbefore)}\textsuperscript{#{@content}}#{linebreak(@crafter)}',
469
+ :wiki => '#{linebreak(@crbefore)}^#{@content}^#{linebreak(@crafter)}',
470
+ :text => '#{linebreak(@crbefore)}^#{@content}^#{linebreak(@crafter)}'
491
471
  } )
492
472
 
493
473
  #
@@ -528,8 +508,12 @@ Element.create( [:centering ], {},false,
528
508
  #~ :option=> {:value=>nil}, #complete it
529
509
  #~ :select=> events.update({}), #complete it
530
510
 
531
- Element.create( :input, {}, true )
532
- Element.create( :include, {}, true )
511
+ Element.create( :input, {}, true, {
512
+ :latex => '#{linebreak(@crbefore)}\input{#{@content}}#{linebreak(@crafter)}'
513
+ } )
514
+ Element.create( :include, {}, true, {
515
+ :latex => '#{linebreak(@crbefore)}\include{#{@content}}#{linebreak(@crafter)}'
516
+ } )
533
517
 
534
518
 
535
519
  Element.create( [:img, :includegraphics],
@@ -1,14 +1,15 @@
1
1
  class Environment < Element
2
+ Element.add( [:environment], Environment)
2
3
  #Parameters are given as a string (or anything what gives a String with to_s).
3
4
  #It is difficult to make a generic parameter interface.
4
5
  #If needed, redefine the method.
5
- def to_latex_environment( environment, parameter = nil)
6
+ def to_latex_environment( environment, parameter = nil, options={})
6
7
  cmd = ''
7
8
  cmd << "\n" if @crbefore
8
9
  cmd << "\n\\begin{#{environment}}"
9
10
  cmd << parameter.to_s if parameter
10
11
  cmd << "\n" if @crmid
11
- cmd << @content.to_s
12
+ cmd << @content.to_latex
12
13
  cmd << "\n" if @crmid and cmd[-1,1] != "\n"
13
14
  cmd << "\\end{#{environment}}\n"
14
15
  cmd << "\n" if @crafter
@@ -45,18 +46,22 @@ Element.create( [:landscape ], {}, true,
45
46
  :latex => '#{linebreak(@crbefore)}\begin{landscape}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{landscape}#{linebreak(@crafter)}'
46
47
  } )
47
48
 
48
- Element.create( [:verb ], {}, true,
49
+ Element.create( [:verb ], HTML_ATTR_CORE, true,
49
50
  { :htmltag => 'pre', #fixme
50
51
  :latex => '#{linebreak(@crbefore)}\verb|#{@content}|#{linebreak(@crafter)}'
51
52
  } )
53
+
52
54
  class Verbatim < Environment
53
- add_attributes( HTML_ATTR_ALL )
55
+ add_attributes( {
56
+ :width => Attribute.create( [ :html ], [Integer], 1 ), #Number of characters
57
+ }.update(HTML_ATTR_ALL))
58
+
54
59
  Element.add( [:verbatim, :pre], Verbatim)
55
60
  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' )
61
+ def to_text(options = {}); "#{content}" end
62
+ def to_wiki(options = {} ); " #{content}" end
63
+ def to_latex(options = {} )
64
+ return to_latex_environment( 'verbatim', options = {} )
60
65
  end
61
66
  end
62
67
 
@@ -64,10 +69,11 @@ class Figure < Environment
64
69
  add_attributes( HTML_ATTR_ALL )
65
70
  Element.add( [:figure], Figure)
66
71
  def htmltag(); 'div'; end
67
- def to_latex( )
68
- return to_latex_environment( 'figure' )
72
+ def to_latex( options = {} )
73
+ return to_latex_environment( 'figure', options = {} )
69
74
  end
70
75
  end
76
+
71
77
  Element.create( [:listoffigures], {},false, {
72
78
  :latex => '#{linebreak(@crbefore)}\listoffigures #{linebreak(@crafter)}',
73
79
  })
@@ -2,63 +2,85 @@
2
2
  # Footnotes
3
3
  #
4
4
  class Footnote < Element
5
- @@group = Hash.new()
6
5
  Element.add( [:footnote ], Footnote)
7
6
  add_attributes( {
8
7
  :counter => Attribute.create(),
9
8
  :groupid => Attribute.create()
10
9
  }.update(HTML_ATTR_ALL)
11
- )
10
+ )
11
+ #The footnote group for the corresponding footnote
12
+ attr_reader :group
12
13
  def counter()
13
14
  if ! @attr[:counter].filled?
14
15
  groupid = @attr[:groupid].content[0]
15
- if ! @@group[groupid]
16
- @@group[groupid] = Footnotegroup.get( groupid )
17
- end
18
- @@group[groupid] << self
19
- @attr[:counter] << @@group[groupid].size
16
+ Footnotegroup.get( groupid ) << self
17
+ @attr[:counter] << Footnotegroup.get( groupid ).size
20
18
  end
21
- return @attr[:counter]
19
+ return @attr[:counter].content
22
20
  end
23
- def to_html( )
21
+ def link()
22
+ link = "foot"
23
+ if @attr[:groupid].content[0]
24
+ link << "#{@attr[:groupid]}-"
25
+ end
26
+ link << self.counter().to_s
27
+ link
28
+ end
29
+ def to_html( options={} )
24
30
  cmd = ''
25
31
  cmd << "\n" if @crbefore
26
32
  if Footnotegroup.get( @attr[:groupid].content[0] ).html_link
27
- cmd << "<sup><a href=\"#foot#{counter}\">#{counter}</a></sup>"
33
+ cmd << "<sup><a href=\"##{link}\">#{counter}</a></sup>"
28
34
  else
29
35
  cmd << "<sup>#{counter}</sup>"
30
36
  end
31
37
  cmd << "\n" if @crafter
32
38
  return cmd
33
39
  end
34
- def to_latex( )
40
+ def to_latex( options={} )
35
41
  cmd = ''
36
42
  cmd << "\n" if @crbefore
37
- cmd << "\\footnote{#{@content}}"
43
+ cmd << "\\footnote{#{@content.to_latex(options)}}"
38
44
  cmd << "\n" if @crafter
39
45
  return cmd
40
46
  end
41
- def to_text()
42
- return '#{linebreak(@crbefore)}' + "- #{@content}" + ' #{linebreak(@crafter)}'
47
+ def to_text(options={})
48
+ cmd = ''
49
+ cmd << "\n" if @crbefore
50
+ cmd << "(#{counter})"
51
+ cmd << "\n" if @crafter
52
+ return cmd
43
53
  end
54
+ alias :to_wiki :to_text
44
55
  def get_content()
45
56
  return @content
46
57
  end
47
58
  end
48
59
 
60
+ #Attention!
61
+ #
62
+ #This is a 'global' group.
63
+ #All footnotes of the actual programm are collected, not of one document!
64
+ #
65
+ #may be fixed in the future.
49
66
  class Footnotegroup
50
67
  @@all = { }
51
68
  #Use
52
69
  # Footnotegroup.get
53
70
  #to get the collected footnotes.
54
71
  #It is not a good idea to use this with LaTeX, because LaTeX makes it automatic.
55
- #(But you can try it with tables.
72
+ #(But you can try it with tables).
56
73
  def self.get( groupid = nil )
57
74
  if ! @@all[groupid]
58
75
  @@all[groupid] = self.new( groupid )
59
76
  end
60
77
  return @@all[groupid]
61
78
  end
79
+ #Ugly -- When you create multiple documents, you get a common Footnotegroup.
80
+ #Here you can clear it.
81
+ def self.clear()
82
+ @@all = { }
83
+ end
62
84
  def initialize( groupid )
63
85
  @groupid = groupid
64
86
  @footnotes = []
@@ -71,33 +93,33 @@ class Footnotegroup
71
93
  @attr = attr
72
94
  end
73
95
  def <<( footnote )
74
- @footnotes << footnote
96
+ @footnotes << footnote unless @footnotes.include?(footnote)
75
97
  end
76
98
  def size()
77
99
  return @footnotes.size
78
100
  end
79
- def to_s()
101
+ def to_doc( target, options={} )
80
102
  return '' if @footnotes.size == 0
81
103
  ul = element(:p, @attr ).cr
82
104
  @footnotes.each{|f|
83
105
  #~ ul << element(:sup, {}, f.counter )
84
- ul << footnotemark = element(:sup )
106
+ ul << footnotemark = element(:sup)
85
107
  if @html_link
86
- footnotemark << element(:label, { :name => "foot#{f.counter}" }, f.counter )
108
+ footnotemark << element(:label, { :name => "#{f.link}" }, f.counter )
87
109
  else
88
110
  footnotemark << f.counter
89
111
  end
90
112
  ul << f.get_content
91
113
  ul << element(:br).cr
92
114
  }
93
- return ul.to_s
115
+ return ul.to_doc(target, options )
94
116
  end
95
- end
117
+ end #Footnotegroup
96
118
 
97
119
 
98
120
  Element.create( [:footnotemark ], {}.update(HTML_ATTR_ALL),true,
99
121
  { :htmltag => 'sup',
100
- :latex => '#{linebreak(@crbefore)}\footnotemark[#{@content}]#{linebreak(@crafter)}' #fixme
122
+ :latex => '#{linebreak(@crbefore)}\footnotemark[#{@content.to_latex}]#{linebreak(@crafter)}' #fixme
101
123
  } )
102
124
 
103
125
 
@@ -1,6 +1,7 @@
1
1
 
2
2
  #Generell class for list environments
3
3
  class ListEnvironment < Environment
4
+ Element.add( [:listenvironment], ListEnvironment)
4
5
  add_attributes( HTML_ATTR_ALL )
5
6
  #Only items are allowed to be added.
6
7
  #
@@ -12,35 +13,43 @@ class ListEnvironment < Environment
12
13
  if self.class == Description
13
14
  #fixme: Reihenfolge
14
15
  if ! ( item.is_a?( Element.get(:dt) ) or item.is_a?( Element.get(:dd) ) )
15
- puts "Add non-item to list (#{item.class} #{@called_by})"
16
+ @log.warn("Add non-item to list (#{item.class} #{@called_by})") if @log.warn
16
17
  end
17
18
  elsif ! item.is_a?( Element.get(:item) )
18
- puts "Add non-item to list (#{item.class} #{@called_by})"
19
+ @log.warn("Add non-item to list (#{item.class} #{@called_by})") if @log.warn
19
20
  end
20
21
  @content << item
21
- set_backlink( item )
22
22
  end
23
23
  end
24
- def to_wiki( )
25
- res = "#{@content}\n"
26
- return res.gsub(/\n\n/, "\n")
24
+ #Add parent-information to options. Is used by the list elements to get the list type.
25
+ def to_doc( target, options = {} )
26
+ o = Docgenerator_logger.set_option_defaults(options)
27
+ o[:log].debug("enter to_doc for #{self.inspect}") if o[:log].debug?
28
+ options[:parent] = self
29
+ super
30
+ end
31
+ def to_wiki( options={} )
32
+ return "#{@content.to_doc(:wiki, options)}\n".gsub(/\n\n/, "\n")
33
+ end
34
+ def to_text( options={} )
35
+ return "#{@content.to_doc(:text,options)}\n".gsub(/\n\n/, "\n")
27
36
  end
28
- alias :to_text :to_wiki
29
37
  end
38
+
30
39
  class Itemize < ListEnvironment
31
40
  add_attributes( HTML_ATTR_ALL )
32
41
  Element.add( [:ul, :itemize], Itemize)
33
42
  def htmltag(); 'ul'; end
34
- def to_latex( )
35
- return to_latex_environment( 'itemize' )
43
+ def to_latex( options={} )
44
+ return to_latex_environment( 'itemize', nil, options )
36
45
  end
37
46
  end
38
47
  class Enumerate < ListEnvironment
39
48
  add_attributes( HTML_ATTR_ALL )
40
49
  Element.add( [:ol, :enumerate], Enumerate)
41
50
  def htmltag(); 'ol'; end
42
- def to_latex( )
43
- return to_latex_environment( 'enumerate' )
51
+ def to_latex( options={} )
52
+ return to_latex_environment( 'enumerate', nil, options )
44
53
  end
45
54
  end
46
55
  #
@@ -53,8 +62,8 @@ class Description < ListEnvironment
53
62
  add_attributes( HTML_ATTR_ALL )
54
63
  Element.add( [:description, :dl], Description)
55
64
  def htmltag(); 'dl'; end
56
- def to_latex( )
57
- return to_latex_environment( 'description' )
65
+ def to_latex( options={} )
66
+ return to_latex_environment( 'description', nil, options )
58
67
  end
59
68
  end
60
69
 
@@ -70,42 +79,38 @@ class Item < Element
70
79
  }.update(HTML_ATTR_ALL)
71
80
  )
72
81
  def htmltag(); 'li'; end
73
- def to_latex( )
82
+ def to_latex( options={} )
74
83
  cmd = ''
75
84
  cmd << "\n" if @crbefore
76
85
  cmd << "\n\\item "
77
86
  cmd << "[#{@attr[:text]}] " if @attr[:text].filled?
78
- cmd << @content.to_s
87
+ cmd << @content.to_doc(:latex, options)
79
88
  cmd << "\n" if @crafter
80
89
  return cmd
81
90
  end
82
- def to_text()
91
+ def to_text(options={})
83
92
  cmd = ''
84
93
  cmd << "\n" if @crbefore
85
- cmd << "- #{@content}"
94
+ cmd << "- #{@content.to_doc(:text, options)}"
86
95
  cmd << "\n" if @crafter
87
96
  return cmd
88
97
  end
89
98
  #fixme geschachtete
90
99
  #- ** auf stufe 2
91
100
  #- kein * wenn als n�chstes eine Liste kommt.
92
- def to_wiki()
101
+ def to_wiki(options={})
102
+ o = Docgenerator_logger.set_option_defaults(options)
103
+ o[:log].debug("enter to_latex for row") if o[:log].debug?
93
104
  cmd = ''
94
- #~ puts part_of.inspect
95
- if part_of.size != 1
96
- puts ":li/wiki: Unclear list type #{part_of.inspect}"
97
- else
98
- list = part_of[0]
99
- end
100
105
  #~ cmd << "\n" if @crbefore
101
- case list.class.to_s.to_sym
106
+ case o[:parent].class.to_s.to_sym
102
107
  when :Itemize
103
- cmd << "\n* #{@content}"
108
+ cmd << "\n* #{@content.to_doc(:wiki, options)}"
104
109
  when :Enumerate
105
- cmd << "\n# #{@content}"
110
+ cmd << "\n# #{@content.to_doc(:wiki, options)}"
106
111
  else
107
- puts ":li/wiki: Unknown list type #{part_of.inspect}"
108
- cmd << "\n* #{@content}"
112
+ o[:log].error(":li/wiki: Unknown list type #{o[:parent].inspect}") if o[:log].error?
113
+ cmd << "\n* #{@content.to_doc(:wiki, options)}"
109
114
  end
110
115
  #~ cmd << "\n" if cmd[-1,1] != "\n"
111
116
  cmd << "\n" if @crafter and cmd[-1,1] != "\n"
@@ -121,18 +126,18 @@ class DT < Element
121
126
  Element.add( [:dt], DT)
122
127
  add_attributes( HTML_ATTR_ALL )
123
128
  def htmltag(); 'dt'; end
124
- def to_text(); "\n#{@content}: " end
125
- def to_wiki()
129
+ def to_text(options={}); "\n#{@content.to_doc(:text, options )}: " end
130
+ def to_wiki(options={})
126
131
  cmd = ''
127
132
  cmd << "\n" if @crbefore
128
- cmd << "\n;#{@content}"
133
+ cmd << "\n;#{@content.to_doc(:wiki, options )}"
129
134
  cmd << "\n"
130
135
  return cmd
131
136
  end
132
- def to_latex( )
137
+ def to_latex( options={} )
133
138
  cmd = ''
134
139
  cmd << "\n" if @crbefore
135
- cmd << "\n\\item[#{@content}] "
140
+ cmd << "\n\\item[#{@content.to_doc(:latex, options)}] "
136
141
  cmd << "\n" if @crafter
137
142
  return cmd
138
143
  end
@@ -145,18 +150,18 @@ class DD < Element
145
150
  Element.add( [:dd], DD)
146
151
  add_attributes( HTML_ATTR_ALL )
147
152
  def htmltag(); 'dd'; end
148
- def to_text(); "\n\t#{@content}\n" end
149
- def to_wiki()
153
+ def to_text(options={}); "\n\t#{@content.to_doc(:text, options)}\n" end
154
+ def to_wiki(options={})
150
155
  cmd = ''
151
156
  cmd << "\n" if @crbefore
152
- cmd << "\n:#{@content}"
157
+ cmd << "\n:#{@content.to_doc(:wiki, options )}"
153
158
  cmd << "\n"
154
159
  return cmd
155
160
  end
156
- def to_latex( )
161
+ def to_latex( options={} )
157
162
  cmd = ''
158
163
  cmd << "\n" if @crbefore
159
- cmd << " #{@content} "
164
+ cmd << " #{@content.to_doc(:latex, options )} "
160
165
  cmd << "\n" if @crafter
161
166
  return cmd
162
167
  end