docgenerator 1.1.1 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (179) hide show
  1. data/examples/docgenerator_example.rb +34 -17
  2. data/examples/docgenerator_example_footnote.rb +82 -61
  3. data/examples/docgenerator_example_list.rb +24 -18
  4. data/examples/docgenerator_example_restrictions.rb +17 -27
  5. data/examples/docgenerator_example_tabular.rb +20 -20
  6. data/examples/docgenerator_example_tripfalls.rb +28 -20
  7. data/examples/results/readme +1 -0
  8. data/examples/results_expected/docgenerator_example.html +39 -0
  9. data/examples/results_expected/docgenerator_example.pdf +0 -0
  10. data/examples/results_expected/docgenerator_example.tex +56 -0
  11. data/examples/results_expected/docgenerator_example_footnote.html +40 -0
  12. data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
  13. data/examples/results_expected/docgenerator_example_footnote.tex +50 -0
  14. data/examples/results_expected/docgenerator_example_list.html +18 -0
  15. data/examples/results_expected/docgenerator_example_list.pdf +0 -0
  16. data/examples/results_expected/docgenerator_example_list.tex +46 -0
  17. data/examples/results_expected/docgenerator_example_restrictions.html +22 -0
  18. data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
  19. data/examples/results_expected/docgenerator_example_restrictions.tex +31 -0
  20. data/examples/results_expected/docgenerator_example_tabular.html +37 -0
  21. data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
  22. data/examples/results_expected/docgenerator_example_tabular.tex +41 -0
  23. data/examples/results_expected/docgenerator_example_tripfalls.html +27 -0
  24. data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
  25. data/examples/results_expected/docgenerator_example_tripfalls.tex +31 -0
  26. data/lib/creole/creole2doc.rb +291 -140
  27. data/lib/creole/creole_inclusion_and_plugins.rb +142 -39
  28. data/lib/creole/creole_placeholder.rb +92 -30
  29. data/lib/creole/creole_tabular.rb +119 -20
  30. data/lib/docgenerator.rb +209 -118
  31. data/lib/{docgenerator_attribute.rb → docgenerator/attribute.rb} +2 -1
  32. data/lib/{docgenerator_characters.rb → docgenerator/characters.rb} +75 -6
  33. data/lib/{docgenerator_css.rb → docgenerator/css.rb} +0 -0
  34. data/lib/docgenerator/document.rb +588 -0
  35. data/lib/{docgenerator_element.rb → docgenerator/element.rb} +52 -80
  36. data/lib/{docgenerator_elements.rb → docgenerator/elements.rb} +43 -17
  37. data/lib/{docgenerator_environments.rb → docgenerator/environments.rb} +20 -6
  38. data/lib/{docgenerator_footnote.rb → docgenerator/footnote.rb} +22 -18
  39. data/lib/{docgenerator_lists.rb → docgenerator/lists.rb} +17 -1
  40. data/lib/{docgenerator_sections.rb → docgenerator/sections.rb} +9 -1
  41. data/lib/docgenerator/standard.rb +81 -0
  42. data/lib/{docgenerator_tabular.rb → docgenerator/tabular.rb} +9 -5
  43. data/lib/packages/docgenerator_listings.rb +9 -5
  44. data/lib/packages/docgenerator_pdfpages.rb +17 -11
  45. data/lib/packages/docgenerator_url.rb +0 -2
  46. data/lib/templates/docgenerator_template.rb +66 -29
  47. data/lib/templates/docgenerator_template.yaml +18 -0
  48. data/lib/wiki2doc/wiki2docgenerator.rb +6 -2
  49. data/readme.rd +132 -0
  50. data/unittest/expected/test_document_usepackage_undefined.log +2 -0
  51. data/unittest/expected/test_enumerate.context +4 -0
  52. data/unittest/expected/test_footnote.html +4 -4
  53. data/unittest/expected/test_footnote.latex +4 -4
  54. data/unittest/expected/test_footnote_group.html +6 -6
  55. data/unittest/expected/test_footnote_group.latex +6 -6
  56. data/unittest/expected/test_href.html +2 -2
  57. data/unittest/expected/test_href.latex +2 -2
  58. data/unittest/expected/test_href.text +2 -2
  59. data/unittest/expected/test_itemize.context +4 -0
  60. data/unittest/expected/test_runtex.stdout +3 -0
  61. data/unittest/expected/test_runtex_2.stdout +3 -0
  62. data/unittest/expected/test_section.context +20 -0
  63. data/unittest/expected/test_tabular.html +2 -2
  64. data/unittest/expected/test_verbatim.html +3 -0
  65. data/unittest/expected/test_verbatim.latex +4 -0
  66. data/unittest/expected/test_verbatim_array.html +1 -0
  67. data/unittest/expected/test_verbatim_array.latex +2 -0
  68. data/unittest/expected_creole/test_creole_characters_all.html +12 -5
  69. data/unittest/expected_creole/test_creole_characters_all.latex +20 -6
  70. data/unittest/expected_creole/test_creole_comment.context +11 -0
  71. data/unittest/expected_creole/test_creole_comment.creole +12 -0
  72. data/unittest/expected_creole/test_creole_comment.html +9 -0
  73. data/unittest/expected_creole/test_creole_comment.latex +11 -0
  74. data/unittest/expected_creole/test_creole_creole1.0test.html +3 -3
  75. data/unittest/expected_creole/test_creole_creole1.0test.latex +3 -3
  76. data/unittest/expected_creole/test_creole_creole1.0test.text +4 -4
  77. data/unittest/expected_creole/test_creole_ignore.html +3 -0
  78. data/unittest/expected_creole/test_creole_ignore.latex +4 -0
  79. data/unittest/expected_creole/test_creole_ignore.text +2 -0
  80. data/unittest/expected_creole/test_creole_input.normsource +12 -12
  81. data/unittest/expected_creole/test_creole_input_file_simple.html +15 -0
  82. data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +15 -0
  83. data/unittest/expected_creole/test_creole_links_external_implicit.html +2 -2
  84. data/unittest/expected_creole/test_creole_links_external_implicit.latex +2 -2
  85. data/unittest/expected_creole/test_creole_links_external_implicit.text +2 -2
  86. data/unittest/expected_creole/test_creole_links_implicit_end.creole +4 -0
  87. data/unittest/expected_creole/test_creole_links_implicit_end.html +3 -0
  88. data/unittest/expected_creole/test_creole_links_implicit_end.latex +4 -0
  89. data/unittest/expected_creole/test_creole_list_ul.normsource +42 -42
  90. data/unittest/expected_creole/test_creole_mix_titles_list.html +10 -0
  91. data/unittest/expected_creole/test_creole_mix_titles_list.latex +18 -0
  92. data/unittest/expected_creole/test_creole_mix_titles_list.text +12 -0
  93. data/unittest/expected_creole/test_creole_paragraphs.normsource +15 -15
  94. data/unittest/expected_creole/test_creole_pictures_css.html +4 -1
  95. data/unittest/expected_creole/test_creole_pictures_css.latex +5 -1
  96. data/unittest/expected_creole/test_creole_pictures_longdesc.html +3 -0
  97. data/unittest/expected_creole/test_creole_pictures_width.html +3 -0
  98. data/unittest/expected_creole/test_creole_pictures_width.latex +4 -0
  99. data/unittest/expected_creole/test_creole_short_html.html +3 -0
  100. data/unittest/expected_creole/test_creole_short_html.latex +4 -0
  101. data/unittest/expected_creole/test_creole_short_html.text +2 -0
  102. data/unittest/expected_creole/test_creole_shy.creole +6 -0
  103. data/unittest/expected_creole/test_creole_shy.html +6 -0
  104. data/unittest/expected_creole/test_creole_shy.latex +8 -0
  105. data/unittest/expected_creole/test_creole_shy.text +4 -0
  106. data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +20 -0
  107. data/unittest/expected_creole/test_creole_toc.html +3 -1
  108. data/unittest/expected_creole/test_creole_toc.latex +1 -1
  109. data/unittest/expected_creole/test_creole_toc.text +1 -1
  110. data/unittest/expected_creole/test_creole_toc_level.html +7 -0
  111. data/unittest/expected_creole/test_creole_toc_level.latex +10 -0
  112. data/unittest/expected_creole/test_creole_toc_level.text +3 -0
  113. data/unittest/expected_creole/test_creole_toc_level_text.html +8 -0
  114. data/unittest/expected_creole/test_creole_toc_level_text.latex +9 -0
  115. data/unittest/expected_creole/test_creole_verbatim.html +1 -1
  116. data/unittest/expected_creole/test_creole_verbatim.latex +1 -1
  117. data/unittest/expected_creole/test_creole_verbatim.text +1 -1
  118. data/unittest/expected_creole/test_creole_verbatim_inline.html +1 -1
  119. data/unittest/expected_creole/test_creole_verbatim_inline.latex +1 -1
  120. data/unittest/expected_wiki/test_wiki_description.html +5 -5
  121. data/unittest/expected_wiki/test_wiki_description.latex +5 -5
  122. data/unittest/expected_wiki/test_wiki_description.text +5 -5
  123. data/unittest/expected_wiki/test_wiki_description.wiki +5 -5
  124. data/unittest/test_rakefile_docgenerator.rb +43 -0
  125. data/unittest/unittest_creole2doc.rb +415 -27
  126. data/unittest/unittest_docgenerator.rb +256 -23
  127. data/unittest/unittest_docgenerator_runtex.rb +83 -0
  128. data/unittest/unittest_versions.rb +44 -0
  129. data/unittest/unittest_wiki2doc.rb +28 -27
  130. metadata +473 -106
  131. data/lib/docgenerator_document.rb +0 -525
  132. data/lib/packages/docgenerator_beamer.rb +0 -253
  133. data/lib/yaml2presentation/yaml2presentation.rb +0 -1091
  134. data/unittest/expected/beamer_01_article.tex +0 -13
  135. data/unittest/expected/beamer_01_attachment.tex +0 -15
  136. data/unittest/expected/beamer_01_doc.html +0 -13
  137. data/unittest/expected/beamer_01_doc.tex +0 -18
  138. data/unittest/expected/beamer_01_notes_only.tex +0 -13
  139. data/unittest/expected/beamer_01_notes_onlyslideswithnotes.tex +0 -13
  140. data/unittest/expected/beamer_01_notes_show.tex +0 -13
  141. data/unittest/expected/beamer_01_presentation.tex +0 -13
  142. data/unittest/expected/beamer_02_doc.html +0 -29
  143. data/unittest/expected/beamer_02_doc.tex +0 -34
  144. data/unittest/expected/beamer_block.html +0 -1
  145. data/unittest/expected/beamer_block.latex +0 -1
  146. data/unittest/expected/beamer_doc_fragile_doc.tex +0 -33
  147. data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +0 -34
  148. data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +0 -34
  149. data/unittest/expected/beamer_doc_key_doc.html +0 -20
  150. data/unittest/expected/beamer_doc_key_doc.tex +0 -29
  151. data/unittest/expected/beamer_doc_note_doc.html +0 -30
  152. data/unittest/expected/beamer_doc_note_doc.tex +0 -37
  153. data/unittest/expected/beamer_doc_pic_bottom_doc.html +0 -24
  154. data/unittest/expected/beamer_doc_pic_doc.html +0 -24
  155. data/unittest/expected/beamer_doc_pic_doc.tex +0 -28
  156. data/unittest/expected/beamer_doc_pic_left_doc.html +0 -24
  157. data/unittest/expected/beamer_doc_pic_left_doc.tex +0 -28
  158. data/unittest/expected/beamer_doc_pic_ratio_doc.tex +0 -29
  159. data/unittest/expected/beamer_doc_pic_right_doc.html +0 -24
  160. data/unittest/expected/beamer_doc_pic_right_doc.tex +0 -28
  161. data/unittest/expected/beamer_doc_pic_top_doc.html +0 -24
  162. data/unittest/expected/beamer_frame.html +0 -5
  163. data/unittest/expected/beamer_frame.tex +0 -11
  164. data/unittest/expected/beamer_frame_fragile.tex +0 -7
  165. data/unittest/expected/beamer_frame_id.html +0 -1
  166. data/unittest/expected/beamer_frame_id.tex +0 -4
  167. data/unittest/expected/beamer_framepic.html +0 -5
  168. data/unittest/expected/beamer_framepic.latex +0 -1
  169. data/unittest/expected/beamer_framepic_link.html +0 -5
  170. data/unittest/expected/beamer_framepic_link.latex +0 -1
  171. data/unittest/expected/beamer_frametitle.html +0 -1
  172. data/unittest/expected/beamer_frametitle.latex +0 -1
  173. data/unittest/expected/beamer_note.html +0 -1
  174. data/unittest/expected/beamer_note.latex +0 -1
  175. data/unittest/expected_privat/test_creole_test_document.html +0 -6
  176. data/unittest/expected_wiki/test_wiki_amazon.html +0 -10
  177. data/unittest/expected_wiki/test_wiki_link.log +0 -3
  178. data/unittest/test_docgenerator.rb +0 -107
  179. data/unittest/unittest_yaml2pres.rb +0 -336
