deplate 0.7.3 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/AUTHORS.TXT +3 -0
  2. data/CHANGES.TXT +248 -175
  3. data/LICENSE.TXT +0 -0
  4. data/NEWS.TXT +28 -24
  5. data/README.TXT +0 -0
  6. data/TODO.TXT +174 -88
  7. data/VERSION.TXT +1 -1
  8. data/bin/deplate +0 -0
  9. data/bin/deplate.bat +0 -0
  10. data/etc/deplate.ini +91 -3
  11. data/lib/action_view/helpers/deplate.rb +45 -0
  12. data/lib/deplate.rb +6 -1
  13. data/lib/deplate/abstract-class.rb +0 -0
  14. data/lib/deplate/bib.rb +576 -0
  15. data/lib/deplate/builtin.rb +0 -0
  16. data/lib/deplate/cache.rb +55 -5
  17. data/lib/deplate/commands.rb +346 -183
  18. data/lib/deplate/common.rb +209 -48
  19. data/lib/deplate/converter.rb +12 -6
  20. data/lib/deplate/core.rb +777 -378
  21. data/lib/deplate/counters.rb +254 -0
  22. data/lib/deplate/css/article.css +4 -3
  23. data/lib/deplate/css/deplate.css +121 -5
  24. data/lib/deplate/css/heading-navbar.css +0 -0
  25. data/lib/deplate/css/layout-deplate-print.css +0 -0
  26. data/lib/deplate/css/layout-deplate.css +0 -0
  27. data/lib/deplate/css/sans-serif.css +0 -0
  28. data/lib/deplate/css/serif-e.css +0 -0
  29. data/lib/deplate/css/serif-rel.css +0 -0
  30. data/lib/deplate/css/serif.css +9 -3
  31. data/lib/deplate/css/slides.css +0 -0
  32. data/lib/deplate/css/tabbar-left.css +0 -0
  33. data/lib/deplate/css/tabbar-right-ie.css +3 -9
  34. data/lib/deplate/css/tabbar-right.css +51 -18
  35. data/lib/deplate/css/tabbar-top.css +7 -1
  36. data/lib/deplate/css/tabbar.css +0 -0
  37. data/lib/deplate/css/text-sans-serif.css +0 -0
  38. data/lib/deplate/css/text-serif.css +0 -0
  39. data/lib/deplate/define.rb +183 -177
  40. data/lib/deplate/deplate-string.rb +82 -0
  41. data/lib/deplate/docbook.rb +236 -128
  42. data/lib/deplate/elements.rb +584 -417
  43. data/lib/deplate/etc.rb +163 -101
  44. data/lib/deplate/external.rb +42 -11
  45. data/lib/deplate/fmt/dbk-article-4.1.2.rb +0 -0
  46. data/lib/deplate/fmt/dbk-article.rb +0 -0
  47. data/lib/deplate/fmt/dbk-book.rb +0 -0
  48. data/lib/deplate/fmt/dbk-ref.rb +3 -3
  49. data/lib/deplate/fmt/dbk-slides.rb +0 -0
  50. data/lib/deplate/fmt/dbk-snippet.rb +0 -0
  51. data/lib/deplate/fmt/html-snippet.rb +0 -0
  52. data/lib/deplate/fmt/html.rb +783 -550
  53. data/lib/deplate/fmt/htmlsite.rb +192 -199
  54. data/lib/deplate/fmt/htmlslides.rb +0 -0
  55. data/lib/deplate/fmt/htmlwebsite.rb +3 -3
  56. data/lib/deplate/fmt/latex-snippet.rb +0 -0
  57. data/lib/deplate/fmt/latex.rb +242 -83
  58. data/lib/deplate/fmt/null.rb +32 -0
  59. data/lib/deplate/fmt/php.rb +4 -4
  60. data/lib/deplate/fmt/phpsite.rb +6 -5
  61. data/lib/deplate/fmt/plain.rb +160 -106
  62. data/lib/deplate/fmt/template.rb +0 -0
  63. data/lib/deplate/fmt/xhtml10t.rb +0 -0
  64. data/lib/deplate/formatter-snippet.rb +0 -0
  65. data/lib/deplate/formatter.rb +613 -301
  66. data/lib/deplate/input.rb +202 -142
  67. data/lib/deplate/input/deplate-headings.rb +4 -6
  68. data/lib/deplate/input/deplate-restricted.rb +15 -9
  69. data/lib/deplate/input/deplate.rb +2 -4
  70. data/lib/deplate/input/rdoc.rb +39 -38
  71. data/lib/deplate/input/template.rb +0 -0
  72. data/lib/deplate/lib/Makefile.config +29 -0
  73. data/lib/deplate/lib/latex/deplate.sty +54 -0
  74. data/lib/deplate/lib/latex/highlight-extra.sty +0 -0
  75. data/lib/deplate/lib/latex/highlight-typical.sty +0 -0
  76. data/lib/deplate/lib/php/page-comment.inc.php +216 -0
  77. data/lib/deplate/lib/tabmenu.js +0 -0
  78. data/lib/deplate/locale/de.latin1 +155 -17
  79. data/lib/deplate/locale/ru.koi8-r +0 -0
  80. data/lib/deplate/locale/zh_cn.gb2312 +0 -0
  81. data/lib/deplate/macros.rb +133 -82
  82. data/lib/deplate/messages.rb +6 -4
  83. data/lib/deplate/metadata.rb +0 -0
  84. data/lib/deplate/metadata/marshal.rb +0 -0
  85. data/lib/deplate/metadata/xml.rb +0 -0
  86. data/lib/deplate/metadata/yaml.rb +0 -0
  87. data/lib/deplate/mod/anyword.rb +3 -3
  88. data/lib/deplate/mod/babelfish.rb +4 -4
  89. data/lib/deplate/mod/code-gvim.rb +8 -4
  90. data/lib/deplate/mod/code-highlight.rb +3 -3
  91. data/lib/deplate/mod/colored-log.rb +0 -0
  92. data/lib/deplate/mod/de.rb +2 -2
  93. data/lib/deplate/mod/en.rb +0 -0
  94. data/lib/deplate/mod/endnotes.rb +0 -0
  95. data/lib/deplate/mod/fr.rb +0 -0
  96. data/lib/deplate/mod/html-asciimath.rb +0 -0
  97. data/lib/deplate/mod/html-deplate-button.rb +0 -0
  98. data/lib/deplate/mod/html-headings-navbar.rb +5 -13
  99. data/lib/deplate/mod/html-jsmath.rb +39 -0
  100. data/lib/deplate/mod/html-obfuscate-email.rb +3 -3
  101. data/lib/deplate/mod/html-sidebar.rb +0 -0
  102. data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -3
  103. data/lib/deplate/mod/iconv.rb +0 -0
  104. data/lib/deplate/mod/imgurl.rb +4 -4
  105. data/lib/deplate/mod/inlatex-compound.rb +7 -10
  106. data/lib/deplate/mod/koma.rb +0 -0
  107. data/lib/deplate/mod/latex-emph-table-head.rb +0 -0
  108. data/lib/deplate/mod/latex-styles.rb +7 -4
  109. data/lib/deplate/mod/latex-verbatim-small.rb +0 -0
  110. data/lib/deplate/mod/makefile.rb +23 -7
  111. data/lib/deplate/mod/mark-external-urls.rb +3 -3
  112. data/lib/deplate/mod/markup-1-warn.rb +10 -10
  113. data/lib/deplate/mod/markup-1.rb +0 -0
  114. data/lib/deplate/mod/navbar-png.rb +24 -8
  115. data/lib/deplate/mod/noindent.rb +0 -0
  116. data/lib/deplate/mod/numpara.rb +0 -0
  117. data/lib/deplate/mod/particle-math.rb +4 -4
  118. data/lib/deplate/mod/php-extra.rb +46 -6
  119. data/lib/deplate/mod/pstoedit.rb +0 -0
  120. data/lib/deplate/mod/recode.rb +0 -0
  121. data/lib/deplate/mod/ru_koi8-r.rb +0 -0
  122. data/lib/deplate/mod/smart-dash.rb +26 -0
  123. data/lib/deplate/mod/smiley.rb +69 -7
  124. data/lib/deplate/mod/soffice.rb +0 -0
  125. data/lib/deplate/mod/symbols-latin1.rb +14 -23
  126. data/lib/deplate/mod/symbols-od-utf-8.rb +5 -3
  127. data/lib/deplate/mod/symbols-plain.rb +5 -35
  128. data/lib/deplate/mod/symbols-sgml.rb +8 -9
  129. data/lib/deplate/mod/symbols-utf-8.rb +8 -9
  130. data/lib/deplate/mod/symbols-xml.rb +5 -9
  131. data/lib/deplate/mod/syntax-region-alt.rb +5 -5
  132. data/lib/deplate/mod/utf8.rb +0 -0
  133. data/lib/deplate/mod/validate-html.rb +0 -0
  134. data/lib/deplate/mod/xmlrpc.rb +0 -0
  135. data/lib/deplate/mod/zh-cn-autospace.rb +18 -20
  136. data/lib/deplate/mod/zh-cn.rb +4 -6
  137. data/lib/deplate/nukumi2.rb +71 -0
  138. data/lib/deplate/once-method.rb +0 -0
  139. data/lib/deplate/output.rb +19 -21
  140. data/lib/deplate/particles.rb +178 -116
  141. data/lib/deplate/regions.rb +99 -58
  142. data/lib/deplate/skeletons.rb +122 -0
  143. data/lib/deplate/structured.rb +164 -106
  144. data/lib/deplate/template.rb +67 -43
  145. data/lib/deplate/templates/html-doc.html +0 -0
  146. data/lib/deplate/templates/html-left-tabbar-js.html +0 -0
  147. data/lib/deplate/templates/html-left-tabbar.html +0 -0
  148. data/lib/deplate/templates/html-tabbar-right-pcomments.php +22 -0
  149. data/lib/deplate/templates/html-tabbar-right-step.html +24 -0
  150. data/lib/deplate/templates/html-tabbar-right-table.html +0 -0
  151. data/lib/deplate/templates/html-tabbar-right.html +2 -4
  152. data/lib/deplate/templates/html-tabbar-top.html +0 -9
  153. data/lib/deplate/templates/html-tabbar.html +0 -0
  154. data/lib/deplate/variables.rb +127 -0
  155. data/lib/deplate/wiki-markup.rb +99 -33
  156. data/lib/deplate/xml.rb +18 -18
  157. data/lib/deplate/zh-cn.rb +0 -0
  158. data/lib/ps2ppm.rb +0 -0
  159. data/man/man1/deplate.1 +564 -474
  160. metadata +201 -186
