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/particles.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: 24-M�r-2004.
|
6
|
-
# @Last Change:
|
7
|
-
# @Revision: 0.
|
6
|
+
# @Last Change: 05-Jun-2006.
|
7
|
+
# @Revision: 0.1847
|
8
8
|
|
9
9
|
require "uri"
|
10
10
|
require "deplate/common"
|
@@ -12,8 +12,6 @@ require "deplate/common"
|
|
12
12
|
|
13
13
|
# Sub-line level text bits.
|
14
14
|
class Deplate::Particle < Deplate::BaseParticle
|
15
|
-
# An array of auto-indexed words/strings.
|
16
|
-
@@autoindexed = []
|
17
15
|
# An array of the default particle classes.
|
18
16
|
@@particles = []
|
19
17
|
# The regular expression for the default particle classes.
|
@@ -25,8 +23,6 @@ class Deplate::Particle < Deplate::BaseParticle
|
|
25
23
|
@@rx_extended = nil
|
26
24
|
|
27
25
|
class << self
|
28
|
-
attr :rx
|
29
|
-
|
30
26
|
def particles
|
31
27
|
@@particles
|
32
28
|
end
|
@@ -44,16 +40,20 @@ class Deplate::Particle < Deplate::BaseParticle
|
|
44
40
|
end
|
45
41
|
|
46
42
|
def match(text)
|
47
|
-
return
|
43
|
+
return self.rx.match(text)
|
48
44
|
end
|
49
45
|
|
50
46
|
def register_particle(c=self)
|
51
47
|
@@particles << c
|
52
48
|
end
|
49
|
+
|
50
|
+
def disable_particle(*particles)
|
51
|
+
particles.each {|p| @@particles.delete(p)}
|
52
|
+
end
|
53
53
|
|
54
54
|
# Create an auto-indexed word. Arguments:
|
55
55
|
# deplate:: An instance of Deplate::Core.
|
56
|
-
# idx:: An instance of the Deplate::
|
56
|
+
# idx:: An instance of the Deplate::IndexEntry structure.
|
57
57
|
def auto_indexing(deplate, idx)
|
58
58
|
if idx
|
59
59
|
i = idx.name
|
@@ -61,14 +61,15 @@ class Deplate::Particle < Deplate::BaseParticle
|
|
61
61
|
name = i.gsub(/\W\|s/) do |x|
|
62
62
|
x.unpack('H2' * x.size)
|
63
63
|
end
|
64
|
-
|
65
|
-
|
64
|
+
autoindexed = deplate.options.autoindexed
|
65
|
+
if !w.any? {|x| autoindexed.include?(x)}
|
66
|
+
autoindexed.concat(w)
|
66
67
|
aname = %{AutoIndex#{name}}
|
67
68
|
if self == Deplate::HyperLink
|
68
69
|
rx = Regexp.escape(i).gsub(/\\/, "\\\\")
|
69
70
|
rx.gsub!(/"/, %{\\\\"})
|
70
71
|
body = <<-EOR
|
71
|
-
|
72
|
+
set_rx(%r{^\\b#{rx}\\b})
|
72
73
|
def setup
|
73
74
|
super
|
74
75
|
name = match[0]
|
@@ -86,7 +87,7 @@ class Deplate::Particle < Deplate::BaseParticle
|
|
86
87
|
rx = w.collect {|i| Regexp.escape(i)}.join("\\b|\\b")
|
87
88
|
rx.gsub!(/"/, %{\\\\"})
|
88
89
|
body = <<-EOR
|
89
|
-
|
90
|
+
set_rx(%r{^\\b#{rx}\\b})
|
90
91
|
def setup
|
91
92
|
@idx = @deplate.add_index(self, %{#{idxName}}) if @container
|
92
93
|
end
|
@@ -95,12 +96,13 @@ class Deplate::Particle < Deplate::BaseParticle
|
|
95
96
|
@elt = plain_text(Deplate::Core.remove_backslashes(@match[0])) +
|
96
97
|
format_particle(:format_index, self, @idx)
|
97
98
|
else
|
98
|
-
@elt =
|
99
|
+
@elt = ''
|
99
100
|
end
|
100
101
|
end
|
101
102
|
EOR
|
102
103
|
end
|
103
104
|
cls = Deplate::Cache.particle(deplate, body,
|
105
|
+
:super => Deplate::Autoindex,
|
104
106
|
:register => true,
|
105
107
|
:extended => true)
|
106
108
|
end
|
@@ -114,9 +116,9 @@ class Deplate::Particle < Deplate::BaseParticle
|
|
114
116
|
|
115
117
|
end
|
116
118
|
|
117
|
-
def initialize(deplate, container, context, match, alt, last=
|
119
|
+
def initialize(deplate, container, context, match, alt, last='', rest='')
|
118
120
|
super(deplate, :container => container)
|
119
|
-
|
121
|
+
self.level_as_string = container.level_as_string if container
|
120
122
|
@context = context
|
121
123
|
@match = match
|
122
124
|
@last = last
|
@@ -133,23 +135,47 @@ class Deplate::Particle < Deplate::BaseParticle
|
|
133
135
|
end
|
134
136
|
|
135
137
|
|
138
|
+
class Deplate::Autoindex < Deplate::Particle
|
139
|
+
end
|
140
|
+
|
141
|
+
|
136
142
|
# A wrapper class for simple particles that require only minimal
|
137
143
|
# processing.
|
138
144
|
class Deplate::SimpleParticle < Deplate::Particle
|
139
145
|
def setup
|
140
146
|
@elt = @deplate.parse(@container, get_text, @alt)
|
141
147
|
end
|
148
|
+
|
142
149
|
def get_text
|
143
150
|
@match[1]
|
144
151
|
end
|
152
|
+
|
153
|
+
def process
|
154
|
+
@elt = @deplate.format_particles(@elt)
|
155
|
+
fmt = self.class.formatter
|
156
|
+
if fmt
|
157
|
+
@elt = format_particle(fmt, self, @elt)
|
158
|
+
# else
|
159
|
+
# raise 'Internal error: No formatter'
|
160
|
+
end
|
161
|
+
end
|
145
162
|
end
|
146
163
|
|
147
164
|
|
148
165
|
# A pseudo-particle class. Note the following difference: @match holds
|
149
166
|
# the plain text as String and not as MatchData.
|
150
167
|
class Deplate::Particle::Text < Deplate::Particle
|
168
|
+
# set_formatter :plain_text
|
169
|
+
class << self
|
170
|
+
def pseudo_match(text)
|
171
|
+
[text]
|
172
|
+
end
|
173
|
+
end
|
151
174
|
def process
|
152
|
-
@elt = plain_text(
|
175
|
+
@elt = plain_text(get_text)
|
176
|
+
end
|
177
|
+
def get_text
|
178
|
+
@match[0]
|
153
179
|
end
|
154
180
|
end
|
155
181
|
|
@@ -157,7 +183,7 @@ end
|
|
157
183
|
# Match characters escaped with a backslash.
|
158
184
|
class Deplate::Particle::Escaped < Deplate::Particle
|
159
185
|
register_particle
|
160
|
-
set_rx
|
186
|
+
set_rx(/^\\(.)/)
|
161
187
|
def process
|
162
188
|
@elt = plain_text(@match[1], true)
|
163
189
|
end
|
@@ -166,12 +192,24 @@ end
|
|
166
192
|
|
167
193
|
# Match emphasized text marked as <tt>__text__</tt>.
|
168
194
|
class Deplate::Particle::Emphasize < Deplate::SimpleParticle
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
195
|
+
class << self
|
196
|
+
def markup(text)
|
197
|
+
if text
|
198
|
+
[
|
199
|
+
'__',
|
200
|
+
Deplate::Core.escape_characters(text, :escape => '_\\'),
|
201
|
+
'__'
|
202
|
+
].join
|
203
|
+
end
|
204
|
+
end
|
174
205
|
end
|
206
|
+
register_particle
|
207
|
+
set_rx(/^__((\\_|.)+?)__/)
|
208
|
+
set_formatter :format_emphasize
|
209
|
+
# def process
|
210
|
+
# @elt = @deplate.format_particles(@elt)
|
211
|
+
# @elt = format_particle(:format_emphasize, self, @elt)
|
212
|
+
# end
|
175
213
|
end
|
176
214
|
|
177
215
|
|
@@ -179,23 +217,29 @@ end
|
|
179
217
|
class Deplate::Particle::Code < Deplate::Particle
|
180
218
|
register_particle
|
181
219
|
set_rx(/^''((\\\\|\\'|.)+?)''/)
|
220
|
+
def_get :text, 1
|
182
221
|
|
183
222
|
class << self
|
184
223
|
# Programmatically markup text as code. Used e.g. for some
|
185
224
|
# R-generated tables.
|
186
225
|
def markup(text)
|
187
|
-
[
|
226
|
+
[
|
227
|
+
%{''},
|
228
|
+
# text.gsub("'", "\\\\'"),
|
229
|
+
Deplate::Core.escape_characters(text, :escape => "'\\"),
|
230
|
+
%{''}
|
231
|
+
].join
|
188
232
|
end
|
189
233
|
end
|
190
234
|
|
235
|
+
def hook_pre_process
|
236
|
+
@elt = Deplate::Core.remove_backslashes(@elt)
|
237
|
+
end
|
238
|
+
|
191
239
|
def process
|
192
240
|
text = Deplate::Core.remove_backslashes(get_text)
|
193
241
|
@elt = format_particle(:format_code, self, text)
|
194
242
|
end
|
195
|
-
|
196
|
-
def get_text
|
197
|
-
@match[1]
|
198
|
-
end
|
199
243
|
end
|
200
244
|
|
201
245
|
|
@@ -204,28 +248,8 @@ end
|
|
204
248
|
class Deplate::Particle::Symbol < Deplate::Particle
|
205
249
|
register_particle
|
206
250
|
|
207
|
-
#
|
208
|
-
@@symbols_table =
|
209
|
-
# An array of symbols in order as they were defined -- as ruby
|
210
|
-
# eagerly sorts the keys in the @@symbols_table hash. This is used
|
211
|
-
# for building the rx.
|
212
|
-
@@symbols_keys = []
|
213
|
-
|
214
|
-
class << self
|
215
|
-
# Add a symbol. If val is nil, a general formatter dependent
|
216
|
-
# routine will be used.
|
217
|
-
def add_symbol(key, val=nil)
|
218
|
-
@@symbols_keys << Regexp.escape(key)
|
219
|
-
@@symbols_table[key] = val
|
220
|
-
end
|
221
|
-
|
222
|
-
# Build the rx based on @@symbols_keys.
|
223
|
-
def setup_rx
|
224
|
-
@rx = Regexp.new(%{^(%s)} % @@symbols_keys.join("|"))
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
for i in [
|
251
|
+
# An association array of symbols and method names for formatting this symbol.
|
252
|
+
@@symbols_table = [
|
229
253
|
["<->"],
|
230
254
|
["<-" ],
|
231
255
|
["->" ],
|
@@ -251,14 +275,44 @@ class Deplate::Particle::Symbol < Deplate::Particle
|
|
251
275
|
["``", :singlequote_open],
|
252
276
|
["`'", :singlequote_close],
|
253
277
|
]
|
254
|
-
|
278
|
+
# An array of symbols in order as they were defined -- as ruby
|
279
|
+
# eagerly sorts the keys in the @@symbols_table hash. This is used
|
280
|
+
# for building the rx.
|
281
|
+
@@symbols_keys = []
|
282
|
+
|
283
|
+
class << self
|
284
|
+
# Add a symbol. If val is nil, a general formatter dependent
|
285
|
+
# routine will be used.
|
286
|
+
def add_symbol(key, val=nil)
|
287
|
+
@@symbols_keys << Regexp.escape(key)
|
288
|
+
# @@symbols_table[key] = val
|
289
|
+
end
|
290
|
+
|
291
|
+
# Build the rx based on @@symbols_keys.
|
292
|
+
def setup_rx
|
293
|
+
set_rx(Regexp.new(%{^(%s)} % @@symbols_keys.join("|")))
|
294
|
+
end
|
295
|
+
|
296
|
+
def reset_symbols
|
297
|
+
@@symbols_keys = []
|
298
|
+
for i in @@symbols_table
|
299
|
+
add_symbol(*i)
|
300
|
+
end
|
301
|
+
setup_rx
|
302
|
+
end
|
255
303
|
end
|
256
|
-
setup_rx
|
257
304
|
|
305
|
+
reset_symbols
|
306
|
+
|
258
307
|
def process
|
259
|
-
sym = @@symbols_table
|
260
|
-
|
308
|
+
sym = @@symbols_table.assoc(@match[1])[1]
|
309
|
+
case sym
|
310
|
+
when ::Proc
|
311
|
+
@elt = instance_eval &sym
|
312
|
+
when ::Symbol
|
261
313
|
@elt = @deplate.formatter.send(sym, self)
|
314
|
+
when ::String
|
315
|
+
@elt = format_particle(:format_symbol, self, sym)
|
262
316
|
else
|
263
317
|
@elt = format_particle(:format_symbol, self, @match[1])
|
264
318
|
end
|
@@ -270,7 +324,7 @@ class Deplate::Particle::DoubleQuote < Deplate::Particle
|
|
270
324
|
register_particle
|
271
325
|
set_rx(/^"/)
|
272
326
|
def process
|
273
|
-
if @last =~ /(^|[\s({\[])$/
|
327
|
+
if @last =~ /(^|[\s({\[])$/ or (@rest =~ /^\w/ and @last =~ /\W$/)
|
274
328
|
@elt = format_particle(:doublequote_open, self)
|
275
329
|
else
|
276
330
|
@elt = format_particle(:doublequote_close, self)
|
@@ -283,7 +337,7 @@ class Deplate::Particle::SingleQuote < Deplate::Particle
|
|
283
337
|
register_particle
|
284
338
|
set_rx(/^'/)
|
285
339
|
def process
|
286
|
-
if @last =~ /(^|[\s({\[])$/
|
340
|
+
if @last =~ /(^|[\s({\[])$/ or (@rest =~ /^\w/ and @last =~ /\W$/)
|
287
341
|
@elt = format_particle(:singlequote_open, self)
|
288
342
|
else
|
289
343
|
@elt = format_particle(:singlequote_close, self)
|
@@ -340,17 +394,29 @@ class Deplate::HyperLink < Deplate::Particle
|
|
340
394
|
def url_anchor(url, anchor)
|
341
395
|
dest = [url]
|
342
396
|
if anchor and !anchor.empty?
|
343
|
-
dest <<
|
397
|
+
dest << '#' << anchor
|
344
398
|
end
|
345
399
|
dest.join
|
346
400
|
end
|
401
|
+
|
402
|
+
def upper_case_chars
|
403
|
+
@@uc
|
404
|
+
end
|
405
|
+
|
406
|
+
def lower_case_chars
|
407
|
+
@@lc
|
408
|
+
end
|
409
|
+
|
410
|
+
def chars
|
411
|
+
@@uc + @@lc
|
412
|
+
end
|
347
413
|
end
|
348
414
|
|
349
415
|
include Deplate::InterWiki
|
350
416
|
|
351
417
|
def get_InterWiki(id)
|
352
418
|
d = @@interwikis[id]
|
353
|
-
Deplate::Core.log([
|
419
|
+
Deplate::Core.log(['Unknown InterWiki name', id], :error, @container.source) unless d
|
354
420
|
return d
|
355
421
|
end
|
356
422
|
|
@@ -367,15 +433,15 @@ class Deplate::HyperLink < Deplate::Particle
|
|
367
433
|
#
|
368
434
|
# +++ the heuristic is fragile and sometimes gives wrong results
|
369
435
|
def complete_wiki_ref(inter, name, dest, anchor)
|
370
|
-
sfx = @deplate.variables[
|
371
|
-
sfx =
|
436
|
+
sfx = @deplate.variables['suffix']
|
437
|
+
sfx = '.%s' % sfx if sfx
|
372
438
|
if dest.empty?
|
373
439
|
label = guess_label(dest, anchor)
|
374
440
|
if label
|
375
441
|
dest = @container.output_file_name(:relative => self)
|
376
442
|
return :wiki, name, dest, label
|
377
443
|
else
|
378
|
-
log([
|
444
|
+
log(['Wiki reference to unknown anchor', "#{dest}##{anchor}"], :error)
|
379
445
|
return nil
|
380
446
|
end
|
381
447
|
elsif @literal
|
@@ -396,23 +462,23 @@ class Deplate::HyperLink < Deplate::Particle
|
|
396
462
|
return :url, name, d.url + @deplate.file_with_suffix(dest, d.sfx), anchor
|
397
463
|
end
|
398
464
|
# we then check if the file was included
|
399
|
-
elsif @deplate.file_included?(dest, File.dirname(@container.source.file ||
|
465
|
+
elsif @deplate.file_included?(dest, File.dirname(@container.source.file || ''), sfx)
|
400
466
|
label = guess_label(@deplate.file_with_suffix(dest, sfx), anchor)
|
401
467
|
if label
|
402
468
|
dest = @container.output_file_name(:label => label)
|
403
469
|
else
|
404
|
-
dest =
|
470
|
+
dest = ''
|
405
471
|
end
|
406
472
|
return :wiki, name, dest, label
|
407
473
|
end
|
408
474
|
# Fallback heuristic
|
409
|
-
src = @container.source.file ||
|
475
|
+
src = @container.source.file || ''
|
410
476
|
dest_sfx = File.extname(dest)
|
411
477
|
dest_abs = File.expand_path(dest, File.basename(src))
|
412
478
|
dest_is_dir = (File.exist?(dest_abs) and File.stat(dest_abs).directory?)
|
413
|
-
if !dest_is_dir and (dest_sfx ==
|
479
|
+
if !dest_is_dir and (dest_sfx == '' or dest_sfx == sfx or dest_sfx == File.extname(src))
|
414
480
|
dest1 = @deplate.file_with_suffix(dest, @deplate.options.suffix)
|
415
|
-
name = dest1 if !dest_sfx.empty? and (name == dest or name ==
|
481
|
+
name = dest1 if !dest_sfx.empty? and (name == dest or name == '')
|
416
482
|
return :url, name, dest1, anchor
|
417
483
|
else
|
418
484
|
return :url, name, dest, anchor
|
@@ -421,8 +487,8 @@ class Deplate::HyperLink < Deplate::Particle
|
|
421
487
|
|
422
488
|
def indexing(idx)
|
423
489
|
idx = idx.compact
|
424
|
-
unless @deplate.variables[
|
425
|
-
auto = @deplate.variables[
|
490
|
+
unless @deplate.variables['indexwiki'] == 'no' or idx.empty?
|
491
|
+
auto = @deplate.variables['autoindex']
|
426
492
|
for i in idx
|
427
493
|
Deplate::Particle.auto_indexing(@deplate, i) if auto
|
428
494
|
end
|
@@ -435,14 +501,14 @@ class Deplate::HyperLink < Deplate::Particle
|
|
435
501
|
def process
|
436
502
|
type, name, dest, anchor = complete_wiki_ref(@inter, *@elt)
|
437
503
|
if type
|
438
|
-
dest.gsub!(/\\/,
|
504
|
+
dest.gsub!(/\\/, '/')
|
439
505
|
dest = encode_dest(dest)
|
440
506
|
anchor = encode_anchor(anchor)
|
441
507
|
if dest =~ Deplate::HyperLink::Url.rx
|
442
508
|
if dest =~ /^mailto:/
|
443
|
-
@styles <<
|
509
|
+
@styles << 'mailto'
|
444
510
|
else
|
445
|
-
@styles <<
|
511
|
+
@styles << 'remote'
|
446
512
|
end
|
447
513
|
end
|
448
514
|
case type
|
@@ -471,7 +537,7 @@ class Deplate::HyperLink < Deplate::Particle
|
|
471
537
|
|
472
538
|
def encode_dest(dest)
|
473
539
|
if dest =~ /^~/
|
474
|
-
return
|
540
|
+
return 'file://%s' % File.join(ENV['HOME'], encode_path(dest[1..-1]))
|
475
541
|
elsif dest =~ Deplate::HyperLink::Url.rx
|
476
542
|
# elsif dest =~ URI::REGEXP::ABS_URI
|
477
543
|
# if it looks like an url, we assume that it's already properly encoded
|
@@ -502,17 +568,24 @@ class Deplate::HyperLink::Extended < Deplate::HyperLink
|
|
502
568
|
class << self
|
503
569
|
def setup
|
504
570
|
# @rx = /^\[\[([^\]#]*)(#(#{@@bc}))?\](\[(.+?)\])?([-!~*]*)\]/
|
505
|
-
@rx = /^\[\[([^\]#]*)(#([^\]]*))?\](\[(.+?)\])?([-!~*]*)\]/
|
571
|
+
# @rx = /^\[\[([^\]#]*)(#([^\]]*))?\](\[(.+?)\])?([-!~*]*)\]/
|
572
|
+
set_rx(/^\[\[(([#{@@uc}]+?)::)?([^\]#]*)(#([^\]]*))?\](\[(.+?)\])?([-!~*]*)\]/)
|
506
573
|
end
|
507
574
|
end
|
508
575
|
|
576
|
+
def_get :interwiki, 2
|
577
|
+
def_get :destination, 3
|
578
|
+
def_get :anchor, 5
|
579
|
+
def_get :name, 7
|
580
|
+
def_get :modifier, 8
|
581
|
+
|
509
582
|
def setup
|
510
|
-
@inter =
|
511
|
-
@dest = get_destination ||
|
583
|
+
@inter = get_interwiki
|
584
|
+
@dest = get_destination || ''
|
512
585
|
@anchor = get_anchor
|
513
586
|
@name = get_name
|
514
|
-
@modifier = get_modifier ||
|
515
|
-
unless @modifier.include?(
|
587
|
+
@modifier = get_modifier || ''
|
588
|
+
unless @modifier.include?('-')
|
516
589
|
if @name
|
517
590
|
id = @name
|
518
591
|
else
|
@@ -529,7 +602,7 @@ class Deplate::HyperLink::Extended < Deplate::HyperLink
|
|
529
602
|
idx = []
|
530
603
|
end
|
531
604
|
@idx = indexing(idx)
|
532
|
-
@literal = @modifier.include?(
|
605
|
+
@literal = @modifier.include?('!') # || @dest =~ Deplate::HyperLink::Url.rx
|
533
606
|
if @modifier.include?('~') and @dest =~ /^\~/
|
534
607
|
@dest = File.expand_path(@dest)
|
535
608
|
end
|
@@ -537,22 +610,6 @@ class Deplate::HyperLink::Extended < Deplate::HyperLink
|
|
537
610
|
@args['target'] = '_blank'
|
538
611
|
end
|
539
612
|
end
|
540
|
-
|
541
|
-
def get_destination
|
542
|
-
@match[1]
|
543
|
-
end
|
544
|
-
|
545
|
-
def get_anchor
|
546
|
-
@match[3]
|
547
|
-
end
|
548
|
-
|
549
|
-
def get_name
|
550
|
-
@match[5]
|
551
|
-
end
|
552
|
-
|
553
|
-
def get_modifier
|
554
|
-
@match[6]
|
555
|
-
end
|
556
613
|
|
557
614
|
def process
|
558
615
|
@name = @deplate.parse_and_format(self, @name, false, [
|
@@ -589,11 +646,21 @@ end
|
|
589
646
|
# OTHERDEPLATE::[-some name-]#there
|
590
647
|
class Deplate::HyperLink::Simple < Deplate::HyperLink
|
591
648
|
register_particle
|
649
|
+
self.pre_condition = lambda do |match|
|
650
|
+
pre = match.pre_match
|
651
|
+
cond = pre.empty? || pre !~ /[#{@@uc}#{@@lc}[:alnum:]]$/
|
652
|
+
if cond
|
653
|
+
post = match.post_match
|
654
|
+
cond &&= (post.empty? || post !~ /^[#{@@uc}#{@@lc}[:alnum:]]/)
|
655
|
+
end
|
656
|
+
cond
|
657
|
+
end
|
592
658
|
|
593
659
|
class << self
|
594
660
|
def setup
|
595
661
|
# @rx = /^((\b[#{@@uc}]+)::)?(\[-(.*?)-\]|\b[#{@@uc}][#{@@lc}]+([#{@@uc}][#{@@lc}0-9]+)+\b)(#(#{@@ac})\b)?/
|
596
|
-
|
662
|
+
# set_rx(/^(([#{@@uc}]+)::)?(\[-(.*?)-\]|\b[#{@@uc}][#{@@lc}]+([#{@@uc}][#{@@lc}0-9]+)+\b)(#(#{@@ac}))?/)
|
663
|
+
set_rx(/^(([#{@@uc}]+)::)?(\[-(.*?)-\]|[#{@@uc}][#{@@lc}]+([#{@@uc}][#{@@lc}0-9]+)+)(#(#{@@ac}))?/)
|
597
664
|
# @rx = /^(([#{@@uc}]+)::)?(\[-(.*?)-\]|\b[A-Z][#{@@lc}]+([#{@@uc}][#{@@lc}0-9]+)+)(#(#{@@ac}))?(?!#{@@ac})/
|
598
665
|
# @rx = /^(([#{@@uc}]+)::)?(\[-(.*?)-\]|\b[#{@@uc}][#{@@lc}]+([#{@@uc}][#{@@lc}0-9]+)+)(#(#{@@ac}))?(?!(#{@@ac}|$))/
|
599
666
|
end
|
@@ -687,29 +754,16 @@ class Deplate::Particle::Macro < Deplate::Particle
|
|
687
754
|
# The macro name.
|
688
755
|
attr_reader :macro
|
689
756
|
|
690
|
-
|
691
|
-
# This function builds the rx for the macro reader. The optional
|
692
|
-
# argument defines the depth of nested macros for which the
|
693
|
-
# regular expression is being built. The default is 5 which should
|
694
|
-
# be sufficient due to the primitivity of the macro language.
|
695
|
-
def build_rx(depth=5)
|
696
|
-
@rx = "\\{(?>\\\\\\{|\\\\\\}|\\\\\\\\|[^{}]+?|#)*\\}"
|
697
|
-
@rxr = @rx.gsub("\\", "\\\\\\\\")
|
698
|
-
for i in 1..depth
|
699
|
-
@rx.gsub!(/#/, @rxr)
|
700
|
-
end
|
701
|
-
@rx.gsub!(/#/, "[^{}]+?")
|
702
|
-
@rx = Regexp.new("^" + @rx)
|
703
|
-
end
|
704
|
-
end
|
705
|
-
|
706
|
-
build_rx
|
757
|
+
set_rx Deplate::Rx.builder('\\{(?>\\\\\\{|\\\\\\}|\\\\\\\\|[^{}]+?|{#})*\\}')
|
707
758
|
|
708
759
|
def setup
|
709
760
|
begin
|
710
761
|
macro = get_text
|
711
|
-
|
762
|
+
if macro.empty?
|
763
|
+
@elt = plain_text(@match[0], false)
|
764
|
+
else
|
712
765
|
@macro, args, text = split_name_args(macro)
|
766
|
+
# args[:macro] = macro
|
713
767
|
if @macro
|
714
768
|
@elt = Deplate::Macro.exec(@deplate, @container, @context, @macro, args, @alt, text)
|
715
769
|
if @elt
|
@@ -733,7 +787,8 @@ class Deplate::Particle::Macro < Deplate::Particle
|
|
733
787
|
end
|
734
788
|
|
735
789
|
def split_name_args(macro)
|
736
|
-
m = /^([^a-zA-Z]|[[:alnum:]_]+)(.*)$/.match(macro)
|
790
|
+
# m = /^([^a-zA-Z]|[[:alnum:]_]+)(.*)$/.match(macro)
|
791
|
+
m = /^([^a-zA-Z]|[^:[:space:]]+)(.*)$/.match(macro)
|
737
792
|
if m
|
738
793
|
macro = m[1]
|
739
794
|
if macro =~ /^[^a-zA-Z]/
|
@@ -750,7 +805,14 @@ class Deplate::Particle::Macro < Deplate::Particle
|
|
750
805
|
end
|
751
806
|
|
752
807
|
def process
|
753
|
-
@elt =
|
808
|
+
@elt = case @elt
|
809
|
+
when String
|
810
|
+
@elt
|
811
|
+
when nil
|
812
|
+
''
|
813
|
+
else
|
814
|
+
@elt.process
|
815
|
+
end
|
754
816
|
end
|
755
817
|
end
|
756
818
|
|
@@ -758,7 +820,7 @@ end
|
|
758
820
|
# Give warnings about misplaced, unbalanced, or not-escaped curly braces.
|
759
821
|
class Deplate::Particle::CurlyBrace < Deplate::Particle
|
760
822
|
register_particle
|
761
|
-
set_rx
|
823
|
+
set_rx(/^([{}])/)
|
762
824
|
|
763
825
|
def process
|
764
826
|
sample_pre = @last[-10..-1]
|
@@ -772,7 +834,7 @@ end
|
|
772
834
|
# Match against whitespace. This class is currently only used for
|
773
835
|
# template input filter.
|
774
836
|
class Deplate::Particle::Whitespace < Deplate::Particle
|
775
|
-
set_rx
|
837
|
+
set_rx(/^\s+/)
|
776
838
|
|
777
839
|
def process
|
778
840
|
@elt = @match[0]
|