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
@@ -0,0 +1,68 @@
|
|
1
|
+
#
|
2
|
+
#Create a test-document with docgenerator.rb.
|
3
|
+
#
|
4
|
+
|
5
|
+
#~ require 'rubygems'
|
6
|
+
$: << ".." #for local tests with uninstalled gem
|
7
|
+
require 'docgenerator'
|
8
|
+
|
9
|
+
#
|
10
|
+
# Create a document
|
11
|
+
#
|
12
|
+
doc = Document.new(
|
13
|
+
:title => 'Testdocument with tabulars'
|
14
|
+
)
|
15
|
+
|
16
|
+
#~ doc.head << element( :usepackage, { }, 'longtable' )
|
17
|
+
#~ doc.head << element( :usepackage, { :option => [] }, 'longtable' )
|
18
|
+
|
19
|
+
#
|
20
|
+
# Set some settings
|
21
|
+
#
|
22
|
+
#~ doc.title ='Titel'
|
23
|
+
#~ doc.author = 'Authorname'
|
24
|
+
#~ doc.date = 'Datum'
|
25
|
+
#~ doc.keywords = 'Test, DocGenerator.rb'
|
26
|
+
#~ doc.description = 'Testdokument f�r DocGenerator.rb'
|
27
|
+
|
28
|
+
#
|
29
|
+
doc.body << element(:maketitle) #Only LaTeX
|
30
|
+
doc.body[:lang] << 'de' #language flag for HTML
|
31
|
+
|
32
|
+
doc.body << element(:h1, {}, 'Tabellen').cr
|
33
|
+
|
34
|
+
def mk_tabular( columns, lines )
|
35
|
+
|
36
|
+
tab = element(:tabular, {
|
37
|
+
:columns => columns.size, #for HTML
|
38
|
+
:columndescription => 'c' * columns.size #for LaTeX
|
39
|
+
} ).CR
|
40
|
+
|
41
|
+
tab << row = element( :row, {:add_vspace=>'1ex'} ).cr
|
42
|
+
row << element(:multicolumn, {
|
43
|
+
:columns => columns.size,
|
44
|
+
:pos => 'c', #LaTeX
|
45
|
+
}, 'Titel' )
|
46
|
+
row.hline #Only LaTeX
|
47
|
+
|
48
|
+
lines.each{|line|
|
49
|
+
tab << row = element( :row ).cr
|
50
|
+
columns.each{|column|
|
51
|
+
row << element(:column, {}, "#{line}#{column}" )
|
52
|
+
}
|
53
|
+
}
|
54
|
+
return tab
|
55
|
+
end
|
56
|
+
|
57
|
+
doc.body << mk_tabular( Array('A'..'D'), Array(1..5) )
|
58
|
+
doc.body << mk_tabular( Array('A'..'F'), Array(1..5) )
|
59
|
+
|
60
|
+
|
61
|
+
# ###############################
|
62
|
+
# �Save the files
|
63
|
+
# ###############
|
64
|
+
|
65
|
+
#~ Element.log = true #Write Errors to stdout
|
66
|
+
doc.save( __FILE__.sub(/\.rb/, ".html"), true )
|
67
|
+
doc.runtex = true
|
68
|
+
doc.save( __FILE__.sub(/\.rb/, ".tex"), true )
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#
|
2
|
+
#Create a test-document with docgenerator.rb.
|
3
|
+
#
|
4
|
+
|
5
|
+
#~ require 'rubygems'
|
6
|
+
$: << ".." #for local tests with uninstalled gem
|
7
|
+
require 'docgenerator'
|
8
|
+
|
9
|
+
#
|
10
|
+
# Create a document
|
11
|
+
#
|
12
|
+
doc = Document.new(
|
13
|
+
:title => 'Testdocument with tripfalls'
|
14
|
+
)
|
15
|
+
|
16
|
+
#~ doc.head << element( :usepackage, { }, 'longtable' )
|
17
|
+
#~ doc.head << element( :usepackage, { :option => [] }, 'longtable' )
|
18
|
+
|
19
|
+
#
|
20
|
+
# Set some settings
|
21
|
+
#
|
22
|
+
#~ doc.title ='Titel'
|
23
|
+
#~ doc.author = 'Authorname'
|
24
|
+
#~ doc.date = 'Datum'
|
25
|
+
#~ doc.keywords = 'Test, DocGenerator.rb'
|
26
|
+
#~ doc.description = 'Testdokument f�r DocGenerator.rb'
|
27
|
+
|
28
|
+
#
|
29
|
+
doc.body << element(:maketitle) #Only LaTeX
|
30
|
+
doc.body[:lang] << 'de' #language flag for HTML
|
31
|
+
|
32
|
+
doc.body << element(:h1, {}, 'Generell Tripfalls').cr
|
33
|
+
puts '!And now an error: Content added to makro without content'
|
34
|
+
doc.body << element( :br, {}, 'Text in br' ).cr
|
35
|
+
|
36
|
+
|
37
|
+
doc.body << element(:h1, {}, 'Tripfalls with HTML').cr
|
38
|
+
doc.body << element(:h2, {}, 'Paragraph forgotten?').cr
|
39
|
+
doc.body << <<txt
|
40
|
+
When you use CSS, you define a layout for
|
41
|
+
txt
|
42
|
+
|
43
|
+
doc.body << element(:h1, {}, 'Tripfalls with LaTeX').cr
|
44
|
+
doc.body << element(:h2, {}, 'Tabulars').cr
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
# ###############################
|
51
|
+
# �Save the files
|
52
|
+
# ###############
|
53
|
+
|
54
|
+
#~ Element.log = true #Write Errors to stdout
|
55
|
+
doc.save( __FILE__.sub(/\.rb/, ".html"), true )
|
56
|
+
doc.runtex = true
|
57
|
+
doc.save( __FILE__.sub(/\.rb/, ".tex"), true )
|
@@ -0,0 +1,270 @@
|
|
1
|
+
require 'C:/usr/Script/MyScripts' if File.exist?('C:/usr/Script/MyScripts.rb')
|
2
|
+
#~ require 'docgenerator'
|
3
|
+
require 'wiki2docgenerator' if ! defined? Wikitext
|
4
|
+
#~ require '20070622_wiki2docgenerator' if ! defined? Wikitext
|
5
|
+
|
6
|
+
#~ Element.log(true)
|
7
|
+
#~ Element.trace==true
|
8
|
+
|
9
|
+
wiki = Wikitext.new( :parsetext => true )
|
10
|
+
wiki << DATA#.readlines.to_s
|
11
|
+
#~ wiki << %q|
|
12
|
+
#~ |
|
13
|
+
|
14
|
+
doc = Document.new()
|
15
|
+
doc.title = 'wiki2docgenerator_example.rb: Test for wiki2docgenerator'
|
16
|
+
#For TeX you can use element(:tableofcontent),
|
17
|
+
#in HTML you can use element( :toc, :h3) in combination with sitegenerator
|
18
|
+
doc.body << wiki.toc( #include the toc
|
19
|
+
:listtype => :ul,
|
20
|
+
:level => 2,
|
21
|
+
:startlevel => 1,
|
22
|
+
:addlinks => false
|
23
|
+
)
|
24
|
+
doc.body << wiki
|
25
|
+
doc.body << wiki.footnotes #include the footnotes
|
26
|
+
doc.save('test_wiki2docgenerator.html', true)
|
27
|
+
doc.save('test_wiki2docgenerator.wiki', true)
|
28
|
+
doc.save('test_wiki2docgenerator.txt', true)
|
29
|
+
doc.save('test_wiki2docgenerator.tex', true)
|
30
|
+
|
31
|
+
__END__
|
32
|
+
==Wiki2docgenerator.rb==
|
33
|
+
The class Wiki2docgenerator allows to analyse a text in Wiki-format and
|
34
|
+
transform it to a "docgenerator"-object.
|
35
|
+
|
36
|
+
This object can be saved as HTML or TeX (or Wiki again - in preparation).
|
37
|
+
|
38
|
+
The wiki-syntax is defined at:
|
39
|
+
*http://de.wikipedia.org/wiki/WikiSyntax
|
40
|
+
*http://de.wikipedia.org/wiki/Hilfe:Textgestaltung
|
41
|
+
|
42
|
+
Not the complete Syntax is used or supported.
|
43
|
+
Please check the following example coding for the features.
|
44
|
+
|
45
|
+
Example-Programm:
|
46
|
+
doc == Document.new()
|
47
|
+
doc.title == 'Test'
|
48
|
+
doc.body << wiki.toc #include the table of content
|
49
|
+
doc.body << wiki.to_element
|
50
|
+
doc.body << wiki.footnotes #include the footnotes
|
51
|
+
doc.save('test.html', true)
|
52
|
+
doc.save('test.wiki', true)
|
53
|
+
doc.save('test.txt', true)
|
54
|
+
doc.save('test.tex', true)
|
55
|
+
|
56
|
+
==Titel 1==
|
57
|
+
===Titel 2===
|
58
|
+
#~ =====Titel 4 ohne 3=====
|
59
|
+
====Titel 3====
|
60
|
+
=====Titel 4=====
|
61
|
+
=====[label]Titel 4 mit label=====
|
62
|
+
|
63
|
+
text text.
|
64
|
+
Mehr text im gleichen Absatz.
|
65
|
+
|
66
|
+
text in neuem Absatz
|
67
|
+
|
68
|
+
|
69
|
+
==Listen==
|
70
|
+
===Normale Punkt-Liste===
|
71
|
+
* liste *
|
72
|
+
* liste *
|
73
|
+
** liste **
|
74
|
+
** liste **
|
75
|
+
*** liste ***
|
76
|
+
**** liste ****
|
77
|
+
*** liste ***
|
78
|
+
* liste *
|
79
|
+
|
80
|
+
===Nummerierte Liste===
|
81
|
+
# liste 1
|
82
|
+
# liste 2
|
83
|
+
## liste 2-1
|
84
|
+
# liste 3
|
85
|
+
|
86
|
+
===Gemischte Liste===
|
87
|
+
# Liste num
|
88
|
+
#* liste num-*
|
89
|
+
## liste num-num
|
90
|
+
|
91
|
+
===Punkte- und Nummerierte Liste nacheinander===
|
92
|
+
*list *
|
93
|
+
#list 1
|
94
|
+
|
95
|
+
===Wilde Mischung Punkte- und Nummerierte Liste nacheinander===
|
96
|
+
*list (*)
|
97
|
+
**list (**)
|
98
|
+
#*list (#*) Hier Wechsel auf erster Ebene
|
99
|
+
|
100
|
+
===Definitionsliste ===
|
101
|
+
;Definitionsliste
|
102
|
+
:Liste von Definitionen
|
103
|
+
:Liste von Definitionen
|
104
|
+
;Begriff
|
105
|
+
:Definition des Begriffs
|
106
|
+
|
107
|
+
===Mehrzeilige Listen===
|
108
|
+
* vorher
|
109
|
+
* text
|
110
|
+
mehr text zum item
|
111
|
+
* nachher und vorher
|
112
|
+
* text
|
113
|
+
mehr text zum item
|
114
|
+
|
115
|
+
neuer Absatz im Item funktioniert auch.
|
116
|
+
* nachher
|
117
|
+
|
118
|
+
===Einr�ckungen===
|
119
|
+
Nicht realisiert, macht implizit Definitionsliste (fixme)
|
120
|
+
: Text macht implizit Definitionsliste (fixme)
|
121
|
+
:: Noch tiefer
|
122
|
+
|
123
|
+
===Fu�noten===
|
124
|
+
Einf�gen mit {{footnote|Fu�notentext}}
|
125
|
+
{{footnote|Fu�notentext}}
|
126
|
+
|
127
|
+
Ausgegeben werden die Fu�noten mit
|
128
|
+
{{footnotes}}
|
129
|
+
{{footnotes|groupid}}
|
130
|
+
|
131
|
+
Die groupid-Variante erm�glicht verschiedene Fu�notenk�rper.
|
132
|
+
(Nur bei HTML-Ausgabe, die Fu�notendefinition erlaubt noch keine Gruppen)
|
133
|
+
|
134
|
+
Und jetzt die Fu�noten:
|
135
|
+
{{footnotes}}
|
136
|
+
#~ Im verarbeitenden Ruby-Programm k�nnen die Fu�noten extra eingef�gt werden.
|
137
|
+
#~ doc.body << wiki.footnotes #include the footnotes
|
138
|
+
|
139
|
+
|
140
|
+
===Allgemeine Formatierungen===
|
141
|
+
Eine
|
142
|
+
----
|
143
|
+
Linie
|
144
|
+
|
145
|
+
==Inline-Formatierungen==
|
146
|
+
===Textformatierungen===
|
147
|
+
Inline-Tags ''kursiv'', '''fett''', ''''kursiv und fett''''
|
148
|
+
|
149
|
+
''kursiv'',
|
150
|
+
'''fett''',
|
151
|
+
''''kursiv und fett''''
|
152
|
+
|
153
|
+
=== Verbatim ===
|
154
|
+
Text vor Verbatim
|
155
|
+
pretext
|
156
|
+
pretext sss
|
157
|
+
Jetzt kein Verbatim mehr
|
158
|
+
|
159
|
+
==Bilder==
|
160
|
+
Details siehe http://de.wikipedia.org/wiki/Hilfe:Bilder
|
161
|
+
|
162
|
+
Bilder lassen sich mit [ [Bild:Dateiname|Beschreibung]] in Artikel einf�gen.
|
163
|
+
Das Bild wird dann in Originalgr��e links im Artikel angezeigt.
|
164
|
+
|
165
|
+
Parameter sind optional mit [ [Bild:Dateiname|parameter|Beschreibung]] anzugeben.
|
166
|
+
Es sind beliebig viele, mit | getrennte Parameter m�glich.
|
167
|
+
|
168
|
+
Unterst�tzt sind:
|
169
|
+
*left, right: Ausgabe als Float
|
170
|
+
*123px: width wird gesetzt
|
171
|
+
*thumb: noch keine Auswertung
|
172
|
+
#~ Mit der Option �framed�, z. B. [[Bild:Dateiname|framed|Beschreibung]] wird das Bild mit einem Rahmen umgeben.
|
173
|
+
*par==val: Der CSS-Parameter ''par'' wird mit dem Wert ''val'' versorgt. (Kein Wiki-Standard, sondern eine Spezialit�t von wiki2docgenerator)
|
174
|
+
|
175
|
+
Besonderheiten:
|
176
|
+
*Die Beschreibung wird in einen ''alt''-Tag verwendet.
|
177
|
+
|
178
|
+
==Tabellen==
|
179
|
+
Die Syntax:
|
180
|
+
*{| beginnt eine Tabelle. Hier k�nnen zus�tzliche Formatierungseigenschaften kommen.
|
181
|
+
**Zumindest columns==__ sollte gesetzt sein
|
182
|
+
*! beginnt eine neue Zelle einer Titelzeile
|
183
|
+
*| beginnt eine neue Zelle
|
184
|
+
*|| trennt zwei Zellen (nicht unterst�tzt)
|
185
|
+
*|format| z.B. rowspan...
|
186
|
+
*|format|| Zwei || beenden die Parameter der Zelle.
|
187
|
+
Dann sinnvoll, wenn im Text selbst ein | vorkommt
|
188
|
+
(z.B. ein Macro verwendet wird)
|
189
|
+
|
190
|
+
*|- trennt zwei Zeilen der Tabelle
|
191
|
+
**hline: Zus�tzlicher Trennstrich �ber der Zeile
|
192
|
+
**toprule, midrule, bottomrule: Zus�tzlicher Trennstrich �ber der Zeile (erfordert booktabs.sty)
|
193
|
+
*|} beendet eine Tabelle
|
194
|
+
|
195
|
+
Beispiel 1:
|
196
|
+
{|columns=2
|
197
|
+
|Zelle 1
|
198
|
+
|Zelle 2
|
199
|
+
|-
|
200
|
+
|Zelle 3
|
201
|
+
|Zelle 4
|
202
|
+
|-
|
203
|
+
|Zelle 5
|
204
|
+
|Zelle 6
|
205
|
+
|}
|
206
|
+
|
207
|
+
Beispiel 2:
|
208
|
+
{| border=1|columns=6
|
209
|
+
|Zelle 1
|
210
|
+
|colspan=5|text-align=center| Zelle 2 �ber zwei Spalten
|
211
|
+
|-
|
212
|
+
|Zelle 3
|
213
|
+
|Zelle 4
|
214
|
+
|Zelle 5
|
215
|
+
|Zelle 6
|
216
|
+
|Zelle 7
|
217
|
+
|Zelle 8
|
218
|
+
|}
|
219
|
+
|
220
|
+
|
221
|
+
#~ Beispiel 3 mit Titelzeile:
|
222
|
+
#~ {| border=1
|
223
|
+
#~ !A
|
224
|
+
#~ !B
|
225
|
+
#~ !C
|
226
|
+
#~ |-
|
227
|
+
#~ |Zelle 1
|
228
|
+
#~ | colspan="2" align="center" | Zelle 2
|
229
|
+
#~ |-
|
230
|
+
#~ |Zelle 3
|
231
|
+
#~ |Zelle 4
|
232
|
+
#~ |Zelle 5
|
233
|
+
#~ |}
|
234
|
+
|
235
|
+
----
|
236
|
+
|
237
|
+
==Makros==
|
238
|
+
Makros sind eingeleitet mit {{.
|
239
|
+
nach dem Makronamen sind Parameter mit | getrennt.
|
240
|
+
|
241
|
+
===Link ins ODP===
|
242
|
+
*{{dmoz|World/Deutsch}}
|
243
|
+
*{{dmoz|World/Deutsch|Deutschsprachige Inhalte}}
|
244
|
+
|
245
|
+
===Neue Zeile===
|
246
|
+
{{newline|clear}}
|
247
|
+
vorher
|
248
|
+
{{newline|clear}}
|
249
|
+
nachher
|
250
|
+
|
251
|
+
Das Makro newline erfordert den Parameter ''clear''.
|
252
|
+
Kann insbesonders genutzt werden um nach floatenden Bildern
|
253
|
+
die Folgezeile unter den float zu setzen.
|
254
|
+
|
255
|
+
==Auspr�nge==
|
256
|
+
Mit
|
257
|
+
>>>key{}
|
258
|
+
...
|
259
|
+
<<<
|
260
|
+
wird eine externe Aufbereitung gerufen.
|
261
|
+
key wird von WikiCollector genutzt um den Aufbereiter (Klasse) zu rufen.
|
262
|
+
Der Aufbereiter muss die Methoden << und to_element unterst�tzen.
|
263
|
+
|
264
|
+
html ist bereits definiert und erlaubt die Verwednung von Original-Htlm
|
265
|
+
|
266
|
+
Beispiel:
|
267
|
+
>>>html{}
|
268
|
+
<strong>Fett</strong>
|
269
|
+
<<<
|
270
|
+
Ende Beispiel
|
data/lib/docgenerator.rb
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
#Generic methods to create documents.
|
2
|
+
#The target format is generic, supported are LaTeX and HTML.
|
3
|
+
#Plain text and a Wiki-version exist also, but they are not well maintained.
|
4
|
+
#
|
5
|
+
#==Elements
|
6
|
+
#A document is structured by elements.
|
7
|
+
#Each element contains attributes/parameters and content.
|
8
|
+
#(Think of HTML-attributes and TeX-Parameters and the content of HTML-Tags and TeX-Environments.).
|
9
|
+
#
|
10
|
+
#Each element corresponds to a HTML-Tag or a LaTeX-Makro/Environment.
|
11
|
+
#There is a "translation" between HTML and LaTeX elements.
|
12
|
+
#
|
13
|
+
#Elements are defined by Element.get (or the method element() ),
|
14
|
+
#new element types can be defined with Element.create() ).
|
15
|
+
#
|
16
|
+
#Some elements (in fact, most of them) are generated dynamic,
|
17
|
+
#so they will not occur in this generated documentation).
|
18
|
+
#
|
19
|
+
#== Examples
|
20
|
+
#See the unit tests and the examples-folder of the docgenerator distribution.
|
21
|
+
#
|
22
|
+
|
23
|
+
#Version information.
|
24
|
+
begin
|
25
|
+
if Gem.loaded_specs['docgenerator']
|
26
|
+
DOCGENERATOR_VERSION = Gem.loaded_specs['docgenerator'].version
|
27
|
+
else
|
28
|
+
DOCGENERATOR_VERSION = "#{File.expand_path('docgenerator')} (no Gem)"
|
29
|
+
end
|
30
|
+
rescue NameError #No gems?
|
31
|
+
DOCGENERATOR_VERSION = "#{File.expand_path('docgenerator')} (no Gem)"
|
32
|
+
end
|
33
|
+
require 'log4r'
|
34
|
+
|
35
|
+
#How to handle the End-Tag for br/hr...
|
36
|
+
#- false: set <br /> (XHTML)
|
37
|
+
#- nil: set <br> (HTML)
|
38
|
+
#Problem:
|
39
|
+
#HTML may have no endtags, XHTML requires it.
|
40
|
+
#~ Die Konstante ENDTAG macht es einstellbar.
|
41
|
+
#~ Zu machen: Flag im Dokument ob HTML oder XHTML.
|
42
|
+
#~ Aber woher weiss element in welches Dokument es geh�rt?
|
43
|
+
#~ Gleiche Problem bei to_s, bzw. Document.target
|
44
|
+
ENDTAG = false if ! defined?( ENDTAG )
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
#The docgenetor own log-formatter.
|
49
|
+
#
|
50
|
+
#Reason:
|
51
|
+
#docgenerator throws logging information.
|
52
|
+
#The trace would inform, where the problems come from (a docgenerator-tool)
|
53
|
+
#but normally the problems are document problems,
|
54
|
+
#so we need the first step outside the docgenerator-path
|
55
|
+
class LogFormatter < Log4r::BasicFormatter
|
56
|
+
#Use another format for the logger.
|
57
|
+
#
|
58
|
+
#Based on BasicFormatter.
|
59
|
+
#When used with trace on, return the location from docgenerator and the first non-docgenerator position.
|
60
|
+
def format(event)
|
61
|
+
buff = sprintf(@@basicformat, Log4r::MaxLevelLength, Log4r::LNAMES[event.level],
|
62
|
+
event.name)
|
63
|
+
mytrace = []
|
64
|
+
#~ buff += (event.tracer.nil? ? "" : "(#{event.tracer[0]})") + ": "
|
65
|
+
if event.tracer.nil?
|
66
|
+
else
|
67
|
+
event.tracer.each{|trace|
|
68
|
+
if trace !~ /lib\/docgenerator/
|
69
|
+
mytrace << trace
|
70
|
+
break
|
71
|
+
end
|
72
|
+
}
|
73
|
+
mytrace << event.tracer[0]
|
74
|
+
end
|
75
|
+
buff += ": "
|
76
|
+
buff += format_object(event.data)
|
77
|
+
#~ buff += (event.tracer.nil? ? "" : " (#{event.tracer.join('/')})")
|
78
|
+
buff += (event.tracer.nil? ? "" : " (#{mytrace.join('|')})")
|
79
|
+
buff += "\n"
|
80
|
+
buff
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
|
85
|
+
#Default Logger
|
86
|
+
DOCGENERATOR_LOGGER = Log4r::Logger.new( 'docgenerator')
|
87
|
+
DOCGENERATOR_LOGGER.level = Log4r::FATAL
|
88
|
+
DOCGENERATOR_LOGGER.outputters = Log4r::StdoutOutputter.new('log_stdout',
|
89
|
+
:formatter => LogFormatter
|
90
|
+
)
|
91
|
+
|
92
|
+
|
93
|
+
#
|
94
|
+
#A 'global' parameter setting
|
95
|
+
#
|
96
|
+
#For usage of
|
97
|
+
# o = Docgenerator_logger.set_option_defaults(options)
|
98
|
+
# o[:log].debug("Enter ...") if o[:log].debug?
|
99
|
+
module Docgenerator_logger
|
100
|
+
#Each to_doc, to_html, to_latex, to_wiki, to_text has an option-parameter.
|
101
|
+
#This option-hash should contain at least a :log-value.
|
102
|
+
#This method completes the option hash with a default logger if no logger is given.
|
103
|
+
def self.set_option_defaults(options)
|
104
|
+
return {
|
105
|
+
:log => DOCGENERATOR_LOGGER
|
106
|
+
#Added from Document:
|
107
|
+
# :document useable for documentation
|
108
|
+
# :filename useable for documentation
|
109
|
+
# :template only Document-internal
|
110
|
+
# :replacements only Document-internal
|
111
|
+
#to think about:
|
112
|
+
#- parent - actually used in list to detect */# for wiki-items.
|
113
|
+
}.update(options)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
require 'docgenerator_element'
|
117
|
+
|
118
|
+
#Returns an element of a type "name".
|
119
|
+
#Attributes and content are optional parameter.
|
120
|
+
#
|
121
|
+
def element( name, attr = {}, content = nil )
|
122
|
+
element = Element.get( name )
|
123
|
+
if element
|
124
|
+
element = element.new(attr, content ) if element
|
125
|
+
else
|
126
|
+
element = Element.create( name, {}, true ).new(attr, content )
|
127
|
+
puts "Usage of undefined element #{name}"
|
128
|
+
end
|
129
|
+
return element
|
130
|
+
end
|
131
|
+
|
132
|
+
require 'templates/docgenerator_template'
|
133
|
+
require 'docgenerator_css'
|
134
|
+
require 'docgenerator_attribute'
|
135
|
+
require 'docgenerator_document'
|
136
|
+
|
137
|
+
require 'docgenerator_elements'
|
138
|
+
require 'docgenerator_environments'
|
139
|
+
require 'docgenerator_lists' #define environment
|
140
|
+
require 'docgenerator_sections'
|
141
|
+
require 'docgenerator_tabular'
|
142
|
+
require 'docgenerator_footnote'
|
143
|
+
require 'docgenerator_characters' #special characters (spaces, euro-sign...)
|
144
|
+
|
145
|
+
__END__
|
146
|
+
class Test
|
147
|
+
def required?(); true; end
|
148
|
+
end
|
149
|
+
test = Test.new()
|
150
|
+
puts test.required?
|
151
|
+
Test.class_eval('def required?(); false; end')
|
152
|
+
puts test.required?
|
153
|
+
|
154
|
+
testclass2 = Class.new( Test )
|
155
|
+
test2 = testclass2.new()
|
156
|
+
puts test2.required?
|
157
|
+
testclass2.class_eval('def required?(); true; end')
|
158
|
+
puts test2.required?
|
159
|
+
puts test.required?
|