@@ -3,31 +3,28 @@
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: 01-Nov-2005.
7
- # @Revision: 0.294
6
+ # @Last Change: 07-Jun-2006.
7
+ # @Revision: 0.467
8
8
  #
9
9
  # = Description
10
10
  # = Usage
11
11
  # = TODO
12
12
  # = CHANGES
13
13
 
14
+ require "deplate/common"
15
+
14
16
  # Input:
15
- class Deplate::Input
17
+ class Deplate::Input < Deplate::CommonObject
16
18
  class << self
17
- attr_reader :myname
18
-
19
- def myname=(value)
20
- @myname = value
21
- klass = self
22
- Deplate::Core.class_eval do
23
- declare_input_format(klass)
24
- end
19
+ def hook_post_myname=(name)
20
+ klass = self
21
+ Deplate::Core.class_eval {declare_input_format(klass)}
25
22
  end
26
23
  end
27
-
28
- self.myname = 'deplate'
29
24
 
30
- attr_reader :elements, :commands, :regions, :macros
25
+ class_attribute :myname, 'deplate'
26
+
27
+ attr_reader :elements, :commands, :regions, :macros, :skeleton_expander
31
28
  attr_reader :paragraph_class, :comment_class, :command_class
32
29
  attr_reader :particles, :rx_particles, :particles_ext, :rx_particles_ext
