deplate 0.8 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. data/AUTHORS.TXT +19 -16
  2. data/CHANGES.TXT +214 -248
  3. data/NEWS.TXT +47 -30
  4. data/README.TXT +0 -1
  5. data/TODO.TXT +93 -20
  6. data/VERSION.TXT +1 -1
  7. data/bin/deplate.exy +192 -0
  8. data/etc/deplate.ini +70 -9
  9. data/lib/action_view/helpers/deplate.rb +33 -33
  10. data/lib/deplate.rb +2 -2
  11. data/lib/deplate/bib.rb +72 -41
  12. data/lib/deplate/builtin.rb +1 -1
  13. data/lib/deplate/cache.rb +1 -1
  14. data/lib/deplate/commands.rb +161 -102
  15. data/lib/deplate/common.rb +93 -7
  16. data/lib/deplate/converter.rb +10 -4
  17. data/lib/deplate/core.rb +215 -108
  18. data/lib/deplate/counters.rb +23 -8
  19. data/lib/deplate/css/article.css +9 -5
  20. data/lib/deplate/css/deplate.css +37 -3
  21. data/lib/deplate/css/heading-navbar.css +1 -1
  22. data/lib/deplate/css/highstep.css +18 -0
  23. data/lib/deplate/css/htmldoc.css +43 -0
  24. data/lib/deplate/css/layout-deplate-print.css +1 -1
  25. data/lib/deplate/css/layout-deplate.css +1 -1
  26. data/lib/deplate/css/play.css +101 -0
  27. data/lib/deplate/css/sans-serif.css +1 -1
  28. data/lib/deplate/css/serif-e.css +1 -1
  29. data/lib/deplate/css/serif-rel.css +1 -1
  30. data/lib/deplate/css/serif.css +1 -1
  31. data/lib/deplate/css/slides.css +1 -1
  32. data/lib/deplate/css/styles.css +4 -0
  33. data/lib/deplate/css/tabbar-right.css +54 -8
  34. data/lib/deplate/css/tabbar-top.css +28 -9
  35. data/lib/deplate/css/text-sans-serif.css +1 -1
  36. data/lib/deplate/css/text-serif.css +1 -1
  37. data/lib/deplate/define.rb +71 -38
  38. data/lib/deplate/deplate-string.rb +3 -3
  39. data/lib/deplate/docbook.rb +9 -9
  40. data/lib/deplate/elements.rb +173 -84
  41. data/lib/deplate/etc.rb +6 -8
  42. data/lib/deplate/external.rb +9 -5
  43. data/lib/deplate/fmt/dbk-article-4.1.2.rb +4 -3
  44. data/lib/deplate/fmt/dbk-article.rb +9 -8
  45. data/lib/deplate/fmt/dbk-book.rb +4 -3
  46. data/lib/deplate/fmt/dbk-ref.rb +5 -4
  47. data/lib/deplate/fmt/dbk-slides.rb +4 -3
  48. data/lib/deplate/fmt/dbk-snippet.rb +4 -3
  49. data/lib/deplate/fmt/html-snippet.rb +1 -1
  50. data/lib/deplate/fmt/html.rb +186 -46
  51. data/lib/deplate/fmt/htmlsite.rb +19 -9
  52. data/lib/deplate/fmt/htmlslides.rb +1 -1
  53. data/lib/deplate/fmt/htmlwebsite.rb +1 -1
  54. data/lib/deplate/fmt/latex-dramatist.rb +175 -0
  55. data/lib/deplate/fmt/latex-snippet.rb +1 -1
  56. data/lib/deplate/fmt/latex.rb +132 -80
  57. data/lib/deplate/fmt/null.rb +1 -1
  58. data/lib/deplate/fmt/php.rb +1 -1
  59. data/lib/deplate/fmt/phpsite.rb +1 -1
  60. data/lib/deplate/fmt/plain.rb +16 -9
  61. data/lib/deplate/fmt/template.rb +1 -1
  62. data/lib/deplate/fmt/xhtml10t.rb +1 -1
  63. data/lib/deplate/formatter-snippet.rb +1 -1
  64. data/lib/deplate/formatter.rb +272 -81
  65. data/lib/deplate/guesslanguage.rb +57 -0
  66. data/lib/deplate/input.rb +205 -50
  67. data/lib/deplate/input/deplate-headings.rb +9 -11
  68. data/lib/deplate/input/deplate-restricted.rb +3 -23
  69. data/lib/deplate/input/deplate.rb +1 -1
  70. data/lib/deplate/input/play.rb +208 -0
  71. data/lib/deplate/input/rdoc.rb +37 -15
  72. data/lib/deplate/input/template.rb +6 -11
  73. data/lib/deplate/lib/Makefile.config +53 -4
  74. data/lib/deplate/lib/html/parbreak +3 -0
  75. data/lib/deplate/lib/javascript/StepwiseNextPage.js +8 -0
  76. data/lib/deplate/lib/javascript/StepwiseNextPage_confirm.js +8 -0
  77. data/lib/deplate/lib/latex/deplate.sty +36 -0
  78. data/lib/deplate/lib/latex/parbreak +6 -0
  79. data/lib/deplate/lib/php/page-comment.inc.php +5 -5
  80. data/lib/deplate/lib/plain/parbreak +6 -0
  81. data/lib/deplate/locale/de.latin1 +87 -15
  82. data/lib/deplate/locale/de.latin1_data +60 -0
  83. data/lib/deplate/locale/en.latin1_data +46 -0
  84. data/lib/deplate/locale/fr.latin1_data +74 -0
  85. data/lib/deplate/locale/ru.koi8-r_data +63 -0
  86. data/lib/deplate/locale/{zh_cn.gb2312 → zh_CN.GB2312} +0 -0
  87. data/lib/deplate/macros.rb +106 -32
  88. data/lib/deplate/messages.rb +22 -8
  89. data/lib/deplate/metadata.rb +1 -1
  90. data/lib/deplate/metadata/marshal.rb +1 -1
  91. data/lib/deplate/metadata/xml.rb +1 -1
  92. data/lib/deplate/metadata/yaml.rb +1 -1
  93. data/lib/deplate/mod/anyword.rb +4 -4
  94. data/lib/deplate/mod/babelfish.rb +1 -1
  95. data/lib/deplate/mod/code-gvim.rb +14 -8
  96. data/lib/deplate/mod/code-gvim71.rb +52 -0
  97. data/lib/deplate/mod/code-highlight.rb +35 -19
  98. data/lib/deplate/mod/colored-log.rb +1 -1
  99. data/lib/deplate/mod/endnotes.rb +1 -1
  100. data/lib/deplate/mod/guesslanguage.rb +75 -0
  101. data/lib/deplate/mod/html-asciimath.rb +1 -1
  102. data/lib/deplate/mod/html-deplate-button.rb +1 -1
  103. data/lib/deplate/mod/html-headings-navbar.rb +1 -1
  104. data/lib/deplate/mod/html-highstep.rb +43 -0
  105. data/lib/deplate/mod/html-jsmath.rb +1 -1
  106. data/lib/deplate/mod/html-obfuscate-email.rb +1 -1
  107. data/lib/deplate/mod/html-sidebar.rb +1 -1
  108. data/lib/deplate/mod/iconv.rb +1 -1
  109. data/lib/deplate/mod/imgurl.rb +1 -1
  110. data/lib/deplate/mod/inlatex-compound.rb +1 -1
  111. data/lib/deplate/mod/koma.rb +4 -4
  112. data/lib/deplate/mod/{de.rb → lang-de.rb} +1 -1
  113. data/lib/deplate/mod/{en.rb → lang-en.rb} +1 -1
  114. data/lib/deplate/mod/{ru_koi8-r.rb → lang-ru-koi8-r.rb} +1 -1
  115. data/lib/deplate/mod/lang-ru.rb +9 -0
  116. data/lib/deplate/mod/{zh-cn-autospace.rb → lang-zh_CN-autospace.rb} +3 -3
  117. data/lib/deplate/mod/{zh-cn.rb → lang-zh_CN.rb} +8 -8
  118. data/lib/deplate/mod/latex-emph-table-head.rb +1 -1
  119. data/lib/deplate/mod/latex-styles.rb +6 -6
  120. data/lib/deplate/mod/latex-verbatim-small.rb +1 -1
  121. data/lib/deplate/mod/linkmap.rb +128 -0
  122. data/lib/deplate/mod/makefile.rb +23 -22
  123. data/lib/deplate/mod/mark-external-urls.rb +13 -7
  124. data/lib/deplate/mod/markup-1-warn.rb +1 -1
  125. data/lib/deplate/mod/markup-1.rb +1 -1
  126. data/lib/deplate/mod/navbar-png.rb +5 -4
  127. data/lib/deplate/mod/noindent.rb +1 -1
  128. data/lib/deplate/mod/numpara.rb +1 -1
  129. data/lib/deplate/mod/particle-math.rb +1 -1
  130. data/lib/deplate/mod/php-extra.rb +1 -1
  131. data/lib/deplate/mod/pstoedit.rb +1 -1
  132. data/lib/deplate/mod/recode.rb +1 -1
  133. data/lib/deplate/mod/smart-dash.rb +1 -1
  134. data/lib/deplate/mod/smiley.rb +1 -1
  135. data/lib/deplate/mod/soffice.rb +1 -1
  136. data/lib/deplate/mod/symbols-latin1.rb +1 -1
  137. data/lib/deplate/mod/symbols-od-utf-8.rb +1 -1
  138. data/lib/deplate/mod/symbols-plain.rb +1 -1
  139. data/lib/deplate/mod/symbols-sgml.rb +1 -1
  140. data/lib/deplate/mod/symbols-utf-8.rb +1 -1
  141. data/lib/deplate/mod/symbols-xml.rb +1 -1
  142. data/lib/deplate/mod/syntax-region-alt.rb +1 -1
  143. data/lib/deplate/mod/utf8.rb +1 -1
  144. data/lib/deplate/mod/validate-html.rb +1 -1
  145. data/lib/deplate/mod/xmlrpc.rb +37 -36
  146. data/lib/deplate/nukumi2.rb +4 -4
  147. data/lib/deplate/once-method.rb +1 -1
  148. data/lib/deplate/output.rb +12 -4
  149. data/lib/deplate/particles.rb +52 -22
  150. data/lib/deplate/regions.rb +160 -90
  151. data/lib/deplate/skeletons.rb +4 -3
  152. data/lib/deplate/structured.rb +19 -13
  153. data/lib/deplate/template.rb +17 -9
  154. data/lib/deplate/templates/html-doc.html +8 -11
  155. data/lib/deplate/templates/html-tabbar-right.html +1 -1
  156. data/lib/deplate/templates/html-tabbar-top.html +3 -3
  157. data/lib/deplate/variables.rb +25 -9
  158. data/lib/deplate/wiki-markup.rb +14 -3
  159. data/lib/deplate/xml.rb +3 -4
  160. data/lib/deplate/{zh-cn.rb → zh_CN.rb} +16 -16
  161. data/man/man1/deplate.1 +80 -65
  162. metadata +72 -48
  163. data/lib/deplate/mod/fr.rb +0 -46