@@ -1,70 +1,4 @@
1
- #Extend all objects by the methods
2
- #- to_doc
3
- #- to_html
4
- #- to_latex
5
- #- to_wiki
6
- #- to_text
7
- #Redefine is_a?:
8
- #Return true, when you test with a symbol.
9
- class Object
10
- alias :old_is_a? :is_a?
11
- #Redefine the standard is_a?
12
- #Returns also true, if one of the ids is in testvalue
13
- def is_a?( testvalue)
14
- if testvalue.old_is_a?(Symbol)
15
- if old_is_a?(Element)
16
- return ids.include?(testvalue)
17
- else
18
- return false
19
- end
20
- else
21
- return old_is_a?(testvalue)
22
- end
23
- end
24
- #
25
- # to_doc returns the object as a string.
26
- # will be redefined for Element
27
- #
28
- def to_doc(target, options = {})
29
- o = Docgenerator_logger.set_option_defaults(options)
30
- str = ""
31
- if self.is_a?(Element) and ! self.respond_to?(:to_doc)
32
- o[:log].error( "Missing to_doc routine for #{self.class}") if o[:log].error?
33
- end
34
- if self.respond_to?(:to_str)
35
- str << self.to_str
36
- else
37
- str << self.to_s
38
- end
39
- str
40
- end
41
- def to_text(options = {}); to_doc(:text, options); end
42
- def to_latex(options = {}); to_doc(:latex, options); end
43
- def to_html(options = {}); to_doc(:html, options); end
44
- def to_wiki(options = {}); to_doc(:wiki, options); end
45
- end
46
-
47
- class Array
48
- #
49
- # Returns the element for each parameter
50
- #
51
- def to_doc(target, options = {})
52
- o = Docgenerator_logger.set_option_defaults(options)
53
- o[:log].debug("enter to_doc(#{target}) for Array, options: #{options.keys.inspect}") if o[:log].debug?
54
- str = ""
55
- self.each{|el|
56
- begin
57
- str << el.to_doc(target, o)
58
- rescue ArgumentError
59
- o[:log].fatal("ArgumentError to_doc for element <#{el.class}>") if o[:log].fatal?
60
- str << el.to_doc(target)
61
- end
62
- }
63
- return str
64
- end
65
- end
66
-
67
-
1
+ #encoding: utf-8
68
2
  #This class defines possible elements of a document.
