docgenerator 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/examples/creole_example.rb +0 -1
- data/examples/creole_example_new_plugin.rb +51 -0
- data/examples/creole_example_tabular.rb +3 -1
- data/examples/wiki2docgenerator_example.rb +2 -2
- data/lib/creole/creole2doc.rb +697 -680
- data/lib/creole/creole_characters.rb +90 -26
- data/lib/creole/creole_inclusion_and_plugins.rb +25 -43
- data/lib/creole/creole_inclusions.rb +87 -75
- data/lib/creole/creole_placeholder.rb +87 -89
- data/lib/creole/creole_plugins.rb +149 -117
- data/lib/creole/creole_tabular.rb +247 -141
- data/lib/creole/plugins/todonotes.rb +48 -48
- data/lib/docgenerator/characters.rb +106 -8
- data/lib/docgenerator/compatibility_v1.rb +7 -1
- data/lib/docgenerator/document.rb +34 -19
- data/lib/docgenerator/element.rb +1 -0
- data/lib/docgenerator/element_meta.rb +1 -1
- data/lib/docgenerator/elements.rb +594 -535
- data/lib/docgenerator/environments.rb +131 -99
- data/lib/docgenerator/index.rb +110 -0
- data/lib/docgenerator/lists.rb +2 -1
- data/lib/docgenerator/packages/caption.rb +32 -34
- data/lib/docgenerator/packages/hyperref.rb +1 -0
- data/lib/docgenerator/packages/multicol.rb +3 -2
- data/lib/docgenerator/packages/pdfpages.rb +71 -20
- data/lib/docgenerator/packages/scrpage2.rb +99 -142
- data/lib/docgenerator/packages/url.rb +75 -81
- data/lib/docgenerator/sections.rb +98 -98
- data/lib/docgenerator/standard.rb +8 -1
- data/lib/docgenerator/tabular.rb +44 -25
- data/lib/docgenerator/templates/docgenerator_template.yaml +28 -0
- data/lib/docgenerator/version.rb +146 -0
- data/lib/docgenerator.rb +20 -15
- data/meta_test_and_doc/build_doc.rb +39 -10
- data/meta_test_and_doc/build_test.rb +34 -12
- data/meta_test_and_doc/manpages/characters.rb +452 -20
- data/meta_test_and_doc/manpages/elementlist.rb +304 -0
- data/meta_test_and_doc/manpages/elements.rb +305 -42
- data/meta_test_and_doc/manpages/others.rb +403 -0
- data/meta_test_and_doc/manpages/pdfpages.rb +117 -18
- data/meta_test_and_doc/manpages/readme.rdoc +3 -1
- data/meta_test_and_doc/manpages/scrpage2.rb +0 -80
- data/meta_test_and_doc/manpages/tables.rb +6 -6
- data/readme.rdoc +11 -120
- data/unittest/expected/test_comment.html +1 -0
- data/unittest/expected/test_comment.latex +5 -0
- data/unittest/expected/test_comment_complex.html +3 -0
- data/unittest/expected/test_comment_complex.latex +15 -0
- data/unittest/expected_creole/test_creole_characters_all.html +6 -5
- data/unittest/expected_creole/test_creole_characters_all.latex +10 -8
- data/unittest/expected_creole/test_creole_creole1.0test.latex +5 -5
- data/unittest/expected_creole/test_creole_input.normsource +11 -9
- data/unittest/expected_creole/test_creole_list_ul.normsource +57 -51
- 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_paragraphs.normsource +12 -10
- data/unittest/expected_creole/test_creole_pictures.latex +2 -2
- data/unittest/expected_creole/test_creole_pictures_css.latex +2 -2
- data/unittest/expected_creole/test_creole_pictures_imgclass.latex +2 -2
- data/unittest/expected_creole/test_creole_pictures_width.latex +1 -1
- data/unittest/expected_creole/test_creole_tabular.latex +3 -3
- data/unittest/expected_creole/test_creole_tabular_creole.latex +2 -2
- data/unittest/expected_creole/test_creole_tabular_css.latex +3 -3
- data/unittest/expected_creole/test_creole_tabular_row_parameters.latex +22 -0
- data/unittest/expected_templates/test_standalone.tex +34 -0
- data/unittest/expected_wikimedia/test_wiki_picture.latex +12 -12
- data/unittest/unittest_creole.rb +22 -3
- data/unittest/unittest_creole_tabular.rb +34 -1
- data/unittest/unittest_docgenerator.rb +46 -3
- data/unittest/unittest_docgenerator_characters.rb +527 -82
- data/unittest/unittest_templates.rb +1 -1
- metadata +149 -108
@@ -10,47 +10,111 @@ This classes define special characters as inclusions.
|
|
10
10
|
#
|
11
11
|
|
12
12
|
module Docgenerator
|
13
|
-
module Creole
|
13
|
+
module Creole
|
14
14
|
|
15
15
|
=begin rdoc
|
16
16
|
Define special characters as inclusions.
|
17
17
|
|
18
18
|
See also Creole::CHARACTERS
|
19
19
|
=end
|
20
|
-
module Characters
|
20
|
+
module Characters
|
21
21
|
=begin rdoc
|
22
22
|
Define a 'shy' as {{shy}}
|
23
23
|
=end
|
24
|
-
class Creole_shy < Creole_inclusion_and_plugin
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end #Creole_shy
|
24
|
+
class Creole_shy < Creole_inclusion_and_plugin
|
25
|
+
set_inclusions_key '-'
|
26
|
+
set_inclusions_key 'shy'
|
27
|
+
|
28
|
+
def to_doc(target, options = {})
|
29
|
+
element(:shy).to_doc(target, options)
|
30
|
+
end
|
31
|
+
end #Creole_shy
|
32
|
+
=begin rdoc
|
33
|
+
Define a 'thinsp' as {{thinsp}}
|
32
34
|
|
35
|
+
Could be used as Soft hypen (­) without dash:
|
36
|
+
http://stackoverflow.com/questions/5038920/html-soft-hypen-shy-without-dash
|
37
|
+
=end
|
38
|
+
class Creole_thinsp < Creole_inclusion_and_plugin
|
39
|
+
set_inclusions_key 'thinsp'
|
40
|
+
|
41
|
+
def to_doc(target, options = {})
|
42
|
+
element(:thinsp).to_doc(target, options)
|
43
|
+
end
|
44
|
+
end #Creole_thinsp
|
45
|
+
=begin rdoc
|
46
|
+
Define a 'wbr' as {{wbr}}
|
47
|
+
=end
|
48
|
+
class Creole_wbr < Creole_inclusion_and_plugin
|
49
|
+
set_inclusions_key 'wbr'
|
50
|
+
|
51
|
+
def to_doc(target, options = {})
|
52
|
+
element(:wbr).to_doc(target, options)
|
53
|
+
end
|
54
|
+
end #Creole_wbr
|
33
55
|
=begin rdoc
|
34
56
|
Define a 'radic' as {{radic}}
|
35
57
|
=end
|
36
|
-
class Creole_radic < Creole_inclusion_and_plugin
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end #Creole_shy
|
58
|
+
class Creole_radic < Creole_inclusion_and_plugin
|
59
|
+
set_inclusions_key 'radic'
|
60
|
+
|
61
|
+
def to_doc(target, options = {})
|
62
|
+
element(:radic).to_doc(target, options)
|
63
|
+
end
|
64
|
+
end #Creole_shy
|
43
65
|
|
44
66
|
=begin rdoc
|
45
67
|
Define a 'nil' as {{nil}}
|
46
68
|
=end
|
47
|
-
class Creole_nil < Creole_inclusion_and_plugin
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end #Creole_nil
|
54
|
-
|
55
|
-
|
69
|
+
class Creole_nil < Creole_inclusion_and_plugin
|
70
|
+
set_inclusions_key 'nil'
|
71
|
+
|
72
|
+
def to_doc(target, options = {})
|
73
|
+
''
|
74
|
+
end
|
75
|
+
end #Creole_nil
|
76
|
+
|
77
|
+
=begin rdoc
|
78
|
+
=end
|
79
|
+
class Creole_gt < Creole_inclusion_and_plugin
|
80
|
+
set_inclusions_key 'gt'
|
81
|
+
set_inclusions_key '>'
|
82
|
+
|
83
|
+
def to_doc(target, options = {})
|
84
|
+
element(:gt).to_doc(target, options)
|
85
|
+
end
|
86
|
+
end #Creole_gt
|
87
|
+
=begin rdoc
|
88
|
+
=end
|
89
|
+
class Creole_lt < Creole_inclusion_and_plugin
|
90
|
+
set_inclusions_key '<'
|
91
|
+
|
92
|
+
def to_doc(target, options = {})
|
93
|
+
element(:lt).to_doc(target, options)
|
94
|
+
end
|
95
|
+
end #Creole_lt
|
96
|
+
|
97
|
+
=begin rdoc
|
98
|
+
=end
|
99
|
+
class Creole_gg < Creole_inclusion_and_plugin
|
100
|
+
set_inclusions_key 'dgt'
|
101
|
+
set_inclusions_key '>>'
|
102
|
+
|
103
|
+
def to_doc(target, options = {})
|
104
|
+
element(:gg).to_doc(target, options)
|
105
|
+
end
|
106
|
+
end #Creole_gt
|
107
|
+
=begin rdoc
|
108
|
+
=end
|
109
|
+
class Creole_ll < Creole_inclusion_and_plugin
|
110
|
+
set_inclusions_key 'dlt'
|
111
|
+
set_inclusions_key '<<'
|
112
|
+
|
113
|
+
def to_doc(target, options = {})
|
114
|
+
element(:ll).to_doc(target, options)
|
115
|
+
end
|
116
|
+
end #Creole_lt
|
117
|
+
|
118
|
+
end #module Characters
|
119
|
+
end #module Creole
|
56
120
|
end #module Docgenerator
|
@@ -19,7 +19,7 @@ You can extend Wikis with additional inclusions:
|
|
19
19
|
#
|
20
20
|
|
21
21
|
module Docgenerator
|
22
|
-
module Creole
|
22
|
+
module Creole
|
23
23
|
|
24
24
|
=begin rdoc
|
25
25
|
Dummy class for all inclusions and plugins.
|
@@ -39,7 +39,7 @@ Derived classes (Plugins):
|
|
39
39
|
- Creole_plugin_ruby_raw
|
40
40
|
More subclasses may be possible.
|
41
41
|
=end
|
42
|
-
class Creole_inclusion_and_plugin
|
42
|
+
class Creole_inclusion_and_plugin
|
43
43
|
=begin rdoc
|
44
44
|
Example:
|
45
45
|
{{inclusionname|description|option1=1,option2=2}}
|
@@ -52,63 +52,45 @@ Parameters:
|
|
52
52
|
['option1=1','option2=2']
|
53
53
|
* wiki: creole-instance, where the plugin/inclusion is defined.
|
54
54
|
=end
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
55
|
+
def initialize( inclusionname, description, options, wiki )
|
56
|
+
@inclusionname = inclusionname
|
57
|
+
@description = description
|
58
|
+
@options = options
|
59
|
+
@wiki = wiki
|
60
|
+
|
61
|
+
raise "Inclusion received no wiki but #{wiki.inspect}" unless wiki.is_a?(Creole)
|
62
|
+
end
|
63
|
+
#Reader for the wiki.
|
64
|
+
attr_reader :wiki
|
65
65
|
|
66
66
|
=begin rdoc
|
67
67
|
Define meta-methods for Creole_inclusion_and_plugin
|
68
68
|
=end
|
69
|
-
|
69
|
+
class << self
|
70
70
|
=begin rdoc
|
71
71
|
Define class as a Inclusion.
|
72
72
|
You may use the class as:
|
73
73
|
{{key}}
|
74
74
|
=end
|
75
|
-
|
76
|
-
|
77
|
-
|
75
|
+
def set_inclusions_key(key)
|
76
|
+
Inclusions::Collection[key] = self
|
77
|
+
end
|
78
78
|
=begin rdoc
|
79
79
|
Define class as a Plugin.
|
80
80
|
You may use the class as:
|
81
81
|
<<key>>
|
82
82
|
=end
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
=begin rdoc
|
87
|
-
fixme
|
83
|
+
def set_plugin_key(key)
|
84
|
+
Plugins::Collection[key] = self
|
85
|
+
end
|
88
86
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
end #Meta-methods
|
93
|
-
end #Creole_inclusion_and_plugin
|
87
|
+
end #Meta-methods
|
88
|
+
end #Creole_inclusion_and_plugin
|
94
89
|
|
95
|
-
require_relative 'creole_inclusions.rb'
|
96
|
-
require_relative 'creole_characters.rb' #inclusions
|
97
|
-
require_relative 'creole_plugins.rb'
|
90
|
+
require_relative 'creole_inclusions.rb'
|
91
|
+
require_relative 'creole_characters.rb' #defined as inclusions
|
92
|
+
require_relative 'creole_plugins.rb'
|
98
93
|
|
99
|
-
end #module Creole
|
94
|
+
end #module Creole
|
100
95
|
end #module Docgenerator
|
101
96
|
|
102
|
-
#~ if $0 == __FILE__
|
103
|
-
#~ require 'quicktest'
|
104
|
-
#~ end
|
105
|
-
|
106
|
-
|
107
|
-
__END__
|
108
|
-
Fixme for image:
|
109
|
-
pack it for a figure-environment (HTML: div/span + float)
|
110
|
-
{{test.jpg|description|beforetitle=vorher]]
|
111
|
-
{{test.jpg|description|aftertitle=nachher}}
|
112
|
-
{{test.jpg|description|figureclass=imgclass}}
|
113
|
-
description = caption
|
114
|
-
|
@@ -17,7 +17,7 @@ You can extend Wikis with additional inclusions:
|
|
17
17
|
#
|
18
18
|
|
19
19
|
module Docgenerator
|
20
|
-
module Creole
|
20
|
+
module Creole
|
21
21
|
|
22
22
|
=begin rdoc
|
23
23
|
Define Inclusions
|
@@ -26,8 +26,8 @@ Inclusions are used via {{...}}
|
|
26
26
|
|
27
27
|
Default: Creole_inclusion_img (defined in class definition Creole_inclusion_img)
|
28
28
|
=end
|
29
|
-
module Inclusions
|
30
|
-
|
29
|
+
module Inclusions
|
30
|
+
Collection = Hash.new()
|
31
31
|
|
32
32
|
|
33
33
|
=begin rdoc
|
@@ -43,8 +43,8 @@ Usage:
|
|
43
43
|
{{picurl.jpg|Alternate text|css=width:50%}}
|
44
44
|
|
45
45
|
=end
|
46
|
-
class Creole_inclusion_img < Creole_inclusion_and_plugin
|
47
|
-
|
46
|
+
class Creole_inclusion_img < Creole_inclusion_and_plugin
|
47
|
+
Collection.default = self
|
48
48
|
=begin rdoc
|
49
49
|
Define an image.
|
50
50
|
The existence of the picture is checked.
|
@@ -53,53 +53,65 @@ Supported options:
|
|
53
53
|
* alt (2nd parameter of {{picsrc|...}}
|
54
54
|
* css or imgcss
|
55
55
|
* class or imgclass
|
56
|
-
* longdesc (can take a url, at
|
56
|
+
* longdesc (can take a url, at least opera offers to call the description)
|
57
57
|
* width (only LaTeX. For HTML, use css-option).
|
58
58
|
|
59
59
|
=end
|
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
|
-
end
|
60
|
+
def initialize( picname, alt_text, options, wiki )
|
61
|
+
super
|
62
|
+
@img = element(:img,{ :src => @inclusionname })
|
63
|
+
@img[:alt] << alt_text if alt_text
|
64
|
+
#Check existence of Picture. Only possible if the related wiki is available.
|
65
|
+
wiki.check_link_existence( @inclusionname, wiki.log )
|
66
|
+
|
67
|
+
css = CSS.new( :log => wiki.log )
|
68
|
+
|
69
|
+
#
|
70
|
+
#Check for options
|
71
|
+
#
|
72
|
+
#Missing options:
|
73
|
+
#* align
|
74
|
+
#* border
|
75
|
+
#* height
|
76
|
+
#* hspace
|
77
|
+
#* name
|
78
|
+
#* vspace
|
79
|
+
options.each{|option|
|
80
|
+
case option
|
81
|
+
when /^(img)?css\s*=\s*(.*)/
|
82
|
+
$2.split(/\s*;\s*/).each{|css_assignment|
|
83
|
+
css_assignment =~ /(.+?)\s*:\s*(.+)/
|
84
|
+
css[$1] = $2
|
85
|
+
}
|
86
|
+
when /^(img)?class\s*=\s*(.*)/
|
87
|
+
@img[:class] << $2
|
88
|
+
when /^width\s*=\s*(.*)/
|
89
|
+
@img[:width] << $1
|
90
|
+
when /^height\s*=\s*(.*)/
|
91
|
+
@img[:height] << $1
|
92
|
+
when /^texoption\s*=\s*(.*)/
|
93
|
+
@img[:texoption] << $1
|
94
|
+
when /^longdesc\s*=\s*(.*)/ #gibt einen URI (nach RFC 2396) an, wo eine Langbeschreibung der Grafik zu finden ist
|
95
|
+
@img[:longdesc] << $1
|
96
|
+
else
|
97
|
+
wiki.log.warn("Img: Undefined option #{option}") if wiki.log.warn?
|
98
|
+
end #case option
|
99
|
+
} if options
|
100
|
+
@img.attr[:style] << css
|
101
|
+
|
102
|
+
end
|
103
|
+
def to_doc(target, options = {})
|
104
|
+
@img.to_doc(target, options)
|
105
|
+
end
|
106
|
+
=begin
|
107
|
+
Fixme for image:
|
108
|
+
pack it into a figure-environment (HTML: div/span + float)
|
109
|
+
{{test.jpg|description|beforetitle=vorher]]
|
110
|
+
{{test.jpg|description|aftertitle=nachher}}
|
111
|
+
{{test.jpg|description|figureclass=imgclass}}
|
112
|
+
description = caption
|
113
|
+
=end
|
114
|
+
end #Creole_inclusion_img
|
103
115
|
|
104
116
|
=begin rdoc
|
105
117
|
Some short html
|
@@ -113,30 +125,30 @@ There is also a placeholder for larger html:
|
|
113
125
|
content
|
114
126
|
>>>
|
115
127
|
=end
|
116
|
-
class Creole_short_html < Creole_inclusion_and_plugin
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
end #Creole_inclusion_html
|
138
|
-
|
139
|
-
|
140
|
-
end #module Inclusions
|
141
|
-
end #module Creole
|
128
|
+
class Creole_short_html < Creole_inclusion_and_plugin
|
129
|
+
#We don't use it as plugin. Closing > from html may be confusing as in:
|
130
|
+
# <<html|<em>kursuiv</em>>>
|
131
|
+
set_inclusions_key 'html'
|
132
|
+
|
133
|
+
|
134
|
+
def initialize( inclusionname, description, options, wiki )
|
135
|
+
super
|
136
|
+
options.each{|option|
|
137
|
+
#~ case option
|
138
|
+
#~ else
|
139
|
+
@wiki.log.warn("HTML with unknown option #{option.inspect} not found") if @wiki.log.warn?
|
140
|
+
#~ end
|
141
|
+
}
|
142
|
+
@source = description
|
143
|
+
|
144
|
+
end
|
145
|
+
#Return content only for html
|
146
|
+
def to_doc( target, options = {})
|
147
|
+
target == :html ? @source.to_doc( target, options ) : ''
|
148
|
+
end
|
149
|
+
end #Creole_inclusion_html
|
150
|
+
end #module Inclusions
|
151
|
+
end #module Creole
|
142
152
|
end #module Docgenerator
|
153
|
+
|
154
|
+
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Docgenerator
|
2
|
-
module Creole
|
2
|
+
module Creole
|
3
3
|
|
4
4
|
=begin rdoc
|
5
5
|
Placeholder are defined in Creole-Syntax via <<< >>>
|
@@ -16,23 +16,23 @@ Derived classes are:
|
|
16
16
|
- Creole::Creole_tabular
|
17
17
|
- Creole::Creole_tab
|
18
18
|
=end
|
19
|
-
class Placeholder
|
19
|
+
class Placeholder
|
20
20
|
=begin rdoc
|
21
21
|
Define meta-methods for Creole_inclusion_and_plugin
|
22
22
|
=end
|
23
|
-
|
23
|
+
class << self
|
24
24
|
=begin rdoc
|
25
25
|
Define class as a placeholder.
|
26
26
|
You may use the class as:
|
27
27
|
{{key}}
|
28
28
|
=end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
def set_placeholder_key(key)
|
30
|
+
Placeholders::Collection[key] = self
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#Error is thrown, if the parameters don't fit the need of the placeholder
|
35
|
+
class ParameterError < ArgumentError; end;
|
36
36
|
=begin rdoc
|
37
37
|
Each placeholder get the wiki where it belongs to.
|
38
38
|
|
@@ -44,27 +44,27 @@ Definition inside the wiki:
|
|
44
44
|
>>>
|
45
45
|
Placeholders collect the content between <<< and >>>.
|
46
46
|
=end
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end #Placeholder
|
47
|
+
def initialize( wiki, parameters = nil)
|
48
|
+
@wiki = wiki
|
49
|
+
@parameters = parameters
|
50
|
+
@log = @wiki.log
|
51
|
+
end
|
52
|
+
#
|
53
|
+
#Add the content between <<< and >>>.
|
54
|
+
def << (content)
|
55
|
+
@source = [] unless @source
|
56
|
+
@source << content
|
57
|
+
end
|
58
|
+
#
|
59
|
+
#Possibility to analyse the content.
|
60
|
+
def close()
|
61
|
+
@source.freeze
|
62
|
+
end
|
63
|
+
#Export it. Should be redefined by sub classes.
|
64
|
+
def to_doc( target, options = {})
|
65
|
+
@source.to_doc( target, options )
|
66
|
+
end
|
67
|
+
end #Placeholder
|
68
68
|
|
69
69
|
|
70
70
|
=begin rdoc
|
@@ -72,21 +72,21 @@ Collection of Placeholder-children
|
|
72
72
|
|
73
73
|
Placeholders are used via <<<...>>>.
|
74
74
|
=end
|
75
|
-
module Placeholders
|
75
|
+
module Placeholders
|
76
76
|
=begin rdoc
|
77
77
|
Just a dummy for wrong definitions.
|
78
78
|
|
79
79
|
This class is used by Creole a default placeholder.
|
80
80
|
=end
|
81
|
-
class Dummy < Placeholder
|
82
|
-
end #Placeholder::Dummy
|
81
|
+
class Dummy < Placeholder
|
82
|
+
end #Placeholder::Dummy
|
83
83
|
|
84
|
-
#List of defined Placeholders.
|
85
|
-
Collection = Hash.new( Dummy )
|
86
|
-
#Get a Placeholder.
|
87
|
-
def self.[](key)
|
88
|
-
|
89
|
-
end
|
84
|
+
#List of defined Placeholders.
|
85
|
+
Collection = Hash.new( Dummy )
|
86
|
+
#Get a Placeholder.
|
87
|
+
def self.[](key)
|
88
|
+
Collection[key]
|
89
|
+
end
|
90
90
|
|
91
91
|
|
92
92
|
=begin rdoc
|
@@ -102,13 +102,13 @@ Note:
|
|
102
102
|
There is also a plugin for short html:
|
103
103
|
{{html|code}}
|
104
104
|
=end
|
105
|
-
class Creole_html < Placeholder
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end #Creole_html
|
105
|
+
class Creole_html < Placeholder
|
106
|
+
set_placeholder_key 'html'
|
107
|
+
#Return content only for html
|
108
|
+
def to_doc( target, options = {})
|
109
|
+
target == :html ? @source.to_doc( target, options ) : ''
|
110
|
+
end
|
111
|
+
end #Creole_html
|
112
112
|
|
113
113
|
=begin
|
114
114
|
Placeholder for pure LaTeX-output.
|
@@ -121,48 +121,46 @@ Pro:
|
|
121
121
|
Cons:
|
122
122
|
-unexpected conversions?
|
123
123
|
=end
|
124
|
-
class Creole_latex < Placeholder
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
end #Creole_latex
|
131
|
-
|
132
|
-
#
|
133
|
-
#Usage:
|
134
|
-
# <<<comment
|
135
|
-
# This text is a comment.
|
136
|
-
# >>>
|
137
|
-
#
|
138
|
-
class Creole_comment < Placeholder
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
end #Creole_comment
|
162
|
-
|
163
|
-
end #module
|
164
|
-
|
165
|
-
end #module Creole
|
124
|
+
class Creole_latex < Placeholder
|
125
|
+
set_placeholder_key 'latex'
|
126
|
+
#Return content only for latex
|
127
|
+
def to_doc( target, options = {})
|
128
|
+
target == :latex ? @source.to_doc( target, options ) : ''
|
129
|
+
end
|
130
|
+
end #Creole_latex
|
131
|
+
|
132
|
+
#
|
133
|
+
#Usage:
|
134
|
+
# <<<comment
|
135
|
+
# This text is a comment.
|
136
|
+
# >>>
|
137
|
+
#
|
138
|
+
class Creole_comment < Placeholder
|
139
|
+
set_placeholder_key 'comment'
|
140
|
+
#Return content as a comment
|
141
|
+
def to_doc( target, options = {})
|
142
|
+
case target
|
143
|
+
when :html; to_html( options )
|
144
|
+
when :latex; to_latex( options )
|
145
|
+
when :context; to_latex( options )
|
146
|
+
when :creole; to_creole( options )
|
147
|
+
else
|
148
|
+
@log.error("Creole_comment not supported for target #{target.inspect}") if @log.error?
|
149
|
+
end
|
150
|
+
end
|
151
|
+
def to_html(options = {})
|
152
|
+
return "<!-- #{@source.join} -->"
|
153
|
+
end
|
154
|
+
alias :to_context :to_latex
|
155
|
+
def to_latex(options = {})
|
156
|
+
return @source.map{|l| "%#{l}" }.join
|
157
|
+
end
|
158
|
+
def to_creole(options = {})
|
159
|
+
return "<<<comment\n#{@source.join}>>>"
|
160
|
+
end
|
161
|
+
end #Creole_comment
|
162
|
+
end #module Placeholders
|
163
|
+
end #module Creole
|
166
164
|
end #module Docgenerator
|
167
165
|
|
168
166
|
|