docgenerator 0.1.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/docgenerator.rb
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
#Generic methods to create documents.
|
2
|
-
#The target format ia generic, supported are LaTeX and HTML.
|
3
|
-
#
|
4
|
-
#==Elements
|
5
|
-
#A document is structured by elements.
|
6
|
-
#Each element contains attributes/parameters and content.
|
7
|
-
#(Think of HTML-attributes and TeX-Parameters and the content of HTML-Tags and TeX-Environments.).
|
8
|
-
#
|
9
|
-
#Each element corresponds to a HTML-Tag or a LaTeX-Makro/Environment.
|
10
|
-
#There is a "translation" between HTML and LaTeX elements.
|
11
|
-
#
|
12
|
-
#Elements are defined by Element.get (or the method element() ),
|
13
|
-
#new element types can be defined with Element.create() ).
|
14
|
-
#
|
15
|
-
#Some elements (in fact, most of them) are generated dynamic,
|
16
|
-
#so they qill not occur in this generated documentation).
|
17
|
-
#== Examples
|
18
|
-
#See the file Example_DocGenerator.rb
|
19
|
-
#
|
20
|
-
#
|
21
|
-
#== Open topics
|
22
|
-
#- control content
|
23
|
-
# (Tag br in HTML klappt).
|
24
|
-
#- Wiki-Output
|
25
|
-
#- ASCII-Output
|
26
|
-
|
27
|
-
|
28
|
-
#How to handle the End-Tag for br/hr...
|
29
|
-
#-false: set <br /> (XHTML)
|
30
|
-
#-nil: set <br> (HTML)
|
31
|
-
#~ Problem:
|
32
|
-
#~ HTML darf keine Endtags haben, XHTML verlangt es.
|
33
|
-
#~ Die Konstante ENDTAG macht es einstellbar.
|
34
|
-
#~ Zu machen: Flag im Dokument ob HTML oder XHTML.
|
35
|
-
#~ Aber woher weiss element in welches Dokument es geh�rt?
|
36
|
-
#~ Gleiche Problem bei to_s, bzw. Document.target
|
37
|
-
ENDTAG = false if ! defined?( ENDTAG )
|
38
|
-
#filled in DocGeneratorTemplate.rb (or elsewhere)
|
39
|
-
SUPPORTED_LaTeX_TEMPLATES = [] if ! defined?( SUPPORTED_LaTeX_TEMPLATES )
|
40
|
-
SUPPORTED_HTML_TEMPLATES = [] if ! defined?( SUPPORTED_HTML_TEMPLATES )
|
41
|
-
|
42
|
-
#
|
43
|
-
#@target @@target hat noch bugs.
|
44
|
-
#mit UNDER_CONSTRUCTION = true kann der Testmodus
|
45
|
-
UNDER_CONSTRUCTION = false if ! defined?( UNDER_CONSTRUCTION )
|
46
|
-
|
47
|
-
module Backlinks
|
48
|
-
def set_backlink( content)
|
49
|
-
#Prepare backword link
|
50
|
-
cl = [ content ].flatten #content list
|
51
|
-
cl.each{|c|
|
52
|
-
if c.respond_to?( :part_of )
|
53
|
-
c.part_of << self
|
54
|
-
end
|
55
|
-
if c.respond_to?( :part_of_doc )
|
56
|
-
c.part_of_doc << self.part_of_doc
|
57
|
-
c.part_of_doc.flatten!
|
58
|
-
#fixme Hier auch attribute backlink setzen?
|
59
|
-
if c.part_of_doc.include?( nil )
|
60
|
-
raise "Add nil as document in #{self.inspect}"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
#Log in case of error.
|
64
|
-
if UNDER_CONSTRUCTION and
|
65
|
-
! ( c.respond_to?( :part_of ) or c.respond_to?( :part_of_doc ) ) and
|
66
|
-
! (c.is_a?(String) or c.is_a?(Fixnum) )
|
67
|
-
puts "set_backlink: Not supported by #{c.inspect} in #{self.inspect} (#{c.respond_to?( :part_of )}/#{c.respond_to?( :part_of_doc )})"
|
68
|
-
end
|
69
|
-
|
70
|
-
}
|
71
|
-
return self
|
72
|
-
end
|
73
|
-
#List of elements, where this element is part of.
|
74
|
-
#Filled by << in the superior element.
|
75
|
-
#Normaly only one element
|
76
|
-
attr_reader :part_of
|
77
|
-
#List of documents, where this element is part of.
|
78
|
-
#Filled by << in the superior element.
|
79
|
-
#Normaly only one element
|
80
|
-
attr_reader :part_of_doc
|
81
|
-
#Return an array with all ancestors.
|
82
|
-
#contains pairs of: [ ancestor, [array of ancestors ancestors]]
|
83
|
-
def ancestors
|
84
|
-
anc = []
|
85
|
-
@part_of.each{|a|
|
86
|
-
anc << a
|
87
|
-
anc << a.ancestors if a.respond_to?(:ancestors)
|
88
|
-
}
|
89
|
-
return anc
|
90
|
-
end
|
91
|
-
end
|
92
|
-
require 'docgenerator_element'
|
93
|
-
|
94
|
-
#Returns an element of a type "name".
|
95
|
-
#Attributes and content are optional parameter.
|
96
|
-
#
|
97
|
-
def element( name, attr = {}, content = nil )
|
98
|
-
element = Element.get( name )
|
99
|
-
if element
|
100
|
-
element = element.new(attr, content ) if element
|
101
|
-
else
|
102
|
-
element = Element.create( name, {}, true ).new(attr, content )
|
103
|
-
puts "Usage of undefined element #{name}"
|
104
|
-
end
|
105
|
-
return element
|
106
|
-
end
|
107
|
-
|
108
|
-
require 'docgenerator_template'
|
109
|
-
require 'docgenerator_css'
|
110
|
-
require 'docgenerator_attribute'
|
111
|
-
require 'docgenerator_document'
|
112
|
-
|
113
|
-
#~ require 'DocGenerator_HTML' if __FILE__ != 'DocGenerator_HTML' #and __FILE__ != $0
|
114
|
-
#~ require 'DocGenerator_LaTeX' if __FILE__ != 'DocGenerator_LaTeX' #and __FILE__ != $0
|
115
|
-
require 'docgenerator_elements'
|
116
|
-
require 'docgenerator_environments'
|
117
|
-
require 'docgenerator_lists' #define environment
|
118
|
-
require 'docgenerator_sections'
|
119
|
-
require 'docgenerator_tabular'
|
120
|
-
require 'docgenerator_footnote'
|
121
|
-
require 'docgenerator_characters' #special characters (spaces, euro-sign...)
|
122
|
-
|
123
|
-
__END__
|
124
|
-
class Test
|
125
|
-
def required?(); true; end
|
126
|
-
end
|
127
|
-
test = Test.new()
|
128
|
-
puts test.required?
|
129
|
-
Test.class_eval('def required?(); false; end')
|
130
|
-
puts test.required?
|
131
|
-
|
132
|
-
testclass2 = Class.new( Test )
|
133
|
-
test2 = testclass2.new()
|
134
|
-
puts test2.required?
|
135
|
-
testclass2.class_eval('def required?(); true; end')
|
136
|
-
puts test2.required?
|
137
|
-
puts test.required?
|
data/docgenerator_template.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
if __FILE__ == $0
|
2
|
-
require 'DocGenerator'
|
3
|
-
end
|
4
|
-
|
5
|
-
class DocumentTemplate
|
6
|
-
@@templates = {}
|
7
|
-
def DocumentTemplate.add_template( key, target, template)
|
8
|
-
@@templates[key] = template.gsub(/^\t*/, '') #fixme check uniqi
|
9
|
-
case target
|
10
|
-
when nil
|
11
|
-
when :latex
|
12
|
-
SUPPORTED_LaTeX_TEMPLATES << key
|
13
|
-
when :html
|
14
|
-
SUPPORTED_HTML_TEMPLATES << key
|
15
|
-
end
|
16
|
-
end
|
17
|
-
def DocumentTemplate.[]( key )
|
18
|
-
if @@templates[key]
|
19
|
-
return @@templates[key].dup
|
20
|
-
else
|
21
|
-
puts "Template unknown: #{key}"
|
22
|
-
return nil
|
23
|
-
end
|
24
|
-
end
|
25
|
-
def DocumentTemplate.keys()
|
26
|
-
return @@templates.keys
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
DocumentTemplate.add_template(
|
32
|
-
:include, :latex, %q|<<prefix>>
|
33
|
-
% ----------------------------------------------------------------
|
34
|
-
<<head>>
|
35
|
-
% ----------------------------------------------------------------
|
36
|
-
<<body>>
|
37
|
-
% ----------------------------------------------------------------
|
38
|
-
|)
|
39
|
-
|
40
|
-
DocumentTemplate.add_template(
|
41
|
-
:article, :latex, %q|<<prefix>>
|
42
|
-
\documentclass[<<classoptions>>]{scrartcl}
|
43
|
-
\usepackage{babel}
|
44
|
-
\usepackage[ansinew]{inputenc}
|
45
|
-
\usepackage{hyperref}
|
46
|
-
% ----------------------------------------------------------------
|
47
|
-
<<head>>
|
48
|
-
% ----------------------------------------------------------------
|
49
|
-
\begin{document}
|
50
|
-
<<body>>
|
51
|
-
\end{document}
|
52
|
-
% ----------------------------------------------------------------
|
53
|
-
|)
|
54
|
-
#~ DocumentTemplate.add_template(
|
55
|
-
#~ :report, '',
|
56
|
-
#~ |)
|
57
|
-
#~ DocumentTemplate.add_template(
|
58
|
-
#~ :book, '',
|
59
|
-
#~ |)
|
60
|
-
|
61
|
-
#~ <!doctype html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
62
|
-
|
63
|
-
DocumentTemplate.add_template(
|
64
|
-
:html, :html, %q|<!--
|
65
|
-
<<prefix>>
|
66
|
-
-->
|
67
|
-
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
|
68
|
-
<html>
|
69
|
-
<<head>>
|
70
|
-
<<body>>
|
71
|
-
</html>
|
72
|
-
|)
|
73
|
-
|
74
|
-
{
|
75
|
-
:xhtml_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
|
76
|
-
:xhtml_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
|
77
|
-
:html401_strict => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
|
78
|
-
:html401_trans => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
|
79
|
-
}.each{ |key, doctype|
|
80
|
-
DocumentTemplate.add_template(
|
81
|
-
key, :html, %Q|<!--
|
82
|
-
<<prefix>>
|
83
|
-
-->
|
84
|
-
#{doctype}
|
85
|
-
<html>
|
86
|
-
|
87
|
-
<<head>>
|
88
|
-
|
89
|
-
<<body>>
|
90
|
-
</html>
|
91
|
-
|)
|
92
|
-
}
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
DocumentTemplate.add_template(
|
97
|
-
:text, :text, %q|
|
98
|
-
<<body>>
|
99
|
-
|)
|
100
|
-
DocumentTemplate.add_template(
|
101
|
-
:wiki, :wiki, %q|
|
102
|
-
<<body>>
|
103
|
-
|)
|
@@ -1,250 +0,0 @@
|
|
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.add_template(: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(/^\t*/, ''))
|
16
|
-
DocumentTemplate.add_template(: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(/^\t*/, ''))
|
26
|
-
[
|
27
|
-
:beamerthemebars, :beamerthemeboxes, :beamerthemeclassic,
|
28
|
-
:beamerthemelined, :beamerthemeplain, :beamerthemesidebar,
|
29
|
-
:beamerthemesidebardark, :beamerthemesidebardarktab,
|
30
|
-
:beamerthemesidebartab, :beamerthemesplit,
|
31
|
-
:beamerthemesplitcondensed, :beamerthemetree,
|
32
|
-
:beamerthemevcd,
|
33
|
-
].each{ |theme|
|
34
|
-
DocumentTemplate.add_template(theme, :latex, DocumentTemplate[:beamerhead].sub(/%<<theme>>/, "\\usepackage{#{theme}}"))
|
35
|
-
}
|
36
|
-
DocumentTemplate.add_template(:beamerarticle, :latex, %q|<<prefix>>
|
37
|
-
\documentclass[class=scrartcl,<<classoptions>>]{beamer}
|
38
|
-
\usepackage{babel}
|
39
|
-
\usepackage{beamerbasearticle}
|
40
|
-
\usepackage[article]{beamertool}
|
41
|
-
\usepackage[ansinew]{inputenc}
|
42
|
-
\usepackage{hyperref}
|
43
|
-
% ----------------------------------------------------------------
|
44
|
-
<<head>>
|
45
|
-
|.gsub(/^\t*/, ''))
|
46
|
-
|
47
|
-
|
48
|
-
#Define TeX-Kommands
|
49
|
-
|
50
|
-
#frame -- environment.
|
51
|
-
#options
|
52
|
-
#~ Element.create( :frame, {}, true, {
|
53
|
-
#~ :latex => '#{linebreak(@crbefore)}\frame{#{@content}}#{linebreak(@crafter)}'
|
54
|
-
#~ } )
|
55
|
-
|
56
|
-
class Frame < Element
|
57
|
-
add_attributes( {
|
58
|
-
:options => Attribute.create( [ :latex ], [nil, 'fragile', 't', 'b'] ),
|
59
|
-
}.update( HTML_ATTR_ALL ) )
|
60
|
-
Element.add( [:frame], Frame)
|
61
|
-
#Returns a div-element.
|
62
|
-
#The class for the css is set to 'frame' (if not defined before).
|
63
|
-
def htmltag( )
|
64
|
-
if @attr[:class].content.empty?
|
65
|
-
@attr[:class] << :frame
|
66
|
-
end
|
67
|
-
'div'
|
68
|
-
end
|
69
|
-
def to_latex( )
|
70
|
-
option = "[#{@attr[:options].content.join(',')}]"
|
71
|
-
option = nil if option == '[]'
|
72
|
-
#~ return "#{linebreak(@crbefore)}\\frame#{option}{\n#{@content}}#{linebreak(@crafter)}"
|
73
|
-
return "#{linebreak(@crbefore)}\\begin{frame}#{option}\n#{@content}\n\\end{frame}#{linebreak(@crafter)}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
#
|
78
|
-
#Frametitle.
|
79
|
-
#Can be changed by
|
80
|
-
# Element.get( :frametitle ).class_eval( "def htmltag(); 'h4'; end")
|
81
|
-
Element.create( :frametitle, { }, true, {
|
82
|
-
:latex => '#{linebreak(@crbefore)}\frametitle{#{@content}}#{linebreak(@crafter)}',
|
83
|
-
:htmltag => 'p', #'h4',
|
84
|
-
:html => '#{linebreak(@crbefore)}<#{htmltag} class = "frametitle">#{@content}</#{htmltag}>#{linebreak(@crafter)}',
|
85
|
-
} )
|
86
|
-
|
87
|
-
Element.create( :block, {
|
88
|
-
:title => Attribute.create( [ :latex ] ),
|
89
|
-
}, true, {
|
90
|
-
:latex => '#{linebreak(@crbefore)}' + '\begin{block}{#{@attr[:title]}}' + '#{linebreak(@crmid)}' + '#{@content}\end{block}' + '#{linebreak(@crafter)}'
|
91
|
-
} )
|
92
|
-
|
93
|
-
#
|
94
|
-
# Notes in Beamer.
|
95
|
-
#
|
96
|
-
Element.create( :note, { }, true, {
|
97
|
-
:latex => '#{linebreak(@crbefore)}\note{#{@content}}#{linebreak(@crafter)}',
|
98
|
-
:htmltag => 'p', #'h4',
|
99
|
-
:html => '#{linebreak(@crbefore)}<#{htmltag} class = "note">#{@content}</#{htmltag}>#{linebreak(@crafter)}',
|
100
|
-
} )
|
101
|
-
|
102
|
-
#\framePic{filename}{
|
103
|
-
# description
|
104
|
-
#}
|
105
|
-
#~ Element.create( :framepic, { :file => Attribute.create( [ :required ] ),
|
106
|
-
#~ :link => Attribute.create( )
|
107
|
-
#~ }, true, {
|
108
|
-
#~ :latex => '\framePic{#{@attr[:file]}}{#{@content}}'
|
109
|
-
#~ } )
|
110
|
-
|
111
|
-
Element.create( :institute, {
|
112
|
-
}, true, {
|
113
|
-
:latex => '#{linebreak(@crbefore)}' + '\institute{#{@content}}' + '#{linebreak(@crafter)}'
|
114
|
-
} )
|
115
|
-
|
116
|
-
Element.create( :subtitle, {
|
117
|
-
}, true, {
|
118
|
-
:latex => '#{linebreak(@crbefore)}' + '\subtitle{#{@content}}' + '#{linebreak(@crafter)}'
|
119
|
-
} )
|
120
|
-
|
121
|
-
begin
|
122
|
-
#define Knut::Picture
|
123
|
-
require 'knut_picture'
|
124
|
-
rescue
|
125
|
-
#Define Knut::Picture with reduced functionality
|
126
|
-
module Knut
|
127
|
-
class Picture
|
128
|
-
def initialize( filename )
|
129
|
-
@filename = filename
|
130
|
-
@basename = File.basename(@filename)
|
131
|
-
@dir = File.dirname(@filename)
|
132
|
-
if ! File.exists?( @filename )
|
133
|
-
puts "#{self.class}: #{@filename} not found"
|
134
|
-
else
|
135
|
-
@size = File.size(@filename)
|
136
|
-
@sizekb = @size / 1024
|
137
|
-
end
|
138
|
-
end
|
139
|
-
#Filename including the path
|
140
|
-
attr_reader :filename
|
141
|
-
#Directory of the picture
|
142
|
-
attr_reader :dir
|
143
|
-
attr_reader :basename
|
144
|
-
def tech_description()
|
145
|
-
"#{@basename} (#{@sizekb}KB)"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
class Framepic < Element
|
152
|
-
Element.add( [:framepic], Framepic)
|
153
|
-
add_attributes( {
|
154
|
-
:file => Attribute.create( [ :required ] ),
|
155
|
-
:link => Attribute.create( ),
|
156
|
-
}.update( HTML_ATTR_ALL ) )
|
157
|
-
#container for the picture
|
158
|
-
def picture()
|
159
|
-
@picture = Knut::Picture.new( @attr[:file].content.first ) if ! @picture
|
160
|
-
@picture
|
161
|
-
end
|
162
|
-
attr_accessor :div_css
|
163
|
-
attr_accessor :img_css
|
164
|
-
attr_accessor :div_class
|
165
|
-
attr_accessor :img_class
|
166
|
-
attr_accessor :picwithname
|
167
|
-
def to_html()
|
168
|
-
html = [] #element(:div, {:class => :framepic })
|
169
|
-
#~ if @attr[:link].content.size > 0
|
170
|
-
#~ html << "[#{@attr[:link]}]"
|
171
|
-
#~ end
|
172
|
-
|
173
|
-
html << div_img = element(:div ).CR
|
174
|
-
if self.picture.href
|
175
|
-
div_img << element(:a, { :href => self.picture.href },
|
176
|
-
img = element(:img )
|
177
|
-
)
|
178
|
-
else
|
179
|
-
div_img << img = element(:img )
|
180
|
-
end
|
181
|
-
if self.picture.thumbname and self.picture.usethumb?
|
182
|
-
img[:src] << self.picture.thumbname
|
183
|
-
else
|
184
|
-
img[:src] << self.picture.filename
|
185
|
-
end
|
186
|
-
@div_css = CSS.new() if ! @div_css
|
187
|
-
div_img[:class] << @div_class if @div_class
|
188
|
-
div_img[:style] << @div_css
|
189
|
-
div_img[:align] << 'center' if div_img[:align].content.empty?
|
190
|
-
img[:class] << @img_class if @img_class
|
191
|
-
img[:style] << @img_css if @img_css
|
192
|
-
if picwithname
|
193
|
-
div_img << element(:br ).cr
|
194
|
-
div_img << element(:footnotesize, {}, self.picture.tech_description)
|
195
|
-
end
|
196
|
-
html << @content
|
197
|
-
return html.to_s
|
198
|
-
end
|
199
|
-
def to_latex()
|
200
|
-
result = ""
|
201
|
-
result << "\n" if @crbefore
|
202
|
-
result << "\\framePic"
|
203
|
-
if self.div_css #Check alignment
|
204
|
-
case self.div_css[:float]
|
205
|
-
when nil, 'left' #standard
|
206
|
-
when 'right'
|
207
|
-
result << "[right]"
|
208
|
-
else
|
209
|
-
puts "#{__FILE__}##{__LINE__}: Undefined float '#{self.div_css[:float]}' for TeX"
|
210
|
-
end
|
211
|
-
end
|
212
|
-
result << "{#{self.picture.filename}}"
|
213
|
-
if @attr[:link].content.size > 0
|
214
|
-
result << "[#{@attr[:link]}]"
|
215
|
-
end
|
216
|
-
result << "{"
|
217
|
-
result << "\n" if @crmid
|
218
|
-
result << "#{@content}"
|
219
|
-
result << "\n" if @crmid
|
220
|
-
result << "}"
|
221
|
-
result << "\n" if @crafter
|
222
|
-
return result
|
223
|
-
end
|
224
|
-
end
|
225
|
-
|
226
|
-
|
227
|
-
Element.create( :includegraphicsJustified, {}, true, {
|
228
|
-
:latex => '\includegraphicsJustified{#{@content}}',
|
229
|
-
:html => '<img src = "#{@content}" style = "max-width: 80%" />',
|
230
|
-
} )
|
231
|
-
|
232
|
-
#fixme --> docgenerator_color ?
|
233
|
-
class Textcolor < Element
|
234
|
-
Element.add( [:textcolor], Textcolor)
|
235
|
-
add_attributes( { :mode => Attribute.create( [ :required ], [:rgb] ),
|
236
|
-
:color => Attribute.create( [ :required ], [String] ),
|
237
|
-
} )
|
238
|
-
def to_latex()
|
239
|
-
result = ""
|
240
|
-
result << "\n" if @crbefore
|
241
|
-
result << "\\textcolor[#{attr[:mode]}]{#{@attr[:color]}}"
|
242
|
-
result << "\n" if @crmid
|
243
|
-
result << "{"
|
244
|
-
result << "#{@content}"
|
245
|
-
result << "\n" if @crmid
|
246
|
-
result << "}"
|
247
|
-
result << "\n" if @crafter
|
248
|
-
return result
|
249
|
-
end
|
250
|
-
end
|