33
30
 
@@ -37,14 +34,20 @@ class Deplate::Input
37
34
  @deplate = deplate
38
35
  @options = deplate.options
39
36
  @args = args
40
- @elements = (args[:elements] || Deplate::Element.elements)
41
- @commands = (args[:commands] || Deplate::Command.commands)
42
- @regions = (args[:regions ] || Deplate::Region.regions)
43
- @macros = (args[:macros] || Deplate::Macro.macros)
37
+ @elements = args[:elements] || Deplate::Element.elements
38
+ @commands = args[:commands] || Deplate::Command.commands
39
+ @regions = args[:regions ] || Deplate::Region.regions
40
+ @macros = args[:macros] || Deplate::Macro.macros
44
41
  @paragraph_class = args[:paragraph_class] || Deplate::Element::Paragraph
45
42
  @comment_class = args[:comment_class] || Deplate::Element::Comment
46
43
  @command_class = args[:command_class] || Deplate::Element::Command
47
44
  @allow_onthefly_particles = args[:onthefly_particles] || true
45
+ if @options.skeletons.empty?
46
+ @skeleton_expander = nil
47
+ else
48
+ expander = args[:expander_class] || Deplate::SkeletonExpander
49
+ @skeleton_expander = expander.new(deplate)
50
+ end
48
51
  initialize_particles
