docgenerator 1.0.4 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/creole/creole2doc.rb +777 -0
- data/lib/creole/creole_inclusion_and_plugins.rb +236 -0
- data/lib/creole/creole_placeholder.rb +74 -0
- data/lib/creole/creole_tabular.rb +170 -0
- data/lib/docgenerator.rb +15 -6
- data/lib/docgenerator_attribute.rb +2 -2
- data/lib/docgenerator_characters.rb +20 -4
- data/lib/docgenerator_document.rb +132 -42
- data/lib/docgenerator_element.rb +531 -524
- data/lib/docgenerator_elements.rb +408 -399
- data/lib/docgenerator_environments.rb +28 -2
- data/lib/docgenerator_footnote.rb +72 -79
- data/lib/docgenerator_sections.rb +1 -1
- data/lib/docgenerator_tabular.rb +8 -3
- data/lib/packages/docgenerator_beamer.rb +253 -0
- data/lib/packages/docgenerator_scrlettr2.rb +53 -9
- data/lib/templates/docgenerator_template_css.rb +4 -0
- data/lib/wiki2doc/wiki2docgenerator.rb +1087 -970
- data/lib/yaml2presentation/yaml2presentation.rb +1091 -0
- data/self_docgenerator.rb +8 -6
- data/unittest/Red_Flower.jpg +0 -0
- data/unittest/creole1.0test.txt +128 -0
- data/unittest/expected/beamer_01_doc.html +1 -1
- data/unittest/expected/beamer_02_doc.html +1 -1
- data/unittest/expected/beamer_doc_html_overview_with_detailpic_and_text_doc.html +34 -0
- data/unittest/expected/beamer_doc_html_overview_with_detailpic_doc.html +34 -0
- data/unittest/expected/beamer_doc_key_doc.html +1 -1
- data/unittest/expected/beamer_doc_note_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_bottom_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_left_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_right_doc.html +1 -1
- data/unittest/expected/beamer_doc_pic_top_doc.html +1 -1
- data/unittest/expected/test_footnote.html +2 -2
- data/unittest/expected/test_footnote.latex +1 -1
- data/unittest/expected/test_footnote_group.html +3 -3
- data/unittest/expected/test_footnote_group.latex +2 -2
- data/unittest/expected_creole/test_creole.html +3 -0
- data/unittest/expected_creole/test_creole_characters_all.html +10 -0
- data/unittest/expected_creole/test_creole_characters_all.latex +20 -0
- data/unittest/expected_creole/test_creole_characters_special.html +10 -0
- data/unittest/expected_creole/test_creole_characters_special.latex +18 -0
- data/unittest/expected_creole/test_creole_countdown.html +3 -0
- data/unittest/expected_creole/test_creole_countdown.latex +4 -0
- data/unittest/expected_creole/test_creole_creole1.0test.html +182 -0
- data/unittest/expected_creole/test_creole_creole1.0test.latex +253 -0
- data/unittest/expected_creole/test_creole_creole1.0test.text +160 -0
- data/unittest/expected_creole/test_creole_footnotes.html +9 -0
- data/unittest/expected_creole/test_creole_footnotes.latex +14 -0
- data/unittest/expected_creole/test_creole_footnotes_label.html +9 -0
- data/unittest/expected_creole/test_creole_headings.html +17 -0
- data/unittest/expected_creole/test_creole_headings.latex +19 -0
- data/unittest/expected_creole/test_creole_headings.text +48 -0
- data/unittest/expected_creole/test_creole_headings.wiki +37 -0
- data/unittest/expected_creole/test_creole_hr.html +7 -0
- data/unittest/expected_creole/test_creole_hr.latex +9 -0
- data/unittest/expected_creole/test_creole_hr.text +4 -0
- data/unittest/expected_creole/test_creole_inline.html +3 -0
- data/unittest/expected_creole/test_creole_inline.latex +4 -0
- data/unittest/expected_creole/test_creole_inline.text +2 -0
- data/unittest/expected_creole/test_creole_inline_ruby.html +12 -0
- data/unittest/expected_creole/test_creole_inline_ruby.latex +20 -0
- data/unittest/expected_creole/test_creole_inline_ruby_raw.html +6 -0
- data/unittest/expected_creole/test_creole_inline_ruby_raw.latex +8 -0
- data/unittest/expected_creole/test_creole_input.normsource +23 -0
- data/unittest/expected_creole/test_creole_label.html +12 -0
- data/unittest/expected_creole/test_creole_label.latex +15 -0
- data/unittest/expected_creole/test_creole_line_break.html +6 -0
- data/unittest/expected_creole/test_creole_line_break.latex +8 -0
- data/unittest/expected_creole/test_creole_links_explicit_internal.html +6 -0
- data/unittest/expected_creole/test_creole_links_explicit_internal.text +4 -0
- data/unittest/expected_creole/test_creole_links_explicit_with_em.html +3 -0
- data/unittest/expected_creole/test_creole_links_explicit_with_em.latex +4 -0
- data/unittest/expected_creole/test_creole_links_explicit_with_em.text +2 -0
- data/unittest/expected_creole/test_creole_links_external.html +6 -0
- data/unittest/expected_creole/test_creole_links_external.latex +8 -0
- data/unittest/expected_creole/test_creole_links_external.text +4 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.html +9 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.latex +12 -0
- data/unittest/expected_creole/test_creole_links_external_implicit.text +6 -0
- data/unittest/expected_creole/test_creole_links_file.html +6 -0
- data/unittest/expected_creole/test_creole_links_file.latex +8 -0
- data/unittest/expected_creole/test_creole_links_file.text +4 -0
- data/unittest/expected_creole/test_creole_list_ol.html +12 -0
- data/unittest/expected_creole/test_creole_list_ol.latex +22 -0
- data/unittest/expected_creole/test_creole_list_ol_after_ul.html +12 -0
- data/unittest/expected_creole/test_creole_list_ol_after_ul.latex +20 -0
- data/unittest/expected_creole/test_creole_list_ol_after_ul.text +6 -0
- data/unittest/expected_creole/test_creole_list_ol_ul.html +15 -0
- data/unittest/expected_creole/test_creole_list_ol_ul.latex +26 -0
- data/unittest/expected_creole/test_creole_list_ul.html +22 -0
- data/unittest/expected_creole/test_creole_list_ul.latex +40 -0
- data/unittest/expected_creole/test_creole_list_ul.normsource +83 -0
- data/unittest/expected_creole/test_creole_list_ul_too_much.html +24 -0
- data/unittest/expected_creole/test_creole_list_ul_too_much.latex +44 -0
- data/unittest/expected_creole/test_creole_newline.html +9 -0
- data/unittest/expected_creole/test_creole_newline.latex +11 -0
- data/unittest/expected_creole/test_creole_newline.text +7 -0
- data/unittest/expected_creole/test_creole_paragraphs.html +6 -0
- data/unittest/expected_creole/test_creole_paragraphs.latex +8 -0
- data/unittest/expected_creole/test_creole_paragraphs.normsource +27 -0
- data/unittest/expected_creole/test_creole_paragraphs.text +4 -0
- data/unittest/expected_creole/test_creole_paragraphs.wiki +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.html +5 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.latex +6 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.text +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap.wiki +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.html +9 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.latex +11 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.text +7 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap0.wiki +7 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.html +5 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.latex +6 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.text +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap60.wiki +4 -0
- data/unittest/expected_creole/test_creole_picture_link.html +6 -0
- data/unittest/expected_creole/test_creole_pictures.html +10 -0
- data/unittest/expected_creole/test_creole_pictures.latex +13 -0
- data/unittest/expected_creole/test_creole_pictures_css.html +3 -0
- data/unittest/expected_creole/test_creole_pictures_css.latex +4 -0
- data/unittest/expected_creole/test_creole_pictures_imgclass.html +6 -0
- data/unittest/expected_creole/test_creole_pictures_imgclass.latex +8 -0
- data/unittest/expected_creole/test_creole_placeholders_html.html +7 -0
- data/unittest/expected_creole/test_creole_placeholders_html.latex +8 -0
- data/unittest/expected_creole/test_creole_placeholders_html.text +4 -0
- data/unittest/expected_creole/test_creole_placeholders_latex.html +6 -0
- data/unittest/expected_creole/test_creole_placeholders_latex.latex +9 -0
- data/unittest/expected_creole/test_creole_placeholders_latex.text +4 -0
- data/unittest/expected_creole/test_creole_tabular.html +20 -0
- data/unittest/expected_creole/test_creole_tabular.latex +22 -0
- data/unittest/expected_creole/test_creole_tabular_creole.html +18 -0
- data/unittest/expected_creole/test_creole_tabular_creole.latex +19 -0
- data/unittest/expected_creole/test_creole_tabular_css.html +20 -0
- data/unittest/expected_creole/test_creole_tabular_css.latex +22 -0
- data/unittest/expected_creole/test_creole_toc.html +11 -0
- data/unittest/expected_creole/test_creole_toc.latex +22 -0
- data/unittest/expected_creole/test_creole_toc.text +4 -0
- data/unittest/expected_creole/test_creole_toc_text.html +5 -0
- data/unittest/expected_creole/test_creole_toc_text.latex +5 -0
- data/unittest/expected_creole/test_creole_ul_multiple_line.html +7 -0
- data/unittest/expected_creole/test_creole_ul_multiple_line.latex +14 -0
- data/unittest/expected_creole/test_creole_ul_with_blank.html +11 -0
- data/unittest/expected_creole/test_creole_ul_with_blank.latex +20 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.creole +0 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.html +11 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.latex +18 -0
- data/unittest/expected_creole/test_creole_ul_with_bold.text +7 -0
- data/unittest/expected_creole/test_creole_verbatim.html +25 -0
- data/unittest/expected_creole/test_creole_verbatim.latex +33 -0
- data/unittest/expected_creole/test_creole_verbatim.text +17 -0
- data/unittest/expected_creole/test_creole_verbatim_inline.html +6 -0
- data/unittest/expected_creole/test_creole_verbatim_inline.latex +8 -0
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.html +6 -0
- data/unittest/expected_creole/test_creole_verbatim_inline_at_start.latex +8 -0
- data/unittest/expected_privat/test_creole_test_document.html +6 -0
- data/unittest/{expected → expected_wiki}/test_wiki.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_amazon.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_description.wiki +0 -0
- data/unittest/expected_wiki/test_wiki_footnote.html +8 -0
- data/unittest/expected_wiki/test_wiki_footnote.latex +17 -0
- data/unittest/{expected → expected_wiki}/test_wiki_footnote.text +2 -4
- data/unittest/expected_wiki/test_wiki_footnote.wiki +10 -0
- data/unittest/expected_wiki/test_wiki_footnote_2.html +8 -0
- data/unittest/expected_wiki/test_wiki_footnote_groupid.html +21 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_html_code.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_inline.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_label.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.log +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_link.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_after_ul.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ol_ul.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_list_ul_too_much.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_picture.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_picture.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_picture_thumb.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_tab1.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_tab1.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_tab1.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_textformatting.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_toc.wiki +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.html +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.latex +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.text +0 -0
- data/unittest/{expected → expected_wiki}/test_wiki_ul_multiple_line.wiki +0 -0
- data/unittest/test_docgenerator.rb +1 -2
- data/unittest/unittest_creole2doc.rb +1024 -0
- data/unittest/unittest_docgenerator.rb +17 -8
- data/unittest/unittest_wiki2doc.rb +92 -88
- data/unittest/unittest_yaml2pres.rb +336 -0
- metadata +202 -70
- data/unittest/expected/test_wiki_footnote.html +0 -8
- data/unittest/expected/test_wiki_footnote.latex +0 -15
- data/unittest/expected/test_wiki_footnote.wiki +0 -12
- data/unittest/expected/test_wiki_footnote_groupid.html +0 -21
@@ -28,243 +28,243 @@ end
|
|
28
28
|
#The proc contains three block-parameter: The match-element, the Wikitext-object and the logger-object.
|
29
29
|
Wikireg = Struct.new( 'WikiReg', :rule, :regex, :proc )
|
30
30
|
class Wikireg
|
31
|
-
|
32
|
-
|
33
|
-
|
31
|
+
@@give_message = true
|
32
|
+
def self.give_message=(val); @@give_message = val; end
|
33
|
+
def self.give_message?(); return @@give_message; end
|
34
34
|
end
|
35
35
|
|
36
36
|
#Constant with all Standard-replacemnts of Wikis.
|
37
37
|
#Each replacement should also convert the part before and after the match.
|
38
38
|
WIKI_INLINE_REPLACEMENTS = [
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
39
|
+
#[[Bild:Dateiname|Zusatzinfos|Beschreibung]]
|
40
|
+
#Zusatzinfos:
|
41
|
+
# -left
|
42
|
+
# -right
|
43
|
+
Wikireg.new(:bild, /\[\[Bild:(.*?)\]\]/,
|
44
|
+
Proc.new{|m, oo, log|
|
45
|
+
parameter = m[1].split('|')
|
46
|
+
[ oo.inline(m.pre_match, log),
|
47
|
+
oo.wiki_bild( parameter.first, parameter[1..-1], log),
|
48
|
+
oo.inline(m.post_match, log),
|
49
|
+
]
|
50
|
+
} ),
|
51
|
+
Wikireg.new(:file, /\[\[File:(.*)\]\]/,
|
52
|
+
Proc.new{|m, oo, log|
|
53
|
+
parameter = m[1].split('|')
|
54
|
+
filename = parameter[0]
|
55
|
+
if parameter.size > 1
|
56
|
+
txt = "#{parameter.last}"
|
57
|
+
else
|
58
|
+
txt = File.basename(filename)
|
59
|
+
end
|
60
|
+
if Wikireg.give_message? and ! File.exist?(filename)
|
61
|
+
log.warn( "Link to unexisting local file #{filename} (from #{Dir.pwd})" ) if log.warn?
|
62
|
+
end
|
63
|
+
|
64
|
+
css = CSS.new()
|
65
|
+
parameter[1..-2].each{|p|
|
66
|
+
case p
|
67
|
+
when 'size'
|
68
|
+
txt << " (#{File.size(filename)/1024}KB)" if File.exist?(filename)
|
69
|
+
when /(.*)=>(.*)/
|
70
|
+
css[$1] = $2
|
71
|
+
else
|
72
|
+
log.warn( "Wiki-File with unknown setting #{p}" ) if log.warn?
|
73
|
+
end
|
74
|
+
}
|
75
|
+
#Result:
|
76
|
+
[
|
77
|
+
oo.inline(m.pre_match, log),
|
78
|
+
element(:a, { :href => filename, :alt => txt, :style => css }, oo.inline(txt, log) ),
|
79
|
+
oo.inline(m.post_match,log)
|
80
|
+
]} ),
|
81
|
+
Wikireg.new(:label, %r{\[\[label:(.*)\]\]},
|
82
|
+
Proc.new{|m, oo, log|
|
83
|
+
[ oo.inline(m.pre_match, log),
|
84
|
+
element(:label, { :name => m[1]} ),
|
85
|
+
oo.inline(m.post_match, log)
|
86
|
+
]
|
87
|
+
} ),
|
88
|
+
Wikireg.new(:ref, %r{<ref>(.*)</ref>},
|
89
|
+
Proc.new{|m, oo, log|
|
90
|
+
puts "<ref> is obsolete, use {{footnote}}. To get footnotes set {{footnotes|ref}}"
|
91
|
+
[ oo.inline(m.pre_match, log),
|
92
|
+
element(:footnote, { :groupid => 'ref' }, oo.inline(m[1],log) ),
|
93
|
+
oo.inline(m.post_match, log)
|
94
|
+
]
|
95
|
+
} ),
|
96
|
+
Wikireg.new(:bf_it, /''''(.*?)''''/,
|
97
|
+
Proc.new{|m, oo, log| [ oo.inline(m.pre_match, log),
|
98
|
+
element(:textbf, {}, element(:emph, {}, oo.inline(m[1], log) )),
|
99
|
+
oo.inline(m.post_match, log)
|
100
|
+
]} ),
|
101
|
+
Wikireg.new(:bf, /'''(.*?)'''/,
|
102
|
+
Proc.new{|m, oo, log| [ oo.inline(m.pre_match, log),
|
103
|
+
element(:textbf, {}, oo.inline(m[1], log)),
|
104
|
+
oo.inline(m.post_match, log)
|
105
|
+
]} ),
|
106
|
+
Wikireg.new(:it, /''(.*?)''/,
|
107
|
+
Proc.new{|m, oo, log| [ oo.inline(m.pre_match, log),
|
108
|
+
element(:emph, {}, oo.inline(m[1], log)),
|
109
|
+
oo.inline(m.post_match, log)
|
110
|
+
]} ),
|
111
|
+
#Soll in Wikipedia-Artikeln nicht verwendet werden.
|
112
|
+
Wikireg.new(:small, %r{<small>(.*)</small>},
|
113
|
+
Proc.new{|m, oo, log|
|
114
|
+
[ oo.inline(m.pre_match, log),
|
115
|
+
element(:small, {}, oo.inline(m[1], log )),
|
116
|
+
oo.inline(m.post_match, log)
|
117
|
+
]
|
118
|
+
} ),
|
119
|
+
Wikireg.new(:stroke, %r{<s>(.*)</s>},
|
120
|
+
Proc.new{|m, oo, log|
|
121
|
+
[ oo.inline(m.pre_match, log),
|
122
|
+
element(:stroke, {}, oo.inline(m[1], log )),
|
123
|
+
oo.inline(m.post_match, log)
|
124
|
+
]
|
125
|
+
} ),
|
126
|
+
#- Textbaustein {{...}}
|
127
|
+
#Standard: [[ legt Textbaustein an, {{ nutzt diesen
|
128
|
+
# http://de.wikipedia.org/wiki/Wikipedia:Textbausteine/Schwesterprojekte
|
129
|
+
#- http://de.wikipedia.org/wiki/Wikipedia:Textbausteine
|
130
|
+
Wikireg.new(:wikidef, /\[\[(.+?):(.*?)\]\]/,
|
131
|
+
Proc.new{|m, oo, log|
|
132
|
+
puts "wikidef #{m[1].inspect} obsolete, please use macro {{..|"
|
133
|
+
[ oo.inline(m.pre_match, log),
|
134
|
+
oo.wikidef(m[1], m[2] ),
|
135
|
+
oo.inline(m.post_match, log)
|
136
|
+
]}
|
137
|
+
),
|
138
|
+
Wikireg.new(:wiki_macro, /\{\{(.+?)(\|(.*?))?\}\}/,
|
139
|
+
Proc.new{|m, oo, log|
|
140
|
+
[ oo.inline(m.pre_match, log),
|
141
|
+
oo.wiki_macro(m[1], m[3] ),
|
142
|
+
oo.inline(m.post_match, log)
|
143
|
+
].delete_if{|e| ! e or e.respond_to?(:to_str) and /\A\s*\Z/m =~ e}
|
144
|
+
#[].delete(nil) may return nil -> use delete_if
|
145
|
+
}
|
146
|
+
),
|
147
|
+
#Problem: detect end of url without a end-character
|
148
148
|
#[uri text]
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
149
|
+
Wikireg.new(:url1, %r{\[\s*((?:https?://|\.|C:\\|C:\/|ftp:|mailto:|webcal://).*?)\s+(.*?)\s*\]},
|
150
|
+
Proc.new{|m, oo, log|
|
151
|
+
#Check local files, but without anchor
|
152
|
+
if /\A\./ =~ m[1] #local file
|
153
|
+
filename = oo.inputsource + m[1].split(/#/).first
|
154
|
+
else
|
155
|
+
filename = m[1].split(/#/).first
|
156
|
+
end
|
157
157
|
if Wikireg.give_message? and /\A(\.|\w:)/ =~ m[1] and ! File.exist?(filename)
|
158
158
|
log.warn( "Link to unexisting local file #{filename} (from #{Dir.pwd})" ) if log.warn?
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
159
|
+
end
|
160
|
+
link_url = m[1]
|
161
|
+
if /^\w:/ =~ link_url #local file with absolut path
|
162
|
+
link_url = 'file://' + link_url
|
163
|
+
end
|
164
|
+
if m[2].size > 0
|
165
|
+
linktext = m[2]
|
166
|
+
else
|
167
|
+
linktext = m[1].sub(/http:\/\//, '').sub(/\/$/, '')
|
168
|
+
end
|
169
|
+
[ oo.inline(m.pre_match, log),
|
170
|
+
element(:a, {:href=> link_url }, oo.inline(linktext, log) ),
|
171
|
+
oo.inline(m.post_match, log)
|
172
|
+
]
|
173
|
+
}
|
174
|
+
),
|
175
175
|
#uri http...
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
176
|
+
Wikireg.new(:url2, %r{(https?://.*?)(\s|\Z)},
|
177
|
+
Proc.new{|m, oo, log|
|
178
|
+
[ oo.inline(m.pre_match, log),
|
179
|
+
#~ element(:a, {:href=> m[1]}, m[1] ), #hier kein oo.inline
|
180
|
+
element(:url, {}, m[1] ), #hier kein oo.inline
|
181
|
+
m[2], #Space/CR
|
182
|
+
oo.inline(m.post_match, log)
|
183
|
+
]} ),
|
184
|
+
Wikireg.new(:wikilink, /\[\[(.+?)(\|(.*?))?\]\]/,
|
185
|
+
#~ Wikireg.new(:wikilink, /\[\[(.+?)\]\]/,
|
186
|
+
Proc.new{|m, oo, log|
|
187
|
+
linktext = m[1]
|
188
|
+
#m[2] includes the |
|
189
|
+
if m[3]
|
190
|
+
linktext = m[3]
|
191
|
+
end
|
192
|
+
[ oo.inline(m.pre_match, log),
|
193
|
+
element(:a, {:href=> m[1]},
|
194
|
+
oo.inline(linktext, log)
|
195
|
+
),
|
196
|
+
oo.inline(m.post_match, log)
|
197
|
+
]
|
198
|
+
} ),
|
199
199
|
]
|
200
200
|
|
201
201
|
#require 'LotusNotes.rb'
|
202
202
|
WIKI_INLINE_REPLACEMENT_NOTES =
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
203
|
+
Wikireg.new(:notes, /(Notes:.*?)(\s|\Z)/, Proc.new{|m, oo, log|
|
204
|
+
[
|
205
|
+
oo.inline( m.pre_match, log),
|
206
|
+
LN_Link.new( m[1] ).to_element,
|
207
|
+
m[2],
|
208
|
+
oo.inline( m.post_match, log ),
|
209
|
+
]})
|
210
210
|
|
211
211
|
WIKI_INLINE_REPLACEMENTS_SYMBOLS = [
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
212
|
+
#Problem: Native LaTeX with beamer and \only...
|
213
|
+
Wikireg.new(:arrow, /->/,
|
214
|
+
Proc.new{|m, oo, log|
|
215
|
+
[ oo.inline(m.pre_match, log),
|
216
|
+
element(:rightarrow),
|
217
|
+
oo.inline(m.post_match, log),
|
218
|
+
]
|
219
|
+
} ),
|
220
|
+
Wikireg.new(:Arrow, /=>/,
|
221
|
+
Proc.new{|m, oo, log|
|
222
|
+
[ oo.inline(m.pre_match, log),
|
223
|
+
element(:Rightarrow),
|
224
|
+
oo.inline(m.post_match, log),
|
225
|
+
]
|
226
|
+
} ),
|
227
|
+
]
|
228
228
|
|
229
229
|
WIKI_INLINE_REPLACEMENTS_UNDERSCORE = Wikireg.new(:underscore, /_/,
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
230
|
+
Proc.new{|m, oo, log|
|
231
|
+
[ oo.inline(m.pre_match, log),
|
232
|
+
"\\_",
|
233
|
+
oo.inline(m.post_match, log),
|
234
|
+
]
|
235
|
+
} )
|
236
|
+
|
237
237
|
#require 'LotusNotes.rb'
|
238
238
|
if defined? LN_Link
|
239
|
-
|
239
|
+
WIKI_INLINE_REPLACEMENTS << WIKI_INLINE_REPLACEMENT_NOTES
|
240
240
|
end
|
241
241
|
|
242
242
|
module Wiki_helper
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
243
|
+
#Transfer the input to a list.
|
244
|
+
#input can be
|
245
|
+
#-String
|
246
|
+
#-List
|
247
|
+
#-File (if .rb, then the part after __END__ is taken)
|
248
|
+
#The method returns a list with lines, but no \n
|
249
|
+
def get_input( input, lineoffset, close_it = false )
|
250
|
+
inputlist = []
|
251
|
+
if input.is_a?(String)
|
252
|
+
#~ inputlist = input.split("\n")
|
253
|
+
#Convert to Array, but keep the \n
|
254
|
+
inputlist = input.split("\n")
|
255
|
+
elsif input.is_a?(Array)
|
256
|
+
inputlist = input.flatten.map{|l| l.nil? ? '' : l.chomp()}
|
257
|
+
elsif input.is_a?(File)
|
258
|
+
#If file is a ruby scriot, then the wiki-code in after __END__
|
259
|
+
if /\.rb\Z/ =~ input.path and $0 != input.path
|
260
|
+
line = input.readline while line != "__END__\n"
|
261
|
+
end
|
262
|
+
lineoffset = input.lineno
|
263
|
+
inputlist << input.readlines.map{|l| l.chomp}
|
264
|
+
input.close if close_it
|
265
|
+
end
|
266
|
+
return inputlist, lineoffset
|
267
|
+
end
|
268
268
|
end
|
269
269
|
#
|
270
270
|
#Struct for wiki elements.
|
@@ -281,263 +281,345 @@ class Wikielements < Struct.new('Wikielements', :first, :l1,:l2,:l3,:l4, :tab,
|
|
281
281
|
end
|
282
282
|
end
|
283
283
|
|
284
|
-
|
284
|
+
#
|
285
|
+
#Get text in wiki-format and build a docgenerator-version.
|
286
|
+
#
|
285
287
|
class Wikitext
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
288
|
+
#
|
289
|
+
#Make short description for the Wiki-syntax
|
290
|
+
def self.help( version = :syntax)
|
291
|
+
hlp = []
|
292
|
+
hlp << "Wikitext.help #{version.inspect}"
|
293
|
+
hlp << "-------------------------------------"
|
294
|
+
case version
|
295
|
+
when :syntax
|
296
|
+
hlp << <<main
|
297
|
+
Sections:
|
298
|
+
==title==
|
299
|
+
===subtitle===
|
300
|
+
====subsubtitle====
|
301
|
+
Lists:
|
302
|
+
* unordered
|
303
|
+
# ordered
|
304
|
+
description-like:
|
305
|
+
;key
|
306
|
+
:entry
|
307
|
+
Pictures:
|
308
|
+
[[Bild:path|options]]
|
309
|
+
For options use Wikitext.help(:img)
|
310
|
+
Tabulars:
|
311
|
+
Use Wikitext.help(:tab) for details
|
312
|
+
Specials:
|
313
|
+
---- hrule
|
314
|
+
main
|
315
|
+
when :img
|
316
|
+
hlp << <<main
|
317
|
+
Pictures in Wikitext:
|
318
|
+
[[Bild:path|options]]
|
319
|
+
The complete command must be in one line.
|
320
|
+
Options:
|
321
|
+
- href=
|
322
|
+
- alt=
|
323
|
+
- imgclass=: Used for CSS-class (img)
|
324
|
+
- figureclass=: Used for CSS-class (span/div)
|
325
|
+
- left, right: CSS: float
|
326
|
+
- aftertitle/beforetitle: Text before/after image
|
327
|
+
- thumb: Add a thumb in the text and link to picture
|
328
|
+
- \d*px: size/width
|
329
|
+
- width=xx% define width for img/includegraphics
|
330
|
+
- xx = : Used for CSS in img
|
331
|
+
main
|
332
|
+
when :tab
|
333
|
+
hlp << <<tabhelp
|
334
|
+
Tabulars in Wikitext:
|
335
|
+
{|taboptions
|
336
|
+
|[lineoptions|]
|
337
|
+
|-[newline-options]
|
338
|
+
|
|
339
|
+
|}
|
340
|
+
taboptions:
|
341
|
+
- columns=: number of columns (required)
|
342
|
+
- columndescription: For LaTeX
|
343
|
+
- border=: HTML
|
344
|
+
- .* = (.*): Used for CSS
|
345
|
+
newline-options
|
346
|
+
- toprule
|
347
|
+
- midrule
|
348
|
+
- hline
|
349
|
+
- .* = (.*): Used for CSS
|
350
|
+
lineoptions:
|
351
|
+
- colspan =
|
352
|
+
- pos
|
353
|
+
- .* = (.*): Used for CSS
|
354
|
+
|
355
|
+
Remark: If the text contains macros with | there is a bit confusion,
|
356
|
+
what is a parameter of the cell and whats part of the macro.
|
357
|
+
|
358
|
+
Solution: Define the end of cell parameters with ||
|
359
|
+
tabhelp
|
360
|
+
else
|
361
|
+
hlp << "Sorry, option #{version.inspect} unknown"
|
362
|
+
end
|
363
|
+
return hlp.join("\n")
|
364
|
+
end #help
|
365
|
+
#Read text and convert it to a Document.
|
366
|
+
def initialize(
|
367
|
+
options = {}
|
368
|
+
)
|
369
|
+
#convert from old interface
|
370
|
+
options = {
|
371
|
+
:wiki_inline_replacements => options
|
372
|
+
} if options.is_a?(Array)
|
373
|
+
@options = {
|
374
|
+
:wiki_inline_replacements => WIKI_INLINE_REPLACEMENTS + WIKI_INLINE_REPLACEMENTS_SYMBOLS,
|
296
375
|
:log => Log4r::Logger.new('Wikitext', Log4r::INFO),
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
376
|
+
:inputsource => './',
|
377
|
+
:parsetest => false #Make an immediate test for parsing
|
378
|
+
}.update(options)
|
379
|
+
@source = []
|
380
|
+
#Hash with all footnote groups
|
381
|
+
@footnotegroups = {}
|
382
|
+
#This rules can be extended via the accessors.
|
383
|
+
@wiki_inline_replacements = @options[:wiki_inline_replacements]
|
384
|
+
@lineoffset = 0 #for better debugging
|
385
|
+
@inputsource = @options[:inputsource]
|
386
|
+
@log = @options[:log]
|
306
387
|
@log.outputters = Log4r::StdoutOutputter.new('log_stdout') if @log.outputters.empty?
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
388
|
+
self << @options[:content] if @options[:content]
|
389
|
+
@parent = self
|
390
|
+
end
|
391
|
+
#Line offset.
|
392
|
+
#Is used as initial value in <<
|
393
|
+
attr_writer :lineoffset
|
394
|
+
#Used for relative filecheck
|
395
|
+
attr_accessor :inputsource
|
396
|
+
#Array with the rules for the inline elements (like text formatting...)
|
397
|
+
#Can be extended/replaces by this accessor
|
398
|
+
#
|
399
|
+
#Don't include arrays. elements must be 'Wikireg'.
|
400
|
+
attr_reader :wiki_inline_replacements
|
320
401
|
#Logger
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
402
|
+
attr_reader :log
|
403
|
+
#Element, where the wiki test belongs to.
|
404
|
+
#Can be used in the procs insiede a wikirule.
|
405
|
+
attr_accessor :parent
|
406
|
+
#Wiki-Code, which is translated to to_element.
|
407
|
+
#Source is an array
|
408
|
+
attr_accessor :source
|
409
|
+
|
410
|
+
include Wiki_helper
|
411
|
+
#Add contents to Wiki-Text
|
412
|
+
def <<( input )
|
413
|
+
inputlist, lineoffset = get_input( input, @lineoffset )
|
414
|
+
#The immediate parsing may help, when an error occurs.
|
415
|
+
#The immediat parsing returns error messages with correct lineoffsets.
|
416
|
+
#(On the other side, it may helt to see the @source itself)
|
417
|
+
wiki2doc( inputlist.join("\n"), lineoffset ) if @options[:parsetest] == true
|
418
|
+
@source.concat(inputlist)
|
419
|
+
return self
|
420
|
+
end
|
421
|
+
#Prepare output for docgenerator.
|
341
422
|
#
|
342
423
|
#Attention! to_doc uses another logger then the wiki.
|
343
424
|
#If it should be the same, it must be added at definition of the wiki.
|
344
|
-
|
425
|
+
def to_doc( target, options = {} )
|
345
426
|
o = Docgenerator_logger.set_option_defaults(options)
|
346
427
|
o[:log].debug("enter to_doc for Wikitext #{self.inspect}") if o[:log].debug?
|
347
|
-
|
348
|
-
|
428
|
+
@footnotegroups = {} #Avoid the multiple additions to groups (this makes parallel processing inpossible!)
|
429
|
+
doc = wiki2doc( @source.join("\n") ) #return lists of element
|
349
430
|
doc.to_doc(target, options )
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
431
|
+
end #Wikitext.to_doc
|
432
|
+
|
433
|
+
#
|
434
|
+
#Method is called for wiki-structures like
|
435
|
+
# [[key:value]]
|
436
|
+
#This can be used to adapt the wiki for special usages.
|
437
|
+
#
|
438
|
+
#This is a inline replacement.
|
439
|
+
#The return code is added at the location, where it is defined
|
440
|
+
def wikidef( key, value )
|
360
441
|
@log.warn("#{self.class}#wikidef #{key}: #{value} in line #{@lineno}" ) if log.warn?
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
442
|
+
return value
|
443
|
+
end
|
444
|
+
#Include a picture
|
445
|
+
# [[Bild:Dateiname|Zusatzinfos|Beschreibung]]
|
446
|
+
#Zusatzinfos:
|
447
|
+
# -left/right
|
448
|
+
# -___px scale the pic. When used in combination with thumb, a pic "widht-picname) is searched.
|
449
|
+
# -thumb (usefull in combination with href or width=50%)
|
450
|
+
#figure_type:
|
451
|
+
#The picture is framed by this value.
|
452
|
+
#When you use :div, you can't make inline-Pics.
|
453
|
+
#:span can be used also as float (HTML)
|
454
|
+
#Correct LaTeX: figure (or not?
|
455
|
+
def wiki_bild( picname, parameter, log, figure_type = :span)
|
456
|
+
thumb = false #Use thumb instead
|
457
|
+
href = false #make pic clickabe
|
458
|
+
figure = element(figure_type, { :style => css_fig = CSS.new() }).cR
|
459
|
+
css_img = CSS.new()
|
460
|
+
option = { :src => picname, :style => css_img } #Options for img
|
461
|
+
before_img = []
|
462
|
+
after_img = []
|
463
|
+
|
464
|
+
parameter.each{|p|
|
465
|
+
case p
|
466
|
+
when /href=(.*)/; href = $1
|
467
|
+
when /alt=(.*)/; option[:alt] = $1
|
468
|
+
when /imgclass=(.*)/; option[:class] = $1
|
469
|
+
when /figureclass=(.*)/; figure[:class] << $1
|
470
|
+
when /^class=(.*)/; option[:class] = $1 #old
|
471
|
+
when 'left', 'right'
|
472
|
+
css_fig[:float] = p
|
473
|
+
when /aftertitle(=(.*))*/
|
474
|
+
after_img << element(:br, { :clear => 'all' } ).cr
|
475
|
+
after_img << $2
|
476
|
+
when /beforetitle(=(.*))*/
|
477
|
+
before_img << $2
|
478
|
+
after_img << element(:br, { :clear => 'all' } ).cr
|
479
|
+
when /thumb(=(.*))*/
|
480
|
+
#Add a thumb in the text and link to picture
|
481
|
+
thumb = true #look later for width-picname
|
482
|
+
thumb = $2 if $2
|
483
|
+
if File.exist?( @inputsource + picname ) and !href
|
484
|
+
href = picname
|
485
|
+
end
|
486
|
+
when /\A\d*px\Z/ #size
|
487
|
+
option[:width] = p
|
488
|
+
when /(width)=(.*)/
|
489
|
+
css_img[$1] = $2
|
490
|
+
w = $2 #store it, $2 is replaced in next regex.
|
491
|
+
case w
|
492
|
+
when /100%/
|
493
|
+
option[:width] = "\\textwidth"
|
494
|
+
when /\A(\d+)%/
|
495
|
+
option[:width] = "0.#{$1}\\textwidth"
|
496
|
+
else
|
497
|
+
option[:width] = w
|
498
|
+
end
|
499
|
+
when /(.*)=(.*)/
|
500
|
+
css_img[$1] = $2
|
501
|
+
else
|
502
|
+
log.warn( "Wiki-Picture with unknown setting #{p}" ) if log.warn?
|
503
|
+
end
|
504
|
+
}
|
505
|
+
|
506
|
+
bild = []
|
507
|
+
bild = element(:a, {:href=>href }).cr if href
|
508
|
+
|
509
|
+
figure << before_img if ! before_img.empty?
|
510
|
+
figure << bild
|
511
|
+
figure << after_img if ! after_img.empty?
|
431
512
|
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
514
|
-
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
513
|
+
if thumb == true
|
514
|
+
if File.exist?( "#{option[:width]}-#{option[:src]}" )
|
515
|
+
thumb = "#{option[:width]}-#{option[:src]}"
|
516
|
+
else
|
517
|
+
thumb = picname
|
518
|
+
end
|
519
|
+
end
|
520
|
+
option[:src] = thumb if thumb
|
521
|
+
|
522
|
+
if /^(http|file|.:\/|\/)/ =~ option[:src]
|
523
|
+
src = option[:src]
|
524
|
+
else
|
525
|
+
src = @inputsource + option[:src]
|
526
|
+
end
|
527
|
+
if /^http/ !~ src and ! File.exist?( (src).sub(%r{file:\/\/}, '') )
|
528
|
+
log.warn( "Wikireg:bild: Picture #{option[:src]} not found (check from #{Dir.pwd} #{inputsource})" ) if log.warn?
|
529
|
+
end
|
530
|
+
if thumb and ! File.exist?( @inputsource + thumb )
|
531
|
+
log.warn( "Wikireg:bild: Thumb #{thumb} not found (check from #{Dir.pwd} #{inputsource})" ) if log.warn?
|
532
|
+
end
|
533
|
+
if href and /^http:/!~ href and ! File.exist?( @inputsource + href )
|
534
|
+
log.warn("Wikireg:bild: reference #{href} not found (check from #{Dir.pwd} #{inputsource})" ) if log.warn?
|
535
|
+
#~ puts Dir.pwd
|
536
|
+
#~ puts @inputsource.inspect
|
537
|
+
#~ puts href
|
538
|
+
#~ puts option[:src]
|
539
|
+
#~ puts '-'*10
|
540
|
+
end
|
541
|
+
|
542
|
+
bild << element(:img, option )
|
543
|
+
figure
|
544
|
+
end #wiki_bild
|
545
|
+
|
546
|
+
#
|
547
|
+
#Analyses {{-Textmacros.
|
548
|
+
#If it is redefined, but want to keep the standard method,
|
549
|
+
#then you can call it via super in the else-branch of your case-command.
|
550
|
+
def wiki_macro( key, value, log = @log )
|
551
|
+
if value
|
552
|
+
val = value.split('|')
|
553
|
+
else
|
554
|
+
val = []
|
555
|
+
end
|
556
|
+
case key
|
557
|
+
when 'maketitle', 'author', 'title', 'date'
|
558
|
+
val = val[0]
|
559
|
+
return [
|
560
|
+
element( key.to_sym,{},val ).cr,
|
561
|
+
]
|
562
|
+
when 'Commons'
|
563
|
+
return [
|
564
|
+
element(:a, { :href => "http://commons.wikimedia.org/wiki/#{val[0]}" }, "Commons: #{val[0]}" ).cr,
|
565
|
+
]
|
566
|
+
#~ when 'Wikibooks'
|
567
|
+
#~ #fixme language?
|
568
|
+
#~ return [
|
569
|
+
#~ element(:a, { :href => "http://en.wikibooks.org/wiki/#{val[0]}" }, "Commons: #{val[0]}" ).cr,
|
570
|
+
#~ ]
|
571
|
+
when 'newline'
|
572
|
+
if val.include?('clear')
|
573
|
+
return element(:br, {:clear=>'all'})
|
574
|
+
else
|
575
|
+
return element(:br)
|
576
|
+
end
|
577
|
+
when 'dmoz'
|
578
|
+
def dmoz_analyse(val)
|
579
|
+
if val[1]
|
580
|
+
catname = val[1]
|
581
|
+
else
|
582
|
+
catname = val[0].split(/\//).last.gsub(/_/, ' ')
|
583
|
+
end
|
584
|
+
cat = val[0].sub(%r{http://(www|editors)*.dmoz.org/}, '')
|
585
|
+
cat << '/' if cat[-1,1] != '/'
|
586
|
+
return cat, catname
|
587
|
+
end
|
588
|
+
cat, catname = dmoz_analyse(val)
|
589
|
+
return [
|
590
|
+
'Weitere Links zum Thema ',
|
591
|
+
element(:a, { :href => "http://dmoz.org/#{cat}" }, catname ),
|
592
|
+
' im Open Directory Project'
|
593
|
+
]
|
594
|
+
when 'dmozed'
|
595
|
+
#fixme: Umlaute
|
596
|
+
cat, catname = dmoz_analyse(val)
|
597
|
+
return [
|
598
|
+
element(:a, { :href => "http://dmoz.org/#{cat}" }, catname ),
|
599
|
+
' ',
|
600
|
+
element(:a, { :href => "http://editors.dmoz.org/editors/editcat.cgi?cat=#{cat}" },
|
601
|
+
[ '(Edit)'])
|
602
|
+
]
|
603
|
+
#footnotes|groupid
|
604
|
+
when 'footnotes'
|
605
|
+
#~ value = self.object_id if ! value
|
606
|
+
value = Footnotegroup::DEFAULTGROUPID unless value
|
607
|
+
return @footnotegroups[value]
|
608
|
+
#footnote[groupid]
|
609
|
+
when /footnote(\[(.*)\])*/
|
610
|
+
groupid = $2 ? $2 : Footnotegroup::DEFAULTGROUPID
|
611
|
+
if ! @footnotegroups[groupid]
|
612
|
+
@footnotegroups[groupid] = Footnotegroup.new(groupid)
|
613
|
+
end
|
614
|
+
return [
|
615
|
+
element(:footnote, { :group => @footnotegroups[groupid] }, self.inline(value, log) ),
|
616
|
+
]
|
617
|
+
when 'html'
|
618
|
+
return element(:htmlonly, {}, value )
|
619
|
+
when 'rubycode', 'rubyvar' ##Pfui, eval
|
620
|
+
log.warn( "#{self.class}#wiki_macro: eval in line #{@lineno} ('#{value}')" ) if log.warn?
|
621
|
+
#~ return eval(value)
|
622
|
+
return eval(value, binding, 'Wiki', @lineno)
|
541
623
|
when 'verbatimfile'
|
542
624
|
if File.exist?( val.first )
|
543
625
|
return element(:verbatim,
|
@@ -555,477 +637,492 @@ class Wikitext
|
|
555
637
|
log.error( "#{self.class}#wiki_macro: File #{value} missing for filecontent in line #{@lineno}" ) if log.error?
|
556
638
|
end
|
557
639
|
#A symbol. The corresponding element must be defined.
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
640
|
+
when 'symbol'; return element(value.to_sym)
|
641
|
+
when 'backslash'; return element(:backslash )
|
642
|
+
when '^'; return element(:ensuremath, {}, element(:'^' ) )
|
643
|
+
when '>'; return element(:gt)
|
644
|
+
when '<'; return element(:lt)
|
645
|
+
when '&'; return element(:'\&')
|
646
|
+
when 'percent', '%'; return element(:percent )
|
647
|
+
when 'rbrace'; return element(:rbrace )
|
648
|
+
when '_'; return element(:underscore )
|
649
|
+
when ' '; return element(:relax )
|
650
|
+
when '...'; return element(:ldots )
|
651
|
+
when 'lbrace'; return element(:lbrace )
|
652
|
+
when 'tilde', 'sim'; return element(:sim )
|
653
|
+
when 'math'; return element(:ensuremath,{}, value )
|
570
654
|
#>>>requires privat/affiliate.rb
|
571
|
-
|
655
|
+
when 'asin'
|
572
656
|
return Amazon.new.asin_in_iframe( value ) if defined? JPC
|
573
657
|
log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
|
574
658
|
return ''
|
575
|
-
|
659
|
+
when 'amazon' #~ {{amazon|produktlinie|keywords}}
|
576
660
|
return Amazon.make_link(val) if defined? JPC
|
577
661
|
log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
|
578
662
|
return ''
|
579
|
-
|
663
|
+
when 'jpc' #~ {{amazon|produktlinie|keywords}}
|
580
664
|
return JPC.make_link(val) if defined? JPC
|
581
665
|
log.error( "#{self.class}#wiki_macro: No privat/docgenerator_affiliate available (line #{@lineno})" ) if log.error?
|
582
666
|
return ''
|
583
667
|
#<<<requires privat/affiliate.rb
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
668
|
+
when 'fixme'
|
669
|
+
log.info( "Fixme: #{value}" ) if log.info?
|
670
|
+
return element(:comment, {}, [ 'Fixme: ', value ] )
|
671
|
+
else
|
672
|
+
log.error( "#{self.class}#wiki_macro Key '#{key}' unknown in line #{@lineno} ('#{value}')" ) if log.error?
|
673
|
+
return value
|
674
|
+
end
|
675
|
+
end
|
592
676
|
|
593
677
|
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
|
678
|
+
#Little structure for use in wiki2doc.
|
679
|
+
Wiki_line = Struct.new('Wiki_line', :type, :content, :lineno, :indent, :add_info)
|
680
|
+
#
|
681
|
+
#Parse the text and creates the elements of it.
|
682
|
+
#
|
683
|
+
def wiki2doc( txt, lineoffset = 0, log = @log )
|
684
|
+
(@wiki_inline_replacements ).each{|rule|
|
685
|
+
if ! rule.is_a?(Wikireg)
|
686
|
+
log.fatal( "Wikitext.wiki2doc: rule is no Wikireg #{rule.inspect}" ) if log.fatal?
|
687
|
+
end
|
688
|
+
}
|
605
689
|
|
606
|
-
|
607
|
-
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
690
|
+
lines = []
|
691
|
+
@lineno = lineoffset
|
692
|
+
collector = nil #collect content for other application
|
693
|
+
collectorline = nil #collect content for other application
|
694
|
+
|
695
|
+
txt.each{|line|
|
696
|
+
|
697
|
+
if line.gsub!( /#~.*/, '') #delete comments
|
698
|
+
#skip processing, if the line is now empty.
|
699
|
+
#Without this, empty paragraphs can be created.
|
700
|
+
next if line == "\n"
|
701
|
+
end
|
702
|
+
@lineno += 1
|
618
703
|
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
|
704
|
+
#if the content should be turned into new variant, do it here.
|
705
|
+
if collector
|
706
|
+
if /^<<</ =~ line #close the collector
|
707
|
+
lines << Wiki_line.new(:collector, collector, collectorline )
|
708
|
+
collector = nil
|
709
|
+
else
|
710
|
+
collector << line.chomp #collect content to collector
|
711
|
+
end
|
712
|
+
next
|
713
|
+
end
|
714
|
+
#Preparse. Detect line type and assign it
|
715
|
+
case line.chomp
|
716
|
+
#Example:
|
717
|
+
#>>>structogramm{title;width;height}
|
718
|
+
when /^>>>(.*)\{(.*)\}/
|
719
|
+
args = []
|
720
|
+
ctype = $1
|
721
|
+
args = $2.split(/[;]/) if $2
|
722
|
+
collector = WikiCollector.create(ctype, args )
|
723
|
+
collectorline = @lineno
|
724
|
+
if ! collector
|
640
725
|
log.error( "#{__FILE__}##{__LINE__}: Undefined Collector #{ctype.inspect} used. Take Array instead (line #{@lineno})" ) if log.error?
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
650
|
-
|
651
|
-
|
652
|
-
|
653
|
-
|
654
|
-
|
655
|
-
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
|
668
|
-
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
681
|
-
|
682
|
-
|
683
|
-
|
684
|
-
|
685
|
-
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
|
710
|
-
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
726
|
+
collector = []
|
727
|
+
end
|
728
|
+
#===[key]Titel===
|
729
|
+
when /\A(=+)(?:\[(.*?)\])?(.+?)(=+)\s*/ #:h1, :h2, :h3, :h4, :h5, :h6
|
730
|
+
#~ puts $1, $2, $3
|
731
|
+
if $1.size != $4.size
|
732
|
+
log.warn("#{__FILE__}: Heading problem #{$1} doesn't match <#{$3}> #{line.inspect}" ) if log.warn?
|
733
|
+
end
|
734
|
+
#Level starts with ==
|
735
|
+
# =title= is not supported.
|
736
|
+
h_level = "h#{$1.size - 1}".to_sym
|
737
|
+
lines << Wiki_line.new(h_level, self.inline($3, log), @lineno, nil, $2)
|
738
|
+
when /^\s*$/ #empty line
|
739
|
+
lines << Wiki_line.new(:p, nil, @lineno)
|
740
|
+
when /^((?:\*|\#)+)(\s*)/ #:li
|
741
|
+
lines << Wiki_line.new(:li, self.inline($~.post_match, log), @lineno, $2.size, $1)
|
742
|
+
#Experiment f�r items in description
|
743
|
+
#~ when /^(:)?((?:\*|\#)+)(\s*)/ #:li
|
744
|
+
#~ puts '>' * 15
|
745
|
+
#~ puts line.inspect
|
746
|
+
#~ puts $1.inspect
|
747
|
+
#~ puts $2.inspect
|
748
|
+
#~ puts $3.inspect
|
749
|
+
#~ puts '<' * 15
|
750
|
+
#~ lines << Wiki_line.new(:li, self.inline($~.post_match, log), @lineno, $3.size, $2)
|
751
|
+
when /^;(\s*)/ #:dt
|
752
|
+
lines << Wiki_line.new(:dt, self.inline($~.post_match, log), @lineno, $1.size)
|
753
|
+
when /^:(\s*)/ #:dd
|
754
|
+
lastline = lines.last
|
755
|
+
if ! lastline
|
756
|
+
log.warn( "#{__FILE__}: Use ':' at start of wiki text. #{@lineno}" ) if log.warn?
|
757
|
+
lastline = Wiki_line.new() #Avoid error with method type
|
758
|
+
end
|
759
|
+
#If there was already an indent before, loo back.
|
760
|
+
if lastline.type == :indent
|
761
|
+
#find first line before indent
|
762
|
+
lines.reverse.each{|line|
|
763
|
+
lastline = line
|
764
|
+
break if lastline.type != :indent
|
765
|
+
}
|
766
|
+
end
|
767
|
+
if [:dt,:dd].include?(lastline.type)
|
768
|
+
lines << Wiki_line.new(:dd, self.inline($~.post_match, log), @lineno, $1.size)
|
769
|
+
else #-> quote
|
770
|
+
lines << Wiki_line.new(:quote, self.inline($~.post_match, log), @lineno, $1.size)
|
771
|
+
end
|
772
|
+
when /^----$/ #:hr #line
|
773
|
+
lines << Wiki_line.new(:hr,nil,@lineno)
|
774
|
+
when /^(\s+)/ #:indent #can be: continuation of a list or a verbatim
|
775
|
+
lines << Wiki_line.new(:indent, $~.post_match, @lineno, $1.size)
|
776
|
+
when /^\{\|/ #:tab
|
777
|
+
lines << Wiki_line.new(:tabular,$~.post_match,@lineno)
|
778
|
+
when /^\|\}/ #:tabend
|
779
|
+
lines << Wiki_line.new(:tabular_end,$~.post_match,@lineno)
|
780
|
+
when /^\|-/ #:tabrow
|
781
|
+
lines << Wiki_line.new(:tabular_row,$~.post_match,@lineno)
|
782
|
+
when /^\|(.*\|)*(.*?)\s*$/ #:tabcell
|
783
|
+
par = $1
|
784
|
+
txt = $2
|
785
|
+
#if the text contains macros with | there is a bit confusion,
|
786
|
+
#what is a parameter of the cell and whats part of the macro.
|
787
|
+
#
|
788
|
+
#Solution:
|
789
|
+
#Define the end of cell parameters with ||
|
790
|
+
if par and par =~ /\|\|/
|
791
|
+
par = $~.pre_match #parameters only before ||
|
792
|
+
txt = $~.post_match + txt #txt all after ||
|
793
|
+
end
|
794
|
+
lines << Wiki_line.new(:tabular_cell ,self.inline(txt, log),@lineno,nil,par)
|
795
|
+
else
|
796
|
+
#~ puts "??\tUnknown line (#{__FILE__} line #{__LINE__})"
|
797
|
+
#~ puts "??\tUnknown line: #{line.inspect}"
|
798
|
+
#lines << Wiki_line.new(:text, self.inline(line, log), @lineno)
|
799
|
+
#Insert space at end of line, but before \n.
|
800
|
+
#Without, a line break results in HTML-Text without space between flow text
|
801
|
+
lines << Wiki_line.new(:text, self.inline("#{line.chomp} \n", log), @lineno)
|
802
|
+
end
|
803
|
+
} #txt.each |line|
|
804
|
+
|
805
|
+
if collector
|
721
806
|
log.error( "#{__FILE__}##{__LINE__}: Content Collector not closed (start in line #{collectorline}" ) if log.error?
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
731
|
-
|
732
|
-
|
733
|
-
|
734
|
-
|
735
|
-
|
736
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
|
794
|
-
|
795
|
-
|
796
|
-
|
807
|
+
end
|
808
|
+
|
809
|
+
elements = [] #main container
|
810
|
+
lists ={} #lists.
|
811
|
+
lines.each{|line|
|
812
|
+
case line.type
|
813
|
+
when :h1, :h2, :h3, :h4, :h5, :h6
|
814
|
+
elements << element( line.type,{},line.content).cr
|
815
|
+
if line.add_info
|
816
|
+
elements.last[:id] << line.add_info
|
817
|
+
end
|
818
|
+
#~ elements << element( line.type,{},self.inline(line.content, log)).cr
|
819
|
+
when :p #new paragraph
|
820
|
+
#fixme: how to detect new paragraph or continuation of item/pre/verbatim
|
821
|
+
if ! elements.last #Start wiki
|
822
|
+
elements << element( :p ).cr
|
823
|
+
elsif elements.last.is_a?(:p) and elements.last.content.empty?
|
824
|
+
#There is already an empty new par, we can use it.
|
825
|
+
elsif elements.last.is_a?(ListEnvironment)
|
826
|
+
#The next indent decides, if we need a new paragraph or continue in the last item.
|
827
|
+
elements.last.content.last << nil #Add neutral flag for new paragraph
|
828
|
+
else
|
829
|
+
elements << element( :p ).cr
|
830
|
+
end
|
831
|
+
when :hr
|
832
|
+
elements << element( :hr ).cr
|
833
|
+
when :text
|
834
|
+
if ! elements.last or ! elements.last.is_a?(:p)
|
835
|
+
elements << element( :p ).cr
|
836
|
+
end
|
837
|
+
elements.last << line.content
|
838
|
+
when :li
|
839
|
+
if ! elements.last.is_a?(ListEnvironment) #ListEnvironment can be also a :dl
|
840
|
+
lists = {} #delete all lists to start fresh
|
841
|
+
end
|
842
|
+
#~ puts "-----#{line.add_info}\t#{line.content.inspect}\t#{lists.keys.inspect}"
|
843
|
+
listtype = ''
|
844
|
+
loclist = {} #temporary list of lists. will be stored in 'lists'
|
845
|
+
1.upto(line.add_info.size){|level|
|
846
|
+
leveltyp = line.add_info[0..level-1] #typ of listhirarchie
|
847
|
+
if lists[leveltyp] #list already defined
|
848
|
+
loclist[leveltyp] = lists[leveltyp]
|
849
|
+
loclist[leveltyp] << element(:li,{}, line.content).cR if leveltyp == line.add_info
|
850
|
+
else #create new list
|
851
|
+
case line.add_info[-1,1]
|
852
|
+
when '*'
|
853
|
+
list_type = :ul
|
854
|
+
when '#'
|
855
|
+
list_type = :ol
|
856
|
+
else
|
857
|
+
log.error( "#{self.class}#wiki2doc: Unknown list type #{v}" ) if log.error?
|
858
|
+
end
|
859
|
+
loclist[leveltyp] = element( list_type ).CR
|
860
|
+
#include first item in list
|
861
|
+
loclist[leveltyp] << li = element(:li,{}).cR #add first item line
|
862
|
+
li << line.content if leveltyp == line.add_info #add content to item line
|
863
|
+
#Include list
|
864
|
+
if level == 1 #Add first list to element-list
|
865
|
+
elements << loclist[leveltyp]
|
866
|
+
elsif leveltyp == line.add_info #add new list to previous list
|
867
|
+
loclist[line.add_info[0,level-1]].content.last << loclist[leveltyp]
|
868
|
+
end
|
869
|
+
end
|
870
|
+
}
|
871
|
+
#copy lists and delete all other lists (so we get level changes)
|
872
|
+
lists = loclist
|
873
|
+
when :dt
|
874
|
+
#~ lists = {} #mixture dl and ul/ol not possible actual
|
875
|
+
if ! elements.last.is_a?(:dl)
|
876
|
+
elements << element(:dl).cR
|
877
|
+
lists[':'] = elements.last
|
878
|
+
end
|
879
|
+
elements.last << element(:dt,{},line.content ).cr
|
880
|
+
when :dd
|
881
|
+
if ! elements.last.is_a?(:dl)
|
797
882
|
log.warn( "#{self.class}#wiki2doc(#{line.lineno}: :dl without :dt (#{line.content.strip})" ) if log.warn?
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
|
814
|
-
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
851
|
-
|
852
|
-
|
853
|
-
|
854
|
-
|
883
|
+
elements << element(:dl).cr
|
884
|
+
end
|
885
|
+
elements.last << element(:dd,{},line.content).cr
|
886
|
+
when :quote
|
887
|
+
if ! elements.last.is_a?(:quote)
|
888
|
+
elements << element(:quote).cR
|
889
|
+
end
|
890
|
+
if line.content =~ /^\s*$/ #Empty line
|
891
|
+
elements.last << element(:newline).cR
|
892
|
+
else
|
893
|
+
elements.last << line.content
|
894
|
+
elements.last << ' '
|
895
|
+
end
|
896
|
+
when :indent
|
897
|
+
#~ puts "#{self.class}#wiki2doc(#{line.lineno}: indent: #{line.indent}\t#{line.add_info}\t#{line.content}"
|
898
|
+
#Check if the indent is part of a list item
|
899
|
+
if elements.last.is_a?(ListEnvironment)
|
900
|
+
lastlist = lists[lists.keys.max] #Get last (deepest) list
|
901
|
+
lastitem = lastlist.content.last
|
902
|
+
|
903
|
+
case lastitem.content.last
|
904
|
+
when nil #new paragraph
|
905
|
+
lastitem << element(:p, {}, self.inline(line.content, log)).cr
|
906
|
+
when Element #add content to last element
|
907
|
+
lastitem.content.last << self.inline(line.content, log)
|
908
|
+
else #add content to item line
|
909
|
+
lastitem << ' '
|
910
|
+
lastitem << self.inline(line.content, log)
|
911
|
+
end
|
912
|
+
elsif elements.last.is_a?(:dl)
|
913
|
+
lastitem << self.inline(line.content, log)
|
914
|
+
elsif ! elements.last.is_a?(:pre)
|
915
|
+
elements << element(:pre).cR
|
916
|
+
end
|
917
|
+
if elements.last.is_a?(:pre)
|
918
|
+
elements.last << (' ' * (line.indent - 1 )) + line.content + "\n"
|
919
|
+
end
|
920
|
+
when :tabular
|
921
|
+
if /longtable/ =~ line.content
|
922
|
+
elements << tab = element(:longtable, {:style=>CSS.new()}).CR
|
923
|
+
else
|
924
|
+
elements << tab = element(:tabular, {:style=>CSS.new()}).CR
|
925
|
+
end
|
926
|
+
if line.content #options
|
927
|
+
options = line.content.split('|')
|
928
|
+
options.each{|opt|
|
929
|
+
case opt
|
930
|
+
when /columndescription\s*=\s*(.*)/
|
931
|
+
tab[:columndescription] << $1.gsub(/!/, '|') #TeX-Format
|
932
|
+
when /columns\s*=\s*(.*)/
|
933
|
+
tab[:columns] << $1.to_i
|
934
|
+
when /border\s*=\s*(.*)/
|
935
|
+
tab[:border] << $1.to_i
|
936
|
+
when /(.*)\s*=\s*(.*)/
|
937
|
+
#~ puts "#{__FILE__}##{__LINE__}: #{opt}" if ! tab[:style].content.first
|
938
|
+
tab[:style].content.first[$1] = $2
|
939
|
+
else
|
855
940
|
log.warn( "#{self.class}#wiki2doc(#{line.lineno}: options for table unknown: #{opt}" ) if log.warn?
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
861
|
-
|
862
|
-
|
863
|
-
|
864
|
-
|
865
|
-
|
866
|
-
|
867
|
-
|
941
|
+
end
|
942
|
+
}
|
943
|
+
end
|
944
|
+
#Add first row
|
945
|
+
elements.last << element(:tr, {} ).cr
|
946
|
+
when :tabular_end
|
947
|
+
elements << nil
|
948
|
+
when :tabular_row
|
949
|
+
if ! elements.last.is_a?(:tabular)
|
950
|
+
log.warn( "#{self.class}#wiki2doc(#{line.lineno}: Add row to non-tabular" ) if log.warn?
|
951
|
+
end
|
952
|
+
prev_row = elements.last.content.last
|
868
953
|
rowcss = CSS.new()
|
869
|
-
|
870
|
-
|
871
|
-
|
954
|
+
elements.last << element(:tr, { :style => rowcss } ).cr
|
955
|
+
if line.content #options
|
956
|
+
options = line.content.split('|')
|
872
957
|
#~ puts options.inspect
|
873
|
-
|
874
|
-
|
875
|
-
|
876
|
-
|
877
|
-
|
878
|
-
|
958
|
+
options.each{|opt|
|
959
|
+
case opt
|
960
|
+
when 'toprule'; prev_row.toprule
|
961
|
+
when 'midrule'; prev_row.midrule
|
962
|
+
when 'hline'; prev_row.hline
|
963
|
+
when /(.+)=(.+)/ #CSS?
|
879
964
|
rowcss[$1] = $2
|
880
|
-
|
881
|
-
|
965
|
+
when /\A\s*\Z/ #empty option
|
966
|
+
else
|
882
967
|
log.warn( "#{self.class}#wiki2doc(#{line.lineno}): Unknown line option #{opt.inspect}" ) if log.warn?
|
883
|
-
|
884
|
-
|
885
|
-
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
896
|
-
|
897
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
906
|
-
|
907
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
968
|
+
end
|
969
|
+
}
|
970
|
+
end
|
971
|
+
when :tabular_cell
|
972
|
+
cellcss = CSS.new()
|
973
|
+
colspan = 1
|
974
|
+
pos = 'c'
|
975
|
+
if line.add_info #options
|
976
|
+
#fixme: Tabelle mit verschiedenen Optionen??
|
977
|
+
options = line.add_info.split('|')
|
978
|
+
options.each{|opt|
|
979
|
+
case opt
|
980
|
+
when /colspan\s*=\s*(.*)/
|
981
|
+
colspan = $1.to_i
|
982
|
+
when /pos\s*=\s*(.*)/
|
983
|
+
pos = $1
|
984
|
+
when /(.*?)\s*=\s*(.*)/
|
985
|
+
cellcss[$1] = $2
|
986
|
+
else
|
987
|
+
log.warn( "options for table cell unknown: #{opt} (line #{line.lineno})" ) if log.warn?
|
988
|
+
end
|
989
|
+
}
|
990
|
+
end
|
991
|
+
row = elements.last.content.last
|
992
|
+
if colspan > 1
|
993
|
+
row << element(:multicolumn, { :colspan => colspan, :style => cellcss, :pos => pos }, line.content).cr
|
994
|
+
else
|
995
|
+
row << element(:td, { :style => cellcss }, line.content).cr
|
996
|
+
end
|
997
|
+
when :collector
|
998
|
+
#~ if line.content.respond_to? :to_doc
|
999
|
+
#~ elements << line.content.to_element
|
1000
|
+
#~ else
|
1001
|
+
elements << line.content
|
1002
|
+
#~ end
|
1003
|
+
else
|
1004
|
+
log.error("#{self.class}#wiki2doc(#{line.lineno}): New line type #{line.type.inspect} (#{line.content.inspect})" ) if log.error?
|
1005
|
+
elements << element( line.type,{},self.inline(line.content, log)).cr
|
1006
|
+
end
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
#Delete empty paragraphs
|
1010
|
+
elements.map!{|element|
|
1011
|
+
if element.is_a?(:p) and element.content.empty?
|
1012
|
+
nil #Delete empty paragraphs
|
1013
|
+
else
|
1014
|
+
element
|
1015
|
+
end
|
1016
|
+
}
|
1017
|
+
|
1018
|
+
return elements
|
1019
|
+
end #wiki2doc
|
1020
|
+
#Translate text for inline tags.
|
1021
|
+
def inline( intext, log, subs = @wiki_inline_replacements )
|
1022
|
+
return Wikitext.inline( intext, log, subs, self )
|
1023
|
+
end
|
1024
|
+
#Translate text for inline tags.
|
1025
|
+
#
|
1026
|
+
#This can also be used from "outside" to translate single lines.
|
1027
|
+
#To keep the same environment if called via an object, the object is given in oo.
|
1028
|
+
def self.inline( intext, log, subs = WIKI_INLINE_REPLACEMENTS,
|
1029
|
+
oo = self)
|
1030
|
+
subs.each{|rule|
|
1031
|
+
if rule.regex =~ intext
|
1032
|
+
if rule.proc.is_a?( Proc )
|
1033
|
+
return rule.proc.call($~, oo, log)
|
1034
|
+
else
|
1035
|
+
return rule.proc
|
1036
|
+
end
|
1037
|
+
end
|
1038
|
+
}
|
1039
|
+
return intext
|
1040
|
+
end
|
1041
|
+
#Obsolete method -don't use.
|
946
1042
|
def toccss()
|
947
1043
|
@log.error("Usage of obsolete toccss, use CSS_collection[:toc]") if @log.error?
|
948
1044
|
return CSS_collection[:toc].style.to_html
|
949
1045
|
end
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
955
|
-
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
960
|
-
|
961
|
-
|
962
|
-
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
972
|
-
|
973
|
-
|
974
|
-
|
975
|
-
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
982
|
-
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
987
|
-
|
988
|
-
|
989
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
|
1011
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
1019
|
-
|
1020
|
-
|
1021
|
-
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1046
|
+
#Make a table of contents
|
1047
|
+
#
|
1048
|
+
#Options:
|
1049
|
+
#- listtype: :ul or :ol
|
1050
|
+
#- addlinks: Set label for each header.
|
1051
|
+
def toc( i_options = {} )
|
1052
|
+
options = {
|
1053
|
+
:listtype => :ul,
|
1054
|
+
:level => 4,
|
1055
|
+
:startlevel => 1,
|
1056
|
+
:addlinks => true,
|
1057
|
+
:tocclass => 'toc',
|
1058
|
+
}.update(i_options)
|
1059
|
+
uls = {}
|
1060
|
+
uls[options[:startlevel]] = element(options[:listtype])
|
1061
|
+
@source.flatten.each{|line|
|
1062
|
+
if /\A(=+)(?:\[(.*?)\])?(.+?)(=+)\s*\z/ =~ line #:h1, :h2, :h3, :h4, :h5, :h6
|
1063
|
+
level = $1.size.to_i - 1
|
1064
|
+
anker = $2
|
1065
|
+
titletext = $3
|
1066
|
+
#Entfernen von Wiki-Links im Titel.
|
1067
|
+
titletext.sub!(/\[\..*\s+(.*)\]/, '\1')
|
1068
|
+
|
1069
|
+
next if level > options[:level]
|
1070
|
+
if level < options[:startlevel]
|
1071
|
+
log.warn( "#{self.class}#toc: TOC starts not at #{options[:startlevel]}, but level #{level} defined at #{line}" ) if log.warn?
|
1072
|
+
next
|
1073
|
+
end
|
1074
|
+
if anker
|
1075
|
+
titel = element(:a, {:href=>"##{anker}"}, titletext)
|
1076
|
+
elsif options[:addlinks]
|
1077
|
+
#Build label for toc
|
1078
|
+
toclabel = []
|
1079
|
+
1.upto(level){|i|
|
1080
|
+
if uls[i]
|
1081
|
+
if i == level #same level - add one for actual element
|
1082
|
+
toclabel << uls[i].content.size + 1
|
1083
|
+
else #Previous level - use size
|
1084
|
+
toclabel << uls[i].content.size
|
1085
|
+
end
|
1086
|
+
else #First element on this level
|
1087
|
+
toclabel << 1
|
1088
|
+
end
|
1089
|
+
}
|
1090
|
+
#~ puts "toclabel <#{$3}>\t#{toclabel.inspect}\t#{toclabel.join('-')}"
|
1091
|
+
titel = element(:a, {:href=>"##{toclabel.join('-')}"}, titletext)
|
1092
|
+
line.sub!(/^(=+)/, "\\1[#{toclabel.join('-')}]")
|
1093
|
+
else
|
1094
|
+
titel = titletext
|
1095
|
+
end
|
1096
|
+
options[:startlevel].upto(6){|i|
|
1097
|
+
#Create 'higher' sections (indicates a problem in the text)
|
1098
|
+
if i < level
|
1099
|
+
if ! uls[i]
|
1100
|
+
log.warn( "#{self.class}#toc: Sectioning jumps over level #{i} at #{line}" ) if log.warn?
|
1101
|
+
uls[i-1].content.last << uls[i] = element(options[:listtype] ).Cr if uls[i-1]
|
1102
|
+
end
|
1103
|
+
if ! uls[i].content.last
|
1104
|
+
uls[i] << element(:li,{}, '' ).cr
|
1105
|
+
end
|
1106
|
+
elsif i == level
|
1107
|
+
#Create new level if necessary
|
1108
|
+
if ! uls[level]
|
1109
|
+
uls[level-1].content.last << uls[level] = element(options[:listtype] ).Cr
|
1110
|
+
end
|
1111
|
+
#Add section title
|
1112
|
+
uls[level] << element(:li,{}, titel ).cr
|
1113
|
+
else
|
1114
|
+
#delete lower levels of previous topic
|
1115
|
+
uls[i] = nil
|
1116
|
+
end
|
1117
|
+
}
|
1118
|
+
end
|
1119
|
+
}
|
1120
|
+
return element(:div, { :class => options[:tocclass] }, uls[options[:startlevel]] ).CR
|
1121
|
+
end
|
1122
|
+
def footnotes()
|
1123
|
+
footnotes = Footnotegroup.get( self.object_id)
|
1124
|
+
return footnotes
|
1125
|
+
end
|
1029
1126
|
end
|
1030
1127
|
|
1031
1128
|
#Wiki-Collector is a hash with collectors.
|
@@ -1035,64 +1132,64 @@ end
|
|
1035
1132
|
#
|
1036
1133
|
#Usage example: see code2structogramm
|
1037
1134
|
class WikiCollector
|
1038
|
-
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
1135
|
+
@@variants = {}
|
1136
|
+
#Add a new collector type.
|
1137
|
+
#
|
1138
|
+
#Each collector must implement the following methods:
|
1139
|
+
#-new without parameters.
|
1140
|
+
#-<< get lines of wiki-source
|
1141
|
+
#-to_doc return the result
|
1045
1142
|
#See the two examples
|
1046
1143
|
#- WikiCollectorHTML
|
1047
1144
|
#- WikiCollectorFilecontent
|
1048
1145
|
#
|
1049
|
-
|
1050
|
-
|
1051
|
-
|
1052
|
-
|
1053
|
-
|
1054
|
-
|
1055
|
-
|
1056
|
-
|
1057
|
-
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1076
|
-
|
1077
|
-
|
1146
|
+
def self.add(key, classtype)
|
1147
|
+
if @@variants[key]
|
1148
|
+
puts "WikiCollector: Double assignment #{key.inspect}, #{classtype}"
|
1149
|
+
end
|
1150
|
+
if ! classtype.method_defined?(:'<<')
|
1151
|
+
puts "WikiCollector: Collector <#{key.inspect}> doesn't support <<"
|
1152
|
+
return false
|
1153
|
+
end
|
1154
|
+
if ! classtype.method_defined?(:to_doc)
|
1155
|
+
puts "WikiCollector: Collector <#{key.inspect}> doesn't support to_doc"
|
1156
|
+
return false
|
1157
|
+
end
|
1158
|
+
@@variants[key] = classtype
|
1159
|
+
end
|
1160
|
+
#Get an instance of the requested collector.
|
1161
|
+
def self.create(key, arguments = [] )
|
1162
|
+
#~ puts "WikiCollector: request #{key.inspect}"
|
1163
|
+
if @@variants[key.to_sym]
|
1164
|
+
begin
|
1165
|
+
return @@variants[key.to_sym].new(*arguments)
|
1166
|
+
rescue ArgumentError
|
1167
|
+
puts "WikiCollector: Collector <#{key.inspect}> get wrong parameters"
|
1168
|
+
return false
|
1169
|
+
end
|
1170
|
+
else
|
1171
|
+
puts "WikiCollector: Collector <#{key}> not found (available: #{@@variants.keys.inspect})"
|
1172
|
+
return nil
|
1173
|
+
end
|
1174
|
+
end
|
1078
1175
|
end #WikiCollector
|
1079
1176
|
#
|
1080
1177
|
#A little collector of "Plain-HTML".
|
1081
1178
|
#
|
1082
1179
|
class WikiCollectorHTML < Element
|
1083
|
-
|
1180
|
+
Element.add( [:wikicollectorhtml], WikiCollectorHTML)
|
1084
1181
|
#Start without parameters.
|
1085
1182
|
#Can be called in a Wiki with:
|
1086
1183
|
# >>>html{}
|
1087
1184
|
# here you can add plain HTML
|
1088
1185
|
# <<<
|
1089
|
-
|
1090
|
-
|
1091
|
-
|
1186
|
+
def initialize()
|
1187
|
+
@htmlcode = []
|
1188
|
+
end
|
1092
1189
|
#Add another line from Wiki
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
1190
|
+
def <<(content)
|
1191
|
+
@htmlcode << content
|
1192
|
+
end
|
1096
1193
|
#
|
1097
1194
|
#Return the content 'as is', but only for HTML
|
1098
1195
|
def to_doc( target, options = {} )
|
@@ -1102,44 +1199,60 @@ class WikiCollectorHTML < Element
|
|
1102
1199
|
else
|
1103
1200
|
''
|
1104
1201
|
end
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1202
|
+
#~ return element(:onlyhtml,{},@htmlcode).restrict_to(:html).to_doc(target)
|
1203
|
+
end
|
1204
|
+
#~ def to_html()
|
1205
|
+
#~ return @htmlcode
|
1206
|
+
#~ end
|
1207
|
+
#~ def to_latex(); ''; end
|
1208
|
+
#~ def to_wiki(); ''; end
|
1209
|
+
#~ def to_text(); ''; end
|
1113
1210
|
end
|
1114
1211
|
WikiCollector.add(:html, WikiCollectorHTML )
|
1115
1212
|
|
1116
1213
|
if __FILE__ == $0
|
1214
|
+
|
1117
1215
|
puts 'Use the unit test for complete test'
|
1118
1216
|
|
1217
|
+
puts Wikitext.help
|
1218
|
+
puts Wikitext.help(:img)
|
1219
|
+
puts Wikitext.help(:tab)
|
1220
|
+
|
1221
|
+
#~ wiki = Wikitext.new(:content => <<wiki
|
1222
|
+
#~ There are normal footnotes{{footnote|Like this one}}. But:
|
1223
|
+
#~ Here is a footnote in group 1{{footnote[group1]some remarks}}, and
|
1224
|
+
#~ a second footnote{{footnote[group1]more remarks}}.
|
1225
|
+
#~ In another group{{footnote[group2]Each group gets a name}}, we can define further remarks.
|
1226
|
+
|
1227
|
+
#~ ----
|
1228
|
+
#~ Normal Footnotes:
|
1229
|
+
#~ {{footnotes}}
|
1230
|
+
#~ ----
|
1231
|
+
#~ Footnote group 1:
|
1232
|
+
#~ {{footnotes|group1}}
|
1233
|
+
#~ ----
|
1234
|
+
#~ Footnote group 2:
|
1235
|
+
#~ {{footnotes|group2}}
|
1236
|
+
#~ wiki
|
1237
|
+
#~ )
|
1119
1238
|
wiki = Wikitext.new(:content => <<wiki
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1239
|
+
vorher
|
1240
|
+
|
1241
|
+
nachher
|
1242
|
+
nachher2
|
1124
1243
|
|
1125
|
-
|
1126
|
-
|
1127
|
-
{{footnotes}}
|
1128
|
-
----
|
1129
|
-
Footnote group 1:
|
1130
|
-
{{footnotes|group1}}
|
1131
|
-
----
|
1132
|
-
Footnote group 2:
|
1133
|
-
{{footnotes|group2}}
|
1244
|
+
==test==
|
1245
|
+
drei
|
1134
1246
|
wiki
|
1135
|
-
|
1247
|
+
)
|
1136
1248
|
puts '---------------------'
|
1137
1249
|
|
1250
|
+
|
1138
1251
|
#~ puts wiki.toc.inspect
|
1139
1252
|
#~ puts wiki.toc.to_html
|
1140
1253
|
#~ puts wiki.toc.to_wiki
|
1141
1254
|
#~ puts '--------HTML-------------'
|
1142
|
-
|
1255
|
+
puts wiki.to_html
|
1143
1256
|
#~ puts '--------HTML-------------'
|
1144
1257
|
#~ puts wiki.to_html
|
1145
1258
|
#~ puts '--------LaTeX-------------'
|
@@ -1148,6 +1261,10 @@ puts '---------------------'
|
|
1148
1261
|
#~ puts wiki.to_wiki
|
1149
1262
|
#~ puts '--------Text-------------'
|
1150
1263
|
#~ puts wiki.to_text
|
1264
|
+
|
1265
|
+
doc = Document.new()
|
1266
|
+
doc.body << wiki
|
1267
|
+
doc.save('test.html')
|
1151
1268
|
end
|
1152
1269
|
|
1153
1270
|
|