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,5 +1,5 @@
1
1
  # builtin.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: 05-Jun-2004.
@@ -1,5 +1,5 @@
1
1
  # cache.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: 21-Aug-2005.
@@ -1,10 +1,10 @@
1
1
  # commands.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: 02-Mai-2006.
7
- # @Revision: 0.1164
6
+ # @Last Change: 2007-09-30.
7
+ # @Revision: 0.1298
8
8
 
9
9
  # Description:
10
10
  #
@@ -16,17 +16,22 @@
16
16
  #
17
17
 
18
18
  module Deplate::Names
19
+ module_function
20
+ def name_match_c(text)
21
+ if text =~ /^\{(.*)\}$/
22
+ return {:surname => $1}
23
+ end
24
+ end
25
+
19
26
  def name_match_sf(text)
20
27
  m = /^\s*(.+?),\s*(.+?)\s*$/.match(text)
21
28
  return m ? {:firstname => m[2], :surname => m[1]} : nil
22
29
  end
23
- module_function :name_match_sf
24
30
 
25
31
  def name_match_fs(text)
26
32
  m = /^\s*(\S+(\s+\S+)*?)\s+(\S+)\s*$/.match(text)
27
33
  return m ? {:firstname => m[1], :surname => m[3]} : nil
28
34
  end
29
- module_function :name_match_fs
30
35
  end
31
36
 
32
37
  class Deplate::Command < Deplate::Element
@@ -84,7 +89,7 @@ class Deplate::Command < Deplate::Element
84
89
  end
85
90
 
86
91
  def finish
87
- @elt = [ @accum.join(" ") ]
92
+ @elt = [ @accum.join(' ') ]
88
93
  return self
89
94
  end
90
95
 
@@ -111,7 +116,7 @@ class Deplate::Command::CAP < Deplate::Command
111
116
  if last
112
117
  last.set_caption(Deplate::CaptionDef.new(text, args, src))
113
118
  else
114
- Deplate::Core.log(["Can't attach caption to", nil], :error, src)
119
+ Deplate::Core.log(["Cannot attach caption to", nil], :error, src)
115
120
  end
116
121
  end
117
122
  end
@@ -133,55 +138,79 @@ end
133
138
  class Deplate::Command::INC < Deplate::Command
134
139
  register_as 'INC'
135
140
  register_as 'INCLUDE'
136
-
137
- def self.accumulate(src, array, deplate, text, match, args, cmd)
138
- Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
139
- doc = args['doc'] || args['var'] || args['val']
140
- if args.has_key?('file')
141
- if text
142
- Deplate::Core.log(['Conflicting arguments', 'file > @anonymous'], :error, src)
141
+
142
+ class << self
143
+ def accumulate(src, array, deplate, text, match, args, cmd)
144
+ Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
145
+ var = args['var'] || args['var'] || args['val']
146
+ if args.has_key?('file')
147
+ if text
148
+ Deplate::Core.log(['Conflicting arguments', 'file > @anonymous'], :error, src)
149
+ end
150
+ text = args['file']
151
+ end
152
+ args['INCLUDED'] = src.file
153
+ vars = swap_variables(deplate, args)
154
+ input_format = args['inputFormat']
155
+ pif = deplate.push_input_format(input_format)
156
+
157
+ begin
158
+ if var
159
+ strings = deplate.variables[var]
160
+ if strings
161
+ deplate.include_stringarray(strings, array, nil, src.file)
162
+ else
163
+ Deplate::Core.log(['Unknown doc variable', var], :error, src)
164
+ end
165
+ elsif !text or text == ''
166
+ Deplate::Core.log(['Malformed command', cmd, text], :error, src)
167
+ else
168
+ fn = deplate.find_in_lib(text, :pwd => true)
169
+ if fn
170
+ deplate.include_file(array, fn, args)
171
+ else
172
+ Deplate::Core.log(['File not found', text], :error, src)
173
+ end
174
+ end
175
+ ensure
176
+ restore_variables(deplate, vars)
177
+ deplate.pop_input_format(input_format) if pif
143
178
  end
