docgenerator 1.0.4 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (231) hide show
  1. data/lib/creole/creole2doc.rb +777 -0
  2. data/lib/creole/creole_inclusion_and_plugins.rb +236 -0
  3. data/lib/creole/creole_placeholder.rb +74 -0
  4. data/lib/creole/creole_tabular.rb +170 -0
  5. data/lib/docgenerator.rb +15 -6
  6. data/lib/docgenerator_attribute.rb +2 -2
  7. data/lib/docgenerator_characters.rb +20 -4
  8. data/lib/docgenerator_document.rb +132 -42
  9. data/lib/docgenerator_element.rb +531 -524
  10. data/lib/docgenerator_elements.rb +408 -399
  11. data/lib/docgenerator_environments.rb +28 -2
  12. data/lib/docgenerator_footnote.rb +72 -79
  13. data/lib/docgenerator_sections.rb +1 -1
  14. data/lib/docgenerator_tabular.rb +8 -3
  15. data/lib/packages/docgenerator_beamer.rb +253 -0
  16. data/lib/packages/docgenerator_scrlettr2.rb +53 -9
  17. data/lib/templates/docgenerator_template_css.rb +4 -0
  18. data/lib/wiki2doc/wiki2docgenerator.rb +1087 -970
  19. data/lib/yaml2presentation/yaml2presentation.rb +1091 -0
  20. data/self_docgenerator.rb +8 -6
  21. data/unittest/Red_Flower.jpg +0 -0
  22. data/unittest/creole1.0test.txt +128 -0
  23. data/unittest/expected/beamer_01_doc.html +1 -1
  24. data/unittest/expected/beamer_02_doc.html +1 -1
  25. data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +34 -0
  26. data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +34 -0
  27. data/unittest/expected/beamer_doc_key_doc.html +1 -1
  28. data/unittest/expected/beamer_doc_note_doc.html +1 -1
  29. data/unittest/expected/beamer_doc_pic_bottom_doc.html +1 -1
  30. data/unittest/expected/beamer_doc_pic_doc.html +1 -1
  31. data/unittest/expected/beamer_doc_pic_left_doc.html +1 -1
  32. data/unittest/expected/beamer_doc_pic_right_doc.html +1 -1
  33. data/unittest/expected/beamer_doc_pic_top_doc.html +1 -1
  34. data/unittest/expected/test_footnote.html +2 -2
  35. data/unittest/expected/test_footnote.latex +1 -1
  36. data/unittest/expected/test_footnote_group.html +3 -3
  37. data/unittest/expected/test_footnote_group.latex +2 -2
  38. data/unittest/expected_creole/test_creole.html +3 -0
  39. data/unittest/expected_creole/test_creole_characters_all.html +10 -0
  40. data/unittest/expected_creole/test_creole_characters_all.latex +20 -0
  41. data/unittest/expected_creole/test_creole_characters_special.html +10 -0
  42. data/unittest/expected_creole/test_creole_characters_special.latex +18 -0
  43. data/unittest/expected_creole/test_creole_countdown.html +3 -0
  44. data/unittest/expected_creole/test_creole_countdown.latex +4 -0
  45. data/unittest/expected_creole/test_creole_creole1.0test.html +182 -0
  46. data/unittest/expected_creole/test_creole_creole1.0test.latex +253 -0
  47. data/unittest/expected_creole/test_creole_creole1.0test.text +160 -0
  48. data/unittest/expected_creole/test_creole_footnotes.html +9 -0
  49. data/unittest/expected_creole/test_creole_footnotes.latex +14 -0
  50. data/unittest/expected_creole/test_creole_footnotes_label.html +9 -0
  51. data/unittest/expected_creole/test_creole_headings.html +17 -0
  52. data/unittest/expected_creole/test_creole_headings.latex +19 -0
  53. data/unittest/expected_creole/test_creole_headings.text +48 -0
  54. data/unittest/expected_creole/test_creole_headings.wiki +37 -0
  55. data/unittest/expected_creole/test_creole_hr.html +7 -0
  56. data/unittest/expected_creole/test_creole_hr.latex +9 -0
  57. data/unittest/expected_creole/test_creole_hr.text +4 -0
  58. data/unittest/expected_creole/test_creole_inline.html +3 -0
  59. data/unittest/expected_creole/test_creole_inline.latex +4 -0
  60. data/unittest/expected_creole/test_creole_inline.text +2 -0
  61. data/unittest/expected_creole/test_creole_inline_ruby.html +12 -0
  62. data/unittest/expected_creole/test_creole_inline_ruby.latex +20 -0
  63. data/unittest/expected_creole/test_creole_inline_ruby_raw.html +6 -0
  64. data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +8 -0
  65. data/unittest/expected_creole/test_creole_input.normsource +23 -0
  66. data/unittest/expected_creole/test_creole_label.html +12 -0
  67. data/unittest/expected_creole/test_creole_label.latex +15 -0
  68. data/unittest/expected_creole/test_creole_line_break.html +6 -0
  69. data/unittest/expected_creole/test_creole_line_break.latex +8 -0
  70. data/unittest/expected_creole/test_creole_links_explicit_internal.html +6 -0
  71. data/unittest/expected_creole/test_creole_links_explicit_internal.text +4 -0
  72. data/unittest/expected_creole/test_creole_links_explicit_with_em.html +3 -0
  73. data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +4 -0
  74. data/unittest/expected_creole/test_creole_links_explicit_with_em.text +2 -0
  75. data/unittest/expected_creole/test_creole_links_external.html +6 -0
  76. data/unittest/expected_creole/test_creole_links_external.latex +8 -0
  77. data/unittest/expected_creole/test_creole_links_external.text +4 -0
  78. data/unittest/expected_creole/test_creole_links_external_implicit.html +9 -0
  79. data/unittest/expected_creole/test_creole_links_external_implicit.latex +12 -0
  80. data/unittest/expected_creole/test_creole_links_external_implicit.text +6 -0
  81. data/unittest/expected_creole/test_creole_links_file.html +6 -0
  82. data/unittest/expected_creole/test_creole_links_file.latex +8 -0
  83. data/unittest/expected_creole/test_creole_links_file.text +4 -0
  84. data/unittest/expected_creole/test_creole_list_ol.html +12 -0
  85. data/unittest/expected_creole/test_creole_list_ol.latex +22 -0
  86. data/unittest/expected_creole/test_creole_list_ol_after_ul.html +12 -0
  87. data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +20 -0
  88. data/unittest/expected_creole/test_creole_list_ol_after_ul.text +6 -0
  89. data/unittest/expected_creole/test_creole_list_ol_ul.html +15 -0
  90. data/unittest/expected_creole/test_creole_list_ol_ul.latex +26 -0
  91. data/unittest/expected_creole/test_creole_list_ul.html +22 -0
  92. data/unittest/expected_creole/test_creole_list_ul.latex +40 -0
  93. data/unittest/expected_creole/test_creole_list_ul.normsource +83 -0
  94. data/unittest/expected_creole/test_creole_list_ul_too_much.html +24 -0
  95. data/unittest/expected_creole/test_creole_list_ul_too_much.latex +44 -0
  96. data/unittest/expected_creole/test_creole_newline.html +9 -0
  97. data/unittest/expected_creole/test_creole_newline.latex +11 -0
  98. data/unittest/expected_creole/test_creole_newline.text +7 -0
  99. data/unittest/expected_creole/test_creole_paragraphs.html +6 -0
  100. data/unittest/expected_creole/test_creole_paragraphs.latex +8 -0
  101. data/unittest/expected_creole/test_creole_paragraphs.normsource +27 -0
  102. data/unittest/expected_creole/test_creole_paragraphs.text +4 -0
  103. data/unittest/expected_creole/test_creole_paragraphs.wiki +4 -0
  104. data/unittest/expected_creole/test_creole_paragraphs_wrap.html +5 -0
  105. data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +6 -0
  106. data/unittest/expected_creole/test_creole_paragraphs_wrap.text +4 -0
  107. data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +4 -0
  108. data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +9 -0
  109. data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +11 -0
  110. data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +7 -0
  111. data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +7 -0
  112. data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +5 -0
  113. data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +6 -0
  114. data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +4 -0
  115. data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +4 -0
  116. data/unittest/expected_creole/test_creole_picture_link.html +6 -0
  117. data/unittest/expected_creole/test_creole_pictures.html +10 -0
  118. data/unittest/expected_creole/test_creole_pictures.latex +13 -0
  119. data/unittest/expected_creole/test_creole_pictures_css.html +3 -0
  120. data/unittest/expected_creole/test_creole_pictures_css.latex +4 -0
  121. data/unittest/expected_creole/test_creole_pictures_imgclass.html +6 -0
  122. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +8 -0
  123. data/unittest/expected_creole/test_creole_placeholders_html.html +7 -0
  124. data/unittest/expected_creole/test_creole_placeholders_html.latex +8 -0
  125. data/unittest/expected_creole/test_creole_placeholders_html.text +4 -0
  126. data/unittest/expected_creole/test_creole_placeholders_latex.html +6 -0
  127. data/unittest/expected_creole/test_creole_placeholders_latex.latex +9 -0
  128. data/unittest/expected_creole/test_creole_placeholders_latex.text +4 -0
  129. data/unittest/expected_creole/test_creole_tabular.html +20 -0
  130. data/unittest/expected_creole/test_creole_tabular.latex +22 -0
  131. data/unittest/expected_creole/test_creole_tabular_creole.html +18 -0
  132. data/unittest/expected_creole/test_creole_tabular_creole.latex +19 -0
  133. data/unittest/expected_creole/test_creole_tabular_css.html +20 -0
  134. data/unittest/expected_creole/test_creole_tabular_css.latex +22 -0
  135. data/unittest/expected_creole/test_creole_toc.html +11 -0
  136. data/unittest/expected_creole/test_creole_toc.latex +22 -0
  137. data/unittest/expected_creole/test_creole_toc.text +4 -0
  138. data/unittest/expected_creole/test_creole_toc_text.html +5 -0
  139. data/unittest/expected_creole/test_creole_toc_text.latex +5 -0
  140. data/unittest/expected_creole/test_creole_ul_multiple_line.html +7 -0
  141. data/unittest/expected_creole/test_creole_ul_multiple_line.latex +14 -0
  142. data/unittest/expected_creole/test_creole_ul_with_blank.html +11 -0
  143. data/unittest/expected_creole/test_creole_ul_with_blank.latex +20 -0
  144. data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
  145. data/unittest/expected_creole/test_creole_ul_with_bold.html +11 -0
  146. data/unittest/expected_creole/test_creole_ul_with_bold.latex +18 -0
  147. data/unittest/expected_creole/test_creole_ul_with_bold.text +7 -0
  148. data/unittest/expected_creole/test_creole_verbatim.html +25 -0
  149. data/unittest/expected_creole/test_creole_verbatim.latex +33 -0
  150. data/unittest/expected_creole/test_creole_verbatim.text +17 -0
  151. data/unittest/expected_creole/test_creole_verbatim_inline.html +6 -0
  152. data/unittest/expected_creole/test_creole_verbatim_inline.latex +8 -0
  153. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +6 -0
  154. data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +8 -0
  155. data/unittest/expected_privat/test_creole_test_document.html +6 -0
  156. data/unittest/{expected → expected_wiki}/test_wiki.html +0 -0
  157. data/unittest/{expected → expected_wiki}/test_wiki.latex +0 -0
  158. data/unittest/{expected → expected_wiki}/test_wiki.text +0 -0
  159. data/unittest/{expected → expected_wiki}/test_wiki.wiki +0 -0
  160. data/unittest/{expected → expected_wiki}/test_wiki_amazon.html +0 -0
  161. data/unittest/{expected → expected_wiki}/test_wiki_description.html +0 -0
  162. data/unittest/{expected → expected_wiki}/test_wiki_description.latex +0 -0
  163. data/unittest/{expected → expected_wiki}/test_wiki_description.text +0 -0
  164. data/unittest/{expected → expected_wiki}/test_wiki_description.wiki +0 -0
  165. data/unittest/expected_wiki/test_wiki_footnote.html +8 -0
  166. data/unittest/expected_wiki/test_wiki_footnote.latex +17 -0
  167. data/unittest/{expected → expected_wiki}/test_wiki_footnote.text +2 -4
  168. data/unittest/expected_wiki/test_wiki_footnote.wiki +10 -0
  169. data/unittest/expected_wiki/test_wiki_footnote_2.html +8 -0
  170. data/unittest/expected_wiki/test_wiki_footnote_groupid.html +21 -0
  171. data/unittest/{expected → expected_wiki}/test_wiki_html_code.html +0 -0
  172. data/unittest/{expected → expected_wiki}/test_wiki_html_code.latex +0 -0
  173. data/unittest/{expected → expected_wiki}/test_wiki_html_code.text +0 -0
  174. data/unittest/{expected → expected_wiki}/test_wiki_html_code.wiki +0 -0
  175. data/unittest/{expected → expected_wiki}/test_wiki_inline.html +0 -0
  176. data/unittest/{expected → expected_wiki}/test_wiki_inline.latex +0 -0
  177. data/unittest/{expected → expected_wiki}/test_wiki_inline.text +0 -0
  178. data/unittest/{expected → expected_wiki}/test_wiki_inline.wiki +0 -0
  179. data/unittest/{expected → expected_wiki}/test_wiki_label.html +0 -0
  180. data/unittest/{expected → expected_wiki}/test_wiki_link.html +0 -0
  181. data/unittest/{expected → expected_wiki}/test_wiki_link.latex +0 -0
  182. data/unittest/{expected → expected_wiki}/test_wiki_link.log +0 -0
  183. data/unittest/{expected → expected_wiki}/test_wiki_link.wiki +0 -0
  184. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.html +0 -0
  185. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.latex +0 -0
  186. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.text +0 -0
  187. data/unittest/{expected → expected_wiki}/test_wiki_list_ol.wiki +0 -0
  188. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.html +0 -0
  189. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.latex +0 -0
  190. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.text +0 -0
  191. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.wiki +0 -0
  192. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.html +0 -0
  193. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.latex +0 -0
  194. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.text +0 -0
  195. data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.wiki +0 -0
  196. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.html +0 -0
  197. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.latex +0 -0
  198. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.text +0 -0
  199. data/unittest/{expected → expected_wiki}/test_wiki_list_ul.wiki +0 -0
  200. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.html +0 -0
  201. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.latex +0 -0
  202. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.text +0 -0
  203. data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.wiki +0 -0
  204. data/unittest/{expected → expected_wiki}/test_wiki_picture.html +0 -0
  205. data/unittest/{expected → expected_wiki}/test_wiki_picture.latex +0 -0
  206. data/unittest/{expected → expected_wiki}/test_wiki_picture_thumb.html +0 -0
  207. data/unittest/{expected → expected_wiki}/test_wiki_tab1.html +0 -0
  208. data/unittest/{expected → expected_wiki}/test_wiki_tab1.latex +0 -0
  209. data/unittest/{expected → expected_wiki}/test_wiki_tab1.wiki +0 -0
  210. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.html +0 -0
  211. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.latex +0 -0
  212. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.text +0 -0
  213. data/unittest/{expected → expected_wiki}/test_wiki_textformatting.wiki +0 -0
  214. data/unittest/{expected → expected_wiki}/test_wiki_toc.html +0 -0
  215. data/unittest/{expected → expected_wiki}/test_wiki_toc.latex +0 -0
  216. data/unittest/{expected → expected_wiki}/test_wiki_toc.text +0 -0
  217. data/unittest/{expected → expected_wiki}/test_wiki_toc.wiki +0 -0
  218. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.html +0 -0
  219. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.latex +0 -0
  220. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.text +0 -0
  221. data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.wiki +0 -0
  222. data/unittest/test_docgenerator.rb +1 -2
  223. data/unittest/unittest_creole2doc.rb +1024 -0
  224. data/unittest/unittest_docgenerator.rb +17 -8
  225. data/unittest/unittest_wiki2doc.rb +92 -88
  226. data/unittest/unittest_yaml2pres.rb +336 -0
  227. metadata +202 -70
  228. data/unittest/expected/test_wiki_footnote.html +0 -8
  229. data/unittest/expected/test_wiki_footnote.latex +0 -15
  230. data/unittest/expected/test_wiki_footnote.wiki +0 -12
  231. data/unittest/expected/test_wiki_footnote_groupid.html +0 -21