69
3
  #For each type of elements a class is defined.
70
4
  #The definition can be done explicite or generic with Element.create.
@@ -77,17 +11,13 @@ end
77
11
  #But the error is done, when the element is created.
78
12
  #When you redefine ELEMENTS_TRACE, some tracing information are stored during creation.
79
13
  class Element
14
+ include Docgenerator #get VERSION
80
15
  #Hash with all ids and their corresponding classes.
81
16
  @@ids = Hash.new( )
82
17
  #All attributes are stored in this hash.
83
18
  #The key is the corresponding class.
84
19
  @@attr = { Element => {} }
85
- #All output routines are stored in this hash.
86
- #The key is the corresponding class.
87
- @@log = false
88
- def Element.log=( log )
89
- @@log = log
90
- end
20
+
91
21
  #Flag, if the calling stack should be analysed for each Element
92
22
  #Only for document debbuging
93
23
  @@trace = nil
@@ -97,6 +27,9 @@ class Element
97
27
  end
98
28
 
99
29
  SUPPORTED_TARGETS = [ :latex, :html, :wiki, :text, :debug ]
30
+ SUPPORTED_TARGETS << :context #Added later
31
+ SUPPORTED_TARGETS << :creole #Added later
32
+
100
33
 
101
34
  #Return a element class.