144
- text = args['file']
145
179
  end
146
-
147
- embeddedTextRx = args['embeddedTextRx']
148
- embeddedTextRx_orig = deplate.variables['embeddedTextRx']
149
- deplate.variables['embeddedTextRx'] = embeddedTextRx if embeddedTextRx
150
-
151
- embeddedVerbatim = args['embeddedVerbatim']
152
- embeddedVerbatim_orig = deplate.variables['embeddedVerbatim']
153
- deplate.variables['embeddedVerbatim'] = embeddedVerbatim if embeddedVerbatim
154
-
155
- syntax = args['codeSyntax'] || args['syntax']
156
- syntax_orig = deplate.variables['codeSyntax']
157
- deplate.variables['codeSyntax'] = syntax if syntax
158
-
159
- input_format = args['inputFormat']
160
- pif = deplate.push_input_format(input_format)
161
-
162
- begin
163
- if doc
164
- strings = deplate.variables[doc]
165
- if strings
166
- deplate.include_stringarray(strings, array, nil, src.file)
180
+
181
+ def swap_variables(deplate, args, vars={})
182
+ # vars[:deplate] ||= deplate.variables.dup
183
+ args.each do |var, val|
184
+ case var
185
+ when 'syntax'
186
+ var = 'codeSyntax'
187
+ when 'codeSyntax', 'embeddedTextRx', 'embeddedVerbatim'
167
188
  else
168
- Deplate::Core.log(['Unknown doc variable', doc], :error, src)
189
+ if var[0..0] == '$'
190
+ var = var[1..-1]
191
+ else
192
+ next
193
+ end
169
194
  end
170
- elsif !text or text == ''
171
- Deplate::Core.log(['Malformed command', cmd, text], :error, src)
172
- else
173
- fn = deplate.find_in_lib(text, :pwd => true)
174
- if fn
175
- deplate.include_file(array, fn)
195
+ has_key = deplate.variables.has_key?(var)
196
+ vars[var] = {
197
+ :has_key => has_key,
198
+ :value => has_key ? deplate.variables[var] : nil,
199
+ }
200
+ deplate.variables[var] = val
201
+ end
202
+ vars
203
+ end
204
+
205
+ def restore_variables(deplate, hash)
206
+ # deplate.variables = hash[:deplate]
207
+ hash.each do |var, val|
208
+ if val[:has_key]
209
+ deplate.variables[var] = val[:value]
176
210
  else
177
- Deplate::Core.log(['File not found', text], :error, src)
211
+ deplate.variables.delete(var)
178
212
  end
179
213
  end
180
- ensure
181
- deplate.variables['embeddedTextRx'] = embeddedTextRx_orig if embeddedTextRx
182
- deplate.variables['embeddedVerbatim'] = embeddedVerbatim_orig if embeddedVerbatim
183
- deplate.variables['codeSyntax'] = syntax_orig if syntax
184
- deplate.pop_input_format(input_format) if pif
185
214
  end
186
215
  end
187
216
  end
@@ -216,7 +245,9 @@ class Deplate::Command::VAR < Deplate::Command
216
245
  set_variable(deplate, id, text, args, src)
217
246
  end
218
247
  else
219
- opts, text = deplate.input.parse_args(text, nil, false)
248
+ cnt = Deplate::PseudoContainer.new(deplate, args)
249
+ cnt.source = src
250
+ opts, text = deplate.input.parse_args(text, cnt, false)
220
251
  for k, v in opts
221
252
  unless set_variable(deplate, k, v, args, src)
222
253
  opts.delete(k)
@@ -228,6 +259,16 @@ class Deplate::Command::VAR < Deplate::Command
228
259
  end
229
260
 
230
261
 