@@ -47,8 +47,16 @@ Element.create( [:landscape ], {}, true,
47
47
  } )
48
48
 
49
49
  Element.create( [:verb ], HTML_ATTR_CORE, true,
50
- { :htmltag => 'pre', #fixme
50
+ {
51
+ #This builds a new block
52
+ #~ :htmltag => 'pre',
53
+ #With "display: inline" the element is continued correct, but <pre starts on new line.
54
+ #~ :html => '#{linebreak(@crbefore)}<pre style = "display: inline">#{@content}</pre>#{linebreak(@crafter)}',
55
+ #fixme font tt
56
+ #~ :html => '#{linebreak(@crbefore)}<span style = "display: inline;white-space:pre;font-family:monospace">#{@content}</span>#{linebreak(@crafter)}',
57
+ :html => '#{linebreak(@crbefore)}<span style = "display: inline;white-space:pre;font-family:monospace">#{@content.join.gsub(/</, \'&lt;\').gsub(/>/, \'&gt;\')}</span>#{linebreak(@crafter)}',
51
58
  :latex => '#{linebreak(@crbefore)}\verb|#{@content}|#{linebreak(@crafter)}'
59
+ #~ :latex => '#{linebreak(@crbefore)}\verb{#{@content}}#{linebreak(@crafter)}'
52
60
  } )
53
61
 
54
62
  class Verbatim < Environment
@@ -57,7 +65,25 @@ class Verbatim < Environment
57
65
  }.update(HTML_ATTR_ALL))
