deplate 0.7.3 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.TXT +3 -0
- data/CHANGES.TXT +248 -175
- data/LICENSE.TXT +0 -0
- data/NEWS.TXT +28 -24
- data/README.TXT +0 -0
- data/TODO.TXT +174 -88
- data/VERSION.TXT +1 -1
- data/bin/deplate +0 -0
- data/bin/deplate.bat +0 -0
- data/etc/deplate.ini +91 -3
- data/lib/action_view/helpers/deplate.rb +45 -0
- data/lib/deplate.rb +6 -1
- data/lib/deplate/abstract-class.rb +0 -0
- data/lib/deplate/bib.rb +576 -0
- data/lib/deplate/builtin.rb +0 -0
- data/lib/deplate/cache.rb +55 -5
- data/lib/deplate/commands.rb +346 -183
- data/lib/deplate/common.rb +209 -48
- data/lib/deplate/converter.rb +12 -6
- data/lib/deplate/core.rb +777 -378
- data/lib/deplate/counters.rb +254 -0
- data/lib/deplate/css/article.css +4 -3
- data/lib/deplate/css/deplate.css +121 -5
- data/lib/deplate/css/heading-navbar.css +0 -0
- data/lib/deplate/css/layout-deplate-print.css +0 -0
- data/lib/deplate/css/layout-deplate.css +0 -0
- data/lib/deplate/css/sans-serif.css +0 -0
- data/lib/deplate/css/serif-e.css +0 -0
- data/lib/deplate/css/serif-rel.css +0 -0
- data/lib/deplate/css/serif.css +9 -3
- data/lib/deplate/css/slides.css +0 -0
- data/lib/deplate/css/tabbar-left.css +0 -0
- data/lib/deplate/css/tabbar-right-ie.css +3 -9
- data/lib/deplate/css/tabbar-right.css +51 -18
- data/lib/deplate/css/tabbar-top.css +7 -1
- data/lib/deplate/css/tabbar.css +0 -0
- data/lib/deplate/css/text-sans-serif.css +0 -0
- data/lib/deplate/css/text-serif.css +0 -0
- data/lib/deplate/define.rb +183 -177
- data/lib/deplate/deplate-string.rb +82 -0
- data/lib/deplate/docbook.rb +236 -128
- data/lib/deplate/elements.rb +584 -417
- data/lib/deplate/etc.rb +163 -101
- data/lib/deplate/external.rb +42 -11
- data/lib/deplate/fmt/dbk-article-4.1.2.rb +0 -0
- data/lib/deplate/fmt/dbk-article.rb +0 -0
- data/lib/deplate/fmt/dbk-book.rb +0 -0
- data/lib/deplate/fmt/dbk-ref.rb +3 -3
- data/lib/deplate/fmt/dbk-slides.rb +0 -0
- data/lib/deplate/fmt/dbk-snippet.rb +0 -0
- data/lib/deplate/fmt/html-snippet.rb +0 -0
- data/lib/deplate/fmt/html.rb +783 -550
- data/lib/deplate/fmt/htmlsite.rb +192 -199
- data/lib/deplate/fmt/htmlslides.rb +0 -0
- data/lib/deplate/fmt/htmlwebsite.rb +3 -3
- data/lib/deplate/fmt/latex-snippet.rb +0 -0
- data/lib/deplate/fmt/latex.rb +242 -83
- data/lib/deplate/fmt/null.rb +32 -0
- data/lib/deplate/fmt/php.rb +4 -4
- data/lib/deplate/fmt/phpsite.rb +6 -5
- data/lib/deplate/fmt/plain.rb +160 -106
- data/lib/deplate/fmt/template.rb +0 -0
- data/lib/deplate/fmt/xhtml10t.rb +0 -0
- data/lib/deplate/formatter-snippet.rb +0 -0
- data/lib/deplate/formatter.rb +613 -301
- data/lib/deplate/input.rb +202 -142
- data/lib/deplate/input/deplate-headings.rb +4 -6
- data/lib/deplate/input/deplate-restricted.rb +15 -9
- data/lib/deplate/input/deplate.rb +2 -4
- data/lib/deplate/input/rdoc.rb +39 -38
- data/lib/deplate/input/template.rb +0 -0
- data/lib/deplate/lib/Makefile.config +29 -0
- data/lib/deplate/lib/latex/deplate.sty +54 -0
- data/lib/deplate/lib/latex/highlight-extra.sty +0 -0
- data/lib/deplate/lib/latex/highlight-typical.sty +0 -0
- data/lib/deplate/lib/php/page-comment.inc.php +216 -0
- data/lib/deplate/lib/tabmenu.js +0 -0
- data/lib/deplate/locale/de.latin1 +155 -17
- data/lib/deplate/locale/ru.koi8-r +0 -0
- data/lib/deplate/locale/zh_cn.gb2312 +0 -0
- data/lib/deplate/macros.rb +133 -82
- data/lib/deplate/messages.rb +6 -4
- data/lib/deplate/metadata.rb +0 -0
- data/lib/deplate/metadata/marshal.rb +0 -0
- data/lib/deplate/metadata/xml.rb +0 -0
- data/lib/deplate/metadata/yaml.rb +0 -0
- data/lib/deplate/mod/anyword.rb +3 -3
- data/lib/deplate/mod/babelfish.rb +4 -4
- data/lib/deplate/mod/code-gvim.rb +8 -4
- data/lib/deplate/mod/code-highlight.rb +3 -3
- data/lib/deplate/mod/colored-log.rb +0 -0
- data/lib/deplate/mod/de.rb +2 -2
- data/lib/deplate/mod/en.rb +0 -0
- data/lib/deplate/mod/endnotes.rb +0 -0
- data/lib/deplate/mod/fr.rb +0 -0
- data/lib/deplate/mod/html-asciimath.rb +0 -0
- data/lib/deplate/mod/html-deplate-button.rb +0 -0
- data/lib/deplate/mod/html-headings-navbar.rb +5 -13
- data/lib/deplate/mod/html-jsmath.rb +39 -0
- data/lib/deplate/mod/html-obfuscate-email.rb +3 -3
- data/lib/deplate/mod/html-sidebar.rb +0 -0
- data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -3
- data/lib/deplate/mod/iconv.rb +0 -0
- data/lib/deplate/mod/imgurl.rb +4 -4
- data/lib/deplate/mod/inlatex-compound.rb +7 -10
- data/lib/deplate/mod/koma.rb +0 -0
- data/lib/deplate/mod/latex-emph-table-head.rb +0 -0
- data/lib/deplate/mod/latex-styles.rb +7 -4
- data/lib/deplate/mod/latex-verbatim-small.rb +0 -0
- data/lib/deplate/mod/makefile.rb +23 -7
- data/lib/deplate/mod/mark-external-urls.rb +3 -3
- data/lib/deplate/mod/markup-1-warn.rb +10 -10
- data/lib/deplate/mod/markup-1.rb +0 -0
- data/lib/deplate/mod/navbar-png.rb +24 -8
- data/lib/deplate/mod/noindent.rb +0 -0
- data/lib/deplate/mod/numpara.rb +0 -0
- data/lib/deplate/mod/particle-math.rb +4 -4
- data/lib/deplate/mod/php-extra.rb +46 -6
- data/lib/deplate/mod/pstoedit.rb +0 -0
- data/lib/deplate/mod/recode.rb +0 -0
- data/lib/deplate/mod/ru_koi8-r.rb +0 -0
- data/lib/deplate/mod/smart-dash.rb +26 -0
- data/lib/deplate/mod/smiley.rb +69 -7
- data/lib/deplate/mod/soffice.rb +0 -0
- data/lib/deplate/mod/symbols-latin1.rb +14 -23
- data/lib/deplate/mod/symbols-od-utf-8.rb +5 -3
- data/lib/deplate/mod/symbols-plain.rb +5 -35
- data/lib/deplate/mod/symbols-sgml.rb +8 -9
- data/lib/deplate/mod/symbols-utf-8.rb +8 -9
- data/lib/deplate/mod/symbols-xml.rb +5 -9
- data/lib/deplate/mod/syntax-region-alt.rb +5 -5
- data/lib/deplate/mod/utf8.rb +0 -0
- data/lib/deplate/mod/validate-html.rb +0 -0
- data/lib/deplate/mod/xmlrpc.rb +0 -0
- data/lib/deplate/mod/zh-cn-autospace.rb +18 -20
- data/lib/deplate/mod/zh-cn.rb +4 -6
- data/lib/deplate/nukumi2.rb +71 -0
- data/lib/deplate/once-method.rb +0 -0
- data/lib/deplate/output.rb +19 -21
- data/lib/deplate/particles.rb +178 -116
- data/lib/deplate/regions.rb +99 -58
- data/lib/deplate/skeletons.rb +122 -0
- data/lib/deplate/structured.rb +164 -106
- data/lib/deplate/template.rb +67 -43
- data/lib/deplate/templates/html-doc.html +0 -0
- data/lib/deplate/templates/html-left-tabbar-js.html +0 -0
- data/lib/deplate/templates/html-left-tabbar.html +0 -0
- data/lib/deplate/templates/html-tabbar-right-pcomments.php +22 -0
- data/lib/deplate/templates/html-tabbar-right-step.html +24 -0
- data/lib/deplate/templates/html-tabbar-right-table.html +0 -0
- data/lib/deplate/templates/html-tabbar-right.html +2 -4
- data/lib/deplate/templates/html-tabbar-top.html +0 -9
- data/lib/deplate/templates/html-tabbar.html +0 -0
- data/lib/deplate/variables.rb +127 -0
- data/lib/deplate/wiki-markup.rb +99 -33
- data/lib/deplate/xml.rb +18 -18
- data/lib/deplate/zh-cn.rb +0 -0
- data/lib/ps2ppm.rb +0 -0
- data/man/man1/deplate.1 +564 -474
- metadata +201 -186
data/lib/deplate/template.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# @Website: http://deplate.sf.net/
|
4
4
|
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
5
|
# @Created: 10-Aug-2004.
|
6
|
-
# @Last Change:
|
7
|
-
# @Revision: 0.
|
6
|
+
# @Last Change: 28-Mai-2006.
|
7
|
+
# @Revision: 0.465
|
8
8
|
#
|
9
9
|
# Description:
|
10
10
|
#
|
@@ -25,6 +25,7 @@ end
|
|
25
25
|
|
26
26
|
|
27
27
|
class Deplate::Command::Matter < Deplate::Command
|
28
|
+
set_formatter :fill_in_template
|
28
29
|
def process
|
29
30
|
id = @args["id"] || @accum[0]
|
30
31
|
@elt = template_get_content(id)
|
@@ -38,28 +39,25 @@ class Deplate::Command::Matter < Deplate::Command
|
|
38
39
|
end
|
39
40
|
|
40
41
|
class Deplate::Command::PREMATTER < Deplate::Command::Matter
|
41
|
-
@formatter = :fill_in_template
|
42
42
|
def template_get_content(arg)
|
43
43
|
@deplate.options.template_manager.template_get_content(:pre, arg)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
47
|
class Deplate::Command::POSTMATTER < Deplate::Command::Matter
|
48
|
-
@formatter = :fill_in_template
|
49
48
|
def template_get_content(arg)
|
50
49
|
@deplate.options.template_manager.template_get_content(:post, arg)
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
53
|
class Deplate::Command::BODY < Deplate::Command::Matter
|
55
|
-
@formatter = :fill_in_template
|
56
54
|
def template_get_content(arg)
|
57
55
|
@deplate.options.template_manager.template_get_content(:body, arg)
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
61
59
|
class Deplate::Regions::Mingle < Deplate::Region
|
62
|
-
|
60
|
+
set_line_cont false
|
63
61
|
|
64
62
|
def finish
|
65
63
|
finish_accum
|
@@ -100,7 +98,7 @@ end
|
|
100
98
|
class Deplate::Template
|
101
99
|
attr_reader :mingled
|
102
100
|
|
103
|
-
@@templateKeys = [
|
101
|
+
@@templateKeys = ['pre', 'body', 'post', 'doc', 'ARG', 'arg', 'clip']
|
104
102
|
@@deplate_for_template = nil
|
105
103
|
@@deplate_options = {
|
106
104
|
:formatter => Deplate::Formatter::Template,
|
@@ -113,28 +111,30 @@ class Deplate::Template
|
|
113
111
|
Deplate::Element::Command,
|
114
112
|
Deplate::Element::Whitespace,
|
115
113
|
],
|
114
|
+
|
116
115
|
:commands => {
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
116
|
+
'INC' => Deplate::Command::INC,
|
117
|
+
'INCLUDE' => Deplate::Command::INC,
|
118
|
+
'GET' => Deplate::Command::GET,
|
119
|
+
'ARG' => Deplate::Command::ARG,
|
120
|
+
'XARG' => Deplate::Command::XARG,
|
121
|
+
'VAL' => Deplate::Command::ARG,
|
122
|
+
'XVAL' => Deplate::Command::XARG,
|
123
|
+
'DOC' => Deplate::Command::VAR,
|
124
|
+
'VAR' => Deplate::Command::VAR,
|
125
|
+
'OPT' => Deplate::Command::OPT,
|
126
|
+
'PREMATTER' => Deplate::Command::PREMATTER,
|
127
|
+
'POSTMATTER' => Deplate::Command::POSTMATTER,
|
128
|
+
'BODY' => Deplate::Command::BODY,
|
130
129
|
},
|
130
|
+
|
131
131
|
:regions => {
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
132
|
+
'Foreach' => Deplate::Regions::Foreach,
|
133
|
+
'Mingle' => Deplate::Regions::Mingle,
|
134
|
+
'Native' => Deplate::Regions::Native,
|
135
|
+
'Ruby' => Deplate::Regions::Ruby,
|
136
|
+
'Doc' => Deplate::Regions::Doc,
|
137
|
+
'Var' => Deplate::Regions::Doc,
|
138
138
|
},
|
139
139
|
|
140
140
|
:particles => [
|
@@ -142,17 +142,19 @@ class Deplate::Template
|
|
142
142
|
Deplate::Particle::Macro,
|
143
143
|
Deplate::Particle::Whitespace,
|
144
144
|
],
|
145
|
+
|
145
146
|
:macros => {
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
147
|
+
'get' => Deplate::Macro::Clip,
|
148
|
+
'clip' => Deplate::Macro::Clip,
|
149
|
+
'opt' => Deplate::Macro::Opt,
|
150
|
+
'arg' => Deplate::Macro::Arg,
|
151
|
+
'xarg' => Deplate::Macro::XArg,
|
152
|
+
'val' => Deplate::Macro::Arg,
|
153
|
+
'xval' => Deplate::Macro::XArg,
|
154
|
+
'var' => Deplate::Macro::Var,
|
155
|
+
'doc' => Deplate::Macro::Var,
|
156
|
+
'ruby' => Deplate::Macro::Ruby,
|
157
|
+
'msg' => Deplate::Macro::Msg,
|
156
158
|
},
|
157
159
|
}
|
158
160
|
|
@@ -160,6 +162,23 @@ class Deplate::Template
|
|
160
162
|
def deplate_options
|
161
163
|
@@deplate_options
|
162
164
|
end
|
165
|
+
|
166
|
+
def copy(deplate, src, dest, invoker=nil)
|
167
|
+
tpl = File.open(src) {|io| io.read}
|
168
|
+
src = invoker ? invoker.source : nil
|
169
|
+
tpl = Deplate::Template.new(:template => tpl,
|
170
|
+
:source => src,
|
171
|
+
:container => self)
|
172
|
+
args = {}
|
173
|
+
if block_given?
|
174
|
+
yield(args)
|
175
|
+
end
|
176
|
+
Deplate::Define.let_variables(deplate, args) do
|
177
|
+
tpl = tpl.fill_in(deplate, :source => src)
|
178
|
+
end
|
179
|
+
tpl = tpl.join("\n")
|
180
|
+
File.open(dest, 'w') {|io| io.puts(tpl)}
|
181
|
+
end
|
163
182
|
end
|
164
183
|
|
165
184
|
attr_reader :template, :pre, :body, :post
|
@@ -181,14 +200,19 @@ class Deplate::Template
|
|
181
200
|
file = args[:file]
|
182
201
|
if file
|
183
202
|
if File.exists?(file)
|
184
|
-
|
185
|
-
|
203
|
+
begin
|
204
|
+
File.open(file) do |io|
|
205
|
+
@template = io.read
|
206
|
+
end
|
207
|
+
rescue Exception => e
|
208
|
+
Deplate::DeplateForTemplates.log([e.message], :error, @source)
|
209
|
+
@template = ''
|
186
210
|
end
|
187
211
|
else
|
188
|
-
Deplate::DeplateForTemplates.log([
|
212
|
+
Deplate::DeplateForTemplates.log(['Template not found', file], :error, @source)
|
189
213
|
end
|
190
214
|
else
|
191
|
-
Deplate::DeplateForTemplates.log(
|
215
|
+
Deplate::DeplateForTemplates.log('No template defined', :error, @source)
|
192
216
|
end
|
193
217
|
end
|
194
218
|
|
@@ -205,7 +229,7 @@ class Deplate::Template
|
|
205
229
|
:post => [],
|
206
230
|
}
|
207
231
|
@keep_whitespace = args.has_key?(:keep_whitespace) ? args[:keep_whitespace] : true
|
208
|
-
if deplate.variables[
|
232
|
+
if deplate.variables['template_version'] == '1'
|
209
233
|
fill_in_1
|
210
234
|
else
|
211
235
|
fill_in_2
|
@@ -216,7 +240,7 @@ class Deplate::Template
|
|
216
240
|
if @@deplate_for_template
|
217
241
|
d = @@deplate_for_template
|
218
242
|
else
|
219
|
-
d = @@deplate_for_template = Deplate::DeplateForTemplates.new(
|
243
|
+
d = @@deplate_for_template = Deplate::DeplateForTemplates.new('', @@deplate_options)
|
220
244
|
end
|
221
245
|
keep_whitespace = d.options.keep_whitespace
|
222
246
|
master = d.options.master
|
@@ -224,7 +248,7 @@ class Deplate::Template
|
|
224
248
|
begin
|
225
249
|
d.reset
|
226
250
|
d.variables = @deplate.variables.dup
|
227
|
-
d.doc_services = @deplate.doc_services
|
251
|
+
# d.doc_services = @deplate.doc_services
|
228
252
|
d.set_all_clips(@deplate.get_unprocessed_clips)
|
229
253
|
d.options.template_manager = self
|
230
254
|
d.options.keep_whitespace = @keep_whitespace
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#Mingle type=pre slot=css:
|
2
|
+
<!--[if IE]>
|
3
|
+
<link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
|
4
|
+
<![endif]-->
|
5
|
+
#End
|
6
|
+
#PREMATTER
|
7
|
+
|
8
|
+
<div id="tabFrame">
|
9
|
+
<div id="tabBodyFrame">
|
10
|
+
<div id="tabBody">
|
11
|
+
<img width="600px" height="1px" src="spacer.png" alt="" />
|
12
|
+
#BODY: -navbar_top -navbar_bottom
|
13
|
+
</div>
|
14
|
+
#ARG: pageComment()
|
15
|
+
#POSTMATTER: html_pageicons_beg..html_pageicons_end
|
16
|
+
</div>
|
17
|
+
<div id="tabBar">
|
18
|
+
#ARG: tabBarRight(spacer=spacer.png depth=2 depthInactive=1)
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
#POSTMATTER
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#Mingle type=pre slot=css:
|
2
|
+
<!--[if IE]>
|
3
|
+
<link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
|
4
|
+
<![endif]-->
|
5
|
+
#End
|
6
|
+
#PREMATTER
|
7
|
+
|
8
|
+
<div id="tabFrame">
|
9
|
+
<div id="tabBodyFrame">
|
10
|
+
<div id="tabBody">
|
11
|
+
<img width="600px" height="1px" src="spacer.png" alt="" />
|
12
|
+
#BODY: -navbar_top -navbar_bottom
|
13
|
+
</div>
|
14
|
+
#POSTMATTER: html_pageicons_beg..html_pageicons_end
|
15
|
+
</div>
|
16
|
+
<div id="tabBar">
|
17
|
+
#ARG: tabBarRight(spacer=spacer.png depth=2 depthInactive=1)
|
18
|
+
</div>
|
19
|
+
#ARG: navigationKeys()
|
20
|
+
#ARG: stepwiseDisplay()
|
21
|
+
#ARG: navigationHandleKeys()
|
22
|
+
</div>
|
23
|
+
|
24
|
+
#POSTMATTER
|
File without changes
|
@@ -1,8 +1,6 @@
|
|
1
1
|
#Mingle type=pre slot=css:
|
2
2
|
<!--[if IE]>
|
3
|
-
<
|
4
|
-
<link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
|
5
|
-
</style>
|
3
|
+
<link rel="stylesheet" type="text/css" href="tabbar-right-ie.css" media="screen">
|
6
4
|
<![endif]-->
|
7
5
|
#End
|
8
6
|
#PREMATTER
|
@@ -16,7 +14,7 @@
|
|
16
14
|
#POSTMATTER: html_pageicons_beg..html_pageicons_end
|
17
15
|
</div>
|
18
16
|
<div id="tabBar">
|
19
|
-
#ARG: tabBarRight(
|
17
|
+
#ARG: tabBarRight(spacer=spacer.png depth=2 depthInactive=1)
|
20
18
|
</div>
|
21
19
|
</div>
|
22
20
|
|
File without changes
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# variables.rb
|
2
|
+
# @Author: Thomas Link (samul AT web de)
|
3
|
+
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
4
|
+
# @Created: 31-Dez-2005.
|
5
|
+
# @Last Change: 18-Apr-2006.
|
6
|
+
# @Revision: 0.37
|
7
|
+
|
8
|
+
class Deplate::Variables < Hash
|
9
|
+
attr_accessor :deplate
|
10
|
+
|
11
|
+
def initialize(deplate=nil)
|
12
|
+
super()
|
13
|
+
@deplate = deplate
|
14
|
+
end
|
15
|
+
|
16
|
+
def log(*args)
|
17
|
+
Deplate::Core.log(*args)
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(hash)
|
21
|
+
for key, val in hash
|
22
|
+
self[key] = val
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def []=(name, value)
|
27
|
+
if name.kind_of?(String) and (m = /^(\S+)\[(\S+)?\]$/.match(name))
|
28
|
+
key = m[1]
|
29
|
+
field = m[2]
|
30
|
+
var = self[key]
|
31
|
+
if !var
|
32
|
+
if !field
|
33
|
+
self[key] = [value]
|
34
|
+
elsif field =~ /^[0-9]$/
|
35
|
+
self[key] = []
|
36
|
+
self[key][field.to_i] = value
|
37
|
+
else
|
38
|
+
self[key] = {field => value}
|
39
|
+
end
|
40
|
+
elsif var.kind_of?(Struct) || var.kind_of?(OpenStruct)
|
41
|
+
var.send("#{field}=", value)
|
42
|
+
elsif var.kind_of?(Hash)
|
43
|
+
var[field] = value
|
44
|
+
elsif var.kind_of?(Array)
|
45
|
+
if !field
|
46
|
+
var << value
|
47
|
+
elsif field =~ /^[0-9]+$/
|
48
|
+
field = field.to_i
|
49
|
+
var[field] = value
|
50
|
+
else
|
51
|
+
Deplate::Core.log(["Wrong index", field, name, var.class], :error)
|
52
|
+
end
|
53
|
+
elsif var
|
54
|
+
Deplate::Core.log(["Doc variable has wrong type", key, var.class], :error)
|
55
|
+
end
|
56
|
+
else
|
57
|
+
super
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def [](name)
|
62
|
+
begin
|
63
|
+
if !name.kind_of?(String) or keys.include?(name)
|
64
|
+
return super
|
65
|
+
# elsif name =~ /^no(\S+)$/ and (keys.include?($1) or keys.include?(name))
|
66
|
+
# return !super($1)
|
67
|
+
elsif name =~ /^\S+\(.*?\)$/
|
68
|
+
m = /^(\S+)\((.*?)?\)$/.match(name)
|
69
|
+
if m
|
70
|
+
method = m[1]
|
71
|
+
args = m[2]
|
72
|
+
args, text = @deplate.input.parse_args(args, nil, false)
|
73
|
+
rv = @deplate.formatter.invoke_service(method, args, text)
|
74
|
+
return rv
|
75
|
+
else
|
76
|
+
Deplate::Core.log(['Malformed variable name', name], :error)
|
77
|
+
end
|
78
|
+
elsif name =~ /^:(\S+)$/
|
79
|
+
n = $1
|
80
|
+
if @deplate.is_allowed?(':', :logger => self)
|
81
|
+
return @deplate.options.send(n)
|
82
|
+
end
|
83
|
+
elsif (m = /^(\S+)\[(\S+)\]$/.match(name))
|
84
|
+
key = m[1]
|
85
|
+
field = m[2]
|
86
|
+
val = self[key]
|
87
|
+
return extract(val, key, field)
|
88
|
+
elsif (m = /^(\S+)\.(\S+)$/.match(name))
|
89
|
+
if @deplate.is_allowed?('.', :logger => self)
|
90
|
+
key = m[1]
|
91
|
+
meth = m[2]
|
92
|
+
val = self[key]
|
93
|
+
begin
|
94
|
+
return val.send(meth)
|
95
|
+
rescue Exception => e
|
96
|
+
log(['Invoking method failed', meth, val.class], :error)
|
97
|
+
end
|
98
|
+
else
|
99
|
+
log(['No permission', name], :anyway)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
rescue Exception => e
|
103
|
+
Deplate::Core.log(['Retrieving doc variable failed', name, e], :error)
|
104
|
+
end
|
105
|
+
return nil
|
106
|
+
end
|
107
|
+
|
108
|
+
def extract(val, key, field)
|
109
|
+
if val.nil?
|
110
|
+
Deplate::Core.log(['Unknown variable', key], :error)
|
111
|
+
elsif val.kind_of?(Struct) || val.kind_of?(OpenStruct)
|
112
|
+
return val.send(field)
|
113
|
+
elsif val.kind_of?(Hash)
|
114
|
+
return val[field]
|
115
|
+
elsif val.kind_of?(Array)
|
116
|
+
if field =~ /^[0-9]+$/
|
117
|
+
field = field.to_i
|
118
|
+
return val[field]
|
119
|
+
else
|
120
|
+
Deplate::Core.log(['Wrong index', field, name, val.class], :error)
|
121
|
+
end
|
122
|
+
else
|
123
|
+
Deplate::Core.log(['Variable has wrong type', key, val.class], :warning)
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
data/lib/deplate/wiki-markup.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
# @Website: http://deplate.sf.net/
|
4
4
|
# @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
|
5
5
|
# @Created: 10-M�r-2005.
|
6
|
-
# @Last Change:
|
7
|
-
# @Revision: 0.
|
6
|
+
# @Last Change: 30-Mrz-2006.
|
7
|
+
# @Revision: 0.260
|
8
8
|
#
|
9
9
|
# = Description
|
10
10
|
# Various elements for defining input filters
|
@@ -12,48 +12,116 @@
|
|
12
12
|
# = TODO
|
13
13
|
# = CHANGES
|
14
14
|
|
15
|
+
require "deplate/abstract-class"
|
16
|
+
|
15
17
|
module Deplate::Input::Wiki; end
|
16
18
|
|
19
|
+
# Textstyles
|
20
|
+
# Italic
|
17
21
|
class Deplate::Input::Wiki::ItalicWordSingleUnderscore < Deplate::Particle::Emphasize
|
18
|
-
|
22
|
+
set_rx(/^\b_(\S+?)_\b/)
|
19
23
|
end
|
20
24
|
|
21
|
-
class Deplate::Input::Wiki::
|
22
|
-
|
25
|
+
class Deplate::Input::Wiki::ItalicDoubleSlash < Deplate::Particle::Emphasize
|
26
|
+
set_rx(/^\b\/\/(\S+?)\/\/\b/)
|
23
27
|
end
|
24
28
|
|
25
|
-
|
26
|
-
|
29
|
+
|
30
|
+
# Bold
|
31
|
+
class Deplate::Input::Wiki::Bold < Deplate::Particle::Emphasize
|
32
|
+
def setup
|
33
|
+
@args['style'] = 'bold'
|
34
|
+
update_styles
|
35
|
+
super
|
36
|
+
end
|
27
37
|
end
|
28
38
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
39
|
+
class Deplate::Input::Wiki::BoldWordSingleAsterisk < Deplate::Input::Wiki::Bold
|
40
|
+
set_rx(/^\B\*(\S+?)\*\B/)
|
41
|
+
end
|
42
|
+
|
43
|
+
class Deplate::Input::Wiki::BoldDoubleAsterisk < Deplate::Input::Wiki::Bold
|
44
|
+
set_rx(/^\*\*(\S+?)\*\*/)
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
# Superscript
|
49
|
+
class Deplate::Input::Wiki::Superscript < Deplate::SimpleParticle
|
50
|
+
set_formatter :format_superscript
|
51
|
+
end
|
52
|
+
|
53
|
+
class Deplate::Input::Wiki::SuperscriptTagSup < Deplate::Input::Wiki::Superscript
|
54
|
+
set_rx(/^<sup>(.*?)<\/sup>/)
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
# Subscript
|
59
|
+
class Deplate::Input::Wiki::Subscript < Deplate::SimpleParticle
|
60
|
+
set_formatter :format_subscript
|
61
|
+
end
|
62
|
+
|
63
|
+
class Deplate::Input::Wiki::SubscriptTagSub < Deplate::Input::Wiki::Subscript
|
64
|
+
set_rx(/^<sub>(.*?)<\/sub>/)
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
# Strikethrough
|
69
|
+
class Deplate::Input::Wiki::StrikeThrough < Deplate::Particle::Emphasize
|
70
|
+
def setup
|
71
|
+
@args['style'] = 'strikethrough'
|
72
|
+
update_styles
|
73
|
+
super
|
34
74
|
end
|
75
|
+
end
|
76
|
+
|
77
|
+
class Deplate::Input::Wiki::StrikethroughTagDeleted < Deplate::Input::Wiki::StrikeThrough
|
78
|
+
set_rx(/^<deleted>(.*?)<\/deleted>/)
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
# Typewriter
|
83
|
+
class Deplate::Input::Wiki::TypewriterWordSinglePlus < Deplate::Particle::Code
|
84
|
+
set_rx(/^\B\+(\S+?)\+\B/)
|
85
|
+
end
|
35
86
|
|
36
|
-
|
37
|
-
|
87
|
+
module Deplate::Input::Wiki::AbstractImg
|
88
|
+
def image_args
|
89
|
+
{}
|
38
90
|
end
|
39
91
|
|
40
|
-
def
|
41
|
-
|
92
|
+
def image_process
|
93
|
+
args = @args.dup
|
94
|
+
args.update(image_args)
|
95
|
+
@elt = @deplate.formatter.include_image(self, @dest, args, true)
|
42
96
|
end
|
43
97
|
end
|
44
98
|
|
99
|
+
# Treat a reference to an image as included images. Requires subclassing and a
|
100
|
+
# definition of @rx.
|
101
|
+
class Deplate::Input::Wiki::ImgUrl < Deplate::HyperLink::Url
|
102
|
+
set_rx(/^((file|https?|mailto|ftps?|www):(\S+?)\.(png|jpg|jpeg|gif|bmp))\b/)
|
103
|
+
include Deplate::Input::Wiki::AbstractImg
|
104
|
+
alias :process :image_process
|
105
|
+
end
|
106
|
+
|
45
107
|
# Treat non-indented text as paragraph, indented as verbatim.
|
46
108
|
class Deplate::Input::Wiki::ParagraphIndentedVerbatim < Deplate::Element::Paragraph
|
47
|
-
|
109
|
+
set_rx(/^([ \t]*)(.+)[ \t]*$/)
|
110
|
+
set_formatter nil
|
111
|
+
|
48
112
|
def get_text
|
49
113
|
@leading_whitespace = @match[1]
|
50
114
|
@keep_whitespace = !@leading_whitespace.empty?
|
51
115
|
@match[2]
|
52
116
|
end
|
53
117
|
|
54
|
-
def to_be_continued?(line)
|
55
|
-
|
56
|
-
|
118
|
+
def to_be_continued?(line, klass, match)
|
119
|
+
if super
|
120
|
+
indent = get_indent(line).size
|
121
|
+
return @level > 0 || indent == 0
|
122
|
+
else
|
123
|
+
return false
|
124
|
+
end
|
57
125
|
end
|
58
126
|
|
59
127
|
def format_special
|
@@ -84,34 +152,32 @@ module Deplate::Input::Wiki::ListExtra
|
|
84
152
|
end
|
85
153
|
end
|
86
154
|
|
87
|
-
class Deplate::Input::Wiki::
|
155
|
+
class Deplate::Input::Wiki::OrderedNotIndented < Deplate::List::Ordered
|
88
156
|
include Deplate::Input::Wiki::ListExtra
|
89
|
-
|
90
|
-
@name = "Numbered"
|
91
|
-
@rx = /^(()([0-9]+\.|[a-zA-Z]\.)[ \t]+)(.+)$/
|
157
|
+
set_rx(/^(()([0-9]+\.|[a-zA-Z]\.)[ \t]+)(.+)$/)
|
92
158
|
end
|
93
159
|
|
94
160
|
class Deplate::Input::Wiki::ItemizeNotIndented < Deplate::List::Itemize
|
95
161
|
include Deplate::Input::Wiki::ListExtra
|
96
|
-
|
97
|
-
@name = "Itemize"
|
98
|
-
@rx = /^(()([-*])[ \t]+)(.+)$/
|
162
|
+
set_rx(/^(()([-*])[ \t]+)(.+)$/)
|
99
163
|
end
|
100
164
|
|
101
165
|
# Requires subclassing & definition of @rx.
|
102
166
|
class Deplate::Input::Wiki::AbstractDescription < Deplate::List::Description
|
103
167
|
include Deplate::Input::Wiki::ListExtra
|
104
|
-
@formatter = :format_list
|
105
|
-
@name = "Description"
|
106
168
|
end
|
107
169
|
|
170
|
+
# Heading
|
108
171
|
class Deplate::Input::Wiki::HeadingPrefixEqual < Deplate::Element::Heading
|
109
|
-
|
110
|
-
|
172
|
+
set_rx(/^(=+)[ \t]+(.*?)$/)
|
173
|
+
end
|
174
|
+
|
175
|
+
class Deplate::Input::Wiki::HeadingEqual < Deplate::Element::Heading
|
176
|
+
set_rx(/^(=+)[[:blank:]]*(.*?)[[:blank:]]*\1$/)
|
111
177
|
end
|
112
178
|
|
179
|
+
# Page Break
|
113
180
|
class Deplate::Input::Wiki::Break3Hyphens < Deplate::Element::Break
|
114
|
-
|
115
|
-
@rx = /^\s*-{3,}\s*$/
|
181
|
+
set_rx(/^\s*-{3,}\s*$/)
|
116
182
|
end
|
117
183
|
|