docgenerator 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +7 -0
  2. data/examples/creole_example.rb +0 -1
  3. data/examples/creole_example_new_plugin.rb +51 -0
  4. data/examples/creole_example_tabular.rb +3 -1
  5. data/examples/wiki2docgenerator_example.rb +2 -2
  6. data/lib/creole/creole2doc.rb +697 -680
  7. data/lib/creole/creole_characters.rb +90 -26
  8. data/lib/creole/creole_inclusion_and_plugins.rb +25 -43
  9. data/lib/creole/creole_inclusions.rb +87 -75
  10. data/lib/creole/creole_placeholder.rb +87 -89
  11. data/lib/creole/creole_plugins.rb +149 -117
  12. data/lib/creole/creole_tabular.rb +247 -141
  13. data/lib/creole/plugins/todonotes.rb +48 -48
  14. data/lib/docgenerator/characters.rb +106 -8
  15. data/lib/docgenerator/compatibility_v1.rb +7 -1
  16. data/lib/docgenerator/document.rb +34 -19
  17. data/lib/docgenerator/element.rb +1 -0
  18. data/lib/docgenerator/element_meta.rb +1 -1
  19. data/lib/docgenerator/elements.rb +594 -535
  20. data/lib/docgenerator/environments.rb +131 -99
  21. data/lib/docgenerator/index.rb +110 -0
  22. data/lib/docgenerator/lists.rb +2 -1
  23. data/lib/docgenerator/packages/caption.rb +32 -34
  24. data/lib/docgenerator/packages/hyperref.rb +1 -0
  25. data/lib/docgenerator/packages/multicol.rb +3 -2
  26. data/lib/docgenerator/packages/pdfpages.rb +71 -20
  27. data/lib/docgenerator/packages/scrpage2.rb +99 -142
  28. data/lib/docgenerator/packages/url.rb +75 -81
  29. data/lib/docgenerator/sections.rb +98 -98
  30. data/lib/docgenerator/standard.rb +8 -1
  31. data/lib/docgenerator/tabular.rb +44 -25
  32. data/lib/docgenerator/templates/docgenerator_template.yaml +28 -0
  33. data/lib/docgenerator/version.rb +146 -0
  34. data/lib/docgenerator.rb +20 -15
  35. data/meta_test_and_doc/build_doc.rb +39 -10
  36. data/meta_test_and_doc/build_test.rb +34 -12
  37. data/meta_test_and_doc/manpages/characters.rb +452 -20
  38. data/meta_test_and_doc/manpages/elementlist.rb +304 -0
  39. data/meta_test_and_doc/manpages/elements.rb +305 -42
  40. data/meta_test_and_doc/manpages/others.rb +403 -0
  41. data/meta_test_and_doc/manpages/pdfpages.rb +117 -18
  42. data/meta_test_and_doc/manpages/readme.rdoc +3 -1
  43. data/meta_test_and_doc/manpages/scrpage2.rb +0 -80
  44. data/meta_test_and_doc/manpages/tables.rb +6 -6
  45. data/readme.rdoc +11 -120
  46. data/unittest/expected/test_comment.html +1 -0
  47. data/unittest/expected/test_comment.latex +5 -0
  48. data/unittest/expected/test_comment_complex.html +3 -0
  49. data/unittest/expected/test_comment_complex.latex +15 -0
  50. data/unittest/expected_creole/test_creole_characters_all.html +6 -5
  51. data/unittest/expected_creole/test_creole_characters_all.latex +10 -8
  52. data/unittest/expected_creole/test_creole_creole1.0test.latex +5 -5
  53. data/unittest/expected_creole/test_creole_input.normsource +11 -9
  54. data/unittest/expected_creole/test_creole_list_ul.normsource +57 -51
  55. data/unittest/expected_creole/test_creole_list_ulul_without_ul.html +6 -0
  56. data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +12 -0
  57. data/unittest/expected_creole/test_creole_paragraphs.normsource +12 -10
  58. data/unittest/expected_creole/test_creole_pictures.latex +2 -2
  59. data/unittest/expected_creole/test_creole_pictures_css.latex +2 -2
  60. data/unittest/expected_creole/test_creole_pictures_imgclass.latex +2 -2
  61. data/unittest/expected_creole/test_creole_pictures_width.latex +1 -1
  62. data/unittest/expected_creole/test_creole_tabular.latex +3 -3
  63. data/unittest/expected_creole/test_creole_tabular_creole.latex +2 -2
  64. data/unittest/expected_creole/test_creole_tabular_css.latex +3 -3
  65. data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +22 -0
  66. data/unittest/expected_templates/test_standalone.tex +34 -0
  67. data/unittest/expected_wikimedia/test_wiki_picture.latex +12 -12
  68. data/unittest/unittest_creole.rb +22 -3
  69. data/unittest/unittest_creole_tabular.rb +34 -1
  70. data/unittest/unittest_docgenerator.rb +46 -3
  71. data/unittest/unittest_docgenerator_characters.rb +527 -82
  72. data/unittest/unittest_templates.rb +1 -1
  73. metadata +149 -108