58
66
 
59
67
  Element.add( [:verbatim, :pre], Verbatim)
60
- def htmltag(); 'pre' end
68
+ #~ def htmltag(); 'pre' end
69
+ def to_html(options = {})
70
+ o = Docgenerator_logger.set_option_defaults(options)
71
+ html = String.new()
72
+ html << "\n" if @crbefore
73
+ html << "<pre"
74
+ @attr.sort_by{|k,v| v.sortkey }.each{|k,v|
75
+ html << " #{k} = \"#{v}\" " if v.to_s != '' and v.html?
76
+ }
77
+ html << ">"
78
+ html <<"\n" if @crmid
79
+ #~ html << "#{@content.to_html(options)}"
80
+ html << @content.join.gsub(/</, '&lt;').gsub(/>/, '&gt;')
81
+ html << "\n" if @crmid and @content.size > 0 and html[-1,1] != "\n"
82
+ html << "</pre>"
83
+ html << "\n" if @crafter
84
+ return html
85
+ end #to_html
86
+
61
87
  def to_text(options = {}); "#{content}" end
62
88
  def to_wiki(options = {} ); " #{content}" end
63
89
  def to_latex(options = {} )
@@ -1,62 +1,3 @@
1
- #
2
- # Footnotes
3
- #
4
- class Footnote < Element
5
- Element.add( [:footnote ], Footnote)
6
- add_attributes( {
7
- :counter => Attribute.create(),
8
- :groupid => Attribute.create()
9
- }.update(HTML_ATTR_ALL)
10
- )
11
- #The footnote group for the corresponding footnote
12
- attr_reader :group
13
- def counter()
14
- if ! @attr[:counter].filled?
15
- groupid = @attr[:groupid].content[0]
16
- Footnotegroup.get( groupid ) << self
17
- @attr[:counter] << Footnotegroup.get( groupid ).size
18
- end
19
- return @attr[:counter].content
20
- end
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={} )
30
- cmd = ''
31
- cmd << "\n" if @crbefore
32
- if Footnotegroup.get( @attr[:groupid].content[0] ).html_link
33
- cmd << "<sup><a href=\"##{link}\">#{counter}</a></sup>"
34
- else
35
- cmd << "<sup>#{counter}</sup>"
36
- end
37
- cmd << "\n" if @crafter
38
- return cmd
39
- end
40
- def to_latex( options={} )
41
- cmd = ''
42
- cmd << "\n" if @crbefore
43
- cmd << "\\footnote{#{@content.to_latex(options)}}"
44
- cmd << "\n" if @crafter
45
- return cmd
46
- end
47
- def to_text(options={})
48
- cmd = ''
49
- cmd << "\n" if @crbefore
50
- cmd << "(#{counter})"
51
- cmd << "\n" if @crafter
52
- return cmd
53
- end
54
- alias :to_wiki :to_text
55
- def get_content()
56
- return @content
57
- end
58
- end
59
-
60
1
  #Attention!
