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
@@ -0,0 +1,57 @@
1
+ # guesslanguage.rb
2
+ # @Author: Thomas Link (micathom AT gmail com)
3
+ # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
4
+ # @Created: 2006-12-29.
5
+ # @Last Change: 2007-01-06.
6
+ # @Revision: 0.1.22
7
+
8
+ require 'zlib'
9
+
10
+ # This is ported form/based on:
11
+ # - Title: Guess language of text using ZIP
12
+ # - Submitter: Dirk Holtwick
13
+ # - Last Updated: 2004/12/07
14
+ # - Version no: 1.2
15
+ # - Category: Algorithms
16
+ # http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/355807
17
+ # http://www.heise.de/newsticker/data/wst-28.01.02-003/
18
+ # http://xxx.uni-augsburg.de/format/cond-mat/0108530
19
+ class Guesslanguage
20
+ def initialize
21
+ @data = []
22
+ end
23
+
24
+ def zip(text)
25
+ Zlib::Deflate.new.deflate(text, Zlib::FINISH)
26
+ end
27
+
28
+ # register a text as corpus for a language or author.
29
+ # <name> may also be a function or whatever you need
30
+ # to handle the result.
31
+ def register(name, corpus)
32
+ ziplen = zip(corpus).size
33
+ @data << [name, corpus, ziplen]
34
+ end
35
+
36
+ # <part> is a text that will be compared with the registered
37
+ # corpora and the function will return what you defined as
38
+ # <name> in the registration process.
39
+ def guess_with_diff(part)
40
+ what = nil
41
+ diff = nil
42
+ for name, corpus, ziplen in @data
43
+ nz = zip(corpus + part).size - ziplen
44
+ if diff.nil? or nz < diff
45
+ what = name
46
+ diff = nz
47
+ end
48
+ end
49
+ return [diff.to_f/part.size, what]
50
+ end
51
+
52
+ def guess(part)
53
+ diff, lang = guess_with_diff(part)
54
+ lang
55
+ end
56
+ end
57
+
@@ -1,10 +1,10 @@
1
1
  # input.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: 10-M�r-2005.
6
- # @Last Change: 07-Jun-2006.
7
- # @Revision: 0.467
6
+ # @Last Change: 2007-09-30.
7
+ # @Revision: 0.809
8
8
  #
9
9
  # = Description
10
10
  # = Usage
@@ -34,32 +34,87 @@ class Deplate::Input < Deplate::CommonObject
34
34
  @deplate = deplate
35
35
  @options = deplate.options
36
36
  @args = args
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
41
- @paragraph_class = args[:paragraph_class] || Deplate::Element::Paragraph
42
- @comment_class = args[:comment_class] || Deplate::Element::Comment
43
- @command_class = args[:command_class] || Deplate::Element::Command
44
- @allow_onthefly_particles = args[:onthefly_particles] || true
37
+ @elements = select_value(args[:elements], Deplate::Element.elements)
38
+ @commands = select_value(args[:commands], Deplate::Command.commands)
39
+ @regions = select_value(args[:regions ], Deplate::Region.regions)
40
+ @macros = select_value(args[:macros], Deplate::Macro.macros)
41
+ @paragraph_class = select_value(args[:paragraph_class], Deplate::Element::Paragraph)
42
+ @comment_class = select_value(args[:comment_class], Deplate::Element::Comment)
43
+ @command_class = select_value(args[:command_class], Deplate::Element::Command)
44
+ @allow_onthefly_particles = select_value(args[:onthefly_particles], true)
45
45
  if @options.skeletons.empty?
46
46
  @skeleton_expander = nil
47
47
  else
48
- expander = args[:expander_class] || Deplate::SkeletonExpander
48
+ expander = select_value(args[:expander_class], Deplate::SkeletonExpander)
49
49
  @skeleton_expander = expander.new(deplate)
50
50
  end
51
51
  initialize_particles
52
52
  end