@@ -23,7 +23,7 @@ Create an instance with
23
23
  or
24
24
  Environment.new( [ attributes, [content]] )
25
25
  =end
26
- class Environment < Element
26
+ class Environment < Element
27
27
  =begin rdoc
28
28
  Parameters are given as a string (or anything what gives a String with to_s).
29
29
 
@@ -31,41 +31,41 @@ It is difficult to make a generic parameter interface.
31
31
 
32
32
  If needed, redefine the method.
33
33
  =end
34
- def to_latex_environment( environment, parameter = nil, options={})
35
- cmd = ''
36
- cmd << "\n" if @crbefore
37
- cmd << "\n\\begin{#{environment}}"
38
- cmd << parameter.to_s if parameter
39
- cmd << "\n" if @crmid
40
- cmd << @content.to_latex(options)
41
- cmd << "\n" if @crmid and cmd[-1,1] != "\n"
42
- cmd << "\\end{#{environment}}\n"
43
- cmd << "\n" if @crafter
44
- return cmd
45
- end
34
+ def to_latex_environment( environment, parameter = nil, options={})
35
+ cmd = ''
36
+ cmd << "\n" if @crbefore
37
+ cmd << "\n\\begin{#{environment}}"
38
+ cmd << parameter.to_s if parameter
39
+ cmd << "\n" if @crmid
40
+ cmd << @content.to_latex(options)
41
+ cmd << "\n" if @crmid and cmd[-1,1] != "\n"
42
+ cmd << "\\end{#{environment}}\n"
43
+ cmd << "\n" if @crafter
44
+ return cmd
45
+ end
46
46
  =begin rdoc
47
47
  ConTeXt-environments start with start and end with stop.
48
48
 
49
49
  Fixme: Parameters
50
50
  =end
51
- def to_context_environment( environment, parameter = nil, options={})
52
- cmd = ''
53
- cmd << "\n" if @crbefore
54
- cmd << "\n\\start#{environment}"
55
- cmd << parameter.to_s if parameter
56
- cmd << "\n" if @crmid
57
- cmd << @content.to_latex(options)
58
- #~ cmd << "\n" if @crmid and cmd[-1,1] != "\n"
59
- cmd << "\n\\stop#{environment}\n"
60
- cmd << "\n" if @crafter
61
- return cmd
62
- end #~ def htmltag()
63
- #~ return 'table'
64
- #~ end
65
- #~ def to_latex( options={} )
66
- #~ return to_latex_environment( 'itemize', nil, options )
67
- #~ end
68
- end
51
+ def to_context_environment( environment, parameter = nil, options={})
52
+ cmd = ''
53
+ cmd << "\n" if @crbefore
54
+ cmd << "\n\\start#{environment}"
55
+ cmd << parameter.to_s if parameter
56
+ cmd << "\n" if @crmid
57
+ cmd << @content.to_latex(options)
58
+ #~ cmd << "\n" if @crmid and cmd[-1,1] != "\n"
59
+ cmd << "\n\\stop#{environment}\n"
60
+ cmd << "\n" if @crafter
61
+ return cmd
62
+ end #~ def htmltag()
63
+ #~ return 'table'
64
+ #~ end
65
+ #~ def to_latex( options={} )
66
+ #~ return to_latex_environment( 'itemize', nil, options )
67
+ #~ end
68
+ end
69
69
 
70
70
  =begin rdoc
71
71
  Define Element :minipage
@@ -78,15 +78,15 @@ Attributes may be:
78
78
  * :width:
79
79
  * :pos: Optional position for LaTeX
80
80
  =end