@@ -1,10 +1,10 @@
1
1
  # regions.rb
2
- # @Author: Thomas Link (samul AT web.de)
2
+ # @Author: Thomas Link (micathom AT gmail com)
3
3
  # @Website: http://deplate.sf.net/
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 08-Mai-2004.
6
- # @Last Change: 05-Jun-2006.
7
- # @Revision: 0.1662
6
+ # @Last Change: 2007-09-30.
7
+ # @Revision: 0.1752
8
8
 
9
9
  # Description:
10
10
  #
@@ -32,11 +32,59 @@ class Deplate::Region < Deplate::Element
32
32
  def set_line_cont(val=true)
33
33
  self.line_cont=val
34
34
  end
35
+
36
+ def check_file(container, out, file, source)
37
+ if Dir[out].empty?
38
+ container.log(['Output not found', out, Dir.pwd])
39
+ return false
40
+ elsif file and source
41
+ if File.exist?(file)
42
+ accum = File.open(file) {|io| io.read}.split(/[\n\r]+/)
43
+ clean_strings(accum)
44
+ clean_strings(source)
45
+ if accum === source
46
+ container.log(['Output exists and source matches', file])
47
+ return true
48
+ else
49
+ container.log(['Source has changed', file, accum.size, source.size])
50
+ # p "DBG", accum, source
51
+ # puts caller[0..10].join("\n")
52
+ for i in 0..[accum.size, source.size].max
53
+ unless accum[i] === source[i]
54
+ container.log('%S != %S', [accum[i], source[i]])
55
+ end
56
+ end
57
+ end
58
+ else
59
+ container.log(['Source not found; assume that output is okay', file])
60
+ return true
61
+ end
62
+ end
63
+ container.log(['Output needs updating', file])
64
+ return false
65
+ end
66
+
67
+ def clean_strings(strings)
68
+ strings.delete('')
69
+ strings.each {|l| l.chomp!}
70
+ end
71
+
72
+ def deprecated_regnote(invoker, args, regNote, arg='@note')
73
+ # if !@args.has_key?(arg) or (!@args[arg] and @regNote)
74
+ if !args.has_key?(arg)
75
+ if regNote and !regNote.empty?
76
+ invoker.log(['Deprecated region syntax: Use argument instead', arg, regNote]
77
+ # , :anyway
78
+ )
79
+ # puts caller[0..10].join("\n")
80
+ end
81
+ args[arg] = regNote
82
+ end
83
+ args[arg]
84
+ end
85
+
35
86
  end