102
35
  def Element.get( name )
@@ -107,7 +40,7 @@ class Element
107
40
  #
108
41
  #Add subclasses to the list of all element classes and initialize some internal hashes.
109
42
  def Element.inherited( subclass )
110
- puts "New subclass for 'Element' created: '#{subclass}'" if @@log
43
+ DOCGENERATOR_LOGGER.debug("New subclass for 'Element' created: '#{subclass}'") if DOCGENERATOR_LOGGER.debug?
111
44
  #All attributes of a class are collected in a hash.
112
45
  @@attr[subclass] = {}
113
46
  #Fill @@ids
@@ -128,13 +61,13 @@ class Element
128
61
 
129
62
  idlist.each{|id|
130
63
  if @@ids[ id ] == nil
131
- puts "Element class '#{id}' is new: #{elementClass}" if @@log
64
+ DOCGENERATOR_LOGGER.debug("Element class '#{id}' is new: #{elementClass}") if DOCGENERATOR_LOGGER.debug?
132
65
  #All new ids are collected
133
66
  @@ids[ id ] = elementClass
134
67
  elsif @@ids[ id ] == elementClass
135
- puts "Element class '#{id}' is defined double: #{elementClass}" if @@log
68
+ DOCGENERATOR_LOGGER.warn("Element class '#{id}' is defined double: #{elementClass}") if DOCGENERATOR_LOGGER.warn?
136
69
  else
137
- puts "Error: ID '#{id}' is redefined #{@@ids[id]} -> #{elementClass}"
70
+ DOCGENERATOR_LOGGER.error("Error: ID '#{id}' is redefined #{@@ids[id]} -> #{elementClass}") if DOCGENERATOR_LOGGER.error?
138
71
  @@ids[id] = elementClass
139
72
  end
140
73
  }