81
- class Minipage < Element
82
- add_attribute :width, Attribute.create( [ :latex, :html ], [ String ] )
83
- add_attribute :pos, Attribute.create( [ :latex ], [ 'b', 't' ] )
84
- add_html_tag 'div'
85
- add_latex_output '#{linebreak(@crbefore)}' +
86
- '\begin{minipage}[#{@attr[:pos]}]{#{@attr[:width]}}' + '#{linebreak(@crmid)}' +
87
- '#{@content}' + '#{linebreak(@crmid)}' +
88
- '\end{minipage}' + '#{linebreak(@crafter)}'
89
- end #Minipage
81
+ class Minipage < Element
82
+ add_attribute :width, Attribute.create( [ :latex, :html ], [ String ] )
83
+ add_attribute :pos, Attribute.create( [ :latex ], [ 'b', 't' ] )
84
+ add_html_tag 'div'
85
+ add_latex_output '#{linebreak(@crbefore)}' +
86
+ '\begin{minipage}[#{@attr[:pos]}]{#{@attr[:width]}}' + '#{linebreak(@crmid)}' +
87
+ '#{@content}' + '#{linebreak(@crmid)}' +
88
+ '\end{minipage}' + '#{linebreak(@crafter)}'
89
+ end #Minipage
90
90
 
91
91
  =begin rdoc
92
92
  Define Element :center
@@ -99,11 +99,11 @@ Attributes may be:
99
99
  * HTML_ATTR_CORE
100
100
 
101
101
  =end
102
- class Center < Element
103
- add_attributes HTML_ATTR_CORE
104
- add_html_tag 'center'
105
- add_latex_output '#{linebreak(@crbefore)}\begin{center}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{center}#{linebreak(@crafter)}'
106
- end #Center
102
+ class Center < Element
103
+ add_attributes HTML_ATTR_CORE
104
+ add_html_tag 'center'
105
+ add_latex_output '#{linebreak(@crbefore)}\begin{center}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{center}#{linebreak(@crafter)}'
106
+ end #Center
107
107
 
108
108
  =begin rdoc
109
109
  Define Element :quote, :blockquote
@@ -116,12 +116,12 @@ or
116
116
  Attributes may be:
117
117
  * HTML_ATTR_CORE
118
118
  =end
119
- class Quote < Element
120
- add_id :blockquote
121
- add_attributes HTML_ATTR_CORE
122
- add_html_tag 'blockquote'
123
- add_latex_output '#{linebreak(@crbefore)}\begin{quote}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{quote}#{linebreak(@crafter)}'
124
- end #Quote
119
+ class Quote < Element
120
+ add_id :blockquote
121
+ add_attributes HTML_ATTR_CORE
122
+ add_html_tag 'blockquote'
123
+ add_latex_output '#{linebreak(@crbefore)}\begin{quote}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{quote}#{linebreak(@crafter)}'
124
+ end #Quote
125
125
 
126
126
  =begin rdoc
127
127
  Define Element :landscape
@@ -134,9 +134,9 @@ or
134
134
  Landscape.new( [ attributes, [content]] )
135
135
  Attributes are not defined for this element.
136
136
  =end
137
- class Landscape < Element
138
- add_latex_output '#{linebreak(@crbefore)}\begin{landscape}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{landscape}#{linebreak(@crafter)}'
139
- end #Landscape
137
+ class Landscape < Element
138
+ add_latex_output '#{linebreak(@crbefore)}\begin{landscape}#{linebreak(@crmid)}#{@content}#{linebreak(@crmid)}\end{landscape}#{linebreak(@crafter)}'
139
+ end #Landscape
140
140
 
141
141
 
142
142
  =begin rdoc
@@ -144,69 +144,101 @@ Environment Verbatim
144
144
 
145
145
  See also Elements::Verb
146
146
  =end