53
-
53
+
54
+ def select_value(arg, default)
55
+ case arg
56
+ when :default
57
+ default
58
+ # when Array
59
+ # p "DBG", arg
60
+ # # arg.collect {|x| x == :default ? default.dup : x}.flatten
61
+ # rv = arg.collect {|x| x == :default ? [] : x}.flatten
62
+ # p "DBG", rv
63
+ # rv
64
+ else
65
+ arg || default
66
+ end
67
+ end
68
+ private :select_value
69
+
70
+ def args_fill_with_default(args)
71
+ # args[:elements] = nil
72
+ # args[:particles] = nil
73
+ # args[:particles_ext] = nil
74
+ # args[:commands] = nil
75
+ # args[:regions] = nil
76
+ # args[:macros] = nil
77
+ # args[:onthefly_particles] = nil
78
+ # args[:paragraph_class] = nil
79
+ # args[:comment_class] = nil
80
+ # args[:command_class] = nil
81
+
82
+ args[:elements] = :default
83
+ args[:particles] = nil
84
+ args[:particles_ext] = nil
85
+ args[:commands] = :default
86
+ args[:regions] = :default
87
+ args[:macros] = :default
88
+ args[:onthefly_particles] = :default
89
+ args[:paragraph_class] = :default
90
+ args[:comment_class] = :default
91
+ args[:command_class] = :default
92
+
93
+ # args[:elements] = Deplate::Element.elements
94
+ # args[:particles] = Deplate::Particle.particles.dup
95
+ # args[:particles_ext] = Deplate::Particle.particles_ext.dup
96
+ # args[:commands] = Deplate::Command.commands
97
+ # args[:regions] = Deplate::Region.regions
98
+ # args[:macros] = Deplate::Macro.macros
99
+ # args[:onthefly_particles] = true
100
+ # args[:paragraph_class] = Deplate::Element::Paragraph
101
+ # args[:comment_class] = Deplate::Element::Comment
102
+ # args[:command_class] = Deplate::Element::Command
103
+ # args[:expander_class] = Deplate::SkeletonExpander
104
+ end
105
+
54
106
  def initialize_particles(alt=false, args=@args)
55
107
  always = args[:always]
56
108
  if always or @allow_onthefly_particles or !@rx_particles
57
- @particles_custom ||= args[:particles]
109
+ # TBD: What was these _custom variables good for?
110
+ @particles_custom ||= select_value(args[:particles], Deplate::Particle.particles)
58
111
  if @particles_custom
59
- @particles = args[:particles].dup
112
+ # @particles = args[:particles].dup
113
+ @particles = @particles_custom.dup
60
114
  else
61
115
  @particles = Deplate::Particle.particles.dup
62
116
  end
117
+ # @particles = select_value(@particles_custom, Deplate::Particle.particles).dup
63
118
  for p in @options.disabled_particles
64
119
  disable_particle_class(p)
65
120
  end
@@ -67,12 +122,14 @@ class Deplate::Input < Deplate::CommonObject
67
122
  end
68
123
 
69
124
  if always or !defined?(@particles_ext) or (@allow_onthefly_particles and alt)
70
- @particles_ext_custom ||= args[:particles_ext]
125
+ @particles_ext_custom ||= select_value(args[:particles_ext], Deplate::Particle.particles_ext)
71
126
  if @particles_ext_custom
72
- @particles_ext = args[:particles_ext].dup
127
+ # @particles_ext = args[:particles_ext].dup
128
+ @particles_ext = @particles_ext_custom.dup
73
129
  else
74
130
  @particles_ext = Deplate::Particle.particles_ext.dup
75
131
  end
132
+ # @particles = select_value(@particles_ext_custom, Deplate::Particle.particles_ext).dup
76
133
  initialize_rx(:extended)
77
134
  else
78
135
  @particles_all = @particles
@@ -126,8 +183,10 @@ class Deplate::Input < Deplate::CommonObject
126
183
  def register_particle(particle, args={})
127
184
  arr = args[:extended] ? @particles_ext : @particles
128
185
  id = args[:id] || particle.name
186
+ rpl = args[:replace]
187
+ oid = rpl ? rpl.name : id
129
188
  catch(:cont) do
130
- old = @@custom_particles[id]
189
+ old = @@custom_particles[oid]
131
190
  if old
132
191
  idx = arr.index(old)
133
192
  if idx
@@ -135,12 +194,46 @@ class Deplate::Input < Deplate::CommonObject
135
194
  throw :cont
136
195
  end
137
196
  end
138
- arr << particle
197
+ if rpl and (rpli = arr.index(rpl))
198
+ arr[rpli] = particle
199
+ elsif args[:unshift]
200
+ arr.unshift(particle)
201
+ else
202
+ arr << particle
203
+ end
139
204
  end
140
205
  @@custom_particles[id] = particle
141
206
  initialize_rx(:both)
142
207
  end
143
208
 