@@ -178,12 +111,16 @@ class Element
178
111
  case k
179
112
  when :latex
180
113
  elementclass.add_output( :latex, v )
114
+ when :context
115
+ elementclass.add_output( :context, v )
181
116
  when :html
182
117
  elementclass.add_output( :html, v )
183
118
  when :text
184
119
  elementclass.add_output( :text, v )
185
120
  when :wiki
186
121
  elementclass.add_output( :wiki, v )
122
+ when :creole
123
+ elementclass.add_output( :creole, v )
187
124
  when :htmltag
188
125
  if v
189
126
  elementclass.class_eval( "def htmltag()\n'#{v}'\nend" )
@@ -191,7 +128,7 @@ class Element
191
128
  elementclass.class_eval( "def htmltag()\nnil\nend" )
192
129
  end
193
130
  else
194
- puts "Unknown format #{k} for #{name}"
131
+ puts "#{__FILE__}##{__LINE__}: Unknown format #{k} for #{name}"
195
132
  end
196
133
  }
197
134
  elementclass.add_attributes( attr )
@@ -252,12 +189,16 @@ class Element
252
189
  case target
253
190
  when :latex
254
191
  cmd = "def to_latex(options = {})\n"
192
+ when :context
193
+ cmd = "def to_context(options = {})\n"
255
194
  when :html
256
195
  cmd = "def to_html(options = {})\n"
257
196
  when :text
258
197
  cmd = "def to_text(options = {})\n"
259
198
  when :wiki
260
199
  cmd = "def to_wiki(options = {})\n"
200
+ when :creole
201
+ cmd = "def to_creole(options = {})\n"
261
202
  else
262
203
  puts "#{self}: Undefined target format #{target}"
263
204
  end
@@ -493,8 +434,13 @@ code
493
434
  end
494
435
  @@level = 0
495
436
  #Build a String to be used for the target document.
496
- #Calls Element#to_latex (target :latex)
497
- #and Element#to_html (target :html).
437
+ #Calls
438
+ #-Element#to_latex (target :latex),
439
+ #-Element#to_context (target :context)
440
+ #-Element#to_html (target :html)
441
+ #-Element#to_wiki (target :wiki) (support stopped)
442
+ #-Element#to_creole (target :creole) (not really good results)
443
+ #-Element#to_text (target :text) (not really good results)
498
444
  #
499
445
  #Via the options-hash, you can transport additional information.
500
446
  def to_doc( target, options = {} )
@@ -517,13 +463,18 @@ code
517
463
  }
518
464
  #Build the string.
519
465
  result = ''
466
+
520
467
  case target
521
468
  when :latex
522
469
  result = to_latex(o)
470
+ when :context
471
+ result = to_context(o)
523
472
  when :html
524
473
  result = to_html(o)
525
474
  when :wiki
526
475
  result = to_wiki(o)
476
+ when :creole
477
+ result = to_creole(o)
527
478
  when :text
528
479
  result = to_text(o)
529
480
  else
@@ -551,6 +502,22 @@ code
551
502
  cmd << "\n" if @crafter
552
503
  return cmd
553
504
  end
505
+ #Create context-output.
506
+ #
507
+ #ConTeXt-support is added later and there are a lot of gaps (2009-07-01)
508
+ def to_context(options = {})
509
+ o = Docgenerator_logger.set_option_defaults(options)
510
+ o[:log].error("Missing output routine for ConTeXt (#{self.ids.join(',')}) [#{@called_by}]") if o[:log].error?
511
+ makroname = 'dummy'
512
+ self.ids.each{|id|
513
+ makroname = id if id.is_a?(Symbol) or id.is_a?(String)
514
+ }
515
+ cmd = ''
516
+ cmd << "\n" if @crbefore
517
+ cmd << "\\#{makroname}{#{@content}}"
518
+ cmd << "\n" if @crafter
519
+ return cmd
520
+ end
554
521
  #Method for definition inside Element.create.
