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
@@ -21,7 +21,7 @@ class ListEnvironment < Environment
21
21
  @content << item
22
22
  end
23
23
  end
24
- #Add parent-information to options. Is used by the list elements to get the list type.
24
+ #Add parent-information to options. This is used by the list elements to get the list type.
25
25
  def to_doc( target, options = {} )
26
26
  o = Docgenerator_logger.set_option_defaults(options)
27
27
  o[:log].debug("enter to_doc for #{self.inspect}") if o[:log].debug?
@@ -43,6 +43,9 @@ class Itemize < ListEnvironment
43
43
  def to_latex( options={} )
44
44
  return to_latex_environment( 'itemize', nil, options )
45
45
  end
46
+ def to_context( options={} )
47
+ return to_context_environment( 'itemize', '[1]', options )
48
+ end
46
49
  end
47
50
  class Enumerate < ListEnvironment
48
51
  add_attributes( HTML_ATTR_ALL )
@@ -51,6 +54,9 @@ class Enumerate < ListEnvironment
51
54
  def to_latex( options={} )
52
55
  return to_latex_environment( 'enumerate', nil, options )
53
56
  end
57
+ def to_context( options={} )
58
+ return to_context_environment( 'itemize', '[n]', options )
59
+ end
54
60
  end
55
61
  #
56
62
  #
@@ -88,6 +94,16 @@ class Item < Element
88
94
  cmd << "\n" if @crafter
89
95
  return cmd
90
96
  end
97
+ #Item is the same like in LaTeX,but we have to use to_context() for the sub-elements.
98
+ def to_context( options={} )
99
+ cmd = ''
100
+ cmd << "\n" if @crbefore
101
+ cmd << "\n\\item "
102
+ #~ cmd << "[#{@attr[:text]}] " if @attr[:text].filled? #fixme
103
+ cmd << @content.to_doc(:context, options)
104
+ cmd << "\n" if @crafter
105
+ return cmd
106
+ end
91
107
  def to_text(options={})
92
108
  cmd = ''
93
109
  cmd << "\n" if @crbefore
@@ -5,13 +5,15 @@
5
5
  #Small helper to make TeX-Hyperlinks like in HTML (attribute id)
6
6
  def hypertarget(id)
7
7
  return "\\hypertarget{#{id}}{}" if id.is_a?(String)
8
- return '' if ! id.content or id.content.to_s =~/\A\s*\Z/
8
+ #~ return '' if ! id.content or id.content.to_s =~/\A\s*\Z/
9
+ return '' if ! id.content or id.content.join =~/\A\s*\Z/ #Ruby 1.9
9
10
  return "\\hypertarget{#{id}}{}"
10
11
  end
11
12
 
12
13
  #Fixmes:
13
14
  #- addsec
14
15
  #- article/report
16
+ #- context (actual like latex
15
17
  sect = Struct.new( 'Sections', :keys, :wiki, :html, :tex )
16
18
  [
17
19
  sect.new( [:part], 0, '', 'part'), #fixme: neue HTML-Datei?
@@ -33,9 +35,15 @@ sect = Struct.new( 'Sections', :keys, :wiki, :html, :tex )
33
35
  '{#{@content}}' +
34
36
  '#{hypertarget(@attr[:id])}' +
35
37
  '#{linebreak(@crafter)}',
38
+ :context => '#{linebreak(@crbefore)}' + "\\#{s.tex}" +
39
+ '#{texoptional(:short)}' +
40
+ '{#{@content}}' +
41
+ '#{hypertarget(@attr[:id])}' +
42
+ '#{linebreak(@crafter)}',
36
43
  :text => "\n" + '#{linebreak(@crbefore)}#{@content}' + "\n" +
37
44
  ' ' * s.wiki * 2 + '-' * 30 + "\n" + '#{linebreak(@crafter)}',
38
45
  :wiki => '#{linebreak(@crbefore)}' + "\n" + '='* (s.wiki ) + '#{@content}' + '='* (s.wiki) + "\n" + '#{linebreak(@crafter)}',
46
+ :creole => '#{linebreak(@crbefore)}' + "\n" + '='* (s.wiki ) + '#{@content}' + "\n" + '#{linebreak(@crafter)}',
39
47
  } )