209
+ def remove_named_elements(hash, field, default, elements)
210
+ arr = hash[field] ||= default
211
+ for e in elements
212
+ case e
213
+ when String
214
+ arr.delete(e)
215
+ else
216
+ i = arr.index(e)
217
+ arr.delete(i) if i
218
+ end
219
+ end
220
+ end
221
+
222
+ def replace_named_elements(hash, field, default, elements)
223
+ arr = hash[field] ||= default
224
+ arr.collect! do |elt|
225
+ elements.each do |from, to|
226
+ case from
227
+ when String
228
+ elt.myname == from ? to : elt
229
+ else
230
+ elt == from ? to : elt
231
+ end
232
+ end
233
+ end
234
+ arr
235
+ end
236
+
144
237
  def get_rx_particles(particles)
145
238
  return Regexp.new(particles.collect do |e|
146
239
  e.rx.source[1..-1]
@@ -181,7 +274,7 @@ class Deplate::Input < Deplate::CommonObject
181
274
  unless accum.empty?
182
275
  line.gsub!(/^\s+/, '')
183
276
  end
184
- if !unfinished_region?(acc_array.last) and comment_class.match(line)
277
+ if !unfinished_region?(acc_array.last) and (comment_class.match(line) and !comment_class.show_comment?(@deplate, line))
185
278
  next
186
279
  else
187
280
  use_line_continuation = acc_array.last ? acc_array.last.line_cont : true
@@ -198,6 +291,7 @@ class Deplate::Input < Deplate::CommonObject
198
291
  end
199
292
 
200
293
  def handle_line(array, line, lineNumber=-1)
294
+ # p "DBG line=#{line.inspect}"
201
295
  last = array.last
202
296
  if line
203
297
  src = Deplate::Source.new(@deplate.current_source, @deplate.current_source_stats,
@@ -247,12 +341,14 @@ class Deplate::Input < Deplate::CommonObject
247
341
  e, m = match_elements(line)
248
342
  if last
249
343
  # so, there is a element in the queue
250
- if e == comment_class
251
- c = nil
252
- elsif last.finished?
344
+ # if e == comment_class
345
+ # # and !e.show_comment?(@deplate, line)
346
+ # # c = nil
347
+ # elsif last.finished?
348
+ if last.finished?
253
349
  # last is finished, so we start a new element
254
350
  c = e || paragraph_class
255
- elsif last.to_be_continued?(line, e, m)
351
+ elsif last.to_be_continued?(line, e, m) and (e != comment_class or last.is_a?(comment_class))
256
352
  # this line is something else, so we ask last if it wants
257
353
  # to be continued
258
354
  case last.multiliner
@@ -285,8 +381,10 @@ class Deplate::Input < Deplate::CommonObject
285
381
  c.do_accumulate(src, array, @deplate, line, m)
286
382
  end
287
383
  end
288
- elsif last and !last.finished?
289
- last = finish_last(array, last, lineNumber)
384
+ else
385
+ if last and !last.finished?
386
+ last = finish_last(array, last, lineNumber)
387
+ end
290
388
  end
291
389
  end
292
390
  private :handle_line
@@ -294,11 +392,13 @@ class Deplate::Input < Deplate::CommonObject
294
392
  def unfinished_region?(last)
295
393
  return last && !last.finished? && last.endRx
296
394
  end
297
-
395
+
298
396
  def finish_last(array, last, lineNumber=-1)
299
- last.source.end = lineNumber if lineNumber > 0
397
+ last.source.end = lineNumber if lineNumber > 0
300
398
  # finished_element = last.finish
301
- finished_element = array.pop.finish
399
+ finished_element = array.pop
400
+ finished_element = finished_element.finish
401
+ # finished_element = array.pop.finish
302
402
  if finished_element.kind_of?(Array)
303
403
  for e in finished_element
304
404
  handle_finished_element(array, e)
@@ -311,14 +411,21 @@ class Deplate::Input < Deplate::CommonObject
311
411
  private :finish_last
312
412
 
313
413
  def handle_finished_element(array, element)
314
- unless element.nil? or element.drop?
414
+ filter = @deplate.variables['efilter']
415
+ unless element.nil? or element.drop?(filter)
315
416
  pred = array.last
316
- unless pred and pred.unify(element)
417
+ if pred and pred.unify(element)
418
+ if pred.exclude?(filter)
419
+ pred.pop(array)
420
+ end
421
+ else
317
422
  if !@deplate.labels_floating.empty? and element.can_be_labelled
318
423
  element.put_label(@deplate.labels_floating)
319
424
  @deplate.labels_floating = []
320
425
  end
321
- array << element
426
+ unless element.exclude?(filter)
427
+ array << element
428
+ end
322
429
  end
323
430
  end
324
431
  end
@@ -336,7 +443,12 @@ class Deplate::Input < Deplate::CommonObject
336
443
  return [e, m]
337
444
  end
338
445
  end
339
- return [nil, @paragraph_class.match(line)]
446
+ m = comment_class.match(line)
447
+ if m
448
+ return [comment_class, m]
449
+ else
450
+ return [nil, @paragraph_class.match(line)]
451
+ end
340
452
  end
341
453
  private :match_elements
342
454
 
@@ -356,10 +468,10 @@ class Deplate::Input < Deplate::CommonObject
356
468
  #
357
469
  # Anyway, you should call this method directly unless you have to, but use
358
470
  # the more specialized ones.
359
- def parse_using(container, text, rx, particles, alt=true)
471
+ def parse_using(container, text, rx, particles, alt=true, args={})
360
472
  rest = text
361
473
  rt = []
362
- last = ""
474
+ last = ''
363
475
  src = container ? container.source : nil
364
476
  while !rest.empty?
365
477
  begin
@@ -370,7 +482,7 @@ class Deplate::Input < Deplate::CommonObject
370
482
  else
371
483
  sample = rest
372
484
  end
373
- log_error(container, ["Regexp error when parsing", sample], :error, src)
485
+ log_error(container, ['Regexp error when parsing', sample], :error, src)
374
486
  rescue Exception => e
375
487
  puts e.backtrace[0..10].join("\n")
376
488
  raise e
@@ -392,6 +504,7 @@ class Deplate::Input < Deplate::CommonObject
392
504
  rt << e.new(@deplate, container, rt, m, alt, txt, rest)
393
505
  rescue Exception => exc
394
506
  puts exc
507
+ # puts exc.backtrace[0..10].join("\n")
395
508
  # puts "#{exc}\nInternal error when initializing %s: %s" % [e.name, txt]
396
509
  # raise exc
397
510
  end
@@ -408,6 +521,12 @@ class Deplate::Input < Deplate::CommonObject
408
521
  break
409
522
  end
410
523
  end
524
+ if (filter = @deplate.variables['pfilter'])
525
+ # c = container.kind_of?(Deplate::BaseParticle) ? container : nil
526
+ rt.delete_if do |p|
527
+ p.exclude?(filter, args[:pcontainer])
528
+ end
529
+ end
411
530
  return rt
412
531
  end
413
532
 
@@ -428,7 +547,8 @@ class Deplate::Input < Deplate::CommonObject
428
547
  parse(container, text, alt, excluded)
429
548
  end
430
549
 
431
- def parse(container, text, alt=true, excluded=[])
550
+ def parse(container, text, alt=true, excluded=nil, args={})
551
+ excluded ||= []
432
552
  rx, particles = get_particles(:both, alt)
433
553
  for p in excluded
434
554
  case p
@@ -438,7 +558,7 @@ class Deplate::Input < Deplate::CommonObject
438
558
  particles.delete(p)
439
559
  end
440
560
  end
441
- parse_using(container, text, rx, particles, alt)
561
+ parse_using(container, text, rx, particles, alt, args)
442
562
  end
443
563
 
444
564
  ### Arguments
@@ -447,13 +567,32 @@ class Deplate::Input < Deplate::CommonObject
447
567
  # @@rxsrc_argval = %{("(\\\\"|[^"])*?"|(\\\\=|\\\\:|\\\\!|[^=!]+)+?)}
448
568
  # @@rxsrc_argval = %{(\\\\=|\\\\:|[^=:]*)+?}
449
569
  # @@rxsrc_argval = %{("(\\\\"|[^"])*?"|(\\\\ |\\\\=|\\\\:|\\\\!|[%s]+)+?)}
450
- @@rxsrc_argval = %{("(\\\\"|[^"])*"|\\([^)]+\\)|\\\\.|[%s"]+)+?}
451
570
  # @@rxsrc_argval = %{("(\\\\"|[^"])*"|\\\\.|[%s"]+)+?}
452
- @@rxsrc_key = %{[@\\w]+(\\[\\S*?\\])?}
453
- @@rxsrc_args1 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "^=!:"
454
- @@rxsrc_args2 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "^=!"
571
+ @@rxsrc_argval = %{("(\\\\"|[^"])*"|\\([^)]+\\)|\\\\.|[^%s"]+)+?}
572
+
573
+ # @@rxsrc_key = %{[$@\\w]+(\\[\\S*?\\])?}
574
+ # @@rxsrc_args1 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "=!:"
575
+ # @@rxsrc_args2 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "=!"
576
+ # @@rx_args = /^\s*(#{@@rxsrc_args2})(?=(\s*$|\s+#{@@rxsrc_key}(!|=)))/
577
+ # @@rx_argstext = /^\s*((#{@@rxsrc_args1})*?)(:\s*(.+))?$/
578
+ # @@ri_text = 9
579
+
580
+ @@rxsrc_key = %{[$@\\w]+(\\[\\S*?\\])?}
581
+ # @@rxsrc_args1 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "=!:"
582
+ # @@rxsrc_args2 = %{(#{@@rxsrc_key})(!|=(#{@@rxsrc_argval}))\\s*} % "=!"
583
+ @@rxsrc_args1 = %{(#{@@rxsrc_key})((?>!)|(?>=)(#{@@rxsrc_argval}))\\s*} % "=!:"
584
+ @@rxsrc_args2 = %{(#{@@rxsrc_key})((?>!)|(?>=)(#{@@rxsrc_argval}))\\s*} % "=!"
455
585
  @@rx_args = /^\s*(#{@@rxsrc_args2})(?=(\s*$|\s+#{@@rxsrc_key}(!|=)))/
456
586
  @@rx_argstext = /^\s*((#{@@rxsrc_args1})*?)(:\s*(.+))?$/
587
+ @@ri_text = 9
588
+
589
+ # @@rxsrc_key = %{\\s+([$@[:alnum:]_]+(\\[[^\\]]*\\])?)}
590
+ # # @@rxsrc_key = %{\\s+([$@[:alnum:]_]+(\\[[^\\]]*\\])?)}
591
+ # @@rxsrc_args1 = %{#{@@rxsrc_key}(!|=(#{@@rxsrc_argval}))} % "=!:"
592
+ # @@rxsrc_args2 = %{#{@@rxsrc_key}(!|=(#{@@rxsrc_argval}))} % "=!"
593
+ # @@rx_args = /^(#{@@rxsrc_args2})(?=(\s*$|#{@@rxsrc_key}(!|=)))/
594
+ # @@rx_argstext = /^((#{@@rxsrc_args1})*?)\s*(:\s*(.+))?$/
595
+ # @@ri_text = 9
457
596
 
458
597
  def parse_args(argText, container=nil, firstPass=true, parseText=false)
459
598
  unless argText
@@ -462,28 +601,44 @@ class Deplate::Input < Deplate::CommonObject
462
601
  argText.strip!
463
602
  if argText.empty?
464
603
  return [{}, '']
604
+ else
605
+ # argText.insert(0, ' ')
465
606
  end
607
+ # p "DBG 0 #{argText.inspect}"
466
608
  if firstPass
467
- m = @@rx_argstext.match(argText)
609
+ m = @@rx_argstext.match(argText)
610
+ m &&= m.captures
468
611
  else
469
- m = [nil, argText]
612
+ m = [argText]
470
613
  end
471
614
  accum = {}
472
615
  if m
473
- args = m[1]
474
- text = m[10]
475
- while !args.empty?
616
+ args = m[0]
617
+ # args.insert(0, ' ')
618
+ text = m[@@ri_text]
619
+ # p "DBG 1.1 m=#{m.inspect}"
620
+ # p "DBG 1.2 args=#{args.inspect} => #{(args =~ /\S/).inspect}"
621
+ # p "DBG 1.3 text=#{text.inspect}"
622
+ while args =~ /\S/
623
+ if args =~ /^[^=[:space:]]+=[^"([:space:]]*?[^\\"(]([!=])/
624
+ log_error(container, ['Argument parse error', $1, args])
625
+ return [{}, '']
626
+ end
627
+ # p "DBG 2.1 #@@rx_args"
628
+ # p "DBG 2.2 #{args.inspect}"
476
629
  m = @@rx_args.match(args)
630
+ # p "DBG 3"
477
631
  if m
478
632
  key = m[2]
479
633
  val = m[5]
480
- Deplate::Core.canonic_args(accum, key, val)
634
+ # p "DBG #{key.inspect}=#{val.inspect}"
635
+ Deplate::Core.canonic_args(accum, key, val, container && container.source)
481
636
  args = m.post_match
482
637
  if args.empty?
483
638
  break
484
639
  end
485
640
  else
486
- log_error(@container, ['Argument parse error', args, argText])
641
+ log_error(container, ['Argument parse error', args, argText])
487
642
  break
488
643
  end
489
644
  end
@@ -503,7 +658,7 @@ class Deplate::Input < Deplate::CommonObject
503
658
  accum['@id'] = id
504
659
  accum['id'] = @deplate.formatter.encode_id(id)
505
660
  end
506
- fmt = accum['fmt']
661
+ fmt = accum['fmt']
507
662
  accum.delete('fmt') if fmt
508
663
  ifOpt0 = ifOpt = accum['if']
509
664
  if ifOpt