147
- class Verbatim < Environment
148
- add_attribute :width, Attribute.create( [ :html ], [Integer], 1 ) #Number of characters
149
- add_attributes HTML_ATTR_ALL
150
- add_id :pre
151
- =begin rdoc
152
- =end
153
- def to_html(options = {})
154
- o = set_option_defaults(options)
155
- html = String.new()
156
- html << "\n" if @crbefore
157
- html << "<pre"
158
- @attr.sort_by{|k,v| v.sortkey }.each{|k,v|
159
- html << " #{k} = \"#{v}\" " if v.to_s != '' and v.html?
160
- }
161
- html << ">"
162
- html <<"\n" if @crmid
163
- #~ html << "#{@content.to_html(options)}"
164
- html << @content.join.gsub(/</, '&lt;').gsub(/>/, '&gt;')
165
- html << "\n" if @crmid and @content.size > 0 and html[-1,1] != "\n"
166
- html << "</pre>"
167
- html << "\n" if @crafter
168
- return html
169
- end #to_html
147
+ class Verbatim < Environment
148
+ add_attribute :width, Attribute.create( [ :html ], [Integer], 1 ) #Number of characters
149
+ add_attributes HTML_ATTR_ALL
150
+ add_id :pre
151
+ =begin rdoc
152
+ =end
153
+ def to_html(options = {})
154
+ o = set_option_defaults(options)
155
+ html = String.new()
156
+ html << "\n" if @crbefore
157
+ html << "<pre"
158
+ @attr.sort_by{|k,v| v.sortkey }.each{|k,v|
159
+ html << " #{k} = \"#{v}\" " if v.to_s != '' and v.html?
160
+ }
161
+ html << ">"
162
+ html <<"\n" if @crmid
163
+ #~ html << "#{@content.to_html(options)}"
164
+ html << @content.join.gsub(/</, '&lt;').gsub(/>/, '&gt;')
165
+ html << "\n" if @crmid and @content.size > 0 and html[-1,1] != "\n"
166
+ html << "</pre>"
167
+ html << "\n" if @crafter
168
+ return html
169
+ end #to_html
170
170
 
171
171
  =begin rdoc
172
172
  =end
173
- def to_text(options = {}); "#{@content.join}" end
173
+ def to_text(options = {}); "#{@content.join}" end
174
174
  =begin rdoc
175
175
  =end
176
- def to_wiki(options = {} ); " #{@content.join}" end
176
+ def to_wiki(options = {} ); " #{@content.join}" end
177
177
  =begin rdoc
178
178
  =end
179
- def to_creole(options = {} ); "{{{\n#{@content.join}\n}}}" end
179
+ def to_creole(options = {} ); "{{{\n#{@content.join}\n}}}" end
180
180
  =begin rdoc
181
181
  =end
182
- def to_latex(options = {} )
183
- return to_latex_environment( 'verbatim', nil, options )
184
- end
185
- end
182
+ def to_latex(options = {} )
183
+ return to_latex_environment( 'verbatim', nil, options )
184
+ end
185
+ end
186
186
 
187
187
  =begin rdoc
188
188
  =end
189
- class Figure < Environment
190
- add_attributes HTML_ATTR_ALL
191
- def htmltag(); 'div'; end
192
- def to_latex( options = {} )
193
- return to_latex_environment( 'figure', nil, options )
194
- end
195
- end
189
+ class Figure < Environment
190
+ add_attributes HTML_ATTR_ALL
191
+ def htmltag(); 'div'; end
192
+ def to_latex( options = {} )
193
+ return to_latex_environment( 'figure', nil, options )
194
+ end
195
+ end
196
196
 
197
197
  =begin rdoc
198
198
  Environment Abstract.
199
199
 
200
200
  Only LaTeX
201
201
  =end
202
- class Abstract < Environment
203
- #~ add_attributes( HTML_ATTR_ALL )
204
- #~ def htmltag(); ''; end
202
+ class Abstract < Environment
203
+ #~ add_attributes( HTML_ATTR_ALL )
204
+ #~ def htmltag(); ''; end
205
205
  =begin rdoc
206
206
  =end
207
- def to_latex( options = {} )
208
- return to_latex_environment( 'abstract', nil, options )
209
- end
210
- end
211
- end #module Environments
207
+ def to_latex( options = {} )
208
+ return to_latex_environment( 'abstract', nil, options )
209
+ end
210
+ end
211
+
212
+ =begin rdoc
213
+ Environment Flushleft.
214
+
215
+ Only LaTeX ##fixme##
216
+ =end
217
+ class Flushleft < Environment
218
+ #~ add_attributes( HTML_ATTR_ALL )
219
+ #~ def htmltag(); ''; end
220
+ =begin rdoc
221
+ =end
222
+ def to_latex( options = {} )
223
+ return to_latex_environment( 'flushleft', nil, options )
224
+ end
225
+ end
226
+ =begin rdoc
227
+ Environment Flushright.
228
+
229
+ Only LaTeX ##fixme##
230
+ =end
231
+ class Flushright < Environment
232
+ #~ add_attributes( HTML_ATTR_ALL )
233
+ #~ def htmltag(); ''; end
234
+ =begin rdoc
235
+ =end
236
+ def to_latex( options = {} )
237
+ return to_latex_environment( 'flushright', nil, options )
238
+ end
239
+ end
240
+
241
+ end #module Environments
242
+
243
+
212
244
  end #module Docgenerator