36
87
 
37
- attr_reader :regNote
38
- attr_accessor :indent
39
-
40
88
  def setup(region=nil)
41
89
  if region
42
90
  @region = region
@@ -48,10 +96,10 @@ class Deplate::Region < Deplate::Element
48
96
  def finish_accum
49
97
  if @region
50
98
  unify_now(@region)
51
- @regNote = @region.regNote ? @region.regNote.strip : ""
99
+ @regNote = @region.regNote ? @region.regNote.strip : ''
52
100
  @accum = @region.accum
53
101
  else
54
- @regNote = ""
102
+ @regNote = ''
55
103
  end
56
104
  if defined?(@indent)
57
105
  rx = /^#{@indent}/
@@ -84,40 +132,8 @@ class Deplate::Region < Deplate::Element
84
132
  end
85
133
  end
86
134
 
87
- class << self
88
- def check_file(container, out, file, source)
89
- if Dir[out].empty?
90
- container.log(["Output not found", out, Dir.pwd])
91
- return false
92
- elsif file and source
93
- if File.exist?(file)
94
- accum = File.open(file) {|io| io.read}.split(/[\n\r]+/)
95
- clean_strings(accum)
96
- clean_strings(source)
97
- if accum === source
98
- container.log(["Output exists and source matches", file])
99
- return true
100
- else
101
- container.log(["Source has changed", file, accum.size, source.size])
102
- for i in 0..[accum.size, source.size].max
103
- unless accum[i] === source[i]
104
- container.log("%S != %S", [accum[i], source[i]])
105
- end
106
- end
107
- end
108
- else
109
- container.log(["Source not found; assume that output is okay", file])
110
- return true
111
- end
112
- end
113
- container.log(["Output needs updating", file])
114
- return false
115
- end
116
-
117
- def clean_strings(strings)
118
- strings.delete("")
119
- strings.each {|l| l.chomp!}
120
- end
135
+ def deprecated_regnote(arg='@note')
136
+ Deplate::Region.deprecated_regnote(self, @args, @regNote, arg)
121
137
  end