262
+ class Deplate::Command::PUSH < Deplate::Command::VAR
263
+ register_as 'PUSH'
264
+ self.volatile = true
265
+ def self.accumulate(src, array, deplate, text, match, args, cmd)
266
+ args['add'] ||= ','
267
+ super
268
+ end
269
+ end
270
+
271
+
231
272
  class Deplate::Command::KEYWORDS < Deplate::Command::VAR
232
273
  register_as 'KEYWORDS'
233
274
  self.volatile = true
@@ -240,17 +281,22 @@ end
240
281
 
241
282
  class Deplate::Command::OPT < Deplate::Command
242
283
  register_as 'OPT'
284
+ # register_as 'ATTR'
285
+ register_as 'PROP'
286
+ register_as 'PP'
243
287
  self.volatile = true
244
288
  def self.accumulate(src, array, deplate, text, match, args, cmd)
245
289
  Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
246
290
  elt = array.last
247
291
  if elt
248
- opts, text = deplate.input.parse_args(text, nil, false)
292
+ cnt = Deplate::PseudoContainer.new(deplate, args)
293
+ cnt.source = src
294
+ opts, text = deplate.input.parse_args(text, cnt, false)
249
295
  deplate.register_id(opts, elt)
250
296
  update_variables(elt.args, args, opts)
251
297
  elt.update_args
252
298
  else
253
- Deplate::Core.log(["No element given", match[0]], :error, src)
299
+ Deplate::Core.log(['No element given', match[0]], :error, src)
254
300
  end
255
301
  end
256
302
  end
@@ -262,12 +308,12 @@ class Deplate::Command::PUT < Deplate::Command
262
308
  register_as 'SET'
263
309
  def self.accumulate(src, array, deplate, text, match, args, cmd)
264
310
  Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
265
- id = args["id"]
311
+ id = args['id']
266
312
  if id
267
313
  text = deplate.parse_with_source(src, text, false)
268
314
  deplate.set_clip(id, Deplate::Element::Clip.new(text, deplate, src))
269
315
  else
270
- Deplate::Core.log(["No ID given", text], :error, src)
316
+ Deplate::Core.log(['No ID given', text], :error, src)
271
317
  end
272
318
  end
273
319
  end
@@ -278,7 +324,7 @@ class Deplate::Command::GET < Deplate::Command
278
324
  set_formatter :format_GET
279
325
 
280
326
  def setup_command
281
- @id = @args["id"] || @accum[0]
327
+ @id = @args['id'] || @accum[0]
282
328
  end
283
329
 
284
330
  def process
@@ -286,7 +332,7 @@ class Deplate::Command::GET < Deplate::Command
286
332
  if @elt
287
333
  return self
288
334
  else
289
- log(["GET: Clip not found", @id], :error)
335
+ log(['GET: Clip not found', @id], :error)
290
336
  return nil
291
337
  end
292
338
  end
@@ -296,20 +342,18 @@ end
296
342
  class Deplate::Command::XARG < Deplate::Command
297
343
  register_as 'XARG'
298
344
  register_as 'XVAL'
299
- self.volatile = true
345
+ # self.volatile = true
300
346
 
301
347
  def setup_command
302
- id = args["id"] || @accum[0]
303
- @elt = @deplate.variables[id] || @args["default"]
348
+ id = args['id'] || @accum[0]
349
+ @elt = @deplate.variables[id] || @args['default']
304
350
  if @elt
305
- @elt = Deplate::Core.escape_characters(@elt, @args)
306
- @elt = post_process_text(@elt)
307
- @elt = @elt.split(/[\n\r]/).each {|l| l.chomp!}
351
+ @elt = Deplate::Command::ARG.preformat_element(@elt, @args)
308
352
  else
309
- log(["Unknown variable", id, @name], :error)
353
+ log(['Unknown variable', id, @name], :error)
310
354
  end
311
355
  end
312
-
356
+
313
357
  def format_special
314
358
  @elt
315
359
  end
