docgenerator 1.2.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/build_test_and_doc.rb +505 -0
- data/examples/creole_example.rb +82 -0
- data/examples/creole_example_footnote.rb +67 -0
- data/examples/creole_example_placeholder.rb +77 -0
- data/examples/creole_example_rail.rb +154 -0
- data/examples/creole_example_rubycode.rb +144 -0
- data/examples/creole_example_struktex.rb +169 -0
- data/examples/docgenerator_example.rb +1 -1
- data/examples/docgenerator_example_footnote.rb +1 -0
- data/examples/docgenerator_example_list.rb +3 -0
- data/examples/docgenerator_example_restrictions.rb +1 -1
- data/examples/docgenerator_example_tabular.rb +1 -1
- data/examples/docgenerator_example_tripfalls.rb +2 -2
- data/examples/results/readme +2 -1
- data/examples/wiki2docgenerator_example.rb +61 -32
- data/lib/creole/creole2doc.rb +57 -58
- data/lib/creole/creole_characters.rb +56 -0
- data/lib/creole/creole_inclusion_and_plugins.rb +59 -284
- data/lib/creole/creole_inclusions.rb +142 -0
- data/lib/creole/creole_placeholder.rb +57 -23
- data/lib/creole/creole_plugins.rb +198 -0
- data/lib/creole/creole_tabular.rb +16 -8
- data/lib/creole/plugins/rail.rb +182 -0
- data/lib/creole/plugins/rubycode4creole.rb +136 -0
- data/lib/creole/plugins/struktex.rb +59 -0
- data/lib/creole/plugins/todonotes.rb +70 -0
- data/lib/docgenerator.rb +161 -71
- data/lib/docgenerator/attribute.rb +189 -156
- data/lib/docgenerator/characters.rb +824 -267
- data/lib/docgenerator/compatibility_v1.rb +249 -0
- data/lib/docgenerator/css.rb +53 -32
- data/lib/docgenerator/document.rb +119 -56
- data/lib/docgenerator/element.rb +304 -351
- data/lib/docgenerator/element_meta.rb +303 -0
- data/lib/docgenerator/elements.rb +1112 -481
- data/lib/docgenerator/environments.rb +153 -62
- data/lib/docgenerator/footnote.rb +30 -9
- data/lib/docgenerator/lists.rb +71 -47
- data/lib/docgenerator/packages/attachfile.rb +136 -0
- data/lib/{packages/docgenerator_caption.rb → docgenerator/packages/caption.rb} +28 -19
- data/lib/docgenerator/packages/hyperref.rb +194 -0
- data/lib/docgenerator/packages/listings.rb +179 -0
- data/lib/docgenerator/packages/pdfpages.rb +43 -0
- data/lib/docgenerator/packages/rubycode4doc.rb +227 -0
- data/lib/{packages/docgenerator_scrlettr2.rb → docgenerator/packages/scrlettr2.rb} +25 -16
- data/lib/docgenerator/packages/scrpage2.rb +410 -0
- data/lib/docgenerator/packages/struktex.rb +447 -0
- data/lib/docgenerator/packages/todonotes.rb +85 -0
- data/lib/{packages/docgenerator_url.rb → docgenerator/packages/url.rb} +7 -6
- data/lib/docgenerator/sections.rb +257 -83
- data/lib/docgenerator/standard.rb +19 -11
- data/lib/docgenerator/tabular.rb +234 -118
- data/lib/{templates → docgenerator/templates}/docgenerator_template.rb +52 -44
- data/lib/{templates → docgenerator/templates}/docgenerator_template.yaml +0 -0
- data/lib/{templates → docgenerator/templates}/docgenerator_template_css.rb +22 -16
- data/lib/wiki2doc/plugins/rubycode4wiki.rb +53 -0
- data/lib/wiki2doc/plugins/struktex.rb +12 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +39 -38
- data/lib/wiki2doc/wikimedia_document.rb +24 -0
- data/manpage_elements.rb +10411 -0
- data/readme.rd +34 -24
- data/unittest/creole_testtext.creole +11 -0
- data/unittest/expected/test_document_usepackage_undefined.log +2 -2
- data/unittest/expected/test_runtex.stdout +0 -1
- data/unittest/expected/test_runtex_2.stdout +0 -1
- data/unittest/expected/toc_css.css +3 -2
- data/unittest/expected_creole/test_creole_characters_all.creole +28 -0
- data/unittest/expected_creole/test_creole_characters_all.html +15 -15
- data/unittest/expected_creole/test_creole_characters_all.latex +15 -15
- data/unittest/expected_creole/test_creole_footnotes_groupid.html +15 -0
- data/unittest/expected_creole/test_creole_links_file.html +2 -2
- data/unittest/expected_creole/test_creole_links_file.latex +2 -2
- data/unittest/expected_creole/test_creole_links_file.text +2 -2
- data/unittest/expected_creole/test_creole_picture_link.html +1 -1
- data/unittest/expected_creole_rail/test_rail_creole_object.tex +33 -0
- data/unittest/expected_creole_rail/test_rail_creole_placeholder.tex +40 -0
- data/unittest/expected_rubycode4doc/creole_complete.html +26 -0
- data/unittest/expected_rubycode4doc/creole_complete.tex +40 -0
- data/unittest/expected_rubycode4doc/creole_in_tab.html +4 -0
- data/unittest/expected_rubycode4doc/creole_in_tab.tex +6 -0
- data/unittest/expected_rubycode4doc/creole_inline_ruby.html +7 -0
- data/unittest/expected_rubycode4doc/creole_output.html +2 -0
- data/unittest/expected_rubycode4doc/creole_output.tex +4 -0
- data/unittest/expected_rubycode4doc/creole_rubycode.html +1 -0
- data/unittest/expected_rubycode4doc/creole_rubycode.tex +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.html +1 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated.tex +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.html +3 -0
- data/unittest/expected_rubycode4doc/creole_rubycode_evaluated_listings.tex +5 -0
- data/unittest/expected_rubycode4doc/wiki_1.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_2.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_3.html +9 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_1.html +5 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_2.html +5 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_3.html +8 -0
- data/unittest/expected_rubycode4doc/wiki_immediate_full.html +21 -0
- data/unittest/expected_struktex/test_struktex_krug.creole +15 -0
- data/unittest/expected_struktex/test_struktex_krug.tex +19 -0
- data/unittest/expected_struktex/test_struktex_krug.wiki +15 -0
- data/unittest/expected_struktex/test_struktex_statement.creole +7 -0
- data/unittest/expected_struktex/test_struktex_statement.tex +9 -0
- data/unittest/expected_struktex/test_struktex_statement.wiki +7 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.html +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.latex +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.text +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_description.wiki +1 -1
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_2.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_footnote_groupid.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_html_code.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_inline.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_label.html +0 -0
- data/unittest/expected_wikimedia/test_wiki_link.html +8 -0
- data/unittest/expected_wikimedia/test_wiki_link.latex +17 -0
- data/unittest/expected_wikimedia/test_wiki_link.wiki +11 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_after_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ol_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_list_ul_too_much.wiki +0 -0
- data/unittest/expected_wikimedia/test_wiki_picture.html +55 -0
- data/unittest/expected_wikimedia/test_wiki_picture.latex +76 -0
- data/unittest/expected_wikimedia/test_wiki_picture_thumb.html +5 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_tab1.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_textformatting.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_toc.wiki +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.html +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.latex +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.text +0 -0
- data/unittest/{expected_wiki → expected_wikimedia}/test_wiki_ul_multiple_line.wiki +0 -0
- data/unittest/{unittest_creole2doc.rb → unittest_creole.rb} +385 -476
- data/unittest/unittest_creole_placeholders.rb +272 -0
- data/unittest/unittest_creole_plugin_rail.rb +147 -0
- data/unittest/unittest_docgenerator.rb +206 -332
- data/unittest/unittest_docgenerator_characters.rb +650 -0
- data/unittest/unittest_docgenerator_runtex.rb +48 -20
- data/unittest/unittest_packages_struktex.rb +187 -0
- data/unittest/unittest_rubycode4doc.rb +275 -0
- data/unittest/unittest_wikimedia.rb +479 -0
- metadata +245 -172
- data/examples/results_expected/docgenerator_example.html +0 -39
- data/examples/results_expected/docgenerator_example.pdf +0 -0
- data/examples/results_expected/docgenerator_example.tex +0 -56
- data/examples/results_expected/docgenerator_example_footnote.html +0 -40
- data/examples/results_expected/docgenerator_example_footnote.pdf +0 -0
- data/examples/results_expected/docgenerator_example_footnote.tex +0 -50
- data/examples/results_expected/docgenerator_example_list.html +0 -18
- data/examples/results_expected/docgenerator_example_list.pdf +0 -0
- data/examples/results_expected/docgenerator_example_list.tex +0 -46
- data/examples/results_expected/docgenerator_example_restrictions.html +0 -22
- data/examples/results_expected/docgenerator_example_restrictions.pdf +0 -0
- data/examples/results_expected/docgenerator_example_restrictions.tex +0 -31
- data/examples/results_expected/docgenerator_example_tabular.html +0 -37
- data/examples/results_expected/docgenerator_example_tabular.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tabular.tex +0 -41
- data/examples/results_expected/docgenerator_example_tripfalls.html +0 -27
- data/examples/results_expected/docgenerator_example_tripfalls.pdf +0 -0
- data/examples/results_expected/docgenerator_example_tripfalls.tex +0 -31
- data/lib/packages/docgenerator_attachfile.rb +0 -71
- data/lib/packages/docgenerator_hyperref.rb +0 -109
- data/lib/packages/docgenerator_listings.rb +0 -103
- data/lib/packages/docgenerator_pdfpages.rb +0 -24
- data/lib/packages/docgenerator_scrpage2.rb +0 -172
- data/self_docgenerator.rb +0 -163
- data/unittest/expected_wiki/test_wiki_link.html +0 -8
- data/unittest/expected_wiki/test_wiki_link.latex +0 -17
- data/unittest/expected_wiki/test_wiki_link.wiki +0 -11
- data/unittest/expected_wiki/test_wiki_picture.html +0 -55
- data/unittest/expected_wiki/test_wiki_picture.latex +0 -76
- data/unittest/expected_wiki/test_wiki_picture_thumb.html +0 -5
- data/unittest/test_rakefile_docgenerator.rb +0 -43
- data/unittest/unittest_versions.rb +0 -44
- data/unittest/unittest_wiki2doc.rb +0 -464
@@ -0,0 +1,479 @@
|
|
1
|
+
# encoding: ASCII-8BIT
|
2
|
+
require 'test/unit'
|
3
|
+
require 'more_unit_test/assert_equal_filecontent.rb'
|
4
|
+
|
5
|
+
|
6
|
+
=begin
|
7
|
+
To make it better:
|
8
|
+
|
9
|
+
make more testclasses and create test data in setup.
|
10
|
+
eiach test in its own method.
|
11
|
+
|
12
|
+
=end
|
13
|
+
if $0 == __FILE__
|
14
|
+
$:.unshift("../lib")
|
15
|
+
#~ $:.unshift("../lib_privat")
|
16
|
+
end
|
17
|
+
require 'wiki2doc/wiki2docgenerator'
|
18
|
+
include Docgenerator
|
19
|
+
include Wikimedia
|
20
|
+
#~ DOCGENERATOR_LOGGER.level = Log4r::DEBUG
|
21
|
+
|
22
|
+
$fixmes = []
|
23
|
+
|
24
|
+
END { puts $fixmes }
|
25
|
+
|
26
|
+
class Testcase < Test::Unit::TestCase
|
27
|
+
def setup()
|
28
|
+
#Avoid warnings about missing logger in to_doc
|
29
|
+
@opt = { :log => DOCGENERATOR_DEFAULT_LOGGER }
|
30
|
+
end
|
31
|
+
def test_wiki()
|
32
|
+
wiki = Wikitext.new(:content => <<wiki
|
33
|
+
==Titel 1==
|
34
|
+
Text
|
35
|
+
===Titel 2===
|
36
|
+
Text unter Titel 2
|
37
|
+
wiki
|
38
|
+
)
|
39
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki.html", wiki.to_doc(:html, @opt))
|
40
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki.latex", wiki.to_doc(:latex, @opt))
|
41
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki.wiki", wiki.to_doc(:wiki, @opt))
|
42
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki.text", wiki.to_doc(:text, @opt))
|
43
|
+
end
|
44
|
+
#
|
45
|
+
#Including the definition of a label tor the toc.
|
46
|
+
def test_wiki_toc()
|
47
|
+
wiki = Wikitext.new(:content => <<wiki
|
48
|
+
==Titel 1==
|
49
|
+
Text
|
50
|
+
===Titel 2===
|
51
|
+
Text unter Titel 2
|
52
|
+
===[2b]Titel 2b===
|
53
|
+
Text unter Titel 2b
|
54
|
+
wiki
|
55
|
+
)
|
56
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.html", wiki.to_doc(:html, @opt))
|
57
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.latex", wiki.to_doc(:latex, @opt))
|
58
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.wiki", wiki.to_doc(:wiki, @opt))
|
59
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_toc.text", wiki.to_doc(:text, @opt))
|
60
|
+
end
|
61
|
+
def test_wiki_inline()
|
62
|
+
wiki = Wikitext.new(:content => <<wiki
|
63
|
+
Inline-Tags ''kursiv'', '''fett''', ''''kursiv und fett''''
|
64
|
+
|
65
|
+
''kursiv'',
|
66
|
+
'''fett''',
|
67
|
+
''''kursiv und fett''''
|
68
|
+
wiki
|
69
|
+
)
|
70
|
+
#fixme tex unklar. wie zwei dd-tags in tex nachbilden?
|
71
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.html", wiki.to_doc(:html, @opt))
|
72
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.latex", wiki.to_doc(:latex, @opt))
|
73
|
+
#~ bug! fixme
|
74
|
+
$fixmes << 'inline 2 wiki'
|
75
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.wiki", wiki.to_doc(:wiki))
|
76
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_inline.text", wiki.to_doc(:text, @opt))
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_wiki_textformatting()
|
80
|
+
#Clear in newline is used by HTML (needed to handle floats)
|
81
|
+
wiki = Wikitext.new(:content => <<wiki
|
82
|
+
vorher{{newline}}Nachher
|
83
|
+
|
84
|
+
vorher{{newline|clear}}Nachher
|
85
|
+
----
|
86
|
+
Nach einer Trennlinie
|
87
|
+
wiki
|
88
|
+
)
|
89
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.html", wiki.to_doc(:html, @opt))
|
90
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.latex", wiki.to_doc(:latex, @opt))
|
91
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.wiki", wiki.to_doc(:wiki, @opt))
|
92
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_textformatting.text", wiki.to_doc(:text, @opt))
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_wiki_label()
|
96
|
+
wiki = Wikitext.new(:content => <<wiki
|
97
|
+
[[label:a]]
|
98
|
+
|
99
|
+
text text
|
100
|
+
[[#a|hier]]
|
101
|
+
[[#a|hier]]
|
102
|
+
wiki
|
103
|
+
)
|
104
|
+
#~ fixme: TeX href hyperlabel??
|
105
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_label.html", wiki.to_doc(:html, @opt))
|
106
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_label.latex", wiki.to_doc(:latex))
|
107
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_label.wiki", wiki.to_doc(:wiki)) #fixme
|
108
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_label.text", wiki.to_doc(:text))
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_wiki_list_ul()
|
112
|
+
wiki = Wikitext.new(:content => <<wiki
|
113
|
+
Text before
|
114
|
+
*Listentry 1
|
115
|
+
*Listentry 2
|
116
|
+
**Listentry 2.1
|
117
|
+
**Listentry 2.2
|
118
|
+
*Listentry 3
|
119
|
+
Text afterwords
|
120
|
+
wiki
|
121
|
+
)
|
122
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.html", wiki.to_doc(:html, @opt))
|
123
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.latex", wiki.to_doc(:latex, @opt))
|
124
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.wiki", wiki.to_doc(:wiki, @opt))
|
125
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul.text", wiki.to_doc(:text, @opt))
|
126
|
+
end
|
127
|
+
#It works fine here, but LaTeX will give you an error.
|
128
|
+
def test_wiki_list_ul_too_much()
|
129
|
+
wiki = Wikitext.new(:content => <<wiki
|
130
|
+
Text before
|
131
|
+
*Listentry 1
|
132
|
+
*Listentry 2
|
133
|
+
**Listentry 2.1
|
134
|
+
**Listentry 2.2
|
135
|
+
***Listentry 2.2.1
|
136
|
+
****Listentry 2.2.1.1
|
137
|
+
*****Listentry 2.2.1.1.1
|
138
|
+
*Listentry 3
|
139
|
+
Text afterwords
|
140
|
+
wiki
|
141
|
+
)
|
142
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.html", wiki.to_doc(:html, @opt))
|
143
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.latex", wiki.to_doc(:latex, @opt))
|
144
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.wiki", wiki.to_doc(:wiki, @opt))
|
145
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ul_too_much.text", wiki.to_doc(:text, @opt))
|
146
|
+
end
|
147
|
+
def test_wiki_list_ol()
|
148
|
+
wiki = Wikitext.new(:content => <<wiki
|
149
|
+
Text before
|
150
|
+
#Listentry 1
|
151
|
+
#Listentry 2
|
152
|
+
##Listentry 2.1
|
153
|
+
##Listentry 2.2
|
154
|
+
#Listentry 3
|
155
|
+
Text afterwords
|
156
|
+
wiki
|
157
|
+
)
|
158
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.html", wiki.to_doc(:html, @opt))
|
159
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.latex", wiki.to_doc(:latex, @opt))
|
160
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.wiki", wiki.to_doc(:wiki, @opt))
|
161
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol.text", wiki.to_doc(:text, @opt))
|
162
|
+
end #ol
|
163
|
+
|
164
|
+
def test_wiki_list_ol_ul()
|
165
|
+
wiki = Wikitext.new(:content => <<wiki
|
166
|
+
Text before
|
167
|
+
#Listentry 1
|
168
|
+
#Listentry 2
|
169
|
+
#*Listentry 2.1
|
170
|
+
#*Listentry 2.2
|
171
|
+
#Listentry 3
|
172
|
+
Text afterwords
|
173
|
+
wiki
|
174
|
+
)
|
175
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.html", wiki.to_doc(:html, @opt))
|
176
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.latex", wiki.to_doc(:latex, @opt))
|
177
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.wiki", wiki.to_doc(:wiki, @opt))
|
178
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_ul.text", wiki.to_doc(:text, @opt))
|
179
|
+
$fixmes << "nested lists/wiki: bug"
|
180
|
+
$fixmes << "nested lists/text: bug"
|
181
|
+
end
|
182
|
+
|
183
|
+
def test_wiki_list_ol_after_ul()
|
184
|
+
wiki = Wikitext.new(:content => <<wiki
|
185
|
+
Text before
|
186
|
+
*Listentry 1
|
187
|
+
#Listentry 2
|
188
|
+
Text afterwords
|
189
|
+
wiki
|
190
|
+
)
|
191
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.html", wiki.to_doc(:html, @opt))
|
192
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.latex", wiki.to_doc(:latex, @opt))
|
193
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.wiki", wiki.to_doc(:wiki, @opt))
|
194
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_list_ol_after_ul.text", wiki.to_doc(:text, @opt))
|
195
|
+
end
|
196
|
+
|
197
|
+
#Line breaks will be lost.
|
198
|
+
def test_wiki_ul_multiple_line()
|
199
|
+
wiki = Wikitext.new(:content => <<wiki
|
200
|
+
* vorher
|
201
|
+
* text
|
202
|
+
mehr text zum item
|
203
|
+
* nachher und vorher
|
204
|
+
* text
|
205
|
+
mehr text zum item
|
206
|
+
|
207
|
+
neuer Absatz im Item funktioniert auch.
|
208
|
+
* nachher
|
209
|
+
wiki
|
210
|
+
)
|
211
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.html", wiki.to_doc(:html, @opt))
|
212
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.latex", wiki.to_doc(:latex, @opt))
|
213
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.wiki", wiki.to_doc(:wiki, @opt))
|
214
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_ul_multiple_line.text", wiki.to_doc(:text, @opt)) #fixme
|
215
|
+
end
|
216
|
+
def test_wiki_description()
|
217
|
+
wiki = Wikitext.new(:content => <<wiki
|
218
|
+
;Something
|
219
|
+
:Now a long description of Something,
|
220
|
+
continued on a second line.
|
221
|
+
:Another entry
|
222
|
+
;Something Else
|
223
|
+
:Definition of Something Else
|
224
|
+
wiki
|
225
|
+
)
|
226
|
+
#~ fixme - latex how to implement different <dd> values
|
227
|
+
# fixme UTF-fehler
|
228
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_description.html", wiki.to_doc(:html, @opt))
|
229
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_description.latex", wiki.to_doc(:latex, @opt))
|
230
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_description.wiki", wiki.to_doc(:wiki, @opt))
|
231
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_description.text", wiki.to_doc(:text, @opt))
|
232
|
+
end
|
233
|
+
|
234
|
+
#~ Die Syntax:
|
235
|
+
#~ *{| beginnt eine Tabelle. Hier k�nnen zus�tzliche Formatierungseigenschaften kommen.
|
236
|
+
#~ **Zumindest columns==__ sollte gesetzt sein
|
237
|
+
#~ *! beginnt eine neue Zelle einer Titelzeile
|
238
|
+
#~ *| beginnt eine neue Zelle
|
239
|
+
#~ *|format| z.B. rowspan...
|
240
|
+
#~ *|format|| Zwei || beenden die Parameter der Zelle.
|
241
|
+
#~ Dann sinnvoll, wenn im Text selbst ein | vorkommt
|
242
|
+
#~ (z.B. ein Macro verwendet wird)
|
243
|
+
#~ *|- trennt zwei Zeilen der Tabelle
|
244
|
+
#~ **hline: Zus�tzlicher Trennstrich �ber der Zeile
|
245
|
+
#~ **toprule, midrule, bottomrule: Zus�tzlicher Trennstrich �ber der Zeile (erfordert booktabs.sty)
|
246
|
+
#~ *|} beendet eine Tabelle
|
247
|
+
|
248
|
+
|
249
|
+
def mk_wiki_tab( columns, lines )
|
250
|
+
tab = [ "{|columns=#{columns.size}|columndescription=#{'c' * columns.size}" ]
|
251
|
+
tab << "|colspan=#{columns.size}|pos=c|Titel"
|
252
|
+
lines.each{|line|
|
253
|
+
tab << "|-"
|
254
|
+
columns.each{|column|
|
255
|
+
tab << "|#{line}#{column}"
|
256
|
+
}
|
257
|
+
}
|
258
|
+
tab << "|}"
|
259
|
+
return tab.join("\n")
|
260
|
+
end
|
261
|
+
def test_wiki_tab1()
|
262
|
+
wiki = Wikitext.new(:content => mk_wiki_tab(Array('A'..'D'), Array(1..5) ) )
|
263
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.html", wiki.to_doc(:html, @opt))
|
264
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.latex", wiki.to_doc(:latex, @opt))
|
265
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.wiki", wiki.to_doc(:wiki, @opt))
|
266
|
+
$fixmes << "text-output for tables"
|
267
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_tab1.text", wiki.to_doc(:text))
|
268
|
+
end
|
269
|
+
|
270
|
+
#With >>> you can call ''WikiCollector''
|
271
|
+
#This collector gets teh content between the start and <<<.
|
272
|
+
#
|
273
|
+
#Collectors must support the methods << and to_doc.
|
274
|
+
#
|
275
|
+
#One predefined collector is html. It takes the content as 'plain text'.
|
276
|
+
#
|
277
|
+
def test_wiki_html_code()
|
278
|
+
wiki = Wikitext.new(:content => <<wiki
|
279
|
+
Beispiel:
|
280
|
+
>>>html{}
|
281
|
+
<div style = "float: right; background-color: yellow">
|
282
|
+
<strong>Fett</strong>
|
283
|
+
<em>kursiv</em>
|
284
|
+
</div>
|
285
|
+
<<<
|
286
|
+
Ende Beispiel
|
287
|
+
wiki
|
288
|
+
)
|
289
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.html", wiki.to_doc(:html, @opt))
|
290
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.latex", wiki.to_doc(:latex, @opt))
|
291
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.wiki", wiki.to_doc(:wiki, @opt))
|
292
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_html_code.text", wiki.to_doc(:text, @opt))
|
293
|
+
end
|
294
|
+
#
|
295
|
+
#Add File as verbatimtext
|
296
|
+
def test_wiki_verbatimfile()
|
297
|
+
#
|
298
|
+
#This test uses the coding of the test itself.
|
299
|
+
#
|
300
|
+
wiki = Wikitext.new(:content => <<wiki
|
301
|
+
{{verbatimfile|#{__FILE__}}}
|
302
|
+
wiki
|
303
|
+
)
|
304
|
+
|
305
|
+
escaped_filecontent = File.read(__FILE__).gsub(/</, '<').gsub(/>/, '>')
|
306
|
+
#~ puts wiki.to_latex[1..50].inspect
|
307
|
+
#~ puts wiki.to_latex[-50..-1].inspect
|
308
|
+
assert_equal( "<p ><pre>#{escaped_filecontent}</pre></p>\n", wiki.to_doc(:html, @opt))
|
309
|
+
assert_equal( "\n\n\n\\begin{verbatim}#{File.read(__FILE__)}\\end{verbatim}\n\n\n", wiki.to_doc(:latex, @opt))
|
310
|
+
|
311
|
+
#Add some attributes to the pre-environment.
|
312
|
+
wiki = Wikitext.new(:content => <<wiki
|
313
|
+
{{verbatimfile|#{__FILE__}|class=cssklasse}}
|
314
|
+
wiki
|
315
|
+
)
|
316
|
+
assert_equal( "<p ><pre class = \"cssklasse\" >#{escaped_filecontent}</pre></p>\n",
|
317
|
+
wiki.to_doc(:html, @opt))
|
318
|
+
end
|
319
|
+
#Add File as verbatimtext
|
320
|
+
def test_wiki_filecontent()
|
321
|
+
#
|
322
|
+
#This test uses the coding of the test itself.
|
323
|
+
#
|
324
|
+
wiki = Wikitext.new(:content => <<wiki
|
325
|
+
{{filecontent|#{__FILE__}}}
|
326
|
+
wiki
|
327
|
+
)
|
328
|
+
#~ puts wiki.to_latex[1..50].inspect
|
329
|
+
assert_equal( "<p ><div >#{File.read(__FILE__)}</div></p>\n", wiki.to_doc(:html, @opt))
|
330
|
+
assert_equal( "\n\n\\begingroup #{File.read(__FILE__)}\\endgroup \n\n", wiki.to_doc(:latex, @opt))
|
331
|
+
|
332
|
+
#Add some attributes to the pre-environment.
|
333
|
+
wiki = Wikitext.new(:content => <<wiki
|
334
|
+
{{filecontent|#{__FILE__}|class=cssklasse}}
|
335
|
+
wiki
|
336
|
+
)
|
337
|
+
assert_equal( "<p ><div class = \"cssklasse\" >#{File.read(__FILE__)}</div></p>\n",
|
338
|
+
wiki.to_doc(:html, @opt))
|
339
|
+
end
|
340
|
+
def test_wiki_footnote()
|
341
|
+
wiki = Wikitext.new(:content => <<wiki
|
342
|
+
Here is a footnote{{footnote|some remarks}}, and
|
343
|
+
a second footnote{{footnote|more remarks}}.
|
344
|
+
|
345
|
+
----
|
346
|
+
{{footnotes}}
|
347
|
+
wiki
|
348
|
+
)
|
349
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.html", wiki.to_doc(:html, @opt))
|
350
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_2.html", wiki.to_doc(:html, @opt))
|
351
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.latex", wiki.to_doc(:latex, @opt))
|
352
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.wiki", wiki.to_doc(:wiki, @opt))
|
353
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote.text", wiki.to_doc(:text, @opt))
|
354
|
+
end
|
355
|
+
def test_wiki_footnote_groupid()
|
356
|
+
wiki = Wikitext.new(:content => <<wiki
|
357
|
+
There are normal footnotes{{footnote|Like this one}}. But:
|
358
|
+
Here is a footnote in group 1{{footnote[group1]some remarks}}, and
|
359
|
+
a second footnote{{footnote[group1]more remarks}}.
|
360
|
+
In another group{{footnote[group2]Each group gets a name}}, we can define further remarks.
|
361
|
+
|
362
|
+
----
|
363
|
+
Normal Footnotes:
|
364
|
+
{{footnotes}}
|
365
|
+
----
|
366
|
+
Footnote group 1:
|
367
|
+
{{footnotes|group1}}
|
368
|
+
----
|
369
|
+
Footnote group 2:
|
370
|
+
{{footnotes|group2}}
|
371
|
+
wiki
|
372
|
+
)
|
373
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.html", wiki.to_doc(:html, @opt))
|
374
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.latex", wiki.to_doc(:latex, @opt))
|
375
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.wiki", wiki.to_doc(:wiki, @opt))
|
376
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_footnote_groupid.text", wiki.to_doc(:text, @opt))
|
377
|
+
end
|
378
|
+
#~ Bilder lassen sich mit [ [Bild:Dateiname|Beschreibung]] in Artikel einf�gen.
|
379
|
+
#~ Das Bild wird dann in Originalgr��e links im Artikel angezeigt.
|
380
|
+
|
381
|
+
#~ Parameter sind optional mit [ [Bild:Dateiname|parameter|Beschreibung]] anzugeben.
|
382
|
+
#~ Es sind beliebig viele, mit | getrennte Parameter m�glich.
|
383
|
+
def test_wiki_picture()
|
384
|
+
wiki = Wikitext.new(:content => <<wiki
|
385
|
+
[[Bild:Red_Flower.jpg]]
|
386
|
+
|
387
|
+
[[Bild:Red_Flower.jpg|alt=description]]
|
388
|
+
[[Bild:Red_Flower.jpg|alt=description|beforetitle=vorher]]
|
389
|
+
[[Bild:Red_Flower.jpg|alt=description|aftertitle=nachher]]
|
390
|
+
|
391
|
+
[[Bild:Red_Flower.jpg|href=http://ruby.lickert.net]]
|
392
|
+
[[Bild:Red_Flower.jpg|href=http://ruby.lickert.net|alt=test]]
|
393
|
+
|
394
|
+
[[Bild:Red_Flower.jpg|right]]
|
395
|
+
[[Bild:Red_Flower.jpg|left]]
|
396
|
+
|
397
|
+
[[Bild:Red_Flower.jpg|width=123px]]
|
398
|
+
|
399
|
+
[[Bild:Red_Flower.jpg|class=pictureclass]]
|
400
|
+
[[Bild:Red_Flower.jpg|imgclass=imgclass]]
|
401
|
+
[[Bild:Red_Flower.jpg|figureclass=imgclass]]
|
402
|
+
wiki
|
403
|
+
)
|
404
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.html", wiki.to_doc(:html, @opt))
|
405
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.latex", wiki.to_doc(:latex, @opt))
|
406
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.wiki", wiki.to_doc(:wiki, @opt))
|
407
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture.text", wiki.to_doc(:text, @opt))
|
408
|
+
|
409
|
+
wiki = Wikitext.new(:content => <<wiki
|
410
|
+
[[Bild:Red_Flower.jpg|thumb=testthumb.jpg]]
|
411
|
+
wiki
|
412
|
+
)
|
413
|
+
wiki.log.level = Log4r::FATAL #Avoid warning for missing picture
|
414
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.html", wiki.to_doc(:html, @opt))
|
415
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.latex", wiki.to_doc(:latex, @opt))
|
416
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.wiki", wiki.to_doc(:wiki, @opt))
|
417
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_picture_thumb.text", wiki.to_doc(:text, @opt))
|
418
|
+
end
|
419
|
+
|
420
|
+
#
|
421
|
+
#
|
422
|
+
def test_wiki_link()
|
423
|
+
#thisfile is needed to avoid different values of __FILE__
|
424
|
+
#(Running stand alone it's the filename, with require it's './<<filename>>'
|
425
|
+
thisfile = File.basename(__FILE__)
|
426
|
+
|
427
|
+
wiki = Wikitext.new(:content => <<wiki
|
428
|
+
text before [./#{thisfile} link to test] text after
|
429
|
+
|
430
|
+
text before
|
431
|
+
[./#{thisfile} link to test]
|
432
|
+
text after
|
433
|
+
|
434
|
+
[./unexisting_file.xx link with error]
|
435
|
+
wiki
|
436
|
+
)
|
437
|
+
wiki.log.level = Log4r::FATAL
|
438
|
+
#~ wiki.log.outputters = Log4r::FileOutputter.new('wiki_link', :filename => "expected_wikimedia/test_wiki_link.log")
|
439
|
+
|
440
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_link.html", wiki.to_doc(:html, @opt))
|
441
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_link.log", wiki.to_doc(:html, @opt))
|
442
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_link.latex", wiki.to_doc(:latex, @opt))
|
443
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_link.wiki", wiki.to_doc(:wiki, @opt))
|
444
|
+
#~ assert_equal_filecontent( "expected_wikimedia/test_wiki_link.text", wiki.to_doc(:text, @opt))
|
445
|
+
end
|
446
|
+
end #TestWiki
|
447
|
+
|
448
|
+
def newtest(text)
|
449
|
+
code = <<code
|
450
|
+
def test_wiki_??()
|
451
|
+
wiki = Wikitext.new(:content => <<wiki
|
452
|
+
==Titel 1==
|
453
|
+
Text
|
454
|
+
wiki
|
455
|
+
)
|
456
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_??.html", wiki.to_doc(:html, @opt))
|
457
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_??.latex", wiki.to_doc(:latex, @opt))
|
458
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_??.wiki", wiki.to_doc(:wiki, @opt))
|
459
|
+
assert_equal_filecontent( "expected_wikimedia/test_wiki_??.text", wiki.to_doc(:text, @opt))
|
460
|
+
end
|
461
|
+
code
|
462
|
+
puts code.gsub(/\?\?/, text)
|
463
|
+
end
|
464
|
+
#~ newtest('link')
|
465
|
+
|
466
|
+
__END__
|
467
|
+
==Wiki2docgenerator.rb==
|
468
|
+
===Einr�ckungen===
|
469
|
+
Nicht realisiert, macht implizit Definitionsliste (fixme)
|
470
|
+
: Text macht implizit Definitionsliste (fixme)
|
471
|
+
:: Noch tiefer
|
472
|
+
|
473
|
+
==Makros==
|
474
|
+
Makros sind eingeleitet mit {{.
|
475
|
+
nach dem Makronamen sind Parameter mit | getrennt.
|
476
|
+
|
477
|
+
===Link ins ODP===
|
478
|
+
*{{dmoz|World/Deutsch}}
|
479
|
+
*{{dmoz|World/Deutsch|Deutschsprachige Inhalte}}
|