122
138
  end
123
139
 
@@ -171,14 +187,14 @@ class Deplate::Regions::UNKNOWN < Deplate::Region
171
187
  end
172
188
 
173
189
 
174
- class Deplate::Regions::Doc < Deplate::Region
190
+ class Deplate::Regions::Var < Deplate::Region
175
191
  register_as 'Doc'
176
192
  register_as 'Var'
177
193
  set_line_cont false
178
194
 
179
195
  def finish
180
196
  finish_accum
181
- id = @args['id'] || @regNote
197
+ id = deprecated_regnote('id')
182
198
  Deplate::Command::VAR.set_variable(@deplate, id, @accum, @args, @source)
183
199
  return nil
184
200
  end
@@ -194,17 +210,26 @@ class Deplate::Regions::Native < Deplate::Region
194
210
  def finish
195
211
  finish_accum
196
212
  @elt = @accum
213
+ if @args['template']
214
+ @elt = filter_template(@elt)
215
+ end
197
216
  return self
198
217
  end
199
218
 
200
219
  def process
201
220
  process_etc
202
- @elt = @elt.join("\n")
203
221
  return self
204
222
  end
205
223
 
206
224
  def format_special
207
- @elt
225
+ case @elt
226
+ when Array
227
+ @elt.join("\n")
228
+ else
229
+ puts "TBD DBG This shouldn't be @elt.class=#{@elt.class}. Please report."
230
+ puts @elt
231
+ @elt
232
+ end
208
233
  end