@@ -319,7 +363,7 @@ end
319
363
  class Deplate::Command::ARG < Deplate::Command
320
364
  register_as 'ARG'
321
365
  register_as 'VAL'
322
- self.volatile = true
366
+ # self.volatile = true
323
367
 
324
368
  class << self
325
369
  def accumulate(src, array, deplate, text, match, args, cmd)
@@ -327,17 +371,30 @@ class Deplate::Command::ARG < Deplate::Command
327
371
  id = args['id'] || text
328
372
  val = deplate.variables[id] || args['default']
329
373
  if val
330
- val = Deplate::Core.escape_characters(val, args)
331
- val = Deplate::CommonGround.post_process_text(val, args)
332
- # val.gsub!(/\\/, '\\\\\\\\')
333
- acc = val.split(/[\n\r]/)
334
- acc.each {|l| l.chomp!}
374
+ acc = preformat_element(val, args)
335
375
  d = deplate.options.master ? deplate.options.master : deplate
336
376
  d.include_stringarray(acc, array, src.begin, src.file)
337
377
  else
338
378
  Deplate::Core.log(['Unknown variable', id, cmd], :error, src)
339
379
  end
340
380
  end
381
+
382
+ def preformat_element(elt, args)
383
+ case elt
384
+ when Array
385
+ elt = elt.collect {|text| preformat_text(text, args)}
386
+ else
387
+ elt = preformat_text(elt, args)
388
+ end
389
+ elt.flatten!
390
+ return elt
391
+ end
392
+
393
+ def preformat_text(text, args)
394
+ text = Deplate::Core.escape_characters(text, args)
395
+ text = Deplate::CommonGround.post_process_text(text, args)
396
+ return text.split(/[\n\r]/).each {|l| l.chomp!}
397
+ end
341
398
  end
342
399
  end
343
400
 
@@ -361,13 +418,13 @@ class Deplate::Command::TITLE < Deplate::Command
361
418
  register_as 'TI'
362
419
  self.volatile = true
363
420
  def self.accumulate(src, array, deplate, text, match, args, cmd)
364
- Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
421
+ Deplate::Core.log('%s: %s' % [cmd, text], :debug, src)
365
422
  c = deplate.parse_with_source(src, text, false)
366
- deplate.set_clip("title", Deplate::Element::Clip.new(c, deplate, src))
423
+ deplate.set_clip('title', Deplate::Element::Clip.new(c, deplate, src))
367
424
  deplate.register_metadata(src,
368
- "type" => "metadata",
369
- "name" => "title",
370
- "value" => text
425
+ 'type' => 'metadata',
426
+ 'name' => 'title',
427
+ 'value' => text
371
428
  )
372
429
  end
373
430
  end
@@ -379,34 +436,34 @@ class Deplate::Command::AUTHOR < Deplate::Command
379
436
  self.volatile = true
380
437
  class << self
381
438
  def accumulate(src, array, deplate, text, match, args, cmd)
382
- Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
439
+ Deplate::Core.log('%s: %s' % [cmd, text], :debug, src)
383
440
  deplate.options.author ||= []
384
441
  for this in text.split(/([;\/]|\s+(&|and))\s+/)
385
442
  unless this =~ /^\s*([;\/&]|and)\s*$/
386
443
  author = Deplate::Names.name_match_sf(this) ||
387
444
  Deplate::Names.name_match_fs(this) || {}
388
- sn = args["surname"]
445
+ sn = args['surname']
389
446
  author[:surname] = sn if sn
390
- fn = args["firstname"]
447
+ fn = args['firstname']
391
448
  author[:firstname] = fn if fn
392
449
  if this.empty?
393
- author[:name] = args["name"] || "%s %s" % [args["firstname"], args["surname"]]
450
+ author[:name] = args['name'] || '%s %s' % [args['firstname'], args['surname']]
394
451
  else
395
452
  author[:name] = this
396
453
  end