@@ -0,0 +1,110 @@
1
+ =begin rdoc
2
+ Elements to build an index
3
+ =end
4
+
5
+ #
6
+ module Docgenerator
7
+ =begin rdoc
8
+ Elements to build an index.
9
+
10
+ This module supports the standard index and splitidx.
11
+ =end
12
+ module Index
13
+ PACKAGE = element(:usepackage,{},'makeidx').cr
14
+ #See http://www.ctan.org/pkg/splitindex
15
+ PACKAGE_SPLITINDEX = element(:usepackage,{},'splitidx').cr
16
+ =begin rdoc
17
+ Define Element ':index'
18
+
19
+ Create an instance with
20
+ element( :index, [ attributes, [content]] )
21
+
22
+ Index.new( [ attributes, [content]] )
23
+ =end
24
+ class Index < Element
25
+ #~ add_html_tag 'head'
26
+ add_latex_output '#{linebreak(@crbefore)}\\index{#{@content}}#{linebreak(@crafter)}'
27
+ #~ add_context_output '#{@content}'
28
+ #~ add_text_output '#{@content}'
29
+ #~ add_wiki_output '#{@content}'
30
+ #~ add_creole_output '#{@content}'
31
+ end #Index
32
+ =begin rdoc
33
+ Define Element :makeindex
34
+
35
+ Create an instance with
36
+ element( :makeindex, [ attributes, [content]] )
37
+ or
38
+ Makeindex.new( [ attributes, [content]] )
39
+ Attributes are not defined for this element.
40
+ =end
41
+ class Makeindex < Element
42
+ #~ add_id :makeindex
43
+ has_no_content false
44
+
45
+ #~ add_html_tag 'head'
46
+ add_latex_output '#{linebreak(@crbefore)}\\makeindex #{linebreak(@crafter)}'
47
+ #~ add_context_output '#{@content}'
48
+ #~ add_text_output '#{@content}'
49
+ #~ add_wiki_output '#{@content}'
50
+ #~ add_creole_output '#{@content}'
51
+ end #Index
52
+ =begin rdoc
53
+ Define Element :printindex
54
+
55
+ Create an instance with
56
+ element( :printindex, [ attributes, [content]] )
57
+ or
58
+ Printindex.new( [ attributes, [content]] )
59
+ Attributes are not defined for this element.
60
+ =end
61
+ class Printindex < Element
62
+ has_no_content false
63
+ add_attribute :subindex, Attribute.create( [ :latex] )
64
+ #~ add_html_tag 'head'
65
+ #~ add_latex_output '#{linebreak(@crbefore)}\\printindex#{@attr[:subindex] ? "[#{@attr[:subindex]}]" : ""} #{linebreak(@crafter)}'
66
+
67
+ #Include support for splitindex.
68
+ def to_latex( options = {} )
69
+ cmd = linebreak(@crbefore)
70
+ cmd << "\\printindex"
71
+ case @attr[:subindex].to_s
72
+ when ''
73
+ when '*'
74
+ cmd << "*"
75
+ else
76
+ cmd << "[#{@attr[:subindex]}]"
77
+ end
78
+ cmd = linebreak(@crafter)
79
+ cmd
80
+ end
81
+
82
+ #~ add_context_output '#{@content}'
83
+ #~ add_text_output '#{@content}'
84
+ #~ add_wiki_output '#{@content}'
85
+ #~ add_creole_output '#{@content}'
86
+ end #Index
87
+ #Provide \sindex. Defined in the splitidx-package
88
+ class Newindex < Element
89
+ add_attribute :subname, Attribute.create( [ :latex, :required ] )
90
+
91
+ #~ add_html_tag 'head'
92
+ add_latex_output '#{linebreak(@crbefore)}\\newindex[#{@attr[:subname]}]{#{@content}}#{linebreak(@crafter)}'
93
+ #~ add_context_output '#{@content}'
94
+ #~ add_text_output '#{@content}'
95
+ #~ add_wiki_output '#{@content}'
96
+ #~ add_creole_output '#{@content}'
97
+ end #Index
98
+ #Provide \sindex. Defined in the splitidx-package
99
+ class Sindex < Element
100
+ add_attribute :subindex, Attribute.create( [ :latex, :required ] )
101
+
102
+ #~ add_html_tag 'head'
103
+ add_latex_output '#{linebreak(@crbefore)}\\sindex[#{@attr[:subindex]}]{#{@content}}#{linebreak(@crafter)}'
104
+ #~ add_context_output '#{@content}'
105
+ #~ add_text_output '#{@content}'
106
+ #~ add_wiki_output '#{@content}'
107
+ #~ add_creole_output '#{@content}'
108
+ end #Index
109
+ end #Index
110
+ end
@@ -15,7 +15,7 @@ Used to define Itemize, Enumerate...
15
15
  item.each{|it| self << it }