209
234
  end
210
235
 
@@ -214,30 +239,39 @@ class Deplate::Regions::Write < Deplate::Regions::Native
214
239
  self.label_mode = :none
215
240
 
216
241
  def finish
217
- @vars = @deplate.variables.dup
242
+ unless @args['noTemplate']
243
+ @args['template'] = true
244
+ end
245
+ # @vars = @deplate.variables.dup
218
246
  super
219
247
  end
220
248
 
221
249
  def format_special
222
- @elt = Deplate::Template.new(:template => @elt,
223
- :source => @source,
224
- :container => self)
225
- Deplate::Define.let_variables(@deplate, @vars) do
226
- @elt = @elt.fill_in(@deplate, :source => @source)
227
- end
228
- @elt = @elt.join("\n")
250
+ # @elt = Deplate::Template.new(:template => @elt,
251
+ # :source => @source,
252
+ # :container => self)
253
+ # Deplate::Define.let_variables(@deplate, @vars) do
254
+ # @elt = @elt.fill_in(@deplate, :source => @source)
255
+ # end
256
+ # @elt = @elt.join("\n")
257
+ # @elt = filter_template(@elt, @vars, :container => self).join("\n")
229
258
  fname = @args['file'] || @args['id']
230
- if @deplate.is_allowed?(['w', 'W'], :logger => self)
259
+ if fname == '-' or @deplate.is_allowed?(['w', 'W'], :logger => self)
231
260
  if fname
232
- unless @deplate.is_allowed?('W')
233
- fname = File.basename(fname)
234
- end
235
- fname = Deplate::Core.get_out_fullname(fname, nil, @deplate.options)
236
- sfx = @args['suffix'] || @args['sfx']
237
- fname = [fname, sfx.gsub(/[^[:alnum:].]/, '_')].join('.') if sfx
238
- mode = @args['append'] ? 'a' : 'w'
239
- @deplate.write_file(fname, mode) do |io|
240
- io.puts(@elt)
261
+ if fname == '-'
262
+ # fname = 2
263
+ puts @elt
264
+ else
265
+ unless @deplate.is_allowed?('W')
266
+ fname = File.basename(fname)
267
+ end
268
+ fname = Deplate::Core.get_out_fullname(fname, nil, @deplate.options)
269
+ sfx = @args['suffix'] || @args['sfx']
270
+ fname = [fname, sfx.gsub(/[^[:alnum:].]/, '_')].join('.') if sfx
271
+ mode = @args['append'] ? 'a' : 'w'
272
+ @deplate.write_file(fname, mode) do |io|
273
+ io.puts(@elt)
274
+ end
241
275
  end