61
2
  #
62
3
  #This is a 'global' group.
@@ -64,24 +5,12 @@ end
64
5
  #
65
6
  #may be fixed in the future.
66
7
  class Footnotegroup
67
- @@all = { }
68
- #Use
69
- # Footnotegroup.get
70
- #to get the collected footnotes.
71
- #It is not a good idea to use this with LaTeX, because LaTeX makes it automatic.
72
- #(But you can try it with tables).
73
- def self.get( groupid = nil )
74
- if ! @@all[groupid]
75
- @@all[groupid] = self.new( groupid )
76
- end
77
- return @@all[groupid]
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
84
- def initialize( groupid )
8
+ #Define a default key for the footnotes.
9
+ #Used as part of the link.
10
+ DEFAULTGROUPID = 'footnote'
11
+ DEFAULTGROUPID.freeze
12
+ #Build a new footnote group.
13
+ def initialize( groupid = DEFAULTGROUPID)
85
14
  @groupid = groupid
86
15
  @footnotes = []
87
16
  @attr = {}
@@ -89,6 +18,7 @@ class Footnotegroup
89
18
  end
90
19
  #Flag, if the footnote and the footnote mark should be linked.
91
20
  attr_accessor :html_link
21
+ attr_reader :groupid
92
22
  def attr=( attr )
93
23
  @attr = attr
94
24
  end
@@ -105,9 +35,9 @@ class Footnotegroup
105
35
  #~ ul << element(:sup, {}, f.counter )
106
36
  ul << footnotemark = element(:sup)