49
52
  end
50
53
 
@@ -90,6 +93,35 @@ class Deplate::Input
90
93
  @rx_particles = get_rx_particles(@particles)
91
94
  end
92
95
  end
96
+
97
+ def register_element(instance, args={})
98
+ # <+TBD+> duplicates will be ignored
99
+ @elements << instance
100
+ end
101
+
102
+ def register_macro(instance, args={})
103
+ name = Deplate::CommonGround.get_explicit_id(args)
104
+ if @macros[name]
105
+ @deplate.log(['Macro already defined', name])
106
+ end
107
+ @macros[name] = instance
108
+ end
109
+
110
+ def register_region(instance, args={})
111
+ name = Deplate::CommonGround.get_explicit_id(args)
112
+ if @regions[name]
113
+ @deplate.log(['Region already defined', name])
114
+ end
115
+ @regions[name] = instance
116
+ end
117
+
118
+ def register_command(instance, args={})
119
+ name = Deplate::CommonGround.get_explicit_id(args)
120
+ if @commands[name]
121
+ @deplate.log(['Command already defined', name])
122
+ end
123
+ @commands[name] = instance
124
+ end
93
125
 
94
126
  def register_particle(particle, args={})
95
127
  arr = args[:extended] ? @particles_ext : @particles
@@ -110,7 +142,9 @@ class Deplate::Input
110
142
  end
111
143
 
112
144
  def get_rx_particles(particles)
113
- return Regexp.new(particles.collect {|e| e.rx.source[1..-1]}.join("|"))
145
+ return Regexp.new(particles.collect do |e|
146
+ e.rx.source[1..-1]
147
+ end.join("|"))
114
148
  end
115
149
 
116
150
  def get_particles(what, alt=true)
@@ -138,23 +172,26 @@ class Deplate::Input
138
172
  # This is the general function for including text from whatever source
139
173
  # that follows the enumeration interface. In general, the more
140
174
  # specialized methods from Deplate::Core should be used to call this.
141
- def include_enum(enum, acc_array, linenumber)
142
- accum = []
143
- for line in enum
175
+ def include_string(string, acc_array, linenumber)
176
+ accum = []
177
+ string = @skeleton_expander.expand(string) if @skeleton_expander
178
+ for line in string
144
179
  linenumber += 1
145
180
  line.chomp!
146
181
  unless accum.empty?
147
- line.gsub!(/^\s+/, "")
182
+ line.gsub!(/^\s+/, '')
148
183
  end
149
- use_line_continuation = acc_array.last ? acc_array.last.line_cont : true
150
- if comment_class.match(line)
184
+ if !unfinished_region?(acc_array.last) and comment_class.match(line)
151
185
  next
152
- elsif use_line_continuation and line =~ /(^|[^\\])\\$/
153
- accum << line[0..-2]
154
186
  else
155
- accum << line
156
- handle_line(acc_array, accum.join, linenumber)
157
- accum = []
187
+ use_line_continuation = acc_array.last ? acc_array.last.line_cont : true
188
+ if use_line_continuation and line =~ /(^|[^\\])\\$/
189
+ accum << line[0..-2]
190
+ else
191
+ accum << line
192
+ handle_line(acc_array, accum.join, linenumber)
193
+ accum = []
194
+ end
158
195
  end
159
196
  end