242
276
  else
243
277
  log(['No filename'], :error)
@@ -271,41 +305,41 @@ class Deplate::Regions::Code < Deplate::Regions::Native
271
305
 
272
306
  def setup(region)
273
307
  super
274
- @syntax = @deplate.variables["codeSyntax"]
275
- @style = @deplate.variables["codeStyle"]
308
+ @syntax = @deplate.variables['codeSyntax']
309
+ @style = @deplate.variables['codeStyle']
276
310
  end
277
311
 
278
312
  def process
279
313
  process_etc
280
314
  text = @elt.join("\n")
281
- if (s = @args["syntax"])
315
+ if (s = @args['syntax'])
282
316
  @syntax = s
283
317
  end
284
- if (s = @args["style"])
318
+ if (s = @args['style'])
285
319
  @style = s
286
320
  end
287
321
  if @style
288
- @style = Deplate::Core.clean_file_name(@style)
322
+ @style = Deplate::Core.clean_name(@style)
289
323
  @deplate.call_methods_matching(@deplate.formatter, /^hook_code_process_/, @style)
290
324
  end
291
325
  if @syntax
292
326
  e = nil
293
327
  @deplate.in_working_dir do
294
328
  fmt_name = @deplate.formatter.formatter_name
295
- id = @args["id"]
329
+ id = @args['id']
296
330
  if id
297
- id.gsub!(/\W/, "00")
331
+ id.gsub!(/\W/, '00')
298
332
  fcode = @deplate.auxiliary_filename("code_#{id}")
299
333
  fout = @deplate.auxiliary_filename("code_#{id}.#{fmt_name}")
300
334
  else
301
- log("No ID given", :anyway)
335
+ log('No ID given', :anyway)
302
336
  @@code_idx += 1
303
337
  fcode = @deplate.auxiliary_filename(@deplate.auxiliary_auto_filename('code', @@code_idx, @elt, @syntax))
304
338
  fout = @deplate.auxiliary_filename(@deplate.auxiliary_auto_filename('code', @@code_idx, @elt, fmt_name))
305
339
  end
306
340
  if Deplate::Region.check_file(self, fout, fcode, @elt)
307
341
  log(["Files exist! Using", fout], :anyway)
308
- File.open(fout) {|io| @elt = io.read}
342
+ File.open(fout) {|io| @elt = io.readlines.collect {|l| l.chomp}}
309
343
  return self
310
344
  else
311
345
  begin
@@ -314,6 +348,7 @@ class Deplate::Regions::Code < Deplate::Regions::Native
314
348
  specialized_highlighter.each do |fmt, agent|
315
349
  if @deplate.formatter.matches?(fmt)
316
350
  e = send(agent, @syntax, @style, text)
351
+ # p "DBG Code 1 #{e.class}"
317
352
  break if e
318
353
  end
319
354
  end
@@ -321,6 +356,7 @@ class Deplate::Regions::Code < Deplate::Regions::Native
321
356
  unless e
322
357
  agent = self.class.general_highlighter[fmt_name]
323
358
  e = send(agent, @syntax, @style, text) if agent
359
+ # p "DBG Code 2 #{e.class}"
324
360
  end
325
361
  rescue StandardError => e
326
362
  log("#Code: #{e}", :error)
@@ -332,13 +368,21 @@ class Deplate::Regions::Code < Deplate::Regions::Native
332
368
  end
