docgenerator 1.0.2 → 1.0.4
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/lib/docgenerator.rb +27 -1
- data/lib/docgenerator_css.rb +26 -23
- data/lib/docgenerator_document.rb +78 -16
- data/lib/docgenerator_element.rb +10 -25
- data/lib/docgenerator_elements.rb +78 -13
- data/lib/templates/docgenerator_template_css.rb +73 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +12 -19
- data/unittest/expected/beamer_01_article.tex +13 -0
- data/unittest/expected/beamer_01_attachment.tex +15 -0
- data/unittest/expected/beamer_01_doc.html +13 -0
- data/unittest/expected/beamer_01_doc.tex +18 -0
- data/unittest/expected/beamer_01_notes_only.tex +13 -0
- data/unittest/expected/beamer_01_notes_onlyslideswithnotes.tex +13 -0
- data/unittest/expected/beamer_01_notes_show.tex +13 -0
- data/unittest/expected/beamer_01_presentation.tex +13 -0
- data/unittest/expected/beamer_02_doc.html +29 -0
- data/unittest/expected/beamer_02_doc.tex +34 -0
- data/unittest/expected/beamer_block.html +1 -0
- data/unittest/expected/beamer_block.latex +1 -0
- data/unittest/expected/beamer_doc_fragile_doc.tex +33 -0
- data/unittest/expected/beamer_doc_key_doc.html +20 -0
- data/unittest/expected/beamer_doc_key_doc.tex +29 -0
- data/unittest/expected/beamer_doc_note_doc.html +30 -0
- data/unittest/expected/beamer_doc_note_doc.tex +37 -0
- data/unittest/expected/beamer_doc_pic_bottom_doc.html +24 -0
- data/unittest/expected/beamer_doc_pic_doc.html +24 -0
- data/unittest/expected/beamer_doc_pic_doc.tex +28 -0
- data/unittest/expected/beamer_doc_pic_left_doc.html +24 -0
- data/unittest/expected/beamer_doc_pic_left_doc.tex +28 -0
- data/unittest/expected/beamer_doc_pic_ratio_doc.tex +29 -0
- data/unittest/expected/beamer_doc_pic_right_doc.html +24 -0
- data/unittest/expected/beamer_doc_pic_right_doc.tex +28 -0
- data/unittest/expected/beamer_doc_pic_top_doc.html +24 -0
- data/unittest/expected/beamer_frame.html +5 -0
- data/unittest/expected/beamer_frame.tex +11 -0
- data/unittest/expected/beamer_frame_fragile.tex +7 -0
- data/unittest/expected/beamer_frame_id.html +1 -0
- data/unittest/expected/beamer_frame_id.tex +4 -0
- data/unittest/expected/beamer_framepic.html +5 -0
- data/unittest/expected/beamer_framepic.latex +1 -0
- data/unittest/expected/beamer_framepic_link.html +5 -0
- data/unittest/expected/beamer_framepic_link.latex +1 -0
- data/unittest/expected/beamer_frametitle.html +1 -0
- data/unittest/expected/beamer_frametitle.latex +1 -0
- data/unittest/expected/beamer_note.html +1 -0
- data/unittest/expected/{test_beamer_note.latex → beamer_note.latex} +0 -0
- data/unittest/expected/css_collection.html +9 -0
- data/unittest/expected/css_collection_anonym.html +9 -0
- data/unittest/expected/test_css.css +1 -1
- data/unittest/expected/test_css2.css +1 -1
- data/unittest/expected/test_document_toc.html +14 -0
- data/unittest/expected/test_document_toc_article.latex +64 -0
- data/unittest/expected/test_document_toc_deep.html +18 -0
- data/unittest/expected/test_document_toc_deep.latex +35 -0
- data/unittest/expected/test_document_toc_deep_1.html +6 -0
- data/unittest/expected/test_document_toc_deep_1.latex +11 -0
- data/unittest/expected/test_document_toc_deep_4.html +24 -0
- data/unittest/expected/test_document_toc_deep_4.latex +47 -0
- data/unittest/expected/test_document_toc_deep_err.html +34 -0
- data/unittest/expected/test_document_toc_deep_err.latex +37 -0
- data/unittest/expected/test_document_toc_deep_err.log +4 -0
- data/unittest/expected/test_document_toc_deep_single.html +30 -0
- data/unittest/expected/test_document_toc_html.html +34 -0
- data/unittest/expected/test_document_toc_single.html +14 -0
- data/unittest/expected/test_document_toc_single.latex +27 -0
- data/unittest/expected/test_document_toc_single_pre.html +16 -0
- data/unittest/expected/test_document_toc_single_pre.latex +35 -0
- data/unittest/expected/test_document_toc_single_pre2.html +15 -0
- data/unittest/expected/test_document_toc_single_pre2.latex +35 -0
- data/unittest/expected/test_html_css.html +1 -1
- data/unittest/expected/test_tabular.html +2 -2
- data/unittest/expected/test_wiki_amazon.html +2 -2
- data/unittest/expected/test_wiki_link.html +6 -6
- data/unittest/expected/test_wiki_link.latex +7 -4
- data/unittest/expected/test_wiki_link.wiki +6 -1
- data/unittest/expected/test_wiki_picture.html +3 -3
- data/unittest/expected/toc_css.css +15 -0
- data/unittest/test_docgenerator.rb +24 -1
- data/unittest/unittest_docgenerator.rb +166 -37
- data/unittest/unittest_wiki2doc.rb +9 -1
- metadata +75 -8
- data/unittest/expected/test_beamer_note.html +0 -1
- data/unittest/expected/test_beamer_note.text +0 -1
- data/unittest/expected/test_beamer_note.wiki +0 -1
data/lib/docgenerator.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
#The target format is generic, supported are LaTeX and HTML.
|
|
3
3
|
#Plain text and a Wiki-version exist also, but they are not well maintained.
|
|
4
4
|
#
|
|
5
|
+
#
|
|
5
6
|
#==Elements
|
|
6
7
|
#A document is structured by elements.
|
|
7
8
|
#Each element contains attributes/parameters and content.
|
|
@@ -17,8 +18,31 @@
|
|
|
17
18
|
#so they will not occur in this generated documentation).
|
|
18
19
|
#
|
|
19
20
|
#== Examples
|
|
20
|
-
#
|
|
21
|
+
#A document with a paragraph:
|
|
22
|
+
# doc = Document.new
|
|
23
|
+
# doc.body << element(:p,{}, 'Content')
|
|
24
|
+
# doc.save( 'test.tex', true)
|
|
25
|
+
# doc.save( 'test.html', true)
|
|
26
|
+
#
|
|
27
|
+
#A document with a (unnumbered) list:
|
|
28
|
+
# doc = Document.new
|
|
29
|
+
# doc.body << ul = element(:ul)
|
|
30
|
+
# ul << element(:li,{}, 'List content 1')
|
|
31
|
+
# ul << element(:li,{}, 'List content 2')
|
|
32
|
+
# doc.save( 'test.tex', true)
|
|
33
|
+
# doc.save( 'test.html', true)
|
|
34
|
+
#
|
|
35
|
+
#See the unit tests and the examples-folder of the docgenerator distribution for more examples.
|
|
36
|
+
#
|
|
37
|
+
#== Known problems
|
|
38
|
+
#This program is developed under Windows.
|
|
39
|
+
#I expect encoding problems on other systems
|
|
40
|
+
#(It's not a problem of the program, but a test problem on my side).
|
|
41
|
+
#
|
|
42
|
+
#HTML-Versions are not supported properly
|
|
43
|
+
#(main problem: End-Tag for br)
|
|
21
44
|
#
|
|
45
|
+
#More at http://ruby.lickert.net/docgenerator/index.html
|
|
22
46
|
|
|
23
47
|
#Version information.
|
|
24
48
|
begin
|
|
@@ -31,6 +55,7 @@ rescue NameError #No gems?
|
|
|
31
55
|
DOCGENERATOR_VERSION = "#{File.expand_path('docgenerator')} (no Gem)"
|
|
32
56
|
end
|
|
33
57
|
require 'log4r'
|
|
58
|
+
require 'yaml' #needed by docgenerator_template.rb
|
|
34
59
|
|
|
35
60
|
#How to handle the End-Tag for br/hr...
|
|
36
61
|
#- false: set <br /> (XHTML)
|
|
@@ -131,6 +156,7 @@ end
|
|
|
131
156
|
|
|
132
157
|
require 'templates/docgenerator_template'
|
|
133
158
|
require 'docgenerator_css'
|
|
159
|
+
require 'templates/docgenerator_template_css'
|
|
134
160
|
require 'docgenerator_attribute'
|
|
135
161
|
require 'docgenerator_document'
|
|
136
162
|
|
data/lib/docgenerator_css.rb
CHANGED
|
@@ -25,12 +25,7 @@ class Style < Element
|
|
|
25
25
|
res << "\n" if @crbefore
|
|
26
26
|
res << "<style type=\"text/css\">\n"
|
|
27
27
|
@content.each{|c|
|
|
28
|
-
|
|
29
|
-
res << c.to_tab.join(";\n")
|
|
30
|
-
res << ";\n"
|
|
31
|
-
else #For compatibility
|
|
32
|
-
res << "#{c};\n"
|
|
33
|
-
end
|
|
28
|
+
res << c.to_html(options)
|
|
34
29
|
}
|
|
35
30
|
res << "</style>"
|
|
36
31
|
res << "\n" if @crafter
|
|
@@ -129,6 +124,9 @@ class CSS
|
|
|
129
124
|
}
|
|
130
125
|
def initialize( values ={} )
|
|
131
126
|
@values = {}
|
|
127
|
+
@log = values[:log] ? values[:log] : DOCGENERATOR_LOGGER #fixme
|
|
128
|
+
values.delete(:log)
|
|
129
|
+
|
|
132
130
|
values.each{|k,v|
|
|
133
131
|
self[k] = v
|
|
134
132
|
}
|
|
@@ -155,26 +153,32 @@ class CSS
|
|
|
155
153
|
def []=( k, v )
|
|
156
154
|
key = generalize_key( k )
|
|
157
155
|
if @values[key]
|
|
158
|
-
|
|
156
|
+
@log.warn("CSS: Overwrite #{k.inspect}") if @log.warn?
|
|
159
157
|
end
|
|
160
158
|
if ! @@values[key]
|
|
161
|
-
|
|
159
|
+
@log.error("CSS: Undefined key #{k.inspect}") if @log.error?
|
|
162
160
|
elsif @@values[key].include?(v) #Fine
|
|
163
161
|
elsif @@values[key][0].is_a?(Regexp) and @@values[key][0] =~ v.to_s
|
|
164
162
|
else
|
|
165
|
-
|
|
163
|
+
@log.error("CSS: #{v} not allowed for #{key}") if @log.error?
|
|
166
164
|
end
|
|
167
165
|
|
|
168
166
|
@values[key] = v
|
|
169
167
|
end
|
|
170
168
|
#returns the values for a direct css in the style-attribute for a HTML-tag.
|
|
169
|
+
def to_html(options={})
|
|
170
|
+
o = {
|
|
171
|
+
:map => "%s;",
|
|
172
|
+
}.update(options)
|
|
173
|
+
return self.to_tab.map{|p| o[:map] % p}.join()
|
|
174
|
+
end
|
|
171
175
|
def to_s()
|
|
172
|
-
return self.
|
|
176
|
+
return self.to_html
|
|
173
177
|
end
|
|
174
178
|
#Returns a tab with the textes for each characteristic.
|
|
175
179
|
def to_tab()
|
|
176
180
|
s = []
|
|
177
|
-
@values.each{|k,v|
|
|
181
|
+
@values.sort.each{|k,v|
|
|
178
182
|
s << "#{k}: #{v}"
|
|
179
183
|
}
|
|
180
184
|
return s
|
|
@@ -182,19 +186,18 @@ class CSS
|
|
|
182
186
|
end
|
|
183
187
|
|
|
184
188
|
if __FILE__ == $0
|
|
185
|
-
|
|
186
|
-
css = CSS.new({ :text_align => 'AA', :font_size => 'large'})
|
|
187
|
-
css2 = CSS.new({ :font_size => '12px'})
|
|
188
|
-
puts '-'*10
|
|
189
|
-
style = element(:style)
|
|
190
|
-
style << 'a'
|
|
191
|
-
style << css
|
|
192
|
-
style << css
|
|
193
|
-
puts css.to_s()
|
|
194
|
-
puts '-'*5
|
|
195
|
-
puts style.
|
|
189
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
|
|
190
|
+
#~ css = CSS.new({ :text_align => 'AA', :font_size => 'large'})
|
|
191
|
+
#~ css2 = CSS.new({ :font_size => '12px'})
|
|
192
|
+
#~ puts '-'*10
|
|
193
|
+
#~ style = element(:style)
|
|
194
|
+
#~ style << 'a'
|
|
195
|
+
#~ style << css
|
|
196
|
+
#~ style << css
|
|
197
|
+
#~ puts css.to_s()
|
|
198
|
+
#~ puts '-'*5
|
|
199
|
+
#~ puts style.to_html
|
|
196
200
|
#~ puts style.to_s(:latex)
|
|
197
|
-
|
|
198
201
|
end
|
|
199
202
|
|
|
200
203
|
__END__
|
|
@@ -56,7 +56,7 @@ class Document
|
|
|
56
56
|
when Symbol
|
|
57
57
|
templ = DocumentTemplate[template]
|
|
58
58
|
if ! templ.is_a?( DocumentTemplate )
|
|
59
|
-
|
|
59
|
+
@log.fatal("Unknown template #{template}, valid:\n\t#{DocumentTemplate.keys.join("\n\t")}") if @log.fatal?
|
|
60
60
|
else
|
|
61
61
|
@template[templ.target] = templ
|
|
62
62
|
end
|
|
@@ -64,8 +64,9 @@ class Document
|
|
|
64
64
|
} #templates
|
|
65
65
|
when :maketitle
|
|
66
66
|
@body << element(:maketitle ).cr
|
|
67
|
+
when :log
|
|
67
68
|
else
|
|
68
|
-
|
|
69
|
+
@log.error("Document.new: Unknown setting #{key.inspect} (=#{value.inspect})") if @log.error?
|
|
69
70
|
end
|
|
70
71
|
} #settings
|
|
71
72
|
|
|
@@ -136,27 +137,85 @@ class Document
|
|
|
136
137
|
@options << option
|
|
137
138
|
end
|
|
138
139
|
#Prepare a table of content.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
#
|
|
141
|
+
#There is no sense to use it with LaTeX, better you use \tableofcontents
|
|
142
|
+
#
|
|
143
|
+
#Options:
|
|
144
|
+
#- id: Id of div, needed for CSS-formatting
|
|
145
|
+
#- tocfilename: Added as prefix to link.
|
|
146
|
+
# can be used to make toc for in another file (cross-referencing)
|
|
147
|
+
#- level: Depth of toc
|
|
148
|
+
def toc( options = {} )
|
|
149
|
+
opt = {
|
|
150
|
+
:id => 'toc',
|
|
151
|
+
:tocfilename => nil, #Can be used to build cross references
|
|
152
|
+
:level => 3,
|
|
153
|
+
:log => @log
|
|
154
|
+
}.update(options)
|
|
155
|
+
|
|
156
|
+
opt[:level] = 3 unless opt[:level]
|
|
157
|
+
opt[:log].info("Prepare Table of contents, options: #{options.keys.inspect}") if opt[:log].info?
|
|
158
|
+
opt[:log].debug("Options: #{[:id, :level, :tocfilename].map{|k| "#{k}: #{opt[k].inspect}"}.join(',')}") if opt[:log].debug?
|
|
159
|
+
|
|
160
|
+
toc = element(:div, { :id => opt[:id] }).cR
|
|
161
|
+
opt[:pre].is_a?(String) ? toc << element(:p, {}, opt[:pre] ).cr : toc << opt[:pre]
|
|
162
|
+
|
|
163
|
+
toc_uls = [ toc ]
|
|
164
|
+
|
|
165
|
+
#fixme
|
|
166
|
+
#It would be nicer to get something like 1-1-1 instead of a counter.
|
|
143
167
|
toccnt = 0
|
|
144
|
-
#~ toc = element(:ul).cR
|
|
145
168
|
toc_ids = [ :chapter, :section,:subsection, :subsubsection, :paragraph, :subparagraph,:minisec]
|
|
146
169
|
@body.content.flatten.each{|el|
|
|
170
|
+
if ! el.respond_to?(:ids)
|
|
171
|
+
#e.g. Wikitext. Has a to_doc, but doesn't react on flatten.
|
|
172
|
+
opt[:log].error("Toc: Element ohne :ids #{el.class}") if opt[:log].error?
|
|
173
|
+
next
|
|
174
|
+
end
|
|
147
175
|
depth = toc_ids.index((el.ids & toc_ids)[0])
|
|
148
|
-
|
|
176
|
+
next if ! depth #Element is no header
|
|
177
|
+
|
|
178
|
+
opt[:log].debug("Toc: Found entry on level #{depth}: <#{el.content}>") if opt[:log].debug?
|
|
179
|
+
#Create an id if not already defined
|
|
149
180
|
if el[:id].content.empty?
|
|
150
181
|
el[:id] << "toc#{toccnt += 1}"
|
|
151
182
|
end
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
183
|
+
if depth > opt[:level]
|
|
184
|
+
opt[:log].debug("Toc: Reject by level #{el.content}") if opt[:log].debug?
|
|
185
|
+
next
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
#Check missing levels
|
|
189
|
+
(depth - toc_uls.size).times{|i|
|
|
190
|
+
opt[:log].warn("Toc: Jump over section level #{depth-1+i} (#{opt[:tocfilename]})") if opt[:log].warn?
|
|
191
|
+
toc_uls << element(:ul, {}, element(:li ).cr ).cR
|
|
192
|
+
if toc_uls.size == 2 #First entry
|
|
193
|
+
toc_uls.first << toc_uls.last
|
|
194
|
+
else
|
|
195
|
+
toc_uls[-2].content.last << toc_uls.last
|
|
196
|
+
end
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
#Build new toc-list and deletet bigger ones
|
|
200
|
+
if ! toc_uls[depth]
|
|
201
|
+
opt[:log].debug("Toc: Start new level #{depth}") if opt[:log].debug?
|
|
202
|
+
toc_uls << element(:ul).cR
|
|
203
|
+
if depth == 1
|
|
204
|
+
toc << toc_uls[depth]
|
|
205
|
+
else
|
|
206
|
+
toc_uls[depth -1 ].content.last << toc_uls[depth]
|
|
207
|
+
end
|
|
208
|
+
else #delete levels under actual level
|
|
209
|
+
if toc_uls.slice!(depth+1..toc_uls.size+1)
|
|
210
|
+
opt[:log].debug("Toc: Stop level > #{depth}") if opt[:log].debug?
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
toc_uls[depth] << element(:li, {}, element(:a, {:href => "#{opt[:tocfilename]}##{el[:id]}" }, el.content ) ).cr
|
|
214
|
+
}
|
|
215
|
+
opt[:post].is_a?(String) ? toc << element(:p, {}, opt[:post] ).cr : toc << opt[:post]
|
|
216
|
+
|
|
158
217
|
return toc
|
|
159
|
-
end
|
|
218
|
+
end #toc
|
|
160
219
|
#Save the file.
|
|
161
220
|
#The type of the document is determined by the file extensison.
|
|
162
221
|
#Supported document types are:
|
|
@@ -209,7 +268,6 @@ class Document
|
|
|
209
268
|
|
|
210
269
|
new = to_doc( @target, {
|
|
211
270
|
:template=> @template[target],
|
|
212
|
-
:document => self,
|
|
213
271
|
:filename => filename,
|
|
214
272
|
:replacements => replacements,
|
|
215
273
|
:log => @log
|
|
@@ -304,8 +362,11 @@ class Document
|
|
|
304
362
|
options[:log].error( "New is wrong type: #{new.inspect}") if options[:log].error?
|
|
305
363
|
end
|
|
306
364
|
|
|
365
|
+
options[:document] = self
|
|
307
366
|
@head << self.docinfo()
|
|
367
|
+
options[:log].debug( "Build header data") if options[:log].debug?
|
|
308
368
|
new.sub!( '<<head>>', @head.to_doc(target, options ))
|
|
369
|
+
options[:log].debug( "Build body") if options[:log].debug?
|
|
309
370
|
new.sub!( '<<body>>', @body.to_doc(target, options))
|
|
310
371
|
new.sub!( '<<classoptions>>', @options.uniq.join(','))
|
|
311
372
|
|
|
@@ -363,6 +424,7 @@ class Document
|
|
|
363
424
|
out.gsub!( /\$/, '\$')
|
|
364
425
|
out.gsub!( /&/, '\\\\&')
|
|
365
426
|
out.gsub!( /_/, '\_')
|
|
427
|
+
out.gsub!( /#/, '\#')
|
|
366
428
|
out.gsub!( /�/, '\euro ')
|
|
367
429
|
return out
|
|
368
430
|
end
|
data/lib/docgenerator_element.rb
CHANGED
|
@@ -50,7 +50,7 @@ class Array
|
|
|
50
50
|
#
|
|
51
51
|
def to_doc(target, options = {})
|
|
52
52
|
o = Docgenerator_logger.set_option_defaults(options)
|
|
53
|
-
o[:log].debug("enter to_doc
|
|
53
|
+
o[:log].debug("enter to_doc(#{target}) for Array, options: #{options.keys.inspect}") if o[:log].debug?
|
|
54
54
|
str = ""
|
|
55
55
|
self.each{|el|
|
|
56
56
|
begin
|
|
@@ -266,14 +266,15 @@ class Element
|
|
|
266
266
|
end
|
|
267
267
|
cmd << <<code
|
|
268
268
|
o = Docgenerator_logger.set_option_defaults(options)
|
|
269
|
-
o[:log].debug("enter to_doc for #{self.inspect}") if o[:log].debug?
|
|
269
|
+
o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: \#{options.keys.inspect}") if o[:log].debug?
|
|
270
270
|
code
|
|
271
271
|
template = string.gsub(/\\/, '\\\\\\')
|
|
272
272
|
template.gsub!(/"/, '\"')
|
|
273
|
-
template.gsub!(/@content\}/, "@content.to_doc(#{target.inspect},
|
|
273
|
+
template.gsub!(/@content\}/, "@content.to_doc(#{target.inspect}, o)}")
|
|
274
274
|
cmd << " \"#{template}\"\n"
|
|
275
275
|
cmd << "end\n"
|
|
276
276
|
class_eval( cmd )
|
|
277
|
+
cmd #return cmd for unit test
|
|
277
278
|
end
|
|
278
279
|
#Defines an element.
|
|
279
280
|
#
|
|
@@ -491,7 +492,7 @@ code
|
|
|
491
492
|
#~ def to_s( target = Document.target( self ) )
|
|
492
493
|
def to_doc( target, options = {} )
|
|
493
494
|
o = Docgenerator_logger.set_option_defaults(options)
|
|
494
|
-
o[:log].debug("enter to_doc for #{self.inspect}") if o[:log].debug?
|
|
495
|
+
o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
|
|
495
496
|
#Return empty string, if target is not requested.
|
|
496
497
|
if ! @targets.include?( target )
|
|
497
498
|
if @suppressed_targets.include?(target)
|
|
@@ -511,29 +512,13 @@ code
|
|
|
511
512
|
result = ''
|
|
512
513
|
case target
|
|
513
514
|
when :latex
|
|
514
|
-
result = to_latex(
|
|
515
|
+
result = to_latex(o)
|
|
515
516
|
when :html
|
|
516
|
-
result = to_html(
|
|
517
|
+
result = to_html(o)
|
|
517
518
|
when :wiki
|
|
518
|
-
result = to_wiki(
|
|
519
|
+
result = to_wiki(o)
|
|
519
520
|
when :text
|
|
520
|
-
result = to_text(
|
|
521
|
-
when :debug
|
|
522
|
-
@@level += 1
|
|
523
|
-
result = "\n<element #{self.ids.join(',')} begin>"
|
|
524
|
-
@attr.each{|k,v|
|
|
525
|
-
#result += "\n\t#{k}: #{v.inspect}"
|
|
526
|
-
if v != []
|
|
527
|
-
result << "\n\t#{k}:"
|
|
528
|
-
v.each{|v2|
|
|
529
|
-
result << v2.to_s
|
|
530
|
-
}
|
|
531
|
-
end
|
|
532
|
-
}
|
|
533
|
-
result << @content.to_s
|
|
534
|
-
result << "\n<element #{self.ids.join(',')} end>"
|
|
535
|
-
@@level -= 1
|
|
536
|
-
result.gsub!(/^/, "\t" * @@level )
|
|
521
|
+
result = to_text(o)
|
|
537
522
|
else
|
|
538
523
|
o[:log].fatal("Undefined target format '#{target}'") if o[:log].fatal?
|
|
539
524
|
end
|
|
@@ -613,7 +598,7 @@ code
|
|
|
613
598
|
if @content
|
|
614
599
|
html << ">"
|
|
615
600
|
html <<"\n" if @crmid
|
|
616
|
-
html << "#{@content.to_html(options
|
|
601
|
+
html << "#{@content.to_html(options)}"
|
|
617
602
|
html << "\n" if @crmid and @content.size > 0 and html[-1,1] != "\n"
|
|
618
603
|
html << "</#{tag}>"
|
|
619
604
|
elsif content?() == nil
|
|
@@ -14,7 +14,7 @@ Element.create( [:head], {}, true,
|
|
|
14
14
|
{ :htmltag => 'head',
|
|
15
15
|
:latex => '#{@content}',
|
|
16
16
|
:text => '#{@content}',
|
|
17
|
-
:wiki => '
|
|
17
|
+
:wiki => '#{@content}',
|
|
18
18
|
} )
|
|
19
19
|
Element.create( [:body], {
|
|
20
20
|
:bgcolor => Attribute.create( [ :html ] ),
|
|
@@ -53,17 +53,21 @@ class Title < Element
|
|
|
53
53
|
}.update(HTML_ATTR_ALL)
|
|
54
54
|
)
|
|
55
55
|
#Unsaubere realisierung .. fixme
|
|
56
|
-
def shortoption()
|
|
56
|
+
def shortoption( options = {} )
|
|
57
57
|
@attr[:short].content.compact! #delete nils.
|
|
58
58
|
return nil if ! @attr[:short].filled?
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
60
|
+
o[:log].debug("enter shortoption") if o[:log].debug?
|
|
61
|
+
if o[:document]
|
|
62
|
+
if o[:document].template[:latex].template.include?('Beamer')
|
|
61
63
|
return "[#{@attr[:short].content}]"
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
end
|
|
65
|
+
else
|
|
66
|
+
o[:log].info("No related document for shortoption") if o[:log].info?
|
|
67
|
+
end
|
|
68
|
+
return nil
|
|
65
69
|
end
|
|
66
|
-
add_output( :latex, '#{linebreak(@crbefore)}\title#{shortoption}{#{@content}}#{linebreak(@crmid)}\hypersetup{pdftitle={#{@content}}}#{linebreak(@crafter)}')
|
|
70
|
+
add_output( :latex, '#{linebreak(@crbefore)}\title#{shortoption(o)}{#{@content}}#{linebreak(@crmid)}\hypersetup{pdftitle={#{@content}}}#{linebreak(@crafter)}')
|
|
67
71
|
#~ add_output( :latex, '#{linebreak(@crbefore)}\title{#{@content}}#{linebreak(@crmid)}\hypersetup{pdftitle={#{@content}}}#{linebreak(@crafter)}')
|
|
68
72
|
add_output( :html, '#{linebreak(@crbefore)}<title>#{@content}</title>#{linebreak(@crafter)}')
|
|
69
73
|
add_output( :text, "\n" + '#{linebreak(@crbefore)}#{@content}#{linebreak(@crafter)}' + "\n")
|
|
@@ -121,11 +125,72 @@ Element.create( [:maketitle], {}, false,
|
|
|
121
125
|
:html => "<!-- maketitle -->\n",
|
|
122
126
|
:latex => '#{linebreak(@crbefore)}' + '\maketitle #{linebreak(@crafter)}'
|
|
123
127
|
} )
|
|
124
|
-
Element.create( [:tableofcontents], {}, false,
|
|
125
|
-
{ :htmltag => 'span', #Empty span
|
|
126
|
-
:html =>
|
|
127
|
-
:latex => '#{linebreak(@crbefore)}' + '\tableofcontents ' + ' #{linebreak(@crafter)}'
|
|
128
|
-
} )
|
|
128
|
+
#~ Element.create( [:tableofcontents], {}, false,
|
|
129
|
+
#~ { :htmltag => 'span', #Empty span
|
|
130
|
+
#~ :html => '#{linebreak(@crbefore)}<!-- tableofcontents -->#{linebreak(@crafter)}',
|
|
131
|
+
#~ :latex => '#{linebreak(@crbefore)}' + '\tableofcontents ' + ' #{linebreak(@crafter)}'
|
|
132
|
+
#~ } )
|
|
133
|
+
|
|
134
|
+
#Build table of contents.
|
|
135
|
+
#
|
|
136
|
+
#This element requires a related document.
|
|
137
|
+
#
|
|
138
|
+
#For LaTeX \tableofcontents is created, with attribute :as_list you can create a list.
|
|
139
|
+
class Tableofcontents < Element
|
|
140
|
+
Element.add( [:tableofcontents], Tableofcontents)
|
|
141
|
+
add_attributes( {
|
|
142
|
+
:level => Attribute.create( [ :html, :latex ], [Fixnum], 1 ),
|
|
143
|
+
:pre => Attribute.create( [ :html, :latex ], nil, 2 ),
|
|
144
|
+
:post => Attribute.create( [ :html, :latex ], nil, 2 ),
|
|
145
|
+
:as_list => Attribute.create( [ :latex ], [true, false], 2 ),
|
|
146
|
+
}.update(HTML_ATTR_ALL)
|
|
147
|
+
)
|
|
148
|
+
def content?(); return false; end
|
|
149
|
+
def to_doc( target, options = {} )
|
|
150
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
151
|
+
o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
|
|
152
|
+
tocoptions = {
|
|
153
|
+
:level => @attr[:level].content.first,
|
|
154
|
+
:pre => @attr[:pre].content,
|
|
155
|
+
:post => @attr[:post].content,
|
|
156
|
+
:as_list => @attr[:as_list].content.first,
|
|
157
|
+
}.update(o)
|
|
158
|
+
tocoptions[:level] = 3 unless tocoptions[:level]
|
|
159
|
+
case target
|
|
160
|
+
when :latex
|
|
161
|
+
if @attr[:as_list].content.first
|
|
162
|
+
if o[:document]
|
|
163
|
+
return o[:document].toc(tocoptions).to_doc(target, options)
|
|
164
|
+
else
|
|
165
|
+
o[:log].error("No related document for tableofcontents") if o[:log].error?
|
|
166
|
+
return ''
|
|
167
|
+
end
|
|
168
|
+
else
|
|
169
|
+
return "#{linebreak(@crbefore)}\\tableofcontents #{linebreak(@crafter)}"
|
|
170
|
+
end
|
|
171
|
+
when :html
|
|
172
|
+
return to_html(tocoptions)
|
|
173
|
+
when :wiki, :text
|
|
174
|
+
if o[:document]
|
|
175
|
+
return o[:document].toc(tocoptions).to_doc(target, options)
|
|
176
|
+
else
|
|
177
|
+
o[:log].error("No related document for tableofcontents") if o[:log].error?
|
|
178
|
+
return ''
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
end
|
|
182
|
+
#Build toc, if there is a related document.
|
|
183
|
+
def to_html( options = {} )
|
|
184
|
+
o = Docgenerator_logger.set_option_defaults(options)
|
|
185
|
+
o[:log].debug("enter to_html for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
|
|
186
|
+
if o[:document]
|
|
187
|
+
return o[:document].toc(options).to_html(options)
|
|
188
|
+
else
|
|
189
|
+
o[:log].error("No related document for tableofcontents") if o[:log].error?
|
|
190
|
+
return "#{linebreak(@crbefore)}<!-- tableofcontents -->#{linebreak(@crafter)}"
|
|
191
|
+
end
|
|
192
|
+
end
|
|
193
|
+
end
|
|
129
194
|
Element.create( [:addcontentsline], {
|
|
130
195
|
:file => Attribute.create( [ :latex, :required ], [ 'toc', 'lof', 'lot' ] ),
|
|
131
196
|
:depth => Attribute.create( [ :latex, :required ], [ -1, 0,1,2,3,4,5,6] ),
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#
|
|
2
|
+
#Definition of templates.
|
|
3
|
+
#
|
|
4
|
+
#This templates are used for document types.
|
|
5
|
+
#
|
|
6
|
+
class CSS_collection
|
|
7
|
+
@@templates = {}
|
|
8
|
+
#
|
|
9
|
+
#Define a CSS template.
|
|
10
|
+
#
|
|
11
|
+
#If key is nil (or false), an anonym CSS-Collection is made
|
|
12
|
+
def initialize( key, descr )
|
|
13
|
+
@key = key
|
|
14
|
+
@descr = descr
|
|
15
|
+
@css = {}
|
|
16
|
+
if @@templates[key]
|
|
17
|
+
puts "DocumentTemplateCSS: Double definition of template #{key.inspect}"
|
|
18
|
+
end
|
|
19
|
+
@@templates[key] = self if @key
|
|
20
|
+
end
|
|
21
|
+
#Add a css definition to the collection.
|
|
22
|
+
#key is the CSS-locator, e.g. "div.toc ul li a"
|
|
23
|
+
def add( key, css)
|
|
24
|
+
@css[key] = css
|
|
25
|
+
end
|
|
26
|
+
#Returns the complete CSS-definition.
|
|
27
|
+
def css()
|
|
28
|
+
css_coll = "/*\n"
|
|
29
|
+
css_coll << "\t#{@descr}"
|
|
30
|
+
css_coll << "\n*/\n"
|
|
31
|
+
@css.each{|k,css|
|
|
32
|
+
css_coll << "#{k}\t{\n"
|
|
33
|
+
css_coll << css.to_html(:map => "\t%s;\n")
|
|
34
|
+
css_coll << "}\n"
|
|
35
|
+
}
|
|
36
|
+
css_coll
|
|
37
|
+
end
|
|
38
|
+
#Returns the Style definition for the HTTP-Head.
|
|
39
|
+
#
|
|
40
|
+
#Use it like this:
|
|
41
|
+
# doc.head << CSS_collection[:toc].style
|
|
42
|
+
def style()
|
|
43
|
+
return element(:style, {}, self.css )
|
|
44
|
+
end
|
|
45
|
+
#Get CSS_Collection.
|
|
46
|
+
def self.[]( key )
|
|
47
|
+
if @@templates[key]
|
|
48
|
+
return @@templates[key]
|
|
49
|
+
else
|
|
50
|
+
return nil
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
#Returns array with all defined template keys.
|
|
54
|
+
def self.keys()
|
|
55
|
+
return @@templates.keys
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
#
|
|
60
|
+
#Use it as:
|
|
61
|
+
# doc.head << CSS_collection[:toc].style
|
|
62
|
+
CSS_collection.new(:toc, 'CSS for table of contents')
|
|
63
|
+
CSS_collection[:toc].add('div.toc', CSS.new(
|
|
64
|
+
:float => 'right',
|
|
65
|
+
:width => '45%',
|
|
66
|
+
:background => 'lightgray',
|
|
67
|
+
:border => '2px solid'
|
|
68
|
+
))
|
|
69
|
+
CSS_collection[:toc].add('div.toc ul li a', CSS.new(
|
|
70
|
+
:font_size => 'xx-small',
|
|
71
|
+
:font_weight => 'normal'
|
|
72
|
+
))
|
|
73
|
+
|
|
@@ -17,7 +17,6 @@
|
|
|
17
17
|
# http://de.wikipedia.org/wiki/Wikipedia:Textbausteine/Schwesterprojekte
|
|
18
18
|
#- http://de.wikipedia.org/wiki/Wikipedia:Textbausteine
|
|
19
19
|
|
|
20
|
-
require 'C:/usr/Script/MyScripts' if File.exist?('C:/usr/Script/MyScripts.rb')
|
|
21
20
|
require 'docgenerator'
|
|
22
21
|
require 'log4r'
|
|
23
22
|
begin
|
|
@@ -168,7 +167,7 @@ WIKI_INLINE_REPLACEMENTS = [
|
|
|
168
167
|
linktext = m[1].sub(/http:\/\//, '').sub(/\/$/, '')
|
|
169
168
|
end
|
|
170
169
|
[ oo.inline(m.pre_match, log),
|
|
171
|
-
element(:a, {:href=> link_url }, oo.inline(linktext, log) )
|
|
170
|
+
element(:a, {:href=> link_url }, oo.inline(linktext, log) ),
|
|
172
171
|
oo.inline(m.post_match, log)
|
|
173
172
|
]
|
|
174
173
|
}
|
|
@@ -570,11 +569,17 @@ class Wikitext
|
|
|
570
569
|
when 'math'; return element(:ensuremath,{}, value )
|
|
571
570
|
#>>>requires privat/affiliate.rb
|
|
572
571
|
when 'asin'
|
|
573
|
-
|
|
572
|
+
return Amazon.new.asin_in_iframe( value ) if defined? JPC
|
|
573
|
+
log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
|
|
574
|
+
return ''
|
|
574
575
|
when 'amazon' #~ {{amazon|produktlinie|keywords}}
|
|
575
|
-
|
|
576
|
+
return Amazon.make_link(val) if defined? JPC
|
|
577
|
+
log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
|
|
578
|
+
return ''
|
|
576
579
|
when 'jpc' #~ {{amazon|produktlinie|keywords}}
|
|
577
|
-
|
|
580
|
+
return JPC.make_link(val) if defined? JPC
|
|
581
|
+
log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
|
|
582
|
+
return ''
|
|
578
583
|
#<<<requires privat/affiliate.rb
|
|
579
584
|
when 'fixme'
|
|
580
585
|
log.info( "Fixme: #{value}" ) if log.info?
|
|
@@ -939,20 +944,8 @@ class Wikitext
|
|
|
939
944
|
return intext
|
|
940
945
|
end
|
|
941
946
|
def toccss()
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
div.toc {
|
|
945
|
-
float: right;
|
|
946
|
-
width: 45%;
|
|
947
|
-
background: lightgray;
|
|
948
|
-
border: 2px solid;
|
|
949
|
-
}
|
|
950
|
-
div.toc ul li a {
|
|
951
|
-
font-size: xx-small;
|
|
952
|
-
font-weight: normal;
|
|
953
|
-
}
|
|
954
|
-
</style>
|
|
955
|
-
wikitoc
|
|
947
|
+
@log.error("Usage of obsolete toccss, use CSS_collection[:toc]") if @log.error?
|
|
948
|
+
return CSS_collection[:toc].style.to_html
|
|
956
949
|
end
|
|
957
950
|
#Make a table of contents
|
|
958
951
|
#
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<<prefix>>
|
|
2
|
+
\documentclass[class=scrartcl,ngerman]{beamer}
|
|
3
|
+
\usepackage{babel}
|
|
4
|
+
\usepackage{beamerbasearticle}
|
|
5
|
+
\usepackage[article]{beamertool}
|
|
6
|
+
\usepackage[ansinew]{inputenc}
|
|
7
|
+
\usepackage{hyperref}
|
|
8
|
+
% ----------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
%BibTeX-Entry>
|
|
11
|
+
%BibTeX-Entry<
|
|
12
|
+
\input{beamer_01_article.tex}
|
|
13
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<<prefix>>
|
|
2
|
+
% ----------------------------------------------------------------
|
|
3
|
+
|
|
4
|
+
%BibTeX-Entry>
|
|
5
|
+
%BibTeX-Entry<
|
|
6
|
+
|
|
7
|
+
% ----------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
%
|
|
10
|
+
% Big Pictures / Plainframes
|
|
11
|
+
\section{Enlarged Pictures}%\frame{\sectionpage}
|
|
12
|
+
|
|
13
|
+
\usebackgroundtemplate{}
|
|
14
|
+
|
|
15
|
+
% ----------------------------------------------------------------
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
<<prefix>>
|
|
3
|
+
-->
|
|
4
|
+
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
5
|
+
<html>
|
|
6
|
+
<head >
|
|
7
|
+
<title>Title</title>
|
|
8
|
+
<meta name="author" content="Knut Lickert">
|
|
9
|
+
<meta name="creation-date" content="2008-05-15">
|
|
10
|
+
<meta name = "shorttitle" content = "Short title" />
|
|
11
|
+
</head>
|
|
12
|
+
<body ></body>
|
|
13
|
+
</html>
|