docgenerator-creole 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/examples/creole_example.rb +76 -0
- data/examples/creole_example_footnote.rb +66 -0
- data/examples/creole_example_new_plugin.rb +51 -0
- data/examples/creole_example_placeholder.rb +77 -0
- data/examples/creole_example_rail.rb +155 -0
- data/examples/creole_example_rubycode.rb +144 -0
- data/examples/creole_example_struktex.rb +170 -0
- data/examples/creole_example_tabular.rb +96 -0
- data/examples/creole_example_tikz.rb +47 -0
- data/lib/docgenerator-creole.rb +5 -0
- data/lib/docgenerator/creole.rb +15 -0
- data/lib/docgenerator/creole/base.rb +170 -0
- data/lib/docgenerator/creole/characters.rb +131 -0
- data/lib/docgenerator/creole/creole.rb +708 -0
- data/lib/docgenerator/creole/document.rb +91 -0
- data/lib/docgenerator/creole/inclusion_and_plugins.rb +91 -0
- data/lib/docgenerator/creole/inclusions.rb +148 -0
- data/lib/docgenerator/creole/placeholder.rb +242 -0
- data/lib/docgenerator/creole/plugins.rb +230 -0
- data/lib/docgenerator/creole/plugins/index.rb +61 -0
- data/lib/docgenerator/creole/plugins/rail.rb +179 -0
- data/lib/docgenerator/creole/plugins/rubycode4creole.rb +136 -0
- data/lib/docgenerator/creole/plugins/struktex.rb +60 -0
- data/lib/docgenerator/creole/plugins/tikz.rb +93 -0
- data/lib/docgenerator/creole/plugins/todonotes.rb +77 -0
- data/lib/docgenerator/creole/tabular.rb +405 -0
- data/readme.rdoc +44 -0
- data/unittest/Red_Flower.jpg +0 -0
- data/unittest/expected_creole/test_creole.html +3 -0
- data/unittest/expected_creole/test_creole_characters_all.creole +28 -0
- data/unittest/expected_creole/test_creole_characters_all.html +18 -0
- data/unittest/expected_creole/test_creole_characters_all.latex +36 -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_comment.context +11 -0
- data/unittest/expected_creole/test_creole_comment.creole +12 -0
- data/unittest/expected_creole/test_creole_comment.html +9 -0
- data/unittest/expected_creole/test_creole_comment.latex +11 -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_groupid.html +15 -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_ignore.html +3 -0
- data/unittest/expected_creole/test_creole_ignore.latex +4 -0
- data/unittest/expected_creole/test_creole_ignore.text +2 -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_apostroph.html +7 -0
- data/unittest/expected_creole/test_creole_inline_apostroph.latex +9 -0
- data/unittest/expected_creole/test_creole_inline_apostroph.text +5 -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 +22 -0
- data/unittest/expected_creole/test_creole_input.normsource_1.8 +23 -0
- data/unittest/expected_creole/test_creole_input_file_simple.html +15 -0
- data/unittest/expected_creole/test_creole_input_file_simple_readlines.html +15 -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_links_implicit_end.creole +4 -0
- data/unittest/expected_creole/test_creole_links_implicit_end.html +3 -0
- data/unittest/expected_creole/test_creole_links_implicit_end.latex +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 +85 -0
- data/unittest/expected_creole/test_creole_list_ul.normsource_1.8 +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_list_ulul_without_ul.html +6 -0
- data/unittest/expected_creole/test_creole_list_ulul_without_ul.latex +12 -0
- data/unittest/expected_creole/test_creole_mix_titles_list.html +10 -0
- data/unittest/expected_creole/test_creole_mix_titles_list.latex +18 -0
- data/unittest/expected_creole/test_creole_mix_titles_list.text +12 -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 +26 -0
- data/unittest/expected_creole/test_creole_paragraphs.normsource_1.8 +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_paragraphs_wrap_with_linebreaks.html +5 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap_with_linebreaks.latex +6 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap_with_linebreaks.text +4 -0
- data/unittest/expected_creole/test_creole_paragraphs_wrap_with_linebreaks.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 +6 -0
- data/unittest/expected_creole/test_creole_pictures_css.latex +8 -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_pictures_longdesc.html +3 -0
- data/unittest/expected_creole/test_creole_pictures_width.html +3 -0
- data/unittest/expected_creole/test_creole_pictures_width.latex +4 -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_short_html.html +3 -0
- data/unittest/expected_creole/test_creole_short_html.latex +4 -0
- data/unittest/expected_creole/test_creole_short_html.text +2 -0
- data/unittest/expected_creole/test_creole_shy.creole +6 -0
- data/unittest/expected_creole/test_creole_shy.html +6 -0
- data/unittest/expected_creole/test_creole_shy.latex +8 -0
- data/unittest/expected_creole/test_creole_shy.text +4 -0
- data/unittest/expected_creole/test_creole_tabular.creole +22 -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.creole +21 -0
- data/unittest/expected_creole/test_creole_tabular_creole.html +20 -0
- data/unittest/expected_creole/test_creole_tabular_creole.latex +21 -0
- data/unittest/expected_creole/test_creole_tabular_css.creole +24 -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_tabular_multicols.creole +16 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.html +14 -0
- data/unittest/expected_creole/test_creole_tabular_multicols.latex +16 -0
- data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +22 -0
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.creole +21 -0
- data/unittest/expected_creole/test_creole_tabular_with_cell_option.html +20 -0
- data/unittest/expected_creole/test_creole_toc.html +13 -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_level.html +7 -0
- data/unittest/expected_creole/test_creole_toc_level.latex +10 -0
- data/unittest/expected_creole/test_creole_toc_level.text +3 -0
- data/unittest/expected_creole/test_creole_toc_level_text.html +8 -0
- data/unittest/expected_creole/test_creole_toc_level_text.latex +9 -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_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/unittest_creole.rb +1379 -0
- data/unittest/unittest_creole_placeholders.rb +161 -0
- data/unittest/unittest_creole_plugin_rail.rb +148 -0
- data/unittest/unittest_creole_plugin_rubycode4doc.rb +123 -0
- data/unittest/unittest_creole_plugin_struktex.rb +26 -0
- data/unittest/unittest_creole_tabular.rb +212 -0
- metadata +529 -0
@@ -0,0 +1,230 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
Creole plugins
|
3
|
+
|
4
|
+
This classes define plugins for creole.
|
5
|
+
|
6
|
+
Plugins are used later with <<xx>>
|
7
|
+
more at http://www.wikicreole.org/wiki/Plugin
|
8
|
+
|
9
|
+
You can extend Wikis with additional Plugin:
|
10
|
+
|
11
|
+
wiki = Creole.new()
|
12
|
+
wiki.plugin['xxx'] = Creole_plugin_xxx
|
13
|
+
=end
|
14
|
+
|
15
|
+
#
|
16
|
+
|
17
|
+
module Docgenerator
|
18
|
+
module Creole
|
19
|
+
|
20
|
+
=begin rdoc
|
21
|
+
Creole plugins
|
22
|
+
|
23
|
+
This classes define plugins for creole.
|
24
|
+
|
25
|
+
Plugins are used later with <<xx>>
|
26
|
+
more at http://www.wikicreole.org/wiki/Plugin
|
27
|
+
|
28
|
+
You can extend Wikis with additional Plugin:
|
29
|
+
|
30
|
+
wiki = Creole.new()
|
31
|
+
wiki.plugin['xxx'] = Creole_plugin_xxx
|
32
|
+
=end
|
33
|
+
module Plugins
|
34
|
+
|
35
|
+
=begin rdoc
|
36
|
+
Default Plugin for Creole.
|
37
|
+
<<xx>>
|
38
|
+
=end
|
39
|
+
class Creole_default_plugin < Creole_inclusion_and_plugin
|
40
|
+
def initialize( pluginname, description, options, wiki )
|
41
|
+
super
|
42
|
+
@wiki.log.warn("Use Default plugin instead requested #{pluginname}- nothing special done.") if @wiki.log.warn?
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
#Collection of Plugins
|
47
|
+
Collection = Hash.new(Creole_default_plugin)
|
48
|
+
|
49
|
+
|
50
|
+
=begin rdoc
|
51
|
+
Collection of footnotes.
|
52
|
+
|
53
|
+
Makes sense for HTML-output.
|
54
|
+
|
55
|
+
For LaTeX the support of bigfoot/manyfoot... may be an idea.
|
56
|
+
=end
|
57
|
+
class Creole_footnote_group < Creole_inclusion_and_plugin
|
58
|
+
#
|
59
|
+
|
60
|
+
Collection['footnotes'] = self
|
61
|
+
|
62
|
+
def initialize( inclusionname, description, options, wiki )
|
63
|
+
super
|
64
|
+
description = Footnotegroup::DEFAULTGROUPID unless description
|
65
|
+
@footnotesgroup = wiki.footnotegroups[description]
|
66
|
+
wiki.log.error("Footnotesgroup #{description.inspect} not found") if ! @footnotesgroup and wiki.log.error?
|
67
|
+
end
|
68
|
+
=begin rdoc
|
69
|
+
Call Docgenerator::Footnotegroup#to_doc
|
70
|
+
=end
|
71
|
+
def to_doc(target, options = {})
|
72
|
+
#remove options for Docgenerator::Footnotegroup
|
73
|
+
l_options = options.dup
|
74
|
+
l_options.delete(:plugins)
|
75
|
+
l_options.delete(:inclusions)
|
76
|
+
@footnotesgroup.to_doc(target, l_options)
|
77
|
+
end
|
78
|
+
end #Creole_inclusion_footnote_group
|
79
|
+
|
80
|
+
=begin rdoc
|
81
|
+
One footnote
|
82
|
+
|
83
|
+
Usage:
|
84
|
+
<<footnote|text>>
|
85
|
+
<<footnote|text|label=l1>>
|
86
|
+
<<footnote|text|groupid=g1>>
|
87
|
+
|
88
|
+
Bug: If you create more documents, you get a common footnote counting.
|
89
|
+
|
90
|
+
Solution:
|
91
|
+
* LaTeX: no problem, LaTeX has it's own output mechanism.
|
92
|
+
* HTML: Use grouping.
|
93
|
+
=end
|
94
|
+
class Creole_footnote < Creole_inclusion_and_plugin
|
95
|
+
Collection['footnote'] = self
|
96
|
+
|
97
|
+
def initialize( inclusionname, description, options, wiki )
|
98
|
+
super
|
99
|
+
|
100
|
+
@groupid = Footnotegroup::DEFAULTGROUPID
|
101
|
+
label = nil
|
102
|
+
|
103
|
+
options.each{|option|
|
104
|
+
case option
|
105
|
+
when /label\s*=\s*(.*)/
|
106
|
+
label = $1
|
107
|
+
when /groupid\s*=\s*(.*)/
|
108
|
+
@groupid = $1
|
109
|
+
else
|
110
|
+
@wiki.log.warn("Footnote with unknown option #{option.inspect} not found") if @wiki.log.warn?
|
111
|
+
end
|
112
|
+
}
|
113
|
+
|
114
|
+
if ! wiki.footnotegroups[@groupid]
|
115
|
+
wiki.footnotegroups[@groupid] = Footnotegroup.new(@groupid)
|
116
|
+
end
|
117
|
+
|
118
|
+
group = wiki.footnotegroups[@groupid]
|
119
|
+
|
120
|
+
@footnote = element(:footnote,{
|
121
|
+
:group => group,
|
122
|
+
:label => label,
|
123
|
+
}, description )
|
124
|
+
|
125
|
+
|
126
|
+
end
|
127
|
+
def to_doc(target, options ={})
|
128
|
+
@footnote.to_doc(target, options)
|
129
|
+
end
|
130
|
+
end #Creole_inclusion_footnote
|
131
|
+
|
132
|
+
=begin rdoc
|
133
|
+
Some short latex
|
134
|
+
|
135
|
+
Usage:
|
136
|
+
<<latex|code>>
|
137
|
+
|
138
|
+
Note:
|
139
|
+
There is also a placeholder for larger latex:
|
140
|
+
<<<latex
|
141
|
+
content
|
142
|
+
>>>
|
143
|
+
=end
|
144
|
+
class Creole_short_latex < Creole_inclusion_and_plugin
|
145
|
+
#We don't use it as inclusion. Closing } from latex may be confusing as in:
|
146
|
+
# {{latex|\texttt{kursuiv}}}
|
147
|
+
set_plugin_key 'latex'
|
148
|
+
|
149
|
+
def initialize( inclusionname, description, options, wiki )
|
150
|
+
super
|
151
|
+
options.each{|option|
|
152
|
+
#~ case option
|
153
|
+
#~ else
|
154
|
+
@wiki.log.warn("latex with unknown option #{option.inspect} not found") if @wiki.log.warn?
|
155
|
+
#~ end
|
156
|
+
}
|
157
|
+
@source = description
|
158
|
+
|
159
|
+
end
|
160
|
+
#Return content only for latex
|
161
|
+
def to_doc( target, options = {})
|
162
|
+
target == :latex ? @source.to_doc( target, options ) : ''
|
163
|
+
end
|
164
|
+
end #Creole_short_latex
|
165
|
+
|
166
|
+
|
167
|
+
=begin rdoc
|
168
|
+
Eval the given ruby-code and put it as "raw text".
|
169
|
+
|
170
|
+
|
171
|
+
This is defined as a plugin.
|
172
|
+
=end
|
173
|
+
class Creole_plugin_ruby_raw < Creole_inclusion_and_plugin
|
174
|
+
set_plugin_key 'ruby_raw'
|
175
|
+
|
176
|
+
def initialize( inclusionname, description, options, wiki )
|
177
|
+
#The ruby-code may contain | - so we have to ad it again
|
178
|
+
description << "|#{options.join('|')}" unless options.empty?
|
179
|
+
options = nil
|
180
|
+
super
|
181
|
+
@code = description
|
182
|
+
begin
|
183
|
+
@result = eval(@code)
|
184
|
+
rescue => bang
|
185
|
+
wiki.log.error("Plugin ruby_raw: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
|
186
|
+
end
|
187
|
+
end #initialize
|
188
|
+
def to_doc(target, options ={})
|
189
|
+
@result.to_s
|
190
|
+
end
|
191
|
+
def inspect()
|
192
|
+
"#<Creole_plugin_ruby_raw:#{@code}>"
|
193
|
+
end
|
194
|
+
end #Creole_plugin_ruby
|
195
|
+
|
196
|
+
=begin rdoc
|
197
|
+
Eval the given ruby-code and add it as a interpreted code.
|
198
|
+
|
199
|
+
This is defined as a plugin.
|
200
|
+
|
201
|
+
Ideas for further development: eval later, at doc generation.
|
202
|
+
=end
|
203
|
+
class Creole_plugin_ruby < Creole_inclusion_and_plugin
|
204
|
+
set_plugin_key 'ruby'
|
205
|
+
|
206
|
+
def initialize( inclusionname, description, options, wiki )
|
207
|
+
#The ruby-code may contain | - so we have to ad it again
|
208
|
+
description << "|#{options.join('|')}" unless options.empty?
|
209
|
+
options = nil
|
210
|
+
super
|
211
|
+
|
212
|
+
@code = description
|
213
|
+
begin
|
214
|
+
@result = eval(@code)
|
215
|
+
rescue => bang
|
216
|
+
wiki.log.error("Plugin ruby: <#{@code}> results in #{bang.class}/#{bang}") if wiki.log.error?
|
217
|
+
end
|
218
|
+
end #initialize
|
219
|
+
def to_doc(target, options = {})
|
220
|
+
@wiki.normsource2elements(
|
221
|
+
@wiki.parse(@result.to_s ), options
|
222
|
+
).to_doc(target, options )
|
223
|
+
end
|
224
|
+
def inspect()
|
225
|
+
"#<Creole_plugin_ruby:#{@code}>"
|
226
|
+
end
|
227
|
+
end #Creole_plugin_ruby
|
228
|
+
end #module Plugins
|
229
|
+
end #module Creole
|
230
|
+
end #module Docgenerator
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'docgenerator/index.rb'
|
2
|
+
|
3
|
+
module Docgenerator
|
4
|
+
module Creole
|
5
|
+
|
6
|
+
=begin rdoc
|
7
|
+
Classes to provide support index.
|
8
|
+
=end
|
9
|
+
module Index
|
10
|
+
#Required header to support index with makeindex.
|
11
|
+
HEAD_MAKEINDEX = "\\usepackage{makeidx}\\makeindex\n"
|
12
|
+
=begin rdoc
|
13
|
+
Classes to provide printindex.
|
14
|
+
=end
|
15
|
+
class Creole_printindex < Creole_inclusion_and_plugin
|
16
|
+
set_plugin_key('printindex') #use <<printindex>>
|
17
|
+
def to_doc(target, options = {})
|
18
|
+
element(:printindex, options).to_doc(target, options)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
=begin rdoc
|
22
|
+
Define a plugin for the indexnotes-package.
|
23
|
+
=end
|
24
|
+
class Creole_index < Creole_inclusion_and_plugin
|
25
|
+
|
26
|
+
set_plugin_key('index') #use <<index|..>>
|
27
|
+
|
28
|
+
#define default options for indexnotes. may be redefined for children of this class.
|
29
|
+
def default_options; {}; end
|
30
|
+
|
31
|
+
=begin rdoc
|
32
|
+
Usage:
|
33
|
+
<<index|what to do|color=red>>
|
34
|
+
=end
|
35
|
+
def initialize( inclusionname, value, options, wiki )
|
36
|
+
#~ @inclusionname = inclusionname #fix 'index'
|
37
|
+
@value = value
|
38
|
+
@options = default_options.dup
|
39
|
+
#~ options.each{|opt|
|
40
|
+
#~ case opt
|
41
|
+
#~ when /color\s*=\s*/
|
42
|
+
#~ @options[:color] = $~.post_match
|
43
|
+
#~ when /inline/
|
44
|
+
#~ @options[:inline] = true
|
45
|
+
#~ else
|
46
|
+
#~ wiki.log.warn("index #{@description} with undefined option #{opt}")
|
47
|
+
#~ end
|
48
|
+
#~ }
|
49
|
+
@wiki = wiki
|
50
|
+
|
51
|
+
raise "Inclusion received no wiki but #{wiki.inspect}" unless wiki.is_a?(Creole)
|
52
|
+
end
|
53
|
+
|
54
|
+
def to_doc(target, options = {})
|
55
|
+
element(:index, @options, @value).to_doc(target, options)
|
56
|
+
end
|
57
|
+
end #Creole_index
|
58
|
+
|
59
|
+
end #module index
|
60
|
+
end #module Creole
|
61
|
+
end #module Docgenerator
|
@@ -0,0 +1,179 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
=begin rdoc
|
3
|
+
Support for the rail package.
|
4
|
+
|
5
|
+
This is support for LaTeX-style rail.
|
6
|
+
Don't be confused with ruby on rails - there is no intersection of the two packages.
|
7
|
+
=end
|
8
|
+
|
9
|
+
module Docgenerator
|
10
|
+
module Creole
|
11
|
+
=begin rdoc
|
12
|
+
Support for the rail package.
|
13
|
+
|
14
|
+
This is support for LaTeX-style rail.
|
15
|
+
|
16
|
+
* http://www.ctan.org/tex-archive/support/rail/
|
17
|
+
=end
|
18
|
+
module Rail
|
19
|
+
|
20
|
+
#
|
21
|
+
#A Wrapper for the Creole-placeholder for Rail-diagramms.
|
22
|
+
#
|
23
|
+
class Diagramm4Creole < Placeholder
|
24
|
+
set_placeholder_key 'rail'
|
25
|
+
|
26
|
+
def initialize( wiki, name = 'Raildiagramm')
|
27
|
+
super
|
28
|
+
@name = name
|
29
|
+
raise ParameterError, "Missing id for rail-diagramm" unless @name
|
30
|
+
raise ParameterError, "Id for rail-diagramm contains no-letter" unless @name =~ /\A\w+\Z/
|
31
|
+
end
|
32
|
+
|
33
|
+
#fixme
|
34
|
+
#Check if the rail-diagramm is available as a picture.
|
35
|
+
#~ @filename = "#{@key}.png"
|
36
|
+
#~ if ! File.exist?( @filename )
|
37
|
+
#~ @filename = nil
|
38
|
+
#~ end
|
39
|
+
|
40
|
+
=begin rdoc
|
41
|
+
Return content only for LaTeX
|
42
|
+
=end
|
43
|
+
def to_doc( target, options = {})
|
44
|
+
#fixme: Einmalig beim initialisieren
|
45
|
+
#fixme: Varianten erledigen
|
46
|
+
#fixme: Bild falls verfügbar
|
47
|
+
#fixme: nur TeX (oder Bild)
|
48
|
+
#fixme logs
|
49
|
+
#~ case options[:elementtype]
|
50
|
+
#~ when nil #ignore diagramm
|
51
|
+
#~ when :minipage
|
52
|
+
#~ return to_element_minipage()
|
53
|
+
#~ when :figure
|
54
|
+
#~ return to_element_figure()
|
55
|
+
#~ when :figure_img
|
56
|
+
#~ return to_element_figure_img()
|
57
|
+
#~ when :latexonly
|
58
|
+
#~ return element(:latexonly,{}, self.to_latex_rail ).cr
|
59
|
+
#~ else
|
60
|
+
#~ option[:log].error("Raildiagramm#to_element: Undefined type #{@@elementtype}") if option[:log].error?
|
61
|
+
#~ end
|
62
|
+
|
63
|
+
#fixme Bild?
|
64
|
+
Rail_diagramm.new( @name, @source ).to_doc( target, options )
|
65
|
+
end
|
66
|
+
#Check for picture and return a :img-macro (Only html)
|
67
|
+
def to_img()
|
68
|
+
return element( :img, { :src => @filename }) if @filename
|
69
|
+
end
|
70
|
+
#~ def to_element_figure()
|
71
|
+
#~ figure = element(:figure).cr
|
72
|
+
#~ figure << self.to_s
|
73
|
+
#~ figure << element(:caption,{}, "Rail-Diagramm #{@key}" ).Cr
|
74
|
+
#~ return figure
|
75
|
+
#~ end
|
76
|
+
#~ def to_element_figure_img()
|
77
|
+
#~ if @filename
|
78
|
+
#~ figure = element(:figure, { :style => CSS.new(
|
79
|
+
#~ :text_align => 'center',
|
80
|
+
#~ :float => 'right'
|
81
|
+
#~ )}).cr
|
82
|
+
#~ figure << self.to_img
|
83
|
+
#~ figure << element(:br).cr
|
84
|
+
#~ figure << element(:caption,{}, "Rail-Diagramm #{@key}" ).Cr
|
85
|
+
#~ else
|
86
|
+
#~ figure = nil
|
87
|
+
#~ end
|
88
|
+
#~ return figure
|
89
|
+
#~ end
|
90
|
+
#~ #Requires caption.sty
|
91
|
+
#~ # doc.head << element(:usepackage,{}, 'caption')
|
92
|
+
#~ def to_element_minipage()
|
93
|
+
#~ figure = element(:minipage, {:width => '\textwidth'} ).CR
|
94
|
+
#~ figure << element(:centering)
|
95
|
+
#~ figure << self.to_s
|
96
|
+
#~ figure << element(:captionof,{ :float_type => 'figure' }, "Rail-Diagramm #{@key}" ).Cr
|
97
|
+
#~ return figure
|
98
|
+
#~ end
|
99
|
+
end #Rail_diagramm4Creole
|
100
|
+
|
101
|
+
#
|
102
|
+
#A Rail-diagramm
|
103
|
+
#
|
104
|
+
class Rail_diagramm
|
105
|
+
|
106
|
+
#Can be used in document header to load rail.sty
|
107
|
+
TEX_PACKAGE_RAIL = element(:usepackage,{ }, 'rail').cr
|
108
|
+
#Some command to be added in document header.
|
109
|
+
#Allows the usage of some characters as terminals.
|
110
|
+
RAIL_ALIAS = <<'RAIL_ALIAS'
|
111
|
+
\railalias{lbrace}{\{}
|
112
|
+
\railalias{rbrace}{\}}
|
113
|
+
\railalias{dollar}{\$}
|
114
|
+
\railalias{underscore}{\_}
|
115
|
+
\railalias{percent}{\%}
|
116
|
+
\railalias{at}{@}
|
117
|
+
\railalias{atat}{@@}
|
118
|
+
% \railalias{backslash}{\char"5C}
|
119
|
+
\railalias{backslash}{\ensuremath{\backslash}}
|
120
|
+
\railalias{lt}{\ensuremath{<}}
|
121
|
+
\railalias{le}{\ensuremath{<=}}
|
122
|
+
\railalias{gt}{\ensuremath{>}}
|
123
|
+
\railalias{ge}{\ensuremath{>=}}
|
124
|
+
\railalias{caret}{\ensuremath{\hat{}}}
|
125
|
+
\railalias{tildeeq}{\ensuremath{\sim=}}
|
126
|
+
\railalias{quote}{'}
|
127
|
+
\railalias{dquote}{"}%german: \dq
|
128
|
+
\railterm{quote,dquote}
|
129
|
+
\railterm{lbrace,rbrace,dollar,percent,backslash,underscore,at,atat}
|
130
|
+
\railterm{lt,le,gt,ge,caret,tildeeq}
|
131
|
+
RAIL_ALIAS
|
132
|
+
#~ \railalias{ampersand}{\&} -> umgesetht nachh << head>>
|
133
|
+
|
134
|
+
#Create new Rail diagramm.
|
135
|
+
#Parameter:
|
136
|
+
#-key
|
137
|
+
#-rail-definition
|
138
|
+
def initialize( key, code = '' )
|
139
|
+
@key = key
|
140
|
+
@code = code
|
141
|
+
end
|
142
|
+
#Implement << for Wikicollector
|
143
|
+
def << (code)
|
144
|
+
@code << code
|
145
|
+
end
|
146
|
+
=begin
|
147
|
+
Return LaTeX-environment rail
|
148
|
+
Requires rail.sty and rail.exe to generate the figure.
|
149
|
+
|
150
|
+
|
151
|
+
=end
|
152
|
+
def to_latex(options = {})
|
153
|
+
@code = @code.join if @code.respond_to?(:join) #if Array is given
|
154
|
+
return <<-RAIL
|
155
|
+
%
|
156
|
+
% Define a rail-diagramm #{@key}
|
157
|
+
%
|
158
|
+
\\begin{rail}
|
159
|
+
#{@key} :
|
160
|
+
#{@code.chomp}
|
161
|
+
;
|
162
|
+
\\end{rail}
|
163
|
+
RAIL
|
164
|
+
end #to_latex
|
165
|
+
def to_doc( target, options = {})
|
166
|
+
case target
|
167
|
+
when :latex
|
168
|
+
self.to_latex( options )
|
169
|
+
else
|
170
|
+
o = set_option_defaults(options)
|
171
|
+
#~ o[:log].debug("enter to_doc(#{target}) for #{self.inspect}, options: #{options.keys.inspect}") if o[:log].debug?
|
172
|
+
o[:log].error("Rail-diagramm not supported for #{target}") if o[:log].error?
|
173
|
+
''
|
174
|
+
end #case target
|
175
|
+
end #to_doc
|
176
|
+
end
|
177
|
+
end #module Rail
|
178
|
+
end #module Creole
|
179
|
+
end #module Docgenerator
|