333
369
  end
334
370
  if e
335
- @elt = e
371
+ case e
372
+ when Array
373
+ @elt = e
374
+ when String
375
+ p "DBG e should be an Array. Please report."
376
+ @elt = e.split("\n")
377
+ else
378
+ raise "DBG Unknown class for e: #{e.class}. Please report."
379
+ end
336
380
  return self
337
381
  end
338
382
  else
339
383
  log("Code: No syntax defined!", :error)
340
384
  end
341
- return Deplate::Regions::Verbatim.new(@deplate, @source, text, @match, self).finish.process
385
+ return Deplate::Regions::Verbatim.new(@deplate, @source, @elt, @match, self).finish.process
342
386
  end
343
387
  end
344
388
 
@@ -371,7 +415,7 @@ class Deplate::Regions::Inlatex < Deplate::Region
371
415
 
372
416
  def register_caption
373
417
  if @args["inline"]
374
- log("Can't attach caption to a LaTeX fragment marked as inline", :error)
418
+ log("Cannot attach caption to a LaTeX fragment marked as inline", :error)
375
419
  elsif @content_type == "table"
376
420
  register_table
377
421
  else
@@ -530,6 +574,7 @@ module Deplate::Regions::Img_R
530
574
  raise
531
575
  end
532
576
  post << "dev.off()"
577
+ post << "q(runLast=FALSE)"
533
578
  return (pre + accum + post).flatten
534
579
  end
535
580
 
@@ -564,7 +609,7 @@ class Deplate::Regions::Footnote < Deplate::Region::SecondOrder
564
609
  def finish
565
610
  rv = super
566
611
  @prototype = Deplate::Element
567
- id = (@args['id'] ||= @regNote)
612
+ id = deprecated_regnote('id')
568
613
  if id
569
614
  @deplate.footnotes[id] = rv
570
615
  # @deplate.register_metadata(src,
@@ -582,22 +627,27 @@ end
582
627
 
583
628
  class Deplate::Regions::Foreach < Deplate::Region
584
629
  register_as 'Foreach'
630
+ register_as 'For'
585
631
  self.label_mode = :once
586
632
 
587
633
  def finish
588
634
  finish_accum
589
- @id = @args['@id'].split(/[\s,]+/)
635
+ @id = Deplate::Core.split_list(@args['@id'], ',', '; ', @source)
590
636
  unless @id
591
637
  log('No ID given', :error)
592
638
  return nil
593
639
  end
594
- doc = @args['doc']
640
+ doc = @args['var'] || @args['doc']
595
641
  if doc
596
642
  @list = @deplate.variables[doc]
597
643
  else
598
- @list = @regNote
644
+ @list = deprecated_regnote('each')
599
645
  end
600
- if @list.kind_of?(Array)
646
+ case @list
647
+ when nil
648
+ log('Missing arguments', :error)
649
+ return nil
650
+ when Array
601
651
  @list = @list.flatten
602
652
  else
603
653
  rx = @args['rx']
@@ -613,6 +663,13 @@ class Deplate::Regions::Foreach < Deplate::Region
613
663
  end
614
664
  end
615
665
  end
666
+ use_template = !(@args['noTemplate'] || deplate.variables['legacyFor1'])
667
+ if use_template
668
+ tmpl = Deplate::Template.new(:master => @deplate,
669
+ :template => @accum,
670
+ :source => @source,
671
+ :container => self)
672
+ end
616
673
  @foreach = []
617
674
  while !@list.empty?
618
675
  ids = {}
@@ -620,7 +677,12 @@ class Deplate::Regions::Foreach < Deplate::Region
620
677
  ids[i] = @list.shift
621
678
  end
622
679
  Deplate::Define.let_variables(@deplate, ids) do