107
37
  if @html_link
108
- footnotemark << element(:label, { :name => "#{f.link}" }, f.counter )
38
+ footnotemark << element(:label, { :name => "#{f.link}" }, f.label )
109
39
  else
110
- footnotemark << f.counter
40
+ footnotemark << f.label
111
41
  end
112
42
  ul << f.get_content
113
43
  ul << element(:br).cr
@@ -116,6 +46,69 @@ class Footnotegroup
116
46
  end
117
47
  end #Footnotegroup
118
48
 
49
+ #
50
+ # Footnotes
51
+ #
52
+ class Footnote < Element
53
+ Element.add( [:footnote ], Footnote)
54
+ add_attributes( {
55
+ :label => Attribute.create(),
56
+ :group => Attribute.create([:required], [Footnotegroup] )
57
+ }.update(HTML_ATTR_ALL)
58
+ )
59
+ #The footnote group for the corresponding footnote
60
+ attr_reader :group
61
+ #Label of the footnote
62
+ attr_reader :label
63
+
64
+ def initialize( attr={}, content = nil)
65
+ super
66
+ @group = attr[:group]
67
+ #@group must be defined!
68
+ #This is only a dummy group. it will be lost for overviews.
69
+ if ! @group.is_a?(Footnotegroup)
70
+ @group = Footnotegroup.new()
71
+ @log.error( "Footnote: No group assigned. Build a new group") if @log.error?
72
+ end
73
+
74
+ @group << self
75
+ @label = ( attr[:label] ? attr[:label] : @group.size )
76
+ end
77
+ def link()
78
+ "#{@group.groupid}-#{self.label}"
79
+ end
80
+ def to_html( options={} )
81
+ cmd = ''
82
+ cmd << "\n" if @crbefore
83
+ if @group.html_link
84
+ cmd << "<sup><a href=\"##{link}\">#{label}</a></sup>"
85
+ else
86
+ cmd << "<sup>#{label}</sup>"
87
+ end
88
+ cmd << "\n" if @crafter
89
+ return cmd
90
+ end
91
+ def to_latex( options={} )
92
+ cmd = ''
93
+ cmd << "\n" if @crbefore
94
+ cmd << "\\footnote{#{@content.to_latex(options)}}"
95
+ cmd << "\n" if @crafter
96
+ return cmd
97
+ end
98
+ def to_text(options={})
99
+ cmd = ''
100
+ cmd << "\n" if @crbefore
101
+ cmd << "(#{label})"
102
+ cmd << "\n" if @crafter
103
+ return cmd
104
+ end
105
+ alias :to_wiki :to_text
106
+ def get_content()
107
+ return @content
108
+ end
109
+ end #Footnote
110
+
111
+
119
112
 