16
16
  else
17
17
  if self.class == Description
18
- #fixme: Reihenfolge
18
+ #fixme: check sequence :dt/:dd
19
19
  if ! ( item.is_a?( Element.get(:dt) ) or item.is_a?( Element.get(:dd) ) )
20
20
  @log.warn("Add non-item to list (get #{item.inspect})") if @log.warn
21
21
  end
@@ -125,6 +125,7 @@ The look will be defined by the environment where it is in (itemize/ul, enumerat
125
125
  cmd << "\n" if @crafter
126
126
  return cmd
127
127
  end
128
+
128
129
  #fixme cascaded lists will not work!!
129
130
  #each list will be on first level.
130
131
  #- wanted: ** on level 2
@@ -4,49 +4,47 @@ Support for caption.sty.
4
4
 
5
5
  #
6
6
  module Docgenerator
7
- module Packages
7
+ module Packages
8
8
  =begin rdoc
9
9
  Support for caption.sty.
10
10
 
11
11
  * http://www.ctan.org/tex-archive/macros/latex/contrib/caption/
12
12
  =end
13
- module Caption
14
- #~ Element.create( [:captionof], {
15
- #~ :float_type => Attribute.create( [ :latex, :required ], [ 'figure', 'table' ] ),
16
- #~ :lst_entry => Attribute.create( [ ], [ String ] ),
17
- #~ }, true, {
18
- #~ :latex => '#{linebreak(@crbefore)}\captionof{#{@attr[:float_type]}}[#{@attr[:lst_entry]}]{#{@content}}#{linebreak(@crafter)}',
19
- #~ })
13
+ module Caption
14
+ #~ Element.create( [:captionof], {
15
+ #~ :float_type => Attribute.create( [ :latex, :required ], [ 'figure', 'table' ] ),
16
+ #~ :lst_entry => Attribute.create( [ ], [ String ] ),
17
+ #~ }, true, {
18
+ #~ :latex => '#{linebreak(@crbefore)}\captionof{#{@attr[:float_type]}}[#{@attr[:lst_entry]}]{#{@content}}#{linebreak(@crafter)}',
19
+ #~ })
20
20
 
21
21
  =begin rdoc
22
- Macro defined by caption.sty.
22
+ This Macro is defined by caption.sty.
23
23
 
24
24
  =end
25
- class Captionof < Element
26
- #~ add_attributes( HTML_ATTR_ALL )
27
- add_attribute :float_type, Attribute.create( [ :latex, :required ], [ 'figure', 'table' ] )
28
- add_attribute :lst_entry, Attribute.create( [ ], [ String ] )
29
-
30
- #Redefine standard output.
31
- #Options are given, if an option is avalaible.
32
- add_latex_output { | options = {} |
33
- cmd = linebreak(@crbefore)
34
- cmd << "\\captionof{#{@attr[:float_type]}}"
35
- #Empty [] would return empty entry for list of figures,
36
- cmd << "[#{@attr[:lst_entry]}]" if @attr[:lst_entry].content?
37
- cmd << "{#{@content}}"
38
- cmd << linebreak(@crafter)
39
-
40
- cmd
41
- }
42
-
43
- add_html_tag 'span' #fixme
44
-
45
- end #Captionof
25
+ class Captionof < Element
26
+ #~ add_attributes( HTML_ATTR_ALL )
27
+ add_attribute :float_type, Attribute.create( [ :latex, :required ], [ 'figure', 'table' ] )
28
+ add_attribute :lst_entry, Attribute.create( [ ], [ String ] )
29
+
30
+ #Redefine standard output.
31
+ #Options are given, if an option is avalaible.
32
+ add_latex_output { | options = {} |
33
+ cmd = linebreak(@crbefore)
34
+ cmd << "\\captionof{#{@attr[:float_type]}}"
35
+ #Empty [] would return empty entry for list of figures,
36
+ cmd << "[#{@attr[:lst_entry]}]" if @attr[:lst_entry].content?
37
+ cmd << "{#{@content}}"
38
+ cmd << linebreak(@crafter)
39
+
40
+ cmd
41
+ }
42
+
43
+ add_html_tag 'span' #fixme
44
+
45
+ end #Captionof
46
46
 
47
- end #module Caption
48
- end #module Packages
47
+ end #module Caption
48
+ end #module Packages
49
49
  end #module Docgenerator
50
50
  __END__
51
-
52
- C:\proTeXt\texmf\doc\latex\caption
@@ -63,6 +63,7 @@ Create an instance with
63
63
  element( :PushButton, [ attributes, [content]] )
64
64
  or
65
65
  Pushbutton.new( [ attributes, [content]] )
66
+
66
67
  Attributes may be:
67
68
  * :onclick:
68
69
  * :width:
@@ -7,7 +7,7 @@ Example:
7
7
  class Multicols < Environments::Environment
8
8
  add_attributes( {
9
9
  :colnum => Attribute.create( [:latex], [ Fixnum ], 1 ),
10
- :titleline => Attribute.create( [:latex], [ String], 2 ),
10
+ :titleline => Attribute.create( [:latex], [ String,Element], 2 ),
11
11
  }#.update(HTML_ATTR_ALL)
12
12
  )
13
13
 
@@ -17,7 +17,8 @@ Example:
17
17
  cmd << "\\begin{multicols}{"
18
18
  cmd << @attr[:colnum].content.first.to_s
19
19
  cmd << "}"
20
- cmd << "[#{@attr[:titleline].content.join}]" if @attr[:titleline].filled?
20
+ #~ cmd << "[#{@attr[:titleline].content.join}]" if @attr[:titleline].filled?
21
+ cmd << "[#{@attr[:titleline].content.to_latex(options)}]" if @attr[:titleline].filled?
21
22
  cmd << "\n" if @crmid
22
23
  cmd << @content.to_doc(:latex, options )
23
24
  cmd << "\\end{multicols}"
@@ -15,29 +15,80 @@ You may also use:
15
15
 
16
16
  #
17
17
  module Docgenerator
18
- module Packages
18
+ module Packages
19
19
  =begin rdoc
20
20
  Implement includepdf from pdfpages-package.
21
21
  =end
22
- class IncludePDF < Element
22
+ module PDFPages
23
+ #Add usepackage{pdfpages}
24
+ def self.head()
25
+ element(:usepackage,{},'pdfpages').cr
26
+ end
23
27
  =begin rdoc
24
- Return header definition for usage of the command.
28
+ Implement includepdf from pdfpages-package.
29
+ =end
30
+ class IncludePDF < Element
31
+ add_attribute :pages, Attribute.create( [ :texkeyval], [ String ] )
32
+ add_attribute :nup, Attribute.create( [ :texkeyval], [ /\d+x\d+/ ] ) #multiple logical pages onto each sheet of paper. e.g. 1x2
33
+ add_attribute :landscape, Attribute.create( [ :texkeyval], [ true, false ] ) #
34
+ add_attribute :pagecommand, Attribute.create( [ :texkeyval], [ String ] ) #e.g. \thispagestyle{empty}
35
+ #~ add_attribute :picturecommand, Attribute.create( [ :texkeyval], [ String ] ) #e.g. trim={<left> <lower> <right> <upper>}
36
+ add_attribute :link, Attribute.create( [ :texkeyval], [ true, false] )
37
+ add_attribute :linkname, Attribute.create( [ :texkeyval], [ String ] )
38
+ add_attribute :linktodoc, Attribute.create( [ :texkeyval], [ true, false] ) #Lets the inserted pages be hyperlinks to the document from which they were extracted.
39
+ #~ add_attribute :addtotoc, Attribute.create( [ :texkeyval], [ /.+,.+,.+,.+,.+/] ), #
40
+
41
+ add_output( :latex, '#{linebreak(@crbefore)}\includepdf[#{texkeyval()}]{#{@content}}#{linebreak(@crafter)}')
42
+
43
+ end #IncludePDF
44
+ =begin rdoc
45
+ Implement includepdfmerge from pdfpages-package.
46
+
47
+ The \includepdfmerge command uses the same options as \includepdf with one exception.
48
+ The option pages has no meaning for \includepdfmerge.
49
+
50
+ Content is a file-page-list: filename[,pagespec][,filepagelist]
51
+ =end
52
+ class IncludePDFmerge < IncludePDF
53
+ =begin rdoc
54
+ Copy attributes from IncludePDF (inheritance doas not work with dynamic attribute definition).
55
+ =end
56
+ add_attribute :pages, Attribute.create( [ :texkeyval], [ String ] )
57
+ add_attribute :nup, Attribute.create( [ :texkeyval], [ /\d+x\d+/ ] ) #multiple logical pages onto each sheet of paper. e.g. 1x2
58
+ add_attribute :landscape, Attribute.create( [ :texkeyval], [ true, false ] ) #
59
+ add_attribute :pagecommand, Attribute.create( [ :texkeyval], [ String ] ) #e.g. \thispagestyle{empty}
60
+ #~ add_attribute :picturecommand, Attribute.create( [ :texkeyval], [ String ] ) #e.g. trim={<left> <lower> <right> <upper>}
61
+ add_attribute :link, Attribute.create( [ :texkeyval], [ true, false] )
62
+ add_attribute :linkname, Attribute.create( [ :texkeyval], [ String ] )
63
+ add_attribute :linktodoc, Attribute.create( [ :texkeyval], [ true, false] ) #Lets the inserted pages be hyperlinks to the document from which they were extracted.
64
+ =begin rdoc
65
+
25
66
  =end
26
- def self.head()
27
- element(:usepackage,{},'pdfpages').cr
28
- end
29
-
30
- add_attribute :pages, Attribute.create( [ :texkeyval], [ String ] )
31
- add_attribute :nup, Attribute.create( [ :texkeyval], [ /\d+x\d+/ ] ) #multiple logical pages onto each sheet of paper.
32
- add_attribute :landscape, Attribute.create( [ :texkeyval], [ true, false ] ) #multiple logical pages onto each sheet of paper.
33
- add_attribute :pagecommand, Attribute.create( [ :texkeyval], [ String ] ) #multiple logical pages onto each sheet of paper.
34
- add_attribute :link, Attribute.create( [ :texkeyval], [ true, false] )
35
- add_attribute :linkname, Attribute.create( [ :texkeyval], [ String ] )
36
- add_attribute :linktodoc, Attribute.create( [ :texkeyval], [ true, false] ) #Lets the inserted pages be hyperlinks to the document from which they were extracted.
37
- #~ add_attribute :addtotoc, Attribute.create( [ :texkeyval], [ /.+,.+,.+,.+,.+/] ), #
38
-
39
- add_output( :latex, '#{linebreak(@crbefore)}\includepdf[#{texkeyval()}]{#{@content}}#{linebreak(@crafter)}')
40
-
41
- end #IncludePDF
42
- end #module Packages
67
+ def to_latex(options={})
68
+ filelist = []
69
+ @content.flatten.each{|element|
70
+ case element
71
+ when String
72
+ filelist << element
73
+ when Hash
74
+ element.each{|filename, pagespec|
75
+ filelist << filename
76
+ filelist << pagespec
77
+ }
78
+ else
79
+ raise ArgumentError,"Dont know how to handle %s->%s in %s" % [element, self.class, __method__]
80
+ end
81
+ }
82
+ cmd = ''
83
+ cmd << linebreak(@crbefore)
84
+ cmd << "\\includepdfmerge[#{texkeyval()}]{"
85
+ cmd << filelist.join(',')
86
+ cmd << '}'
87
+ cmd << linebreak(@crafter)
88
+ return cmd
89
+ end
90
+
91
+ end #IncludePDFmerge
92
+ end #PDFPages
93
+ end #module Packages
43
94
  end #module Docgenerator