397
- author[:note] = args["note"]
454
+ author[:note] = args['note']
398
455
  deplate.options.author << author
399
456
  end
400
457
  end
401
- sep = deplate.variables["authorSep"] || "; "
458
+ sep = deplate.variables['authorSep'] || '; '
402
459
  authors = deplate.options.author.collect {|h| h[:name]}
403
460
  authors = authors.join(sep)
404
461
  parsed = deplate.parse_with_source(src, authors, false)
405
- deplate.set_clip("author", Deplate::Element::Clip.new(parsed, deplate, src))
462
+ deplate.set_clip('author', Deplate::Element::Clip.new(parsed, deplate, src))
406
463
  deplate.register_metadata(src,
407
- "type" => "metadata",
408
- "name" => "author",
409
- "value" => authors
464
+ 'type' => 'metadata',
465
+ 'name' => 'author',
466
+ 'value' => authors
410
467
  )
411
468
  end
412
469
  end
@@ -418,7 +475,7 @@ class Deplate::Command::AUTHORNOTE < Deplate::Command
418
475
  register_as 'AN'
419
476
  self.volatile = true
420
477
  def self.accumulate(src, array, deplate, text, match, args, cmd)
421
- Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
478
+ Deplate::Core.log('%s: %s' % [cmd, text], :debug, src)
422
479
  unless text.empty?
423
480
  author = deplate.options.author.last
424
481
  if author
@@ -426,14 +483,14 @@ class Deplate::Command::AUTHORNOTE < Deplate::Command
426
483
  end
427
484
  end
428
485
  ans = deplate.options.author.collect {|h| h[:note]}
429
- sep = deplate.variables["authorSep"] || "; "
486
+ sep = deplate.variables['authorSep'] || '; '
430
487
  ans = ans.compact.join(sep)
431
488
  parsed = deplate.parse_with_source(src, ans, false)
432
- deplate.set_clip("authornote", Deplate::Element::Clip.new(parsed, deplate, src))
489
+ deplate.set_clip('authornote', Deplate::Element::Clip.new(parsed, deplate, src))
433
490
  deplate.register_metadata(src,
434
- "type" => "metadata",
435
- "name" => "authornote",
436
- "value" => ans
491
+ 'type' => 'metadata',
492
+ 'name' => 'authornote',
493
+ 'value' => ans
437
494
  )
438
495
  end
439
496
  end
@@ -443,7 +500,7 @@ class Deplate::Command::DATE < Deplate::Command
443
500
  register_as 'DATE'
444
501
  self.volatile = true
445
502
  def self.accumulate(src, array, deplate, text, match, args, cmd)
446
- Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
503
+ Deplate::Core.log('%s: %s' % [cmd, text], :debug, src)
447
504
  d = get_date(text, args)
448
505
  c = deplate.parse_with_source(src, d, false)
449
506
  deplate.set_clip(cmd.downcase, Deplate::Element::Clip.new(c, deplate, src))
@@ -611,7 +668,7 @@ class Deplate::Command::IDX < Deplate::Command
611
668
  accum = []
612
669
  auto = args['auto']
613
670
  auto = deplate.variables['autoindex'] if auto.nil?
614
- for i in text.split(/\s*;\s*/)
671
+ for i in Deplate::Core.split_list(text, ';', nil, source)
615
672
  # <+TBD IDX+>idx = deplate.add_index(nil, i, deplate.get_current_heading)
616
673
  idx = deplate.add_index(container, i)
617
674
  Deplate::Particle.auto_indexing(deplate, idx) if auto
@@ -652,7 +709,7 @@ class Deplate::Command::AUTOIDX < Deplate::Command
652
709
  def self.accumulate(src, array, deplate, text, match, args, cmd)
653
710
  Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
654
711
  hd = deplate.get_current_heading
655
- for i in text.split(/\s*;\s*/)
712
+ for i in Deplate::Core.split_list(text, ';', nil, src)
656
713
  Deplate::Particle.auto_indexing(deplate, deplate.add_index(nil, i, hd))