40
48
  }
41
49
  #~ Element.create( [:h1], HTML_ATTR_ALL, true,
@@ -0,0 +1,81 @@
1
+ #encoding: utf-8
2
+ =begin rdoc
3
+ This file change the behaviour of each Object.
4
+ =end
5
+
6
+ =begin rdoc
7
+ Extend all objects by the methods
8
+ - to_doc
9
+ - to_html
10
+ - to_latex
11
+ - to_wiki
12
+ - to_text
13
+ - to_context
14
+ Redefine is_a?:
15
+ Return true, when you test with a symbol.
16
+ =end
17
+ class Object
18
+ alias :old_is_a? :is_a?
19
+ =begin rdoc
20
+ Redefine the standard is_a?
21
+
22
+ Returns also true, if one of the ids is in testvalue
23
+ =end
24
+ def is_a?( testvalue)
25
+ if testvalue.old_is_a?(Symbol)
26
+ if old_is_a?(Element)
27
+ return ids.include?(testvalue)
28
+ else
29
+ return false
30
+ end
31
+ else
32
+ return old_is_a?(testvalue)
33
+ end
34
+ end
35
+ =begin rdoc
36
+ to_doc returns the object as a string.
37
+ will be redefined for Element
38
+ =end
39
+ def to_doc(target, options = {})
40
+ o = Docgenerator_logger.set_option_defaults(options)
41
+ if self.is_a?(Element) and ! self.respond_to?(:to_doc)
42
+ o[:log].error( "Missing to_doc routine for #{self.class}") if o[:log].error?
43
+ end
44
+ self.respond_to?(:to_str) ? self.to_str : self.to_s
45
+ end
46
+ def to_text(options = {}); to_doc(:text, options); end
47
+ def to_latex(options = {}); to_doc(:latex, options); end
48
+ def to_context(options = {}); to_doc(:context, options); end
49
+ def to_html(options = {}); to_doc(:html, options); end
50
+ def to_wiki(options = {}); to_doc(:wiki, options); end
51
+ def to_creole(options = {}); to_doc(:creole, options); end
52
+ end
53
+
54
+ =begin rdoc
55
+ Recursive to_doc for each elements in the array.
56
+ =end
57
+ class Array
58
+ =begin rdoc
59
+ Returns the element for each parameter
60
+ =end
61
+ def to_doc(target, options = {})
62
+ o = Docgenerator_logger.set_option_defaults(options)
63
+ o[:log].debug("enter to_doc(#{target}) for Array, options: #{options.keys.inspect}") if o[:log].debug?
64
+ str = ""
65
+ self.each{|el|
66
+ begin
67
+ res = el.to_doc(target, o)
68
+ rescue ArgumentError
69
+ o[:log].fatal("ArgumentError to_doc for element <#{el.class}>") if o[:log].fatal?
70
+ res = el.to_doc(target)
71
+ end
72
+ #Add text. If necessary, convert the encoding.
73
+ begin
74
+ str << res
75
+ rescue Encoding::CompatibilityError
76
+ str << res.encode(str.encoding)
77
+ end
78
+ }
79
+ return str
80
+ end #Array#to_doc
81
+ end #Array
@@ -1,6 +1,8 @@
1
- #
2
- #Definition of tabular elements for DocGenerator.rb
3
- #
1
+ #encoding: utf-8
2
+ =begin rdoc
3
+ Definition of tabular elements for DocGenerator.rb
4
+ =end
5
+
4
6
  #~ if __FILE__ == $0
5
7
  #~ require 'DocGenerator'
6
8
  #~ end
@@ -243,7 +245,7 @@ class Row < Element
243
245
  o[:log].debug("table/row without corresponding file") if o[:log].debug?
244
246
  cmd << Regexp.escape('\\')
245
247
  end