555
522
  def linebreak( flag = true )
556
523
  flag ? "\n" : ''
@@ -621,6 +588,11 @@ code
621
588
  o[:log].error("Missing output routine for Wiki (#{self.ids.join(',')}) [#{@called_by}]") if o[:log].error?
622
589
  return "#{@content.to_wiki(options)}\n"
623
590
  end
591
+ def to_creole(options = {})
592
+ o = Docgenerator_logger.set_option_defaults(options)
593
+ o[:log].error("Missing output routine for creole (#{self.ids.join(',')}) [#{@called_by}]") if o[:log].error?
594
+ return "#{@content.to_creole(options)}\n"
595
+ end
624
596
  def to_text(options = {})
625
597
  o = Docgenerator_logger.set_option_defaults(options)
626
598
  o[:log].error("Missing output routine for Text (#{self.ids.join(',')}) [#{@called_by}]") if o[:log].error?
@@ -13,8 +13,10 @@
13
13
  Element.create( [:head], {}, true,
14
14
  { :htmltag => 'head',
15
15
  :latex => '#{@content}',
16
+ :context => '#{@content}',
16
17
  :text => '#{@content}',
17
18
  :wiki => '#{@content}',
19
+ :creole => '#{@content}',
18
20
  } )
19
21
  Element.create( [:body], {
20
22
  :bgcolor => Attribute.create( [ :html ] ),
@@ -26,43 +28,57 @@ Element.create( [:body], {
26
28
  true,
27
29
  { :htmltag => 'body',
28
30
  :latex => '#{@content}',
31
+ :context => '#{@content}',
29
32
  :text => '#{@content}',
30
33
  :wiki => '#{@content}',
34
+ :creole => '#{@content}',
31
35
  } )
32
36
 
33
37
  Element.create( [:latexdummy, :latexonly ], {},true,
34
38
  { :htmltag => nil,
35
39
  :html => '',
36
- :latex => '#{@content}'
40
+ :latex => '#{@content}',
41
+ :context => '',
37
42
  } )
38
43
  Element.create( [:htmldummy, :htmlonly ], {},true,
39
44
  { :html => '#{@content}',
40
- :latex => ''
45
+ :latex => '',
46
+ :context => '',
41
47
  } )
42
48
 
43
49
 
44
- #
45
- #Titlepage
46
- #
47
- #This parameter are better set with Document.title.
48
- #
50
+ =begin rdoc
51
+ Titlepage
52
+
53
+ This parameter are better set with Document.title.
54
+ =end
49
55
  class Title < Element
50
56
  Element.add( [:title], Title)
51
57
  add_attributes( {
52
58
  :short => Attribute.create( [ :html ], nil, 1 )
53
59
  }.update(HTML_ATTR_ALL)
54
60
  )
55
- #Unsaubere realisierung .. fixme
61
+ =begin rdoc
62
+ Does the LaTeX-class support the shorttitle-option?
63
+
64
+ beamer.sty does it, others not.
65
+
66
+ #Unsaubere realisierung .. fixme
67
+ =end
56
68
  def shortoption( options = {} )
57
69
  @attr[:short].content.compact! #delete nils.
58
70
  return nil if ! @attr[:short].filled?
59
71
  o = Docgenerator_logger.set_option_defaults(options)
60
72
  o[:log].debug("enter shortoption") if o[:log].debug?
61
- if o[:document]
62
- if o[:document].template[:latex].template.include?('Beamer')
63
- return "[#{@attr[:short].content}]"
73
+ if o[:document]
74
+ #Check for known classes, which support the optional short title
75
+ case o[:document].template[:latex].template
76
+ when /beamer/i, /festodoc/
77
+ return "[#{@attr[:short].content.join}]"
78
+ else
79
+ o[:log].info("No usage of option short in title") if o[:log].info?
64
80
  end
65
- else
81
+ else #no related document
66
82
  o[:log].info("No related document for shortoption") if o[:log].info?
67
83
  end
68
84
  return nil
@@ -79,7 +95,9 @@ class Title < Element
79
95
 
80
96
  add_output( :text, "\n" + '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}' + "\n")
81
97
  add_output( :wiki, '#{linebreak(@crbefore)}' + '=#{@content}=' + ' #{linebreak(@crafter)}')
82
- end
98
+ add_output( :creole, '#{linebreak(@crbefore)}' + '=#{@content}' + ' #{linebreak(@crafter)}')
99
+ end #Title
100
+
83
101
  Element.create( [:meta], {
84
102
  :name => Attribute.create( [ :html, :required ], nil, 1 ),
85
103
  :content => Attribute.create( [ :html, :required ], nil, 2 ),
@@ -88,7 +106,11 @@ Element.create( [:meta], {
88
106
  :htmltag => 'meta',
89
107
  #~ :html => '<meta name="#{@attr[:name]}" content="#{@attr[:content]}">',
90
108
  :latex => '',
109
+ :context => '',
91
110
  # :latex => '#{linebreak(@crbefore)}' + '\author{#{@content}}\hypersetup{pdfauthor={#{@content}}}' + ' #{linebreak(@crafter)}'
111
+ :wiki => '',
112
+ :creole => '',
113
+ :text => '',
92
114
  } )
93
115
  #Like Meta, but not name...
94
116
  Element.create( [:meta2], {
@@ -220,8 +242,10 @@ Element.create( [:addtocontents], {
220
242
  Element.create( [:par, :p], HTML_ATTR_ALL, true,
221
243
  { :htmltag => 'p',
222
244
  :latex => "\n\n" + '#{@content}' + "\n\n",
245
+ :context => "\n\n" + '#{@content}' + "\n\n",
223
246
  :text => "\n" + '#{@content}' + "\n", #siehe experimente/textformat.rb
224
- :wiki => "\n" + '#{@content}' + "\n",
247
+ :wiki => "\n" + '#{@content}' + "\n", #
248
+ :creole => "\n" + '#{@content}' + "\n\n",
225
249
  } )
226
250
  #~ par.add_output( :html, '<p>#{@attr[:content]}</p>')
227
251
  #~ par.add_output( :latex, '#{@content}\par')
@@ -437,11 +461,13 @@ class Usepackage < Element
437
461
  #Here we load this special commands/elements if available.
438
462
  def << ( content )
439
463
  @content << content
440
- #Load new makros if available
441
- makrodefinitions = 'docgenerator_' + content + '.rb'
464
+ #Load new additionals makros if available
465
+ makrodefinitions = 'packages/docgenerator_' + content + '.rb'
442
466
  begin
467
+ @log.debug("usepackage: Try to load #{makrodefinitions}") if @log.debug?
443
468
  require makrodefinitions
444
469
  rescue LoadError
470
+ @log.info("usepackage: No supporting definitions #{makrodefinitions} found") if @log.info?
445
471
  end
446
472
  end
447
473
 
@@ -453,7 +479,7 @@ class Usepackage < Element
453
479
  cmd << '\usepackage'
454
480
  opt = @attr[:option].content
455
481
  cmd << '[' + opt.join(',') + ']' if opt.size > 0
456
- cmd << "{#{@content}}"
482
+ cmd << "{#{@content.join}}"
457
483
  cmd << linebreak(@crafter)
458
484
  return cmd
459
485
  end
@@ -15,7 +15,21 @@ class Environment < Element
15
15
  cmd << "\n" if @crafter
16
16
  return cmd
17
17
  end
18
- #~ def htmltag()
18
+ #ConTeXt-environments start with start and end with stop.
19
+ #
20
+ #Fixme: Parameters
21
+ def to_context_environment( environment, parameter = nil, options={})
22
+ cmd = ''
23
+ cmd << "\n" if @crbefore
24
+ cmd << "\n\\start#{environment}"
25
+ cmd << parameter.to_s if parameter
26
+ cmd << "\n" if @crmid
27
+ cmd << @content.to_latex
28
+ #~ cmd << "\n" if @crmid and cmd[-1,1] != "\n"
29
+ cmd << "\n\\stop#{environment}\n"
30
+ cmd << "\n" if @crafter
31
+ return cmd
32
+ end #~ def htmltag()
19
33
  #~ return 'table'
20
34
  #~ end
21
35
  #~ def to_latex( )
@@ -55,8 +69,8 @@ Element.create( [:verb ], HTML_ATTR_CORE, true,
55
69
  #fixme font tt
56
70
  #~ :html => '#{linebreak(@crbefore)}<span style = "display: inline;white-space:pre;font-family:monospace">#{@content}</span>#{linebreak(@crafter)}',
57
71
  :html => '#{linebreak(@crbefore)}<span style = "display: inline;white-space:pre;font-family:monospace">#{@content.join.gsub(/</, \'&lt;\').gsub(/>/, \'&gt;\')}</span>#{linebreak(@crafter)}',
58
- :latex => '#{linebreak(@crbefore)}\verb|#{@content}|#{linebreak(@crafter)}'
59
- #~ :latex => '#{linebreak(@crbefore)}\verb{#{@content}}#{linebreak(@crafter)}'
72
+ :latex => '#{linebreak(@crbefore)}\verb|#{@content}|#{linebreak(@crafter)}',
73
+ :text => '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}',
60
74
  } )
61
75
 
62
76
  class Verbatim < Environment
@@ -84,10 +98,10 @@ class Verbatim < Environment
84
98
  return html
85
99
  end #to_html
86
100
 
87
- def to_text(options = {}); "#{content}" end
88
- def to_wiki(options = {} ); " #{content}" end
101
+ def to_text(options = {}); "#{content.join}" end
102
+ def to_wiki(options = {} ); " #{content.join}" end
89
103
  def to_latex(options = {} )
90
- return to_latex_environment( 'verbatim', options = {} )
104
+ return to_latex_environment( 'verbatim', nil, options = {} )
91
105
  end
92
106
  end
93
107
 
@@ -1,20 +1,29 @@
1
- #Attention!
2
- #
3
- #This is a 'global' group.
4
- #All footnotes of the actual programm are collected, not of one document!
5
- #
6
- #may be fixed in the future.
1
+ =begin rdoc
2
+ Footnotegroup.
3
+
4
+ A Footnote without group-attribute get it#s own Footnotegroup.
5
+ For LaTeX it is ok, for HTML the content of the footnote will disappear.
6
+ =end
7
7
  class Footnotegroup
8
8
  #Define a default key for the footnotes.
9
9
  #Used as part of the link.
10
10
  DEFAULTGROUPID = 'footnote'
11
11
  DEFAULTGROUPID.freeze
12
- #Build a new footnote group.
12
+ @@all = {}
13
+ =begin rdoc
14
+ =end
15
+ def self.[](key=DEFAULTGROUPID)
16
+ @@all[key]
17
+ end
18
+ =begin rdoc
19
+ Build a new footnote group.
20
+ =end
13
21
  def initialize( groupid = DEFAULTGROUPID)
14
22
  @groupid = groupid
15
23
  @footnotes = []
16
24
  @attr = {}
17
25
  @html_link = true
26
+ @@all[@groupid] = self
18
27
  end
19
28
  #Flag, if the footnote and the footnote mark should be linked.
20
29
  attr_accessor :html_link
@@ -29,7 +38,7 @@ class Footnotegroup
29
38
  return @footnotes.size
30
39
  end
31
40
  def to_doc( target, options={} )
32
- return '' if @footnotes.size == 0
41
+ return '' if @footnotes.empty?
33
42
  ul = element(:p, @attr ).cr
34
43
  @footnotes.each{|f|
35
44
  #~ ul << element(:sup, {}, f.counter )
@@ -46,9 +55,9 @@ class Footnotegroup
46
55
  end
47
56
  end #Footnotegroup
48
57
 
49
- #
50
- # Footnotes
51
- #
58
+ =begin rdoc
59
+ Footnotes
60
+ =end
52
61
  class Footnote < Element
53
62
  Element.add( [:footnote ], Footnote)
54
63
  add_attributes( {
@@ -63,12 +72,12 @@ class Footnote < Element
63
72
 
64
73
  def initialize( attr={}, content = nil)
65
74
  super
66
- @group = attr[:group]
75
+ @group = attr[:group] || Footnotegroup[]
67
76
  #@group must be defined!
68
77
  #This is only a dummy group. it will be lost for overviews.
69
78
  if ! @group.is_a?(Footnotegroup)
70
79
  @group = Footnotegroup.new()
71
- @log.error( "Footnote: No group assigned. Build a new group") if @log.error?
80
+ #~ @log.error( "Footnote: No group assigned. Build a new group") if @log.error?
72
81
  end
73
82
 
74
83
  @group << self
@@ -109,13 +118,8 @@ class Footnote < Element
109
118
  end #Footnote
110
119
 
111
120
 
112
-
113
121
  Element.create( [:footnotemark ], {}.update(HTML_ATTR_ALL),true,
114
122
  { :htmltag => 'sup',
115
123
  :latex => '#{linebreak(@crbefore)}\footnotemark[#{@content.to_latex}]#{linebreak(@crafter)}' #fixme
116
124
  } )
117
125
 
118
-
119
- __END__
120
- txt << f = element(:footnote,{:groupid=>1}, 'eins/Gruppe 1')
121
- txt << Footnotegroup.get()