120
113
  Element.create( [:footnotemark ], {}.update(HTML_ATTR_ALL),true,
121
114
  { :htmltag => 'sup',
@@ -21,7 +21,7 @@ sect = Struct.new( 'Sections', :keys, :wiki, :html, :tex )
21
21
  sect.new( [:h3, :subsubsection], 4, 'h3', 'subsubsection'),
22
22
  sect.new( [:h4, :paragraph], 5, 'h4', 'paragraph'),
23
23
  sect.new( [:h5, :subparagraph], 6, 'h5', 'subparagraph'),
24
- sect.new( [:minisec], 7, 'h5', 'minisec'),
24
+ sect.new( [:h6, :minisec], 7, 'h6', 'minisec'),
25
25
  ].each{ |s|
26
26
  Element.create( s.keys, {
27
27
  :short => Attribute.create( [ :latex ] ),
@@ -337,8 +337,7 @@ Element.create( [:endlastfoot ], {},false,
337
337
  class Column < Element
338
338
  #Make the key known to the complete key-list of elements.
339
339
  #~ :th => {:colspan => nil, :rowspan => nil, :align=>align, :valign=>valign, :border=>nil, :width=>nil},#complete it
340
- #~ :td => nil, #like :th
341
- Element.add( [:col, :column, :td, :th], Column )
340
+ Element.add( [:col, :column, :td ], Column )
342
341
  add_attributes( HTML_ATTR_ALL )
343
342
  add_attributes( {
344
343
  :width => Attribute.create( [ :html ] ),
@@ -357,7 +356,6 @@ class Column < Element
357
356
  end
358
357
  def content?; :empty_ok; end
359
358
  def htmltag()
360
- # fixme th for head
361
359
  return 'td'
362
360
  end
363
361
  def to_text(options={}); return "#{@content.to_text(options).strip}\n"; end
@@ -366,6 +364,13 @@ class Column < Element
366
364
  return "<Class Column @content=#{@content.inspect}>"
367
365
  end
368
366
  end #Columns
367
+ #Header cell (only for HTML
368
+ class Column_th < Column
369
+ Element.add( [:th ], Column_th )
370
+ def htmltag()
371
+ return 'th'
372
+ end
373
+ end
369
374
  class Multicolumn < Column
370
375
  #Make the key known to the complete key-list of elements.
371
376
  Element.add( [:multicolumn], Multicolumn )
@@ -0,0 +1,253 @@
1
+ #
2
+ # The text 'Beamer' must be part of this template.
3
+ # Without it, the title-Class will not use the short version for title.#
4
+ #
5
+ DocumentTemplate.new(:beamer, :latex, %q|<<prefix>>
6
+ % ----------------------------------------------------------------
7
+ % For Usage with Beamer
8
+ % ----------------------------------------------------------------
9
+ <<head>>
10
+ % ----------------------------------------------------------------
11
+ \begin{document}
12
+ <<body>>
13
+ \end{document}
14
+ % ----------------------------------------------------------------
15
+ |.gsub(/^\s*/, ''))
16
+ DocumentTemplate.new(:beamerhead, :latex, %q|<<prefix>>
17
+ \documentclass[<<classoptions>>]{beamer}
18
+ %<<theme>>
19
+ \usepackage{babel}
20
+ \usepackage[ansinew]{inputenc}
21
+ \usepackage{beamertool}
22
+ \usepackage{hyperref}
23
+ % ----------------------------------------------------------------
24
+ <<head>>
25
+ |.gsub(/^\s*/, ''))
26
+ [
27
+ :beamerthemebars, :beamerthemeboxes, :beamerthemeclassic,
28
+ :beamerthemelined, :beamerthemeplain, :beamerthemesidebar,
29
+ :beamerthemesidebardark, :beamerthemesidebardarktab,
30
+ :beamerthemesidebartab, :beamerthemesplit,
31
+ :beamerthemesplitcondensed, :beamerthemetree,
32
+ :beamerthemevcd,
33
+ :beamerthemegemeinschaftsauto
34
+ ].each{ |theme|
35
+ DocumentTemplate.new(theme, :latex, DocumentTemplate[:beamerhead].template.sub(/%<<theme>>/, "\\usepackage{#{theme}}"))
36
+ }
37
+ DocumentTemplate.new(:beamerarticle, :latex, %q|<<prefix>>
38
+ \documentclass[class=scrartcl,<<classoptions>>]{beamer}
39
+ \usepackage{babel}
40
+ \usepackage{beamerbasearticle}
41
+ \usepackage[article]{beamertool}
42
+ \usepackage[ansinew]{inputenc}
43
+ \usepackage{hyperref}
44
+ % ----------------------------------------------------------------
45
+ <<head>>
46
+ |.gsub(/^\s*/, ''))
47
+
48
+
49
+ #Define TeX-Kommands
50
+
51
+ #frame -- environment.
52
+ #options
53
+ #~ Element.create( :frame, {}, true, {
54
+ #~ :latex => '#{linebreak(@crbefore)}\frame{#{@content}}#{linebreak(@crafter)}'
55
+ #~ } )
56
+
57
+ class Frame < Element
58
+ add_attributes( {
59
+ :options => Attribute.create( [ :latex ], [nil, 'fragile', 't', 'b'] ),
60
+ }.update( HTML_ATTR_ALL ) )
61
+ Element.add( [:frame], Frame)
62
+ #Returns a div-element.
63
+ #The class for the css is set to 'frame' (if not defined before).
64
+ def htmltag( )
65
+ if @attr[:class].content.empty?
66
+ @attr[:class] << :frame
67
+ end
68
+ 'div'
69
+ end
70
+ def to_latex( options = {} )
71
+ option = "[#{@attr[:options].content.join(',')}]"
72
+ option = nil if option == '[]'
73
+ label = nil
74
+ label = element(:label,{:name => @attr[:id]}).cr.to_latex(options) unless @attr[:id].content.empty?
75
+ #~ return "#{linebreak(@crbefore)}\\frame#{option}{\n#{@content}}#{linebreak(@crafter)}"
76
+ return "#{linebreak(@crbefore)}\\begin{frame}#{option}\n#{label}#{@content.to_latex(options)}\n\\end{frame}#{linebreak(@crafter)}"
77
+ end
78
+ end
79
+
80
+ #
81
+ #Frametitle.
82
+ #Can be changed by
83
+ # Element.get( :frametitle ).class_eval( "def htmltag(); 'h4'; end")
84
+ Element.create( :frametitle, { }, true, {
85
+ :latex => '#{linebreak(@crbefore)}\frametitle{#{@content}}#{linebreak(@crafter)}',
86
+ :htmltag => 'p', #'h4',
87
+ :html => '#{linebreak(@crbefore)}<#{htmltag} class = "frametitle">#{@content}</#{htmltag}>#{linebreak(@crafter)}',
88
+ } )
89
+
90
+ Element.create( :block, {
91
+ :title => Attribute.create( [ :latex ] ),
92
+ }, true, {
93
+ :latex => '#{linebreak(@crbefore)}' + '\begin{block}{#{@attr[:title]}}' + '#{linebreak(@crmid)}' + '#{@content}\end{block}' + '#{linebreak(@crafter)}'
94
+ } )
95
+
96
+ #
97
+ # Notes in Beamer.
98
+ #
99
+ Element.create( :note, { }, true, {
100
+ :latex => '#{linebreak(@crbefore)}\note{#{@content}}#{linebreak(@crafter)}',
101
+ :htmltag => 'p', #'h4',
102
+ :html => '#{linebreak(@crbefore)}<#{htmltag} class = "note">#{@content}</#{htmltag}>#{linebreak(@crafter)}',
103
+ } )
104
+
105
+ #\framePic{filename}{
106
+ # description
107
+ #}
108
+ #~ Element.create( :framepic, { :file => Attribute.create( [ :required ] ),
109
+ #~ :link => Attribute.create( )
110
+ #~ }, true, {
111
+ #~ :latex => '\framePic{#{@attr[:file]}}{#{@content}}'
112
+ #~ } )
113
+
114
+ Element.create( :institute, {
115
+ }, true, {
116
+ :latex => '#{linebreak(@crbefore)}' + '\institute{#{@content}}' + '#{linebreak(@crafter)}'
117
+ } )
118
+
119
+ Element.create( :subtitle, {
120
+ }, true, {
121
+ :latex => '#{linebreak(@crbefore)}' + '\subtitle{#{@content}}' + '#{linebreak(@crafter)}'
122
+ } )
123
+
124
+ begin
125
+ #define Knut::Picture
126
+ require 'knut_picture'
127
+ rescue
128
+ #Define Knut::Picture with reduced functionality
129
+ module Knut
130
+ class Picture
131
+ def initialize( filename )
132
+ @filename = filename
133
+ @basename = File.basename(@filename)
134
+ @dir = File.dirname(@filename)
135
+ if ! File.exists?( @filename )
136
+ puts "#{self.class}: #{@filename} not found"
137
+ else
138
+ @size = File.size(@filename)
139
+ @sizekb = @size / 1024
140
+ end
141
+ end
142
+ #Filename including the path
143
+ attr_reader :filename
144
+ #Directory of the picture
145
+ attr_reader :dir
146
+ attr_reader :basename
147
+ def tech_description()
148
+ "#{@basename} (#{@sizekb}KB)"
149
+ end
150
+ end
151
+ end
152
+ end
153
+
154
+ class Framepic < Element
155
+ Element.add( [:framepic], Framepic)
156
+ add_attributes( {
157
+ :file => Attribute.create( [ :required ] ),
158
+ :link => Attribute.create( [ :latex ]), #Hyperlink
159
+ }.update( HTML_ATTR_ALL ) )
160
+ #container for the picture
161
+ def picture()
162
+ @picture = Knut::Picture.new( @attr[:file].content.first ) if ! @picture
163
+ @picture
164
+ end
165
+ attr_accessor :div_css
166
+ attr_accessor :img_css
167
+ attr_accessor :div_class
168
+ attr_accessor :img_class
169
+ attr_accessor :picwithname
170
+ def to_html( options = {})
171
+ html = [] #element(:div, {:class => :framepic })
172
+ #~ if @attr[:link].content.size > 0
173
+ #~ html << "[#{@attr[:link]}]"
174
+ #~ end
175
+
176
+ html << div_img = element(:div ).CR
177
+ if self.picture.href
178
+ div_img << element(:a, { :href => self.picture.href },
179
+ img = element(:img )
180
+ )
181
+ else
182
+ div_img << img = element(:img )
183
+ end
184
+ if self.picture.thumbname and self.picture.usethumb?
185
+ img[:src] << self.picture.thumbname
186
+ else
187
+ img[:src] << self.picture.filename
188
+ end
189
+ @div_css = CSS.new() if ! @div_css
190
+ div_img[:class] << @div_class if @div_class
191
+ div_img[:style] << @div_css
192
+ div_img[:align] << 'center' if div_img[:align].content.empty?
193
+ img[:class] << @img_class if @img_class
194
+ img[:style] << @img_css if @img_css
195
+ if picwithname
196
+ div_img << element(:br ).cr
197
+ div_img << element(:footnotesize, {}, self.picture.tech_description)
198
+ end
199
+ html << @content
200
+ return html.to_html(options)
201
+ end
202
+ def to_latex( options = {} )
203
+ result = ""
204
+ result << "\n" if @crbefore
205
+ result << "\\framePic"
206
+ if self.div_css #Check alignment
207
+ case self.div_css[:float]
208
+ when nil, 'left' #standard
209
+ when 'right'
210
+ result << "[right]"
211
+ else
212
+ puts "#{__FILE__}##{__LINE__}: Undefined float '#{self.div_css[:float]}' for TeX"
213
+ end
214
+ end
215
+ result << "{#{self.picture.filename}}"
216
+ if @attr[:link].content.size > 0
217
+ result << "[#{@attr[:link]}]"
218
+ end
219
+ result << "{"
220
+ result << "\n" if @crmid
221
+ result << "#{@content.to_latex(options)}"
222
+ result << "\n" if @crmid
223
+ result << "}"
224
+ result << "\n" if @crafter
225
+ return result
226
+ end
227
+ end
228
+
229
+
230
+ Element.create( :includegraphicsJustified, {}, true, {
231
+ :latex => '\includegraphicsJustified{#{@content}}',
232
+ :html => '<img src = "#{@content}" style = "max-width: 80%" />',
233
+ } )
234
+
235
+ #fixme --> docgenerator_color ?
236
+ class Textcolor < Element
237
+ Element.add( [:textcolor], Textcolor)
238
+ add_attributes( { :mode => Attribute.create( [ :required ], [:rgb] ),
239
+ :color => Attribute.create( [ :required ], [String] ),
240
+ } )
241
+ def to_latex( options = {})
242
+ result = ""
243
+ result << "\n" if @crbefore
244
+ result << "\\textcolor[#{attr[:mode]}]{#{@attr[:color]}}"
245
+ result << "\n" if @crmid
246
+ result << "{"
247
+ result << "#{@content.to_latex(options)}"
248
+ result << "\n" if @crmid
249
+ result << "}"
250
+ result << "\n" if @crafter
251
+ return result
252
+ end
253
+ end
@@ -7,7 +7,7 @@ if __FILE__ == $0
7
7
  end
8
8
  #~ require 'date'
9
9
 
10
- DocumentTemplate.add_template(
10
+ DocumentTemplate.new(
11
11
  :scrlttr2, :latex, %q|<<prefix>>
12
12
  \documentclass[<<classoptions>>]{scrlttr2}
13
13
  \usepackage{babel}
@@ -22,6 +22,44 @@ DocumentTemplate.add_template(
22
22
  % ----------------------------------------------------------------
23
23
  |)
24
24
 
25
+
26
+
27
+ class LoadLetterOption < Element
28
+ Element.add( [:loadletteroption], LoadLetterOption)
29
+
30
+ def to_latex( options = {} )
31
+ cmd = ''
32
+ cmd << "\n" if @crbefore
33
+ cmd << "\\LoadLetterOption{#{@content.join(',')}}"
34
+ cmd << "\n" if @crafter
35
+ return cmd
36
+ end
37
+ end #LoadLetterOption
38
+
39
+ #Usage:
40
+ # element(:setkomavar,{:field => field}, .content).cr
41
+ # element(:setkomavar,{:field => field, :fieldtext=>'Text'}, .content).cr
42
+ class Setkomavar < Element
43
+ Element.add( [:setkomavar], Setkomavar)
44
+ add_attributes( {
45
+ :field => Attribute.create( [ :latex, :required ], [Symbol], 1 ),
46
+ :fieldtext => Attribute.create( [ :latex, :required ], [String], 2 ),
47
+ }#.update(HTML_ATTR_ALL)
48
+ )
49
+
50
+ def to_latex( options = {} )
51
+ cmd = ''
52
+ cmd << "\n" if @crbefore
53
+ cmd << "\\setkomavar{#{@attr[:field]}}"
54
+ cmd << "[#{@attr[:fieldtext]}]" if @attr[:fieldtext].filled?
55
+ cmd << "{#{@content.join(',')}}"
56
+ cmd << "\n" if @crafter
57
+ return cmd
58
+ end
59
+ end #Setkomavar
60
+
61
+
62
+
25
63
  #Example:
26
64
  # letter = Letter.new( {
27
65
  # :address => [ 'Name',
@@ -38,10 +76,11 @@ class Letter < Environment
38
76
  :address => Attribute.create( [ :latex, :required ] ),
39
77
  :date => Attribute.create( [ :latex ], [String] ), #Date?
40
78
  :opening => Attribute.create( [ :latex, :required ] ),
79
+ :letter_option => Attribute.create( [ :latex ] ), # F�r \LoadLetterOption
41
80
  :backaddress => Attribute.create( [ :latex ] ), # R�ucksendeadresse f�ur Fensterbriefumschl�age
42
81
  #~ backaddressseparator Trennzeichen innerhalb der R�ucksendeadresse
43
82
  #~ ccseparator Trennzeichen zwischen Verteilertitel und Verteiler
44
- #~ customer Gesch�aftszeilenfeld �Kundennummer�
83
+ :customer => Attribute.create( [ :latex ] ), #Gesch�aftszeilenfeld �Kundennummer�
45
84
  #~ emailseparator Trennzeichen zwischen E-Mail-Bezeichner und E-Mail-Adresse
46
85
  #~ enclseparator Trennzeichen zwischen Anlagetitel und Anlagen
47
86
  #~ faxseparator Trennzeichen zwischen Faxbezeichner und Faxnummer
@@ -75,16 +114,20 @@ class Letter < Environment
75
114
 
76
115
  def setkomavar( field )
77
116
  if @attr[field].content.size > 0
78
- return "\\setkomavar{#{field}}{#{@attr[field]}}\n"
117
+ return element(:setkomavar,{:field => field}, @attr[field].content).cr.to_latex
118
+ #~ return "\\setkomavar{#{field}}{#{@attr[field]}}\n"
79
119
  else
80
120
  return ''
81
121
  end
82
122
  end
83
- def to_latex_environment( environment)
123
+ def to_latex_environment( environment, options = {} )
84
124
  cmd = ''
85
125
  cmd << "\n" if @crbefore
86
126
  cmd << "\n\\begin{#{environment}}"
87
127
  cmd << "{#{@attr[:address]}}\n"
128
+ if @attr[:letter_option].filled?
129
+ cmd << element(:loadletteroption, {}, @attr[:letter_option].content).cr.to_latex(options)
130
+ end
88
131
  #~ cmd << "{"
89
132
  #~ cmd << @attr[:address].content.flatten.join( element(:br).to_latex)
90
133
  #~ cmd << "}\n"
@@ -99,10 +142,11 @@ class Letter < Environment
99
142
  cmd << setkomavar( :fromphone )
100
143
  cmd << setkomavar( :fromurl )
101
144
  cmd << setkomavar( :subject)
145
+ cmd << setkomavar( :customer)
102
146
  cmd << setkomavar( :invoice)
103
147
  cmd << setkomavar( :myref)
104
148
  cmd << "\\opening{#{@attr[:opening]}}\n"
105
- cmd << @content.to_s
149
+ cmd << @content.to_latex(options)
106
150
  cmd = cmd.chomp + "\n"
107
151
  cmd << setkomavar( :signature)
108
152
  cmd << "\\closing{#{@attr[:closing]}}\n"
@@ -110,10 +154,10 @@ class Letter < Environment
110
154
  cmd << "\n" if @crafter
111
155
  return cmd
112
156
  end
113
- def to_latex( )
114
- return to_latex_environment( 'letter' )
157
+ def to_latex( options = {} )
158
+ return to_latex_environment( 'letter', options )
115
159
  end
116
- def to_html()
160
+ def to_html( options = {})
117
161
  cmd = element( :div ).CR
118
162
  #~ cmd << "\n" if @crbefore
119
163
  cmd << anr = element(:p,{}, 'An' )
@@ -123,6 +167,6 @@ class Letter < Environment
123
167
  cmd << @content.to_html
124
168
  cmd << element(:p,{}, @attr[:closing] )
125
169
  #~ cmd << "\n" if @crafter
126
- return cmd.to_html
170
+ return cmd.to_html(options)
127
171
  end
128
172
  end
@@ -23,6 +23,10 @@ class CSS_collection
23
23
  def add( key, css)
24
24
  @css[key] = css
25
25
  end
26
+ #Get CSS-style for new definition.
27
+ def []( key )
28
+ @css[key]
29
+ end
26
30
  #Returns the complete CSS-definition.
27
31
  def css()
28
32
  css_coll = "/*\n"