160
197
  handle_line(acc_array, nil, linenumber)
@@ -172,31 +209,33 @@ class Deplate::Input
172
209
  ec = @deplate.variables['embeddedVerbatim'] || 'Verbatim'
173
210
  rx = /^#{tic}/
174
211
  if line =~ rx
212
+ # p "DBG tic", line
175
213
  if $1
176
214
  line = $1
177
215
  else
178
216
  line.sub!(rx, '')
179
217
  end
180
- if last.kind_of?(Deplate::Element::Region) and last.name == ec and !last.finished?
218
+ if last and last.kind_of?(Deplate::Element::Region) and last.name == ec and !last.finished?
181
219
  last = finish_last(array, last, lineNumber)
182
220
  end
183
221
  else
184
- if !@deplate.switches.last
222
+ # p "DBG notic", line
223
+ if !@deplate.switches.last and !ec.empty?
185
224
  if last.kind_of?(Deplate::Element::Region) and last.name == ec
186
225
  last << line
187
226
  elsif line =~ /\S/
188
- unless last.finished?
227
+ if last and !last.finished?
189
228
  last = finish_last(array, last, lineNumber)
190
229
  end
191
230
  m = Deplate::Element::Region.pseudo_match(:args => '')
192
231
  Deplate::Element::Region.do_accumulate(src, array, @deplate, '', m, ec)
193
- array.last << line
232
+ array.last << line if array.last
194
233
  end
195
234
  end
196
235
  return
197
236
  end
198
237
  end
199
- if last and !last.finished? and last.endRx
238
+ if unfinished_region?(last)
200
239
  # last is a region
201
240
  if line =~ last.endRx
202
241
  last = finish_last(array, last, lineNumber)
@@ -213,20 +252,25 @@ class Deplate::Input
213
252
  elsif last.finished?
214
253
  # last is finished, so we start a new element
215
254
  c = e || paragraph_class
216
- elsif e
217
- unless e.is_volatile?(m)
218
- last = finish_last(array, last, lineNumber - 1)
219
- end
220
- c = e
221
- elsif last.to_be_continued?(line)
255
+ elsif last.to_be_continued?(line, e, m)
222
256
  # this line is something else, so we ask last if it wants
223
257
  # to be continued
224
- if @options.keep_whitespace or last.keep_whitespace
225
- last << line
226
- else
227
- last << line.strip
258
+ case last.multiliner
259
+ when :match
260
+ last.push_match(m)
261
+ when true
262
+ if @options.keep_whitespace or last.keep_whitespace
263
+ last << line
264
+ else
265
+ last << line.strip
266
+ end
228
267
  end
229
268
  c = nil
269
+ elsif e
270
+ unless e.is_volatile?(m, self)
271
+ last = finish_last(array, last, lineNumber - 1)
272
+ end
273
+ c = e
230
274
  else
231
275
  # last doesn't want this line, so we start a new element
232
276
  last = finish_last(array, last, lineNumber - 1)
@@ -247,10 +291,14 @@ class Deplate::Input
247
291
  end
248
292
  private :handle_line
249
293
 
294
+ def unfinished_region?(last)
295
+ return last && !last.finished? && last.endRx
296
+ end
297
+
250
298
  def finish_last(array, last, lineNumber=-1)
251
- last.source.end = lineNumber if lineNumber > 0
252
- finished_element = last.finish
253
- array.pop
299
+ last.source.end = lineNumber if lineNumber > 0
300
+ # finished_element = last.finish
301
+ finished_element = array.pop.finish
254
302
  if finished_element.kind_of?(Array)
255
303
  for e in finished_element
256
304
  handle_finished_element(array, e)
@@ -333,45 +381,62 @@ class Deplate::Input
333
381
  particles.each do |e|
334
382
  m = e.match(mx[0])
335
383
  if m