623
- acc = @deplate.parsed_array_from_strings(@accum, 1 + @source.begin, @source.file)
680
+ if use_template
681
+ body = tmpl.fill_in(deplate, :source => @source)
682
+ else
683
+ body = @accum
684
+ end
685
+ acc = @deplate.parsed_array_from_strings(body, 1 + @source.begin, @source.file)
624
686
  @prototype ||= acc[0]
625
687
  @foreach << [ids, acc]
626
688
  end
@@ -739,6 +801,13 @@ class Deplate::Regions::Quote < Deplate::Region::SecondOrder
739
801
  end
740
802
 
741
803
 
804
+ class Deplate::Regions::Region < Deplate::Region::SecondOrder
805
+ register_as 'Region'
806
+ register_as 'Block'
807
+ set_formatter :format_region, true
808
+ end
809
+
810
+
742
811
  class Deplate::Regions::R < Deplate::Region
743
812
  register_as 'R'
744
813
 
@@ -958,6 +1027,7 @@ class Deplate::Regions::R < Deplate::Region
958
1027
  log(["Running R", d, r, out])
959
1028
  begin
960
1029
  @accum.unshift(%{deplate.fmt <- "#{@deplate.formatter.formatter_name}"})
1030
+ @accum << %{q(runLast=FALSE)}
961
1031
  if Deplate::Region.check_file(self, out, r, @accum)
962
1032
  log(["Files exist! Using", out], :anyway)
963
1033
  else
@@ -974,7 +1044,7 @@ class Deplate::Regions::R < Deplate::Region
974
1044
  @accum = File.open(out) {|io| io.read}.split(/[\n\r]+/)
975
1045
  skip = @args["skip"]
976
1046
  if skip
977
- head, tail = skip.split(/,/).collect {|n| n.to_i}
1047
+ head, tail = Deplate::Core.split_list(skip, nil, nil, @source).collect {|n| n.to_i}
978
1048
  @accum = @accum[(head || 0) .. (@accum.size - tail - 1 || -1)] || []
979
1049
  end
980
1050
  rv = true
@@ -1003,12 +1073,12 @@ class Deplate::Regions::Ruby < Deplate::Region
1003
1073
  def finish
1004
1074
  finish_accum
1005
1075
  @accum = [@deplate.eval_ruby(self, @args, @accum.join("\n")).to_s]
1006
- if @args["verb"]
1076
+ if @args['verb']
1007
1077
  return Deplate::Regions::Verbatim.new(@deplate, @source, @accum, @match, self).finish
1008
- elsif @args["img"] or @args["image"]
1009
- file = @args["img"] || @args["image"]
1010
- return Deplate::Command::IMG.new(@deplate, @source, file, nil, {}, "IMG").finish
1011
- elsif @args["native"]
1078
+ elsif @args['img'] or @args['image']
1079
+ file = @args['img'] || @args['image']
1080
+ return Deplate::Command::IMG.new(@deplate, @source, file, nil, {}, 'IMG').finish
1081
+ elsif @args['native']
1012
1082
  return Deplate::Regions::Native.new(@deplate, @source, @accum, @match, self).finish
1013
1083
  else
1014
1084
  acc = []
@@ -1036,7 +1106,7 @@ class Deplate::Regions::Clip < Deplate::Region::SecondOrder
1036
1106
 
1037
1107
  def finish
1038
1108
  finish_accum
1039
- id = @args["id"] || @regNote
1109
+ id = deprecated_regnote('id')
1040
1110
  @doc_type = :array
1041
1111
  @processed = false
1042
1112
  @elt = @deplate.parsed_array_from_strings(@accum, @source.begin, @source.file)
@@ -1060,7 +1130,7 @@ class Deplate::Regions::Clip < Deplate::Region::SecondOrder
1060
1130
  end
1061
1131
 
1062
1132
  def log(*args)
1063
- if @invoker
1133
+ if defined?(@invoker) and @invoker
1064
1134
  @invoker.log(*args)
1065
1135
  else
1066
1136
  super