246
- cmd << "[#{@attr[:add_vspace].content.to_s}]" if @attr[:add_vspace].content.size > 0
248
+ cmd << "[#{@attr[:add_vspace].content.join}]" if @attr[:add_vspace].content.size > 0
247
249
  cmd << @hline.to_latex(o) if @hline
248
250
  cmd << @toprule.to_latex(o) if @toprule
249
251
  cmd << @midrule.to_latex(o) if @midrule
@@ -269,11 +271,13 @@ class Row < Element
269
271
  css = @attr[:style].content[0]
270
272
  o[:log].error( "docgenerator_tabular: style is no CSS #{css.inspect}" ) if css and ! css.is_a?(CSS) and o[:log].error?
271
273
  @attr[:style] << css = CSS.new if ! css
274
+
272
275
  #Doesn't work. Style sheet setting in tr doesn't go to td
273
276
  if @hline
274
277
  css[:border_bottom_style] = 'solid'
275
- css[:border_bottom_width] = 'thick'
278
+ css[:border_bottom_width] = 'medium'
276
279
  end
280
+
277
281
  # cmd << @toprule.to_s if @toprule
278
282
  # cmd << @midrule.to_s if @midrule
279
283
  # cmd << @bottomrule.to_s if @bottomrule
@@ -28,9 +28,13 @@ LSTSETTINGS = {
28
28
  }
29
29
 
30
30
  Element.create( [:lstlistoflistings], {}, false )
31
- Element.create( [:lstloadlanguages], {}, true, {:html => '' } )
31
+ Element.create( [:lstloadlanguages], {}, true, {
32
+ :latex => '#{linebreak(@crbefore)}\lstloadlanguages{#{@content}}#{linebreak(@crafter)}',
33
+ :html => '',
34
+ } )
32
35
  Element.create( [:lstset], LSTSETTINGS, false, {
33
36
  :latex => '#{linebreak(@crbefore)}\lstset{#{texkeyval()}}#{linebreak(@crafter)}',
37
+ :html => '',
34
38
  })