336
- pre = mx.pre_match
337
- unless pre.empty?
338
- rt << Deplate::Particle::Text.new(@deplate, container, rt, mx.pre_match, alt, last)
384
+ pc = e.pre_condition
385
+ unless pc && !pc.call(mx)
386
+ pre = mx.pre_match
387
+ unless pre.empty?
388
+ rt << as_text(container, rt, mx.pre_match, alt, last)
389
+ end
390
+ txt = last + mx.pre_match
391
+ begin
392
+ rt << e.new(@deplate, container, rt, m, alt, txt, rest)
393
+ rescue Exception => exc
394
+ puts exc
395
+ # puts "#{exc}\nInternal error when initializing %s: %s" % [e.name, txt]
396
+ # raise exc
397
+ end
398
+ throw :ok
339
399
  end
340
- txt = last + mx.pre_match
341
- # begin
342
- rt << e.new(@deplate, container, rt, m, alt, txt, rest)
343
- # rescue Exception => exc
344
- # puts "Internal error when initializing %s: %s" % [e.name, txt]
345
- # raise exc
346
- # end
347
- throw :ok
348
400
  end
349
401
  end
350
402
  txt = mx.pre_match + mx[0]
351
- rt << Deplate::Particle::Text.new(@deplate, container, rt, txt, alt, last, rest)
403
+ rt << as_text(container, rt, txt, alt, last, rest)
352
404
  end
353
405
  last = mx[0]
354
406
  else
355
- rt << Deplate::Particle::Text.new(@deplate, container, rt, rest, alt, last, "")
407
+ rt << as_text(container, rt, rest, alt, last, "")
356
408
  break
357
409
  end
358
410
  end
359
411
  return rt
360
412
  end
361
413
 
414
+ def as_text(container, context, match, alt, last="", rest="")
415
+ case match
416
+ when String
417
+ match = Deplate::Particle::Text.pseudo_match(match)
418
+ end
419
+ Deplate::Particle::Text.new(@deplate, container, context, match, alt, last, rest)
420
+ end
421
+
362
422
  def parse_with_particles(container, text, particles, alt=true)
363
423
  parse_using(container, text, get_particles(:rx, alt), particles, alt)
364
424
  end
365
425
 
366
- def parse_with_source(source, text, alt=true)
426
+ def parse_with_source(source, text, alt=true, excluded=[])
367
427
  container = Deplate::PseudoContainer.new(@deplate, :source => source)
368
- parse(container, text, alt)
428
+ parse(container, text, alt, excluded)
369
429
  end
370
430
 
371
431
  def parse(container, text, alt=true, excluded=[])
372
432
  rx, particles = get_particles(:both, alt)
373
433
  for p in excluded
374
- particles.delete(p)
434
+ case p
435
+ when Proc
436
+ particles.delete_if &p
437
+ else
438
+ particles.delete(p)
439
+ end
375
440
  end
376
441
  parse_using(container, text, rx, particles, alt)
377
442
  end
@@ -387,99 +452,94 @@ class Deplate::Input
387
452
  @@rxsrc_key = %{[@\\w]+(\\[\\S*?\\])?}
388
453
  @@rxsrc_args1 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "^=!:"
389
454
  @@rxsrc_args2 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "^=!"
