docgenerator 0.1.1 → 1.0.2
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.
- data/examples/docgenerator_example.rb +76 -160
- data/examples/docgenerator_example_footnote.rb +98 -0
- data/examples/docgenerator_example_list.rb +62 -0
- data/examples/docgenerator_example_restrictions.rb +59 -0
- data/examples/docgenerator_example_tabular.rb +68 -0
- data/examples/docgenerator_example_tripfalls.rb +57 -0
- data/examples/wiki2docgenerator_example.rb +270 -0
- data/lib/docgenerator.rb +159 -0
- data/{docgenerator_attribute.rb → lib/docgenerator_attribute.rb} +32 -7
- data/{docgenerator_characters.rb → lib/docgenerator_characters.rb} +15 -0
- data/{docgenerator_css.rb → lib/docgenerator_css.rb} +6 -1
- data/{docgenerator_document.rb → lib/docgenerator_document.rb} +92 -93
- data/{docgenerator_element.rb → lib/docgenerator_element.rb} +125 -51
- data/{docgenerator_elements.rb → lib/docgenerator_elements.rb} +40 -56
- data/{docgenerator_environments.rb → lib/docgenerator_environments.rb} +16 -10
- data/{docgenerator_footnote.rb → lib/docgenerator_footnote.rb} +44 -22
- data/{docgenerator_lists.rb → lib/docgenerator_lists.rb} +44 -39
- data/{docgenerator_sections.rb → lib/docgenerator_sections.rb} +2 -2
- data/{docgenerator_tabular.rb → lib/docgenerator_tabular.rb} +71 -39
- data/{packages → lib/packages}/docgenerator_attachfile.rb +0 -0
- data/{packages → lib/packages}/docgenerator_caption.rb +0 -0
- data/{packages → lib/packages}/docgenerator_hyperref.rb +0 -0
- data/{packages → lib/packages}/docgenerator_listings.rb +1 -2
- data/{packages → lib/packages}/docgenerator_pdfpages.rb +0 -0
- data/{packages → lib/packages}/docgenerator_scrlettr2.rb +2 -2
- data/{packages → lib/packages}/docgenerator_scrpage2.rb +0 -0
- data/{packages → lib/packages}/docgenerator_url.rb +0 -0
- data/lib/templates/docgenerator_template.rb +176 -0
- data/lib/templates/docgenerator_template.yaml +105 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +1161 -0
- data/self_docgenerator.rb +161 -0
- data/unittest/expected/test_beamer_note.html +1 -0
- data/unittest/expected/test_beamer_note.latex +1 -0
- data/unittest/expected/test_beamer_note.text +1 -0
- data/unittest/expected/test_beamer_note.wiki +1 -0
- data/unittest/expected/test_block.html +1 -0
- data/unittest/expected/test_block.latex +1 -0
- data/unittest/expected/test_block.text +1 -0
- data/unittest/expected/test_block.wiki +2 -0
- data/unittest/expected/test_css.css +1 -0
- data/unittest/expected/test_css2.css +1 -0
- data/unittest/expected/test_description.html +1 -0
- data/unittest/expected/test_description.latex +3 -0
- data/unittest/expected/test_description.text +3 -0
- data/unittest/expected/test_description.wiki +3 -0
- data/unittest/expected/test_document_article.latex +23 -0
- data/unittest/expected/test_document_html.html +14 -0
- data/unittest/expected/test_document_replacement_article.latex +23 -0
- data/unittest/expected/test_document_replacement_html.html +14 -0
- data/unittest/expected/test_document_replacement_text.text +5 -0
- data/unittest/expected/test_document_replacement_wiki.wiki +5 -0
- data/unittest/expected/test_document_text.text +5 -0
- data/unittest/expected/test_document_wiki.wiki +5 -0
- data/unittest/expected/test_enumerate.html +1 -0
- data/unittest/expected/test_enumerate.latex +3 -0
- data/unittest/expected/test_enumerate.text +1 -0
- data/unittest/expected/test_enumerate.wiki +2 -0
- data/unittest/expected/test_footnote.html +5 -0
- data/unittest/expected/test_footnote.latex +11 -0
- data/unittest/expected/test_footnote.text +13 -0
- data/unittest/expected/test_footnote.wiki +11 -0
- data/unittest/expected/test_footnote_group.html +8 -0
- data/unittest/expected/test_footnote_group.latex +17 -0
- data/unittest/expected/test_footnote_group.wiki +17 -0
- data/unittest/expected/test_href.html +2 -0
- data/unittest/expected/test_href.latex +8 -0
- data/unittest/expected/test_href.text +4 -0
- data/unittest/expected/test_html_css.html +1 -0
- data/unittest/expected/test_itemize.html +1 -0
- data/unittest/expected/test_itemize.latex +3 -0
- data/unittest/expected/test_itemize.text +1 -0
- data/unittest/expected/test_itemize.wiki +2 -0
- data/unittest/expected/test_section.html +8 -0
- data/unittest/expected/test_section.latex +20 -0
- data/unittest/expected/test_section.text +24 -0
- data/unittest/expected/test_section.wiki +20 -0
- data/unittest/expected/test_tabular.html +10 -0
- data/unittest/expected/test_tabular.latex +10 -0
- data/unittest/expected/test_tabular.wiki +31 -0
- data/unittest/expected/test_tabular_doc.latex +22 -0
- data/unittest/expected/test_wiki.html +6 -0
- data/unittest/expected/test_wiki.latex +12 -0
- data/unittest/expected/test_wiki.text +14 -0
- data/unittest/expected/test_wiki.wiki +12 -0
- data/unittest/expected/test_wiki_amazon.html +10 -0
- data/unittest/expected/test_wiki_description.html +7 -0
- data/unittest/expected/test_wiki_description.latex +11 -0
- data/unittest/expected/test_wiki_description.text +6 -0
- data/unittest/expected/test_wiki_description.wiki +6 -0
- data/unittest/expected/test_wiki_footnote.html +8 -0
- data/unittest/expected/test_wiki_footnote.latex +15 -0
- data/unittest/expected/test_wiki_footnote.text +12 -0
- data/unittest/expected/test_wiki_footnote.wiki +12 -0
- data/unittest/expected/test_wiki_footnote_groupid.html +21 -0
- data/unittest/expected/test_wiki_html_code.html +7 -0
- data/unittest/expected/test_wiki_html_code.latex +10 -0
- data/unittest/expected/test_wiki_html_code.text +6 -0
- data/unittest/expected/test_wiki_html_code.wiki +6 -0
- data/unittest/expected/test_wiki_inline.html +6 -0
- data/unittest/expected/test_wiki_inline.latex +12 -0
- data/unittest/expected/test_wiki_inline.text +8 -0
- data/unittest/expected/test_wiki_inline.wiki +8 -0
- data/unittest/expected/test_wiki_label.html +6 -0
- data/unittest/expected/test_wiki_link.html +8 -0
- data/unittest/expected/test_wiki_link.latex +14 -0
- data/unittest/expected/test_wiki_link.log +3 -0
- data/unittest/expected/test_wiki_link.wiki +6 -0
- data/unittest/expected/test_wiki_list_ol.html +24 -0
- data/unittest/expected/test_wiki_list_ol.latex +30 -0
- data/unittest/expected/test_wiki_list_ol.text +10 -0
- data/unittest/expected/test_wiki_list_ol.wiki +12 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.html +16 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.latex +24 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.text +8 -0
- data/unittest/expected/test_wiki_list_ol_after_ul.wiki +10 -0
- data/unittest/expected/test_wiki_list_ol_ul.html +24 -0
- data/unittest/expected/test_wiki_list_ol_ul.latex +30 -0
- data/unittest/expected/test_wiki_list_ol_ul.text +10 -0
- data/unittest/expected/test_wiki_list_ol_ul.wiki +12 -0
- data/unittest/expected/test_wiki_list_ul.html +24 -0
- data/unittest/expected/test_wiki_list_ul.latex +30 -0
- data/unittest/expected/test_wiki_list_ul.text +10 -0
- data/unittest/expected/test_wiki_list_ul.wiki +12 -0
- data/unittest/expected/test_wiki_list_ul_too_much.html +39 -0
- data/unittest/expected/test_wiki_list_ul_too_much.latex +51 -0
- data/unittest/expected/test_wiki_list_ul_too_much.text +11 -0
- data/unittest/expected/test_wiki_list_ul_too_much.wiki +15 -0
- data/unittest/expected/test_wiki_picture.html +55 -0
- data/unittest/expected/test_wiki_picture.latex +76 -0
- data/unittest/expected/test_wiki_picture_thumb.html +5 -0
- data/unittest/expected/test_wiki_tab1.html +30 -0
- data/unittest/expected/test_wiki_tab1.latex +30 -0
- data/unittest/expected/test_wiki_tab1.wiki +29 -0
- data/unittest/expected/test_wiki_textformatting.html +7 -0
- data/unittest/expected/test_wiki_textformatting.latex +16 -0
- data/unittest/expected/test_wiki_textformatting.text +11 -0
- data/unittest/expected/test_wiki_textformatting.wiki +9 -0
- data/unittest/expected/test_wiki_toc.html +9 -0
- data/unittest/expected/test_wiki_toc.latex +18 -0
- data/unittest/expected/test_wiki_toc.text +21 -0
- data/unittest/expected/test_wiki_toc.wiki +18 -0
- data/unittest/expected/test_wiki_ul_multiple_line.html +18 -0
- data/unittest/expected/test_wiki_ul_multiple_line.latex +19 -0
- data/unittest/expected/test_wiki_ul_multiple_line.text +6 -0
- data/unittest/expected/test_wiki_ul_multiple_line.wiki +7 -0
- data/unittest/test_docgenerator.rb +85 -0
- data/unittest/unittest_docgenerator.rb +454 -0
- data/unittest/unittest_wiki2doc.rb +451 -0
- metadata +155 -31
- data/docgenerator.rb +0 -137
- data/docgenerator_template.rb +0 -103
- data/packages/docgenerator_beamer.rb +0 -250
|
@@ -25,7 +25,7 @@ sect = Struct.new( 'Sections', :keys, :wiki, :html, :tex )
|
|
|
25
25
|
].each{ |s|
|
|
26
26
|
Element.create( s.keys, {
|
|
27
27
|
:short => Attribute.create( [ :latex ] ),
|
|
28
|
-
}.update( HTML_ATTR_ALL), true,
|
|
28
|
+
}.update( HTML_ATTR_ALL ), true,
|
|
29
29
|
{ :htmltag => s.html,
|
|
30
30
|
#~ :latex => '#{linebreak(@crbefore)}' + "\\#{s.tex}" + '{#{@content}}#{linebreak(@crafter)}',
|
|
31
31
|
:latex => '#{linebreak(@crbefore)}' + "\\#{s.tex}" +
|
|
@@ -33,7 +33,7 @@ sect = Struct.new( 'Sections', :keys, :wiki, :html, :tex )
|
|
|
33
33
|
'{#{@content}}' +
|
|
34
34
|
'#{hypertarget(@attr[:id])}' +
|
|
35
35
|
'#{linebreak(@crafter)}',
|
|
36
|
-
:text => "\n" + '#{linebreak(@
|
|
36
|
+
:text => "\n" + '#{linebreak(@crbefore)}#{@content}' + "\n" +
|
|
37
37
|
' ' * s.wiki * 2 + '-' * 30 + "\n" + '#{linebreak(@crafter)}',
|
|
38
38
|
:wiki => '#{linebreak(@crbefore)}' + "\n" + '='* (s.wiki ) + '#{@content}' + '='* (s.wiki) + "\n" + '#{linebreak(@crafter)}',
|
|
39
39
|
} )
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#
|
|
2
|
-
#Definition of elements for DocGenerator.rb
|
|
2
|
+
#Definition of tabular elements for DocGenerator.rb
|
|
3
3
|
#
|
|
4
|
-
if __FILE__ == $0
|
|
5
|
-
require 'DocGenerator'
|
|
6
|
-
end
|
|
4
|
+
#~ if __FILE__ == $0
|
|
5
|
+
#~ require 'DocGenerator'
|
|
6
|
+
#~ end
|
|
7
7
|
|
|
8
8
|
#Define some constants to include packages into document header.
|
|
9
9
|
TEX_PACKAGE_TABULARX = element(:usepackage,{},'tabularx').cr
|
|
@@ -14,8 +14,8 @@ class Table < Environment
|
|
|
14
14
|
add_attributes( HTML_ATTR_ALL )
|
|
15
15
|
Element.add( [:table ], Table)
|
|
16
16
|
def htmltag(); 'div'; end
|
|
17
|
-
def to_latex( )
|
|
18
|
-
return to_latex_environment( 'table' )
|
|
17
|
+
def to_latex( options={} )
|
|
18
|
+
return to_latex_environment( 'table', nil, options )
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
|
@@ -62,23 +62,29 @@ class Tabular < Element
|
|
|
62
62
|
row.columns = @attr[:columns].to_s.to_i
|
|
63
63
|
end
|
|
64
64
|
@content << row
|
|
65
|
-
set_backlink( row )
|
|
66
65
|
end
|
|
67
|
-
def to_latex()
|
|
66
|
+
def to_latex(options={})
|
|
67
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
68
|
+
o[:log].debug("enter to_latex for tabular") if o[:log].debug?
|
|
68
69
|
cmd = ''
|
|
69
70
|
cmd << "\n" if @crbefore
|
|
70
71
|
cmd << "\\begin{tabular}{"
|
|
71
|
-
cmd << @attr[:columndescription].content.
|
|
72
|
+
cmd << @attr[:columndescription].content.to_doc(:latex, o)
|
|
72
73
|
cmd << "}"
|
|
73
74
|
cmd << "\n" if @crmid
|
|
74
|
-
cmd << @content.
|
|
75
|
+
cmd << @content.to_doc(:latex, o )
|
|
75
76
|
cmd << "\\end{tabular}"
|
|
76
77
|
cmd << "\n" if @crafter
|
|
77
78
|
return cmd
|
|
78
79
|
end
|
|
80
|
+
def to_text(options={}); return @content.to_text(options); end
|
|
81
|
+
def to_wiki(options={}); return "{|\n#{@content.to_wiki(options).strip}\n|}\n"; end
|
|
79
82
|
def htmltag()
|
|
80
83
|
return 'table'
|
|
81
84
|
end
|
|
85
|
+
def inspect()
|
|
86
|
+
return "<Class Element(tabular) columns=#{@attr[:columns]}>"
|
|
87
|
+
end
|
|
82
88
|
end
|
|
83
89
|
#Requires
|
|
84
90
|
# doc.head << element(:usepackage,{},'longtable')
|
|
@@ -87,14 +93,16 @@ class Longtable < Tabular
|
|
|
87
93
|
Element.add( [:longtable], Longtable )
|
|
88
94
|
#
|
|
89
95
|
add_attributes( Element.get_attribute_list( Tabular ) )
|
|
90
|
-
def to_latex()
|
|
96
|
+
def to_latex(options={})
|
|
97
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
98
|
+
o[:log].debug("enter to_latex for longtable") if o[:log].debug?
|
|
91
99
|
cmd = ''
|
|
92
100
|
cmd << "\n" if @crbefore
|
|
93
101
|
cmd << "\\begin{longtable}{"
|
|
94
|
-
cmd << @attr[:columndescription].content.
|
|
102
|
+
cmd << @attr[:columndescription].content.to_doc(:latex, o)
|
|
95
103
|
cmd << "}"
|
|
96
104
|
cmd << "\n" if @crmid
|
|
97
|
-
cmd << @content.
|
|
105
|
+
cmd << @content.to_latex(o)
|
|
98
106
|
cmd << "\\end{longtable}"
|
|
99
107
|
cmd << "\n" if @crafter
|
|
100
108
|
return cmd
|
|
@@ -108,9 +116,11 @@ class Tabularx < Tabular
|
|
|
108
116
|
Element.add( [:tabularx], Tabularx )
|
|
109
117
|
#
|
|
110
118
|
add_attributes( Element.get_attribute_list( Tabular ) )
|
|
111
|
-
def to_latex()
|
|
119
|
+
def to_latex(options={})
|
|
120
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
121
|
+
o[:log].debug("enter to_latex for tabularx") if o[:log].debug?
|
|
112
122
|
if @attr[:width].content.to_s == ''
|
|
113
|
-
|
|
123
|
+
o[:log].error( "Tabularx: Empty width, set it to \\textwidth" ) if o[:log].error?
|
|
114
124
|
@attr[:width] << '\\textwidth'
|
|
115
125
|
end
|
|
116
126
|
cmd = ''
|
|
@@ -121,7 +131,7 @@ class Tabularx < Tabular
|
|
|
121
131
|
cmd << @attr[:columndescription].content.to_s
|
|
122
132
|
cmd << "}"
|
|
123
133
|
cmd << "\n" if @crmid
|
|
124
|
-
cmd << @content.
|
|
134
|
+
cmd << @content.to_doc(:latex, o )
|
|
125
135
|
cmd << "\\end{tabularx}"
|
|
126
136
|
cmd << "\n" if @crafter
|
|
127
137
|
return cmd
|
|
@@ -213,25 +223,35 @@ class Row < Element
|
|
|
213
223
|
elsif @content.size > @columns
|
|
214
224
|
puts "Tabular with #{@columns} columns get #{@content.size} columns"
|
|
215
225
|
end
|
|
216
|
-
set_backlink( row )
|
|
217
226
|
end
|
|
218
227
|
def inspect()
|
|
219
|
-
return "<Class Row
|
|
228
|
+
return "<Class Row columns=#{@content.size}>"
|
|
220
229
|
end
|
|
221
230
|
#Each cell is separated by '&'.
|
|
222
|
-
def to_latex()
|
|
231
|
+
def to_latex(options={})
|
|
232
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
233
|
+
o[:log].debug("enter to_latex for row") if o[:log].debug?
|
|
223
234
|
cmd = ''
|
|
224
235
|
cmd << "\n" if @crbefore
|
|
225
|
-
cmd << @content.join(' & ')
|
|
236
|
+
cmd << @content.map{|cell| cell.to_latex(o)}.join(' & ')
|
|
237
|
+
#In direct use, one \\ is ok.
|
|
238
|
+
#In usage in documents, two \\ are needed (-> see unittest )
|
|
239
|
+
if o[:filename]
|
|
240
|
+
o[:log].debug("table/row with corresponding file #{o[:filename].inspect}") if o[:log].debug?
|
|
241
|
+
cmd << Regexp.escape('\\' + '\\')
|
|
242
|
+
else
|
|
243
|
+
o[:log].debug("table/row without corresponding file") if o[:log].debug?
|
|
244
|
+
cmd << Regexp.escape('\\')
|
|
245
|
+
end
|
|
226
246
|
cmd << "[#{@attr[:add_vspace].content.to_s}]" if @attr[:add_vspace].content.size > 0
|
|
227
|
-
cmd << @hline.
|
|
228
|
-
cmd << @toprule.
|
|
229
|
-
cmd << @midrule.
|
|
230
|
-
cmd << @bottomrule.
|
|
231
|
-
cmd << @endfirsthead.
|
|
232
|
-
cmd << @endhead.
|
|
233
|
-
cmd << @endfoot.
|
|
234
|
-
cmd << @endlastfoot.
|
|
247
|
+
cmd << @hline.to_latex(o) if @hline
|
|
248
|
+
cmd << @toprule.to_latex(o) if @toprule
|
|
249
|
+
cmd << @midrule.to_latex(o) if @midrule
|
|
250
|
+
cmd << @bottomrule.to_latex(o) if @bottomrule
|
|
251
|
+
cmd << @endfirsthead.to_latex(o) if @endfirsthead
|
|
252
|
+
cmd << @endhead.to_latex(o) if @endhead
|
|
253
|
+
cmd << @endfoot.to_latex(o) if @endfoot
|
|
254
|
+
cmd << @endlastfoot.to_latex(o) if @endlastfoot
|
|
235
255
|
@cline.each{|cline| cmd << "\\cline{#{cline}}" } if @cline
|
|
236
256
|
@cmidrule.each{|cmidrule| cmd << "\\cmidrule{#{cmidrule}}" } if @cmidrule
|
|
237
257
|
cmd << "\n" if @crafter
|
|
@@ -240,12 +260,14 @@ class Row < Element
|
|
|
240
260
|
def htmltag()
|
|
241
261
|
return 'tr'
|
|
242
262
|
end
|
|
243
|
-
def to_html()
|
|
263
|
+
def to_html(options={})
|
|
264
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
265
|
+
o[:log].debug("enter to_html for row") if o[:log].debug?
|
|
244
266
|
cmd = ''
|
|
245
267
|
cmd << "\n" if @crbefore
|
|
246
268
|
cmd << '<tr '
|
|
247
269
|
css = @attr[:style].content[0]
|
|
248
|
-
|
|
270
|
+
o[:log].error( "docgenerator_tabular: style is no CSS #{css.inspect}" ) if css and ! css.is_a?(CSS) and o[:log].error?
|
|
249
271
|
@attr[:style] << css = CSS.new if ! css
|
|
250
272
|
#Doesn't work. Style sheet setting in tr doesn't go to td
|
|
251
273
|
if @hline
|
|
@@ -266,13 +288,15 @@ class Row < Element
|
|
|
266
288
|
cmd << "#{k} = \"#{v}\" " if v.to_s != '' and v.html?
|
|
267
289
|
}
|
|
268
290
|
cmd << '>'
|
|
269
|
-
cmd << "#{@content}"
|
|
291
|
+
cmd << "#{@content.to_html(o)}"
|
|
270
292
|
cmd << "\n" if @crmid
|
|
271
293
|
cmd << '</tr>'
|
|
272
294
|
cmd << "\n" if @crafter
|
|
273
295
|
return cmd
|
|
274
296
|
end
|
|
275
|
-
end
|
|
297
|
+
def to_text(options={}); return "#{@content.to_text(options).strip}\n"; end
|
|
298
|
+
def to_wiki(options={}); return "\n|-\n#{@content.to_wiki(options).strip}"; end
|
|
299
|
+
end #Row
|
|
276
300
|
|
|
277
301
|
Element.create( [:hline ], {},false,
|
|
278
302
|
{ :htmltag => nil,
|
|
@@ -322,10 +346,12 @@ class Column < Element
|
|
|
322
346
|
:align => HTML_ATTR_ALIGN,
|
|
323
347
|
:bgcolor => Attribute.create( [ :html ] ),
|
|
324
348
|
} )
|
|
325
|
-
def to_latex()
|
|
349
|
+
def to_latex(options={})
|
|
350
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
351
|
+
o[:log].debug("enter to_latex for column") if o[:log].debug?
|
|
326
352
|
cmd = ''
|
|
327
353
|
cmd << "\n" if @crbefore
|
|
328
|
-
cmd << "#{@content}"
|
|
354
|
+
cmd << "#{@content.to_latex(o)}"
|
|
329
355
|
cmd << "\n" if @crafter
|
|
330
356
|
return cmd
|
|
331
357
|
end
|
|
@@ -334,31 +360,37 @@ class Column < Element
|
|
|
334
360
|
# fixme th for head
|
|
335
361
|
return 'td'
|
|
336
362
|
end
|
|
363
|
+
def to_text(options={}); return "#{@content.to_text(options).strip}\n"; end
|
|
364
|
+
def to_wiki(options={}); return "|#{@content.to_wiki(options).strip}\n"; end
|
|
337
365
|
def inspect()
|
|
338
366
|
return "<Class Column @content=#{@content.inspect}>"
|
|
339
367
|
end
|
|
340
|
-
end
|
|
368
|
+
end #Columns
|
|
341
369
|
class Multicolumn < Column
|
|
342
370
|
#Make the key known to the complete key-list of elements.
|
|
343
371
|
Element.add( [:multicolumn], Multicolumn )
|
|
344
372
|
#~ add_attributes( HTML_ATTR_ALL )
|
|
345
373
|
add_attributes( {
|
|
346
374
|
#~ :columns => Attribute.create( [:required], [ Fixnum ] ) , #colspan
|
|
347
|
-
:
|
|
348
|
-
:
|
|
375
|
+
:colspan => Attribute.create( [:required, :html, :latex], [ Fixnum ], 2 ) ,
|
|
376
|
+
:columns => :colspan,
|
|
349
377
|
:rowspan => Attribute.create( [:html ], [ Fixnum ], 2 ),
|
|
350
378
|
:pos => Attribute.create( [:latex] ) ,
|
|
351
379
|
:align => HTML_ATTR_ALIGN,
|
|
352
380
|
:width => Attribute.create( [ :html ] ),
|
|
353
381
|
:height => Attribute.create( [ :html ] ),
|
|
354
382
|
}.update( HTML_ATTR_ALL ) )
|
|
355
|
-
def to_latex()
|
|
383
|
+
def to_latex(options={})
|
|
384
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
385
|
+
o[:log].debug("enter to_latex for multicolumn") if o[:log].debug?
|
|
356
386
|
cmd = ''
|
|
357
387
|
cmd << "\n" if @crbefore
|
|
358
|
-
cmd << "\\multicolumn{#{@attr[:
|
|
388
|
+
cmd << "\\multicolumn{#{@attr[:colspan]}}{#{@attr[:pos]}}{#{@content.to_latex(o)}}"
|
|
359
389
|
cmd << "\n" if @crafter
|
|
360
390
|
return cmd
|
|
361
391
|
end
|
|
392
|
+
def to_text(options={}); return "#{@content.to_text(options).strip}\n"; end
|
|
393
|
+
def to_wiki(options={}); return "|columns=#{@attr[:colspan]}|pos=#{@attr[:pos]}||#{@content.to_wiki(options).strip}\n"; end
|
|
362
394
|
#~ def htmltag()
|
|
363
395
|
#~ return 'td'
|
|
364
396
|
#~ end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -54,7 +54,6 @@ class Lstinline < Element
|
|
|
54
54
|
:caption => Attribute.create( [ :latex ], nil, 1 ),
|
|
55
55
|
}.update(HTML_ATTR_ALL).update( LSTSETTINGS)
|
|
56
56
|
)
|
|
57
|
-
|
|
58
57
|
def htmltag; 'pre'; end
|
|
59
58
|
#Redefine standard output.
|
|
60
59
|
#Options are given, if an option is avalaible.
|
|
@@ -68,7 +67,7 @@ class Lstinline < Element
|
|
|
68
67
|
cmd << '\lstinline'
|
|
69
68
|
cmd << "[#{texkeyval()}]"
|
|
70
69
|
cmd << sep
|
|
71
|
-
cmd << "#{@content}"
|
|
70
|
+
cmd << "#{@content.to_latex}"
|
|
72
71
|
cmd << sep
|
|
73
72
|
cmd << linebreak(@crafter)
|
|
74
73
|
return cmd
|
|
File without changes
|
|
@@ -120,9 +120,9 @@ class Letter < Environment
|
|
|
120
120
|
anr << element(:br)
|
|
121
121
|
@attr[:address].content.each{|a| anr << [a, element(:br) ] }
|
|
122
122
|
cmd << element(:p,{}, @attr[:opening] )
|
|
123
|
-
cmd << @content
|
|
123
|
+
cmd << @content.to_html
|
|
124
124
|
cmd << element(:p,{}, @attr[:closing] )
|
|
125
125
|
#~ cmd << "\n" if @crafter
|
|
126
|
-
return cmd.
|
|
126
|
+
return cmd.to_html
|
|
127
127
|
end
|
|
128
128
|
end
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
#
|
|
2
|
+
#Definition of templates.
|
|
3
|
+
#
|
|
4
|
+
#This templates are used for document types.
|
|
5
|
+
class DocumentTemplate
|
|
6
|
+
@@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)
|
|
23
|
+
def initialize( key, target, template)
|
|
24
|
+
@key = key
|
|
25
|
+
@target = target
|
|
26
|
+
@template = template.gsub(/^\t*/, '')
|
|
27
|
+
case target
|
|
28
|
+
when :text
|
|
29
|
+
when :wiki
|
|
30
|
+
when :latex
|
|
31
|
+
when :html
|
|
32
|
+
else
|
|
33
|
+
puts "DocumentTemplate: Undefined target #{target.inspect}"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
if @@templates[key]
|
|
37
|
+
puts "DocumentTemplate: Double definition of template #{key.inspect}"
|
|
38
|
+
end
|
|
39
|
+
@@templates[key] = self
|
|
40
|
+
|
|
41
|
+
#~ puts "Define template #{key.inspect} for #{target}"
|
|
42
|
+
#~ File.open("#{File.dirname(__FILE__)}/#{key}.#{target}", 'w'){|f|
|
|
43
|
+
#~ f << @template
|
|
44
|
+
#~ }
|
|
45
|
+
end
|
|
46
|
+
#Template.
|
|
47
|
+
# Base for the document to be created.
|
|
48
|
+
#
|
|
49
|
+
# <<head>> will be replaced by the header data
|
|
50
|
+
# <<body>> will be replaced by the body data
|
|
51
|
+
#
|
|
52
|
+
def template()
|
|
53
|
+
#Return a dup. Else the template may be changed
|
|
54
|
+
return @template.dup
|
|
55
|
+
end
|
|
56
|
+
#Target format of the Template (:html, :latex...)
|
|
57
|
+
attr_reader :target
|
|
58
|
+
def DocumentTemplate.[]( key )
|
|
59
|
+
if @@templates[key]
|
|
60
|
+
return @@templates[key]
|
|
61
|
+
else
|
|
62
|
+
puts "Template unknown: #{key}"
|
|
63
|
+
return nil
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
#Returns array with all defined template keys.
|
|
67
|
+
def DocumentTemplate.keys()
|
|
68
|
+
return @@templates.keys
|
|
69
|
+
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" )
|
|
77
|
+
File.open(yamlfile){|yaml|
|
|
78
|
+
YAML.load(yaml).each{|key, data|
|
|
79
|
+
DocumentTemplate.new( key, data[:target], data[:source] )
|
|
80
|
+
}}
|
|
81
|
+
end
|
|
82
|
+
#Litte helper to build yaml-files
|
|
83
|
+
def DocumentTemplate.to_yaml()
|
|
84
|
+
yaml = {}
|
|
85
|
+
@@templates.each{|key, template|
|
|
86
|
+
yaml[key] = {
|
|
87
|
+
#~ :key => template.key,
|
|
88
|
+
:source => template.template,
|
|
89
|
+
:target => template.target,
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
puts yaml.to_yaml
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
DocumentTemplate.load()
|
|
97
|
+
|
|
98
|
+
#~ Dir["#{File.dirname(__FILE__)}/*.{wiki,latex,text,html}"].each{|templatename|
|
|
99
|
+
#~ key, target = File.basename(templatename).split(/\./)
|
|
100
|
+
#~ File.open(templatename){|f|
|
|
101
|
+
#~ DocumentTemplate.new( key,target.to_sym, f.readlines.to_s )
|
|
102
|
+
#~ }
|
|
103
|
+
#~ }
|
|
104
|
+
#~ END{DocumentTemplate.to_yaml}
|
|
105
|
+
__END__
|
|
106
|
+
DocumentTemplate.new(
|
|
107
|
+
:include, :latex, %q|<<prefix>>
|
|
108
|
+
% ----------------------------------------------------------------
|
|
109
|
+
<<head>>
|
|
110
|
+
% ----------------------------------------------------------------
|
|
111
|
+
<<body>>
|
|
112
|
+
% ----------------------------------------------------------------
|
|
113
|
+
|)
|
|
114
|
+
|
|
115
|
+
DocumentTemplate.new(
|
|
116
|
+
:article, :latex, %q|<<prefix>>
|
|
117
|
+
\documentclass[<<classoptions>>]{scrartcl}
|
|
118
|
+
\usepackage{babel}
|
|
119
|
+
\usepackage[ansinew]{inputenc}
|
|
120
|
+
\usepackage{hyperref}
|
|
121
|
+
% ----------------------------------------------------------------
|
|
122
|
+
<<head>>
|
|
123
|
+
% ----------------------------------------------------------------
|
|
124
|
+
\begin{document}
|
|
125
|
+
<<body>>
|
|
126
|
+
\end{document}
|
|
127
|
+
% ----------------------------------------------------------------
|
|
128
|
+
|)
|
|
129
|
+
#~ DocumentTemplate.new(
|
|
130
|
+
#~ :report, '',
|
|
131
|
+
#~ |)
|
|
132
|
+
#~ DocumentTemplate.new(
|
|
133
|
+
#~ :book, '',
|
|
134
|
+
#~ |)
|
|
135
|
+
|
|
136
|
+
#~ <!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
137
|
+
|
|
138
|
+
DocumentTemplate.new(
|
|
139
|
+
:html, :html, %q|<!--
|
|
140
|
+
<<prefix>>
|
|
141
|
+
-->
|
|
142
|
+
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
143
|
+
<html>
|
|
144
|
+
<<head>>
|
|
145
|
+
<<body>>
|
|
146
|
+
</html>
|
|
147
|
+
|)
|
|
148
|
+
|
|
149
|
+
{
|
|
150
|
+
:xhtml_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
|
151
|
+
:xhtml_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
|
152
|
+
:html401_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
|
153
|
+
:html401_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
|
154
|
+
}.each{ |key, doctype|
|
|
155
|
+
DocumentTemplate.new(
|
|
156
|
+
key, :html, %Q|<!--
|
|
157
|
+
<<prefix>>
|
|
158
|
+
-->
|
|
159
|
+
#{doctype}
|
|
160
|
+
<html>
|
|
161
|
+
|
|
162
|
+
<<head>>
|
|
163
|
+
|
|
164
|
+
<<body>>
|
|
165
|
+
</html>
|
|
166
|
+
|)
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
DocumentTemplate.new(
|
|
170
|
+
:text, :text, %q|
|
|
171
|
+
<<body>>
|
|
172
|
+
|)
|
|
173
|
+
DocumentTemplate.new(
|
|
174
|
+
:wiki, :wiki, %q|
|
|
175
|
+
<<body>>
|
|
176
|
+
|)
|