657
714
  end
658
715
  end
@@ -664,7 +721,7 @@ class Deplate::Command::NOIDX < Deplate::Command
664
721
  self.volatile = true
665
722
  def self.accumulate(src, array, deplate, text, match, args, cmd)
666
723
  Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
667
- for i in text.split(/\s*;\s*/)
724
+ for i in Deplate::Core.split_list(text, ';', nil, src)
668
725
  deplate.remove_index(self, i)
669
726
  end
670
727
  end
@@ -676,7 +733,7 @@ class Deplate::Command::DONTIDX < Deplate::Command
676
733
  self.volatile = true
677
734
  def self.accumulate(src, array, deplate, text, match, args, cmd)
678
735
  Deplate::Core.log("%s: %s" % [cmd, text], :debug, src)
679
- deplate.options.dont_index += text.split(/\s*;\s*/)
736
+ deplate.options.dont_index += Deplate::Core.split_list(text, ';', nil, src)
680
737
  end
681
738
  end
682
739
 
@@ -723,11 +780,12 @@ class Deplate::Command::ABBREV < Deplate::Command
723
780
  rs = nil
724
781
  tx = nil
725
782
  cmd = nil
726
- deplate.options.abbrevs ||= {}
727
783
  catch(:exit) do
728
784
  w = args['word'] || args['w'] || args['wd']
729
785
  if w
730
- rs = %{\\b%s\\b} % Regexp.escape(w)
786
+ # rs = %{\\b%s\\b} % Regexp.escape(w)
787
+ # rs = %{\\b%s(?=[^#{Deplate::HyperLink.chars}])} % Regexp.escape(w)
788
+ rs = %{\\b%s(?=([[:punct:][:cntrl:][:space:]]|$))} % Regexp.escape(w)
731
789
  # tx = "#{Deplate::Core.remove_backslashes(text.inspect)}"
732
790
  # tx = "#{text.inspect}"
733
791
  # tx = text.inspect
@@ -755,14 +813,14 @@ class Deplate::Command::ABBREV < Deplate::Command
755
813
  cmd = lambda {|c, t| c.deplate.formatter.plain_text(t)}
756
814
  specific = false
757
815
  elsif args['native'] or args['ins']
758
- cmd = tx
816
+ cmd = lambda {|c, t| t}
759
817
  specific = true
760
818
  else
761
819
  # cmd = %{@deplate.parse_and_format(@container, #{tx}, false)}
762
820
  cmd = lambda {|c, t| c.deplate.parse_and_format(c, t, false)}
763
821
  specific = false
764
822
  end
765
- deplate.options.abbrevs[rs] = [tx, cmd]
823
+ deplate.options.abbrevs[[rs, deplate.formatter.formatter_name]] = [tx, cmd]
766
824
  rx = Regexp.new("^#{rs}")
767
825
  # body = <<-EOR
768
826
  # set_rx(#{rx.inspect})
@@ -773,7 +831,7 @@ class Deplate::Command::ABBREV < Deplate::Command
773
831
  body = <<-EOR
774
832
  set_rx(#{rx.inspect})
775
833
  def setup
776
- tx, cmd = @deplate.options.abbrevs[#{rs.inspect}]
834
+ tx, cmd = @deplate.options.abbrevs[[#{rs.inspect}, @deplate.formatter.formatter_name]]
777
835
  case cmd
778
836
  when Proc
779
837
  tx = tx.call(self) if tx.kind_of?(Proc)
@@ -787,7 +845,8 @@ class Deplate::Command::ABBREV < Deplate::Command
787
845
  EOR
788
846
  cls = Deplate::Cache.particle(deplate, body,
789
847
  :register => true,
790
- :specific => specific
848
+ :specific => specific,
849
+ :unshift => args['priority']
791
850
  )
792
851
  else
793
852
  Deplate::Core.log(["No pattern specified", args], :error, src)