390
- @@rx_args = /^\s*(#{@@rxsrc_args2})(\s*$|(?=\s+#{@@rxsrc_key}(!|=)))/
455
+ @@rx_args = /^\s*(#{@@rxsrc_args2})(?=(\s*$|\s+#{@@rxsrc_key}(!|=)))/
391
456
  @@rx_argstext = /^\s*((#{@@rxsrc_args1})*?)(:\s*(.+))?$/
392
457
 
393
458
  def parse_args(argText, container=nil, firstPass=true, parseText=false)
394
- if argText
395
- if firstPass
396
- m = @@rx_argstext.match(argText)
397
- else
398
- m = [nil, argText]
399
- end
400
- accum = {}
401
- if m
402
- args = m[1]
403
- text = m[10]
404
- while !args.empty?
405
- m = @@rx_args.match(args)
406
- if m
407
- key = m[2]
408
- if key =~ /^no[A-Z]/
409
- key_alt = key[2..2].downcase + key[3..-1]
410
- accum[key_alt] = false
411
- val = true
412
- end
413
- if m[4] == "!"
414
- val = true
415
- elsif m[5] == 'true'
416
- val = true
417
- elsif m[5] == 'false'
418
- val = false
419
- else
420
- valm = /^"(.*?)"$/.match(m[5])
421
- if valm
422
- val = valm[1]
423
- else
424
- val = m[5].strip
425
- end
426
- val = Deplate::Core.remove_backslashes(val)
427
- end
428
- accum[key] = val
429
- args = m.post_match
430
- if args.empty?
431
- break
432
- end
433
- else
434
- log_error(@container, ["Argument parse error", args, argText])
459
+ unless argText
460
+ return nil
461
+ end
462
+ argText.strip!
463
+ if argText.empty?
464
+ return [{}, '']
465
+ end
466
+ if firstPass
467
+ m = @@rx_argstext.match(argText)
468
+ else
469
+ m = [nil, argText]
470
+ end
471
+ accum = {}
472
+ if m
473
+ args = m[1]
474
+ text = m[10]
475
+ while !args.empty?
476
+ m = @@rx_args.match(args)
477
+ if m
478
+ key = m[2]
479
+ val = m[5]
480
+ Deplate::Core.canonic_args(accum, key, val)
481
+ args = m.post_match
482
+ if args.empty?
435
483
  break
436
484
  end
485
+ else
486
+ log_error(@container, ['Argument parse error', args, argText])
487
+ break
437
488
  end
438
- if parseText
439
- if text
440
- parsed = parse(container, text)
441
- else
442
- parsed = []
443
- end
444
- end
445
- else
446
- text = nil
447
- parsed = nil
448
- end
449
- id = accum['id']
450
- if id
451
- accum['@id'] = id
452
- accum['id'] = @deplate.formatter.encode_id(id)
453
489
  end
454
- fmt = accum["fmt"]
455
- accum.delete("fmt") if fmt
456
- ifOpt = accum["if"]
457
- if ifOpt
458
- accum.delete("if")
459
- ifOpt = Deplate::Element::Command.check_switch(@deplate, ifOpt)
460
- else
461
- ifOpt = true
462
- end
463
- nofmt = accum["nofmt"]
464
- accum.delete("nofmt") if nofmt
465
- nofmt ||= accum["noFmt"]
466
- accum.delete("noFmt") if nofmt
467
- if (!firstPass or (ifOpt and
468
- (!fmt || @deplate.formatter.matches?(fmt)) and
469
- (!nofmt || !(@deplate.formatter.matches?(nofmt)))))
470
- if parseText
471
- return [accum, text, parsed]
490
+ if parseText
491
+ if text
492
+ parsed = parse(container, text)
472
493
  else
473
- return [accum, text || ""]
494
+ parsed = []
474
495
  end
496
+ end
497
+ else
498
+ text = nil
499
+ parsed = nil
500
+ end
501
+ id = accum['id']
502
+ if id
503
+ accum['@id'] = id
504
+ accum['id'] = @deplate.formatter.encode_id(id)
505
+ end
506
+ fmt = accum['fmt']
507
+ accum.delete('fmt') if fmt
508
+ ifOpt0 = ifOpt = accum['if']
509
+ if ifOpt
510
+ accum.delete('if')
511
+ ifOpt = Deplate::Element::Command.check_switch(@deplate, ifOpt)
512
+ else
513
+ ifOpt = true
514
+ end
515
+ if ifOpt0 and !ifOpt and accum['else']
516
+ text = accum['else']
517
+ accum.delete('else')
518
+ parsed = parse(container, text)
519
+ ifOpt = true
520
+ end
521
+ nofmt = accum['nofmt']
522
+ accum.delete('nofmt') if nofmt
523
+ nofmt ||= accum['noFmt']
524
+ accum.delete('noFmt') if nofmt
525
+ if (!firstPass or
526
+ (ifOpt and
527
+ (!fmt || @deplate.formatter.matches?(fmt)) and
528
+ (!nofmt || !(@deplate.formatter.matches?(nofmt)))))
529
+ if parseText
530
+ return [accum, text, parsed]
475
531
  else
476
- raise Deplate::DontFormatException
532
+ return [accum, text || '']
477
533
  end
478
534
  else
479
- return nil
535
+ raise Deplate::DontFormatException
480
536
  end
481
537
  end
482
538
 
539
+ def allow_set_variable(var)
540
+ true
541
+ end
542
+
483
543
  private
484
544
  def log_error(container, text)
485
545
  (container || @deplate).log(text, :error)