35
39
  Element.create( [:lstdefinestyle], LSTSETTINGS, true, {
36
40
  :latex => '#{linebreak(@crbefore)}\lstdefinestyle{#{@content}}{#{texkeyval()}}#{linebreak(@crafter)}',
@@ -57,7 +61,7 @@ class Lstinline < Element
57
61
  def htmltag; 'pre'; end
58
62
  #Redefine standard output.
59
63
  #Options are given, if an option is avalaible.
60
- def to_latex()
64
+ def to_latex( options={} )
61
65
  if ! @content.include?( '!' ); sep = '!'
62
66
  elsif ! @content.include?( '?' ); sep = '?'
63
67
  else
@@ -67,7 +71,7 @@ class Lstinline < Element
67
71
  cmd << '\lstinline'
68
72
  cmd << "[#{texkeyval()}]"
69
73
  cmd << sep
70
- cmd << "#{@content.to_latex}"
74
+ cmd << "#{@content.to_latex( options)}"
71
75
  cmd << sep
72
76
  cmd << linebreak(@crafter)
73
77
  return cmd
@@ -86,10 +90,10 @@ class Lstlisting < Environment
86
90
  def htmltag; 'pre'; end
87
91
  #Redefine standard output.
88
92
  #Options are given, if an option is avalaible.
89
- def to_latex()
93
+ def to_latex( options={} )
90
94
  option = "[#{texkeyval()}]"
91
95
  option = nil if option == '[]'
92
- return to_latex_environment( 'lstlisting', option )
96
+ return to_latex_environment( 'lstlisting', option, options )
93
97
  end
94
98
  end
95
99
 
@@ -2,17 +2,23 @@
2
2
  #requires a
3
3
  # doc.head << element(:usepackage,{},'pdfpages')
4
4
  #
5
+ #The usepackage command loads this script by its own.
6
+ #
5
7
 
6
8
 
7
- #if ! $".include?('docgenerator.rb')
8
- if ! defined?( Document )
9
- require 'docgenerator'
10
- end
11
-
12
- puts "#{__FILE__} fixme: options includepdf: hyperref/addsec.."
13
- Element.create( :includepdf, {
9
+ #
10
+ #Implement includepdf from pdfpages-package.
11
+ #
12
+ #Only pages-parameter is supported (yet).
13
+ class IncludePDF < Element
14
+
15
+ Element.add( [:includepdf], IncludePDF )
16
+
17
+ add_attributes( {
14
18
  :pages => Attribute.create( [ :texkeyval], [ String ] ),
15
- #~ :pages => Attribute.create( [ :texkeyval], [ String ] ),
16
- }, true, {
17
- :latex => '#{linebreak(@crbefore)}\includepdf[#{texkeyval()}]{#{@content}}#{linebreak(@crafter)}',
18
- })
19
+ }#.update(HTML_ATTR_ALL)
20
+ )
21
+
22
+ add_output( :latex, '#{linebreak(@crbefore)}\includepdf[#{texkeyval()}]{#{@content}}#{linebreak(@crafter)}')
23
+
24
+ end #IncludePDF
@@ -80,5 +80,3 @@ class Url
80
80
  return li_list
81
81
  end
82
82
  end
83
-
84
-
@@ -1,25 +1,34 @@
1
- #
2
- #Definition of templates.
3
- #
4
- #This templates are used for document types.
1
+ #encoding: cp1252
2
+ =begin rdoc
3
+ Definition of templates.
4
+
5
+ This templates are used for document types.
6
+
7
+ This Source-code is stored in cp1252.
8
+ All templates will get this encoding.
9
+
10
+
11
+ =end
5
12
  class DocumentTemplate
6
13
  @@templates = {}
7
- #
8
- #Define a template.
9
- #
10
- #A template gets a key, a target and the corresponding source.
11
- #
12
- #Valid targets are:
13
- #-:latex
14
- #-:html
15
- #-:wiki
16
- #-:text
17
- #
18
- #The source should contain the following place holder:
19
- #- <<prefix>> Contains later some admin data like time of creation...
20
- #- <<head>> Some header definitions
21
- #- <<body>> The main text
22
- #- <<classoptions>> Class options (LaTeX)
14
+ =begin rdoc
15
+
16
+ Define a template.
17
+
18
+ A template gets a key, a target and the corresponding source.
19
+
20
+ Valid targets are:
21
+ -:latex
22
+ -:html
23
+ -:wiki
24
+ -:text
25
+
26
+ The source should contain the following place holder:
27
+ - <<prefix>> Contains later some admin data like time of creation...
28
+ - <<head>> Some header definitions
29
+ - <<body>> The main text
30
+ - <<classoptions>> Class options (LaTeX)
31
+ =end
23
32
  def initialize( key, target, template)
24
33
  @key = key
25
34
  @target = target
@@ -27,7 +36,9 @@ class DocumentTemplate
27
36
  case target
28
37
  when :text
29
38
  when :wiki
39
+ when :creole
30
40
  when :latex
41
+ when :context
31
42
  when :html
32
43
  else
33
44
  puts "DocumentTemplate: Undefined target #{target.inspect}"
@@ -67,13 +78,13 @@ class DocumentTemplate
67
78
  def DocumentTemplate.keys()
68
79
  return @@templates.keys
69
80
  end
70
- #
71
- # To add new templates via an external yaml-definition file.
72
- # See 'docgenerator_template.yaml' as an example.
73
- #
74
- # You can use DocumentTemplate.to_yaml() to build your file.
75
- #
76
- def DocumentTemplate.load( yamlfile = "#{File.dirname(__FILE__)}/docgenerator_template.yaml" )
81
+ =begin rdoc
82
+ To add new templates via an external yaml-definition file.
83
+ See 'docgenerator_template.yaml' as an example.
84
+
85
+ You can use DocumentTemplate.to_yaml() to build your file.
86
+ =end
87
+ def DocumentTemplate.load( yamlfile )
77
88
  File.open(yamlfile){|yaml|
78
89
  YAML.load(yaml).each{|key, data|
79
90
  DocumentTemplate.new( key, data[:target], data[:source] )
@@ -93,7 +104,22 @@ class DocumentTemplate
93
104
  end
94
105
  end
95
106
 
96
- DocumentTemplate.load()
107
+ [
108
+ "#{File.dirname(__FILE__)}/docgenerator_template.yaml",
109
+ =begin
110
+ ocra-settings:
111
+
112
+ If you 'compile' your script with ocra, the template file is not found.
113
+
114
+ You have to add it yourself with
115
+ ocra <your_script>.rb docgenerator_template.yaml
116
+
117
+ (How to do it better?
118
+ =end
119
+ "#{File.dirname(__FILE__)}/../../../../../../../../src/docgenerator_template.yaml", #for ocra-version (exe)
120
+ ].each{| template_file |
121
+ DocumentTemplate.load(template_file) if File.exist?(template_file)
122
+ }
97
123
 
98
124
  #~ Dir["#{File.dirname(__FILE__)}/*.{wiki,latex,text,html}"].each{|templatename|
99
125
  #~ key, target = File.basename(templatename).split(/\./)
@@ -134,7 +160,18 @@ DocumentTemplate.new(
134
160
  #~ |)
135
161
 
136
162
  #~ <!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
137
-
163
+
164
+ DocumentTemplate.new(
165
+ :context, %q|<<prefix>>
166
+ % ----------------------------------------------------------------
167
+ <<head>>
168
+ % ----------------------------------------------------------------
169
+ \starttext
170
+ <<body>>
171
+ \stoptext
172
+ % ----------------------------------------------------------------
173
+ |)
174
+
138
175
  DocumentTemplate.new(
139
176
  :html, :html, %q|<!--
140
177
  <<prefix>>
@@ -24,6 +24,12 @@
24
24
 
25
25
  <<body>>
26
26
 
27
+ :creole:
28
+ :target: :creole
29
+ :source: |
30
+
31
+ <<body>>
32
+
27
33
  :xhtml_trans:
28
34
  :target: :html
29
35
  :source: |
@@ -103,3 +109,15 @@
103
109
  <<body>>
104
110
  \end{document}
105
111
  % ----------------------------------------------------------------
112
+
113
+ :context:
114
+ :target: :context
115
+ :source: |
116
+ <<prefix>>
117
+ % ----------------------------------------------------------------
118
+ <<head>>
119
+ % ----------------------------------------------------------------
120
+ \starttext
121
+ <<body>>
122
+ \stoptext
123
+ % ----------------------------------------------------------------
@@ -285,6 +285,8 @@ end
285
285
  #Get text in wiki-format and build a docgenerator-version.
286
286
  #
287
287
  class Wikitext
288
+ include Docgenerator #get VERSION
289
+
288
290
  #
289
291
  #Make short description for the Wiki-syntax
290
292
  def self.help( version = :syntax)
@@ -630,9 +632,11 @@ tabhelp
630
632
  end
631
633
  when 'filecontent'
632
634
  if File.exist?( val.first )
635
+ text = File.read(val.first)
636
+ #~ text.force_encoding(val[1] ) if val[1]
633
637
  return element(:div,
634
638
  Hash[*val[1..-1].map{|v| kv = v.split(/=/); [kv[0].to_sym, kv[1]]}.flatten],
635
- File.read(val.first) )
639
+ text )
636
640
  else
637
641
  log.error( "#{self.class}#wiki_macro: File #{value} missing for filecontent in line #{@lineno}" ) if log.error?
638
642
  end
@@ -692,7 +696,7 @@ tabhelp
692
696
  collector = nil #collect content for other application
693
697
  collectorline = nil #collect content for other application
694
698
 
695
- txt.each{|line|
699
+ txt.each_line{|line|
696
700
 
697
701
  if line.gsub!( /#~.*/, '') #delete comments
698
702
  #skip processing, if the line is now empty.