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,7 +1,10 @@
1
1
  @import url(deplate.css);
2
2
 
3
3
  body {
4
- background-color: #d9e0f0;
4
+ /* background-color: #d9e0f0; */
5
+ background-color: #e4e8f0;
6
+ background-image: url(grad_blue.jpg);
7
+ background-repeat: repeat-x;
5
8
  }
6
9
 
7
10
  #tabFrame {
@@ -9,17 +12,18 @@ body {
9
12
  top: 0;
10
13
  left: 10%;
11
14
  text-align: left;
12
- width: 100%;
15
+ width: 80%;
13
16
  }
14
17
  #tabBar {
15
18
  padding: 0;
16
19
  border: 0;
17
20
  margin: 10px 0 0 0;
18
- background-color: #d9e0f0;
21
+ /* background-color: #d9e0f0; */
22
+ background-color: transparent;
19
23
  }
20
24
  #tabBodyFrame {
21
25
  /* text-align: left; */
22
- width: 80%;
26
+ width: 100%;
23
27
  padding: 0;
24
28
  }
25
29
  #tabBody {
@@ -28,7 +32,11 @@ body {
28
32
  vertical-align: top;
29
33
  margin-top: 0;
30
34
  padding: 10px;
31
- border: 1px dashed #cae0ea;
35
+ /* border: 1px dashed #cae0ea; */
36
+ border: 1px solid #cae0ea;
37
+ border-bottom-left-radius: 15px;
38
+ border-bottom-right-radius: 15px;
39
+ -moz-border-radius: 0 0 15px 15px;
32
40
  }
33
41
 
34
42
  table.tabBarTop {
@@ -49,18 +57,29 @@ tr.tabBarTop {
49
57
  }
50
58
  td.tabBarTopActive {
51
59
  margin: 0;
52
- border-top: 1px dashed #cae0ea;
53
- border-left: 1px dashed #cae0ea;
54
- border-right: 1px dashed #cae0ea;
60
+ /* border-top: 1px dashed #cae0ea; */
61
+ /* border-left: 1px dashed #cae0ea; */
62
+ /* border-right: 1px dashed #cae0ea; */
63
+ border-top: 1px solid #cae0ea;
64
+ border-left: 1px solid #cae0ea;
65
+ border-right: 1px solid #cae0ea;
55
66
  border-bottom: 0;
56
67
  background-color: #ffffff;
57
68
  text-align: center;
69
+ /* -moz-border-radius: 15px 15px 0 0; */
58
70
  }
59
71
  td.tabBarTopInactive {
60
72
  margin: 0;
61
- border-bottom: 1px dashed #cae0ea;
73
+ /* border-bottom: 1px dashed #cae0ea; */
74
+ border-bottom: 1px solid #cae0ea;
62
75
  background-color: #f0f0f0;
63
76
  text-align: center;
77
+ /* -moz-border-radius: 15px 15px 0 0; */
78
+ }
79
+
80
+ tr.tabBarTopAbout {
81
+ }
82
+ td.tabBarTopAbout {
64
83
  }
65
84
 
66
85
  div.pageicons {
@@ -1,5 +1,5 @@
1
1
  /* Text style: sans-serif */
2
- /* @Author: Thomas Link (samul AT web.de) */
2
+ /* @Author: Thomas Link (micathom AT gmail com) */
3
3
  /* @Created: 13-Apr-2004. */
4
4
  /* @Last Change: 20-Feb-2005. */
5
5
  /* @Revision: 0.587 */
@@ -1,5 +1,5 @@
1
1
  /* Text style: sans-serif */
2
- /* @Author: Thomas Link (samul AT web.de) */
2
+ /* @Author: Thomas Link (micathom AT gmail com) */
3
3
  /* @Created: 13-Apr-2004. */
4
4
  /* @Last Change: 21-Mai-2005. */
5
5
  /* @Revision: 0.585 */
@@ -1,10 +1,10 @@
1
1
  # define.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: 19-Okt-2004.
6
- # @Last Change: 29-Apr-2006.
7
- # @Revision: 0.500
6
+ # @Last Change: 2007-05-20.
7
+ # @Revision: 0.546
8
8
 
9
9
  require 'deplate/commands'
10
10
  require 'deplate/macros'
@@ -88,20 +88,46 @@ class Deplate::Define < Deplate::Region
88
88
  end
89
89
  end
90
90
 
91
+ module Deplate::Define::TemplateExpander
92
+ def use_template(template=@template, oargs={})
93
+ # deplate = @deplate || oargs[:deplate]
94
+ # args = @args || oargs[:args]
95
+ # source = @source || oargs[:source]
96
+ deplate = oargs[:deplate] || @deplate
97
+ args = oargs[:args] || @args
98
+ source = oargs[:source] || @source
99
+ if args['noTemplate'] or deplate.variables['legacyDefine1']
100
+ template
101
+ else
102
+ tmpl = Deplate::Template.new(:master => deplate,
103
+ :template => template,
104
+ :source => source,
105
+ :container => self)
106
+ rv = nil
107
+ Deplate::Define.let_variables(deplate, args) do
108
+ rv = tmpl.fill_in(deplate, :source => source)
109
+ end
110
+ rv
111
+ end
112
+ end
113
+ end
91
114
 
92
115
  # class Deplate::Define::Region < Deplate::Region::SecondOrder
93
116
  class Deplate::Define::Region < Deplate::Region
117
+ include Deplate::Define::TemplateExpander
118
+
94
119
  def finish
95
120
  finish_accum
96
121
  setup_template
97
122
  @args['@body'] = @accum.join("\n")
98
- @args['@note'] = @regNote
123
+ deprecated_regnote
99
124
  Deplate::Define.check_arguments(@mandatory, @args, @source)
100
125
  @expected = Deplate::Element
101
126
  @elt = []
127
+ tpl = use_template
102
128
  Deplate::Define.let_variables(@deplate, @args) do
103
129
  # p "DBG DefineRegion: #{@deplate.options.counters.inspect}"
104
- @elt = @deplate.parsed_array_from_strings(@template, @source.begin, @source.file)
130
+ @elt = @deplate.parsed_array_from_strings(tpl, @source.begin, @source.file)
105
131
  end
106
132
  unless @elt.empty?
107
133
  @elt.first.put_label(@label)
@@ -111,12 +137,12 @@ class Deplate::Define::Region < Deplate::Region
111
137
  end
112
138
 
113
139
  class Deplate::Regions::DefRegion < Deplate::Define
114
- @@regions['DefRegion'] = self
115
- @@regions['DefineRegion'] = self
116
- @@regions['Defr'] = self
140
+ register_as 'DefRegion'
141
+ register_as 'DefineRegion'
142
+ register_as 'Defr'
117
143
 
118
144
  def define
119
- id = @args['id'] ||= @regNote
145
+ id = deprecated_regnote('id')
120
146
  if valid_id?(id)
121
147
  # if @args['lineCont'] == false
122
148
  line_cont = 'set_line_cont false'
@@ -163,15 +189,15 @@ class Deplate::Define::Element < Deplate::Element
163
189
  end
164
190
 
165
191
  class Deplate::Regions::DefElement < Deplate::Define
166
- @@regions['DefElement'] = self
167
- @@regions['DefineElement'] = self
168
- @@regions['Defe'] = self
192
+ register_as 'DefElement'
193
+ register_as 'DefineElement'
194
+ register_as 'Defe'
169
195
  @@def_element_counter = 0
170
196
 
171
197
  set_line_cont false
172
198
 
173
199
  def define
174
- rx = @args['rx'] ||= @regNote
200
+ rx = deprecated_regnote('rx')
175
201
  if rx
176
202
  @@def_element_counter += 1
177
203
  # template = @accum.join("\n").gsub(/\'/, "\\\\\'")
@@ -223,7 +249,7 @@ class Deplate::Regions::DefParticle < Deplate::Define
223
249
  @@def_particle_counter = 0
224
250
 
225
251
  def define
226
- rs = @args['rx'] ||= @regNote
252
+ rs = deprecated_regnote('rx')
227
253
  if rs
228
254
  # template = @accum.join("\n").gsub(/\'/, "\\\\\'")
229
255
  template = @accum.join("\n")
@@ -245,13 +271,20 @@ end
245
271
 
246
272
  class Deplate::Define::Command < Deplate::Command
247
273
  class << self
274
+ include Deplate::Define::TemplateExpander
275
+
248
276
  def accumulate(source, array, deplate, text, match, args, cmd)
249
277
  Deplate::Core.log("%s: %s" % [cmd, text], :debug)
250
278
  template, mandatory = setup_template(text, deplate)
251
279
  args['@body'] = text
252
280
  Deplate::Define.check_arguments(mandatory, args, source)
281
+ tpl = use_template(template,
282
+ :deplate => deplate,
283
+ :args => args,
284
+ :source => source
285
+ )
253
286
  Deplate::Define.let_variables(deplate, args) do
254
- deplate.include_stringarray(template, array, source.begin, source.file)
287
+ deplate.include_stringarray(tpl, array, source.begin, source.file)
255
288
  end
256
289
  end
257
290
  end
@@ -259,13 +292,13 @@ end
259
292
 
260
293
 
261
294
  class Deplate::Regions::DefCommand < Deplate::Define
262
- @@regions['DefCommand'] = self
263
- @@regions['DefCmd'] = self
264
- @@regions['DefineCommand'] = self
265
- @@regions['Defc'] = self
295
+ register_as 'DefCommand'
296
+ register_as 'DefCmd'
297
+ register_as 'DefineCommand'
298
+ register_as 'Defc'
266
299
 
267
300
  def define
268
- id = @args['id'] ||= @regNote
301
+ id = deprecated_regnote('id')
269
302
  if valid_id?(id)
270
303
  body = <<-EOR
271
304
  class << self
@@ -301,11 +334,11 @@ end
301
334
 
302
335
 
303
336
  class Deplate::Regions::DefMacro < Deplate::Define
304
- @@regions['DefMacro'] = self
305
- @@regions['DefineMacro'] = self
306
- @@regions['Defm'] = self
337
+ register_as 'DefMacro'
338
+ register_as 'DefineMacro'
339
+ register_as 'Defm'
307
340
  def define
308
- id = @args['id'] ||= @regNote
341
+ id = deprecated_regnote('id')
309
342
  if valid_id?(id)
310
343
  body = <<-EOR
311
344
  def setup_template(text)
@@ -325,7 +358,7 @@ end
325
358
 
326
359
  class Deplate::Regions::Native
327
360
  def expand_template
328
- @args['@note'] = @regNote
361
+ deprecated_regnote
329
362
  @args['@body'] = @accum.join("\n")
330
363
  tmpl = Deplate::Template.new(:master => @deplate,
331
364
  :template => @template,
@@ -341,11 +374,11 @@ end
341
374
 
342
375
 
343
376
  class Deplate::Regions::DefRegionN < Deplate::Define
344
- @@regions['DefRegionN'] = self
345
- @@regions['DefineRegionN'] = self
346
- @@regions['Defrn'] = self
377
+ register_as 'DefRegionN'
378
+ register_as 'DefineRegionN'
379
+ register_as 'Defrn'
347
380
  def define
348
- id = @args['id'] ||= @regNote
381
+ id = deprecated_regnote('id')
349
382
  if valid_id?(id)
350
383
  body = <<-EOR
351
384
  def finish
@@ -385,12 +418,12 @@ end
385
418
 
386
419
 
387
420
  class Deplate::Regions::DefCommandN < Deplate::Define
388
- @@regions['DefCommandN'] = self
389
- @@regions['DefCmdN'] = self
390
- @@regions['DefineCommandN'] = self
391
- @@regions['Defcn'] = self
421
+ register_as 'DefCommandN'
422
+ register_as 'DefCmdN'
423
+ register_as 'DefineCommandN'
424
+ register_as 'Defcn'
392
425
  def define
393
- id = @args['id'] ||= @regNote
426
+ id = deprecated_regnote('id')
394
427
  if valid_id?(id)
395
428
  body = <<-EOR
396
429
  def finish
@@ -424,11 +457,11 @@ end
424
457
 
425
458
 
426
459
  class Deplate::Regions::DefMacroN < Deplate::Define
427
- @@regions['DefMacroN'] = self
428
- @@regions['DefineMacroN'] = self
429
- @@regions['Defmn'] = self
460
+ register_as 'DefMacroN'
461
+ register_as 'DefineMacroN'
462
+ register_as 'Defmn'
430
463
  def define
431
- id = @args['id'] ||= @regNote
464
+ id = deprecated_regnote('id')
432
465
  if valid_id?(id)
433
466
  body = <<-EOR
434
467
  def setup_template
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
  # deplate-string.rb
3
- # @Author: Thomas Link (samul AT web de)
3
+ # @Author: Thomas Link (micathom AT gmail com)
4
4
  # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
5
  # @Created: 31-Dez-2005.
6
- # @Last Change: 03-Jan-2006.
7
- # @Revision: 0.39
6
+ # @Last Change: 18-Aug-2006.
7
+ # @Revision: 0.40
8
8
 
9
9
  require 'deplate/converter'
10
10
 
@@ -1,10 +1,10 @@
1
1
  # docbook.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: 17-M�r-2004.
6
- # @Last Change: 05-Jun-2006.
7
- # @Revision: 0.2735
6
+ # @Last Change: 2007-09-30.
7
+ # @Revision: 0.2748
8
8
 
9
9
  require 'deplate/xml'
10
10
 
@@ -12,7 +12,6 @@ require 'deplate/xml'
12
12
 
13
13
  class Deplate::Formatter::Docbook < Deplate::Formatter::XML
14
14
  def initialize(deplate, args)
15
- @consumed_ids = []
16
15
  @sgml = false
17
16
  super
18
17
  end
@@ -34,11 +33,11 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
34
33
  end
35
34
  id = opts['id']
36
35
  if id
37
- if @consumed_ids.include?(id)
36
+ if consumed_ids.include?(id)
38
37
  opts = opts.dup
39
38
  opts.delete('id')
40
39
  else
41
- @consumed_ids << id
40
+ consumed_ids << id
42
41
  end
43
42
  opts['xreflabel'] ||= args[:level_as_string]
44
43
  end
@@ -195,8 +194,9 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
195
194
  if text
196
195
  acc = []
197
196
  for au in Deplate::Core.authors_split(text)
198
- author = Deplate::Names.name_match_sf(au) || Deplate::Names.name_match_fs(au)
199
- if author
197
+ if (author = Deplate::Names.name_match_c(au))
198
+ acc << formatted_inline(type, formatted_inline('surname', author[:surname]))
199
+ elsif (author = Deplate::Names.name_match_sf(au) || Deplate::Names.name_match_fs(au))
200
200
  surname = formatted_inline('surname', author[:surname])
201
201
  firstname = formatted_inline('firstname', author[:firstname])
202
202
  acc << formatted_inline(type, surname + firstname)
@@ -522,7 +522,7 @@ class Deplate::Formatter::Docbook < Deplate::Formatter::XML
522
522
 
523
523
  def get_image(args, file, fnroot, inline=false)
524
524
  if file =~ Deplate::HyperLink::Url.rx
525
- Deplate::Core.log([%{Can't include remote images in current document}, file], :error)
525
+ Deplate::Core.log([%{Cannot include remote images in current document}, file], :error)
526
526
  file = File.basename(file)
527
527
  end
528
528
  o = {}
@@ -1,10 +1,10 @@
1
1
  # elements.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: 26-M�r-2004.
6
- # @Last Change: 07-Jun-2006.
7
- # @Revision: 0.4285
6
+ # @Last Change: 2007-09-30.
7
+ # @Revision: 0.4497
8
8
 
9
9
  require "deplate/abstract-class"
10
10
 
@@ -83,17 +83,21 @@ class Deplate::Element < Deplate::BaseElement
83
83
 
84
84
  def do_accumulate(src, array, deplate, text, *args)
85
85
  run_accumulation_hooks(@@accumulate_pre[self], src, array, deplate, text, *args)
86
- top = array.last
87
- accumulate(src, array, deplate, text, *args)
88
- indentation = text.gsub(/^(\s*).*$/, '\\1')
89
- shiftwidth = deplate.variables['tabWidth']
90
- shiftwidth = shiftwidth ? shiftwidth.to_i : 4
91
- indent_level = indentation.size / shiftwidth
92
- i = -1
93
- while ((e = array[i]) and (!top or e != top))
94
- e.indentation = indentation
95
- e.indentation_level = indent_level
96
- i -= 1
86
+ begin
87
+ top = array.last
88
+ accumulate(src, array, deplate, text, *args)
89
+ indentation = text.gsub(/^(\s*).*$/, '\\1')
90
+ shiftwidth = deplate.variables['tabWidth']
91
+ shiftwidth = shiftwidth ? shiftwidth.to_i : 4
92
+ indent_level = indentation.size / shiftwidth
93
+ i = -1
94
+ while ((e = array[i]) and (!top or e != top))
95
+ e.indentation = indentation
96
+ e.indentation_level = indent_level
97
+ i -= 1
98
+ end
99
+ rescue Exception => e
100
+ Deplate::Core.log(['Error when running command', e], :error, src)
97
101
  end
98
102
  run_accumulation_hooks(@@accumulate_post[self], src, array, deplate, text, *args)
99
103
  end
@@ -155,6 +159,7 @@ class Deplate::Element < Deplate::BaseElement
155
159
 
156
160
  @level = get_level if respond_to?(:get_level)
157
161
  @accum = respond_to?(:get_text) ? [get_text] : []
162
+ @accum.compact!
158
163
 
159
164
  set_instance_top
160
165
 
@@ -198,8 +203,8 @@ class Deplate::Element < Deplate::BaseElement
198
203
  return @collapse && other.collapse && self.class == other.class
199
204
  end
200
205
 
201
- def drop?
202
- return @collapse == :drop
206
+ def drop?(filter=nil)
207
+ return @collapse == :drop || (filter && exclude?(filter))
203
208
  end
204
209
 
205
210
  def unify(other)
@@ -222,7 +227,7 @@ class Deplate::Element < Deplate::BaseElement
222
227
  def_abstract :push_match
223
228
 
224
229
  def to_be_continued?(line, klass, match)
225
- klass.nil? && @multiliner
230
+ @multiliner && (klass == @deplate.input.comment_class || klass.nil?)
226
231
  end
227
232
 
228
233
  # compile the accumulated lines in @accum & put the result into @elt
@@ -381,7 +386,7 @@ class Deplate::Element < Deplate::BaseElement
381
386
  end
382
387
 
383
388
  def register_caption
384
- # log(["Can't attach caption to", self.class.name], :error)
389
+ # log(["Cannot attach caption to", self.class.name], :error)
385
390
  end
386
391
 
387
392
  def set_caption(captiondef, quiet=false)
@@ -418,8 +423,8 @@ class Deplate::Element < Deplate::BaseElement
418
423
  # nn = @deplate.get_numbering_mode(en, 2)
419
424
  # nn = nil if nn == 0
420
425
  cn = @deplate.options.listings.get_prop(list, 'counter') || list
421
- # self.level_as_string = @deplate.options.counters.increase(cn, :to_s => true, :level => nn)
422
- self.level_as_string = @deplate.options.counters.increase(cn, :to_s => true)
426
+ # self.level_as_string = @deplate.options.counters.increase(cn, :container => self, :to_s => true, :level => nn)
427
+ self.level_as_string = @deplate.options.counters.increase(cn, :container => self, :to_s => true)
423
428
  prefix = @deplate.options.listings.get_prop(list, 'prefix') || list
424
429
  label = @deplate.elt_label(prefix, level_as_string)
425
430
  @label << label
@@ -432,11 +437,13 @@ class Deplate::Element < Deplate::BaseElement
432
437
  )
433
438
  end
434
439
 
435
- protected
436
440
  def process_etc
437
441
  if !@caption and @args['caption']
438
- log(['DEBUG: Too late: Add caption', @args['caption']], :error)
439
- caption = @deplate.parse(self, @args['caption'])
442
+ # puts caller[0..10].join("\n")
443
+ # log(['DEBUG: Too late: Add caption', @args['caption']], :error)
444
+ log(['Add caption', @args['caption']])
445
+ # caption = @deplate.parse(self, @args['caption'])
446
+ caption = @args['caption']
440
447
  set_caption(Deplate::CaptionDef.new(caption, @args, @source))
441
448
  end
442
449
  if defined?(@caption) && @caption
@@ -459,7 +466,7 @@ class Deplate::Element < Deplate::BaseElement
459
466
  l.compact!
460
467
  l.uniq!
461
468
  put_label(l, true)
462
- @args.update(other.args)
469
+ unify_args(other.args)
463
470
  # p "DBG", self.class, other.class, @args.keys, other.args.keys
464
471
  @level ||= other.level
465
472
  @source.begin ||= other.source.begin
@@ -479,7 +486,19 @@ class Deplate::Element < Deplate::BaseElement
479
486
  update_styles(other.styles)
480
487
  end
481
488
  end
482
-
489
+
490
+ def unify_args(args)
491
+ @args.update(args) do |k, o, n|
492
+ case k
493
+ when 'tag'
494
+ [o, n].join(',')
495
+ else
496
+ n
497
+ end
498
+ end
499
+ update_args
500
+ end
501
+
483
502
  def unify_elt(other)
484
503
  if @elt.nil?
485
504
  @elt = other.elt
@@ -510,7 +529,7 @@ class Deplate::Element < Deplate::BaseElement
510
529
  pre = m.pre_match
511
530
  text = m.post_match
512
531
  add = tabwidth - pre.size % tabwidth
513
- accum << pre + (" " * add)
532
+ accum << pre + (' ' * add)
514
533
  else
515
534
  return accum.join + text
516
535
  end
@@ -523,8 +542,10 @@ class Deplate::Element < Deplate::BaseElement
523
542
  if @elt
524
543
  @elt = (@elt.collect(&block)).join
525
544
  else
526
- log(["Internal error: No @elt", self.class], :error)
527
- @elt = ""
545
+ # p "DBG", @accum
546
+ # puts caller.join("\n")
547
+ log(['Internal error: No @elt', self.class], :error)
548
+ @elt = ''
528
549
  end
529
550
  end
530
551
  alias process_elements process_particles
@@ -539,19 +560,68 @@ class Deplate::Element < Deplate::BaseElement
539
560
  end
540
561
 
541
562
 
542
- class Deplate::Element::Comment < Deplate::Element
563
+ # Don't register Paragraph in @@elements -- it's assigned if nothing else
564
+ # matches
565
+ class Deplate::Element::Paragraph < Deplate::Element
566
+ set_formatter :format_paragraph
567
+ set_rx(/^([[:blank:]]*)(.+)[[:blank:]]*$/)
568
+ def_get :level, lambda {get_indent(@match[1]).size}
569
+ def_get :text, lambda {@deplate.options.keep_whitespace ? @match[0] : @match[2]}
570
+
571
+ class << self
572
+ def from_text(deplate, src, text)
573
+ m = self.rx.match(text)
574
+ self.new(deplate, src, text, m)
575
+ end
576
+ end
577
+
578
+ def setup
579
+ @multiliner = true
580
+ end
581
+ end
582
+
583
+
584
+ class Deplate::Element::Comment < Deplate::Element::Paragraph
543
585
  register_element
544
- set_rx(/^\s*(%+)[[:blank:]]*(.*)$/)
545
- def_get :level, lambda {@match[1].size}
586
+ # set_rx(/^\s*(%+)[[:blank:]]*(.*)$/)
587
+ set_rx(/^\s*(%+)\s*(.*)$/)
588
+ # def_get :level, lambda {@match[1].size}
589
+ def_get :level, lambda {get_marker.size}
590
+ def_get :marker, 1
546
591
  def_get :text, 2
547
-
548
- # disappear
549
- def self.accumulate(src, array, deplate, text, match)
550
- Deplate::Core.log(["Hide comment", text], :debug)
592
+
593
+ # disappear unless commentsShow is set
594
+ class << self
595
+ def accumulate(src, array, deplate, text, match)
596
+ m = deplate.variables['commentsShow']
597
+ if m
598
+ e = self.new(deplate, src, text, match)
599
+ if e and (m == true or e.get_marker == m)
600
+ e.update_styles('sourceComment')
601
+ array << e
602
+ return
603
+ end
604
+ end
605
+ Deplate::Core.log(["Hide comment", text], :debug)
606
+ end
607
+
608
+ def show_comment?(deplate, text)
609
+ m = deplate.variables['commentsShow']
610
+ return m && (m == true || text =~ Regexp.new('^\s*' + Regexp.escape(m)))
611
+ end
551
612
  end
552
613
 
553
614
  def setup
554
- @collapse = true
615
+ if @deplate.variables['commentsShow']
616
+ @multiliner = true
617
+ else
618
+ @collapse = true
619
+ end
620
+ end
621
+
622
+ def <<(line)
623
+ m = self.class.rx.match(line)
624
+ @accum << m[2]
555
625
  end
556
626
  end
557
627
 
@@ -570,6 +640,15 @@ class Deplate::Element::Note < Deplate::Element
570
640
  @multiliner = true
571
641
  @marker = get_marker
572
642
  end
643
+
644
+ def finish
645
+ rv = super
646
+ case @marker
647
+ when '+'
648
+ log(['TODO', @accum.join(' ')], :anyway)
649
+ end
650
+ return rv
651
+ end
573
652
 
574
653
  def to_be_continued?(line, klass, match)
575
654
  indent = get_indent(line).size
@@ -600,7 +679,7 @@ class Deplate::List < Deplate::Element
600
679
  @collapse = true
601
680
  @itemopts = get_opts
602
681
  if self.instance_of?(Deplate::List::Description)
603
- @levelMax = @level + (@deplate.variables["tabwidth"] || 4)
682
+ @levelMax = @level + (@deplate.variables['tabwidth'] || 4)
604
683
  else
605
684
  @levelMax = get_level_max
606
685
  end
@@ -624,7 +703,17 @@ class Deplate::List < Deplate::Element
624
703
  end
625
704
  end
626
705
 
706
+ def pop(array)
707
+ if @elt.empty?
708
+ array.pop
709
+ else
710
+ @elt.pop
711
+ end
712
+ end
713
+
627
714
  def unify_now(other)
715
+ # if other.exclude?(@deplate.variables['efilter'])
716
+ # Basically, this should happen in Input
628
717
  if other.kind_of?(Deplate::Element::Paragraph)
629
718
  @elt << Deplate::ListItem.new([], other.elt.flatten, @elt.last.listtype,
630
719
  "Paragraph", other.level, other.level,
@@ -733,10 +822,10 @@ end
733
822
 
734
823
  class Deplate::List::Task < Deplate::List
735
824
  register_element
736
- set_rx(/^(([[:blank:]]+)#(([0-9][A-Z]?|[A-Z][0-9]?)[[:blank:]]+(_|x|x?[0-9-]+%?)|(_|x|x?[0-9-]+%?)[[:blank:]]+([0-9][A-Z]?|[A-Z][0-9]?)))[[:blank:]]+(.*)$/)
825
+ set_rx(/^(([[:blank:]]+)#(([0-9][A-Z]?|[A-Z][0-9]?)([[:blank:]]+(_|x|x?[0-9-]+%?))?|(_|x|x?[0-9-]+%?)[[:blank:]]+([0-9][A-Z]?|[A-Z][0-9]?)))[[:blank:]]+(.*)$/)
737
826
  self.listtype = 'Task'
738
827
  def_get :item, lambda {[@itemopts[:priority], @itemopts[:category]].join}
739
- def_get :text, 8
828
+ def_get :text, 9
740
829
 
741
830
  attr_accessor :task
742
831
 
@@ -781,7 +870,7 @@ end
781
870
 
782
871
  class Deplate::Element::Region < Deplate::Element
783
872
  register_element
784
- set_rx(/^(\s*)#([A-Z]([a-z][A-Za-z]*)?)\b(.*)(\<\<(.+)|:)\s*$/)
873
+ set_rx(/^(\s*)#([A-Z]([a-z][A-Za-z]*)?)\b(.*)(\<\<(.*)|:)\s*$/)
785
874
 
786
875
  class_attribute :rxi_indent, 1
787
876
  class_attribute :rxi_name, 2
@@ -797,8 +886,10 @@ class Deplate::Element::Region < Deplate::Element
797
886
  /^(#{get_indent})?#End\s*$/
798
887
  else
799
888
  erx = @match[i]
800
- if erx
889
+ if erx =~ /\S/
801
890
  /^(#{get_indent})?#{Regexp.escape(erx)}\s*$/
891
+ else
892
+ /^\s*$/
802
893
  end
803
894
  end
804
895
  }
@@ -816,12 +907,19 @@ class Deplate::Element::Region < Deplate::Element
816
907
 
817
908
  attr_reader :specified, :regNote, :name
818
909
 
819
- def setup(name=nil)
910
+ def setup(name=nil, args=nil)
820
911
  @multiliner = true
821
912
  @endRx = get_endrx
822
913
  @name = name || get_name
823
914
  begin
824
- @args, @regNote = @deplate.input.parse_args(get_args)
915
+ if args
916
+ @args = args
917
+ @regNote = ''
918
+ else
919
+ @args, @regNote = @deplate.input.parse_args(get_args)
920
+ end
921
+ @args = @args.merge(@deplate.variables["args@#{@name}"] || {})
922
+ Deplate::Region.deprecated_regnote(self, @args, @regNote)
825
923
  region = @deplate.input.regions[@name]
826
924
  unless region
827
925
  if @deplate.formatter.matches?(@name)
@@ -861,7 +959,7 @@ end
861
959
 
862
960
  class Deplate::Element::Command < Deplate::Element
863
961
  register_element
864
- set_rx(/^\s*#([A-Z]+)((\s[^:]+)?(:\s*(.+?)\s*)?)$/)
962
+ set_rx(/^\s*#([A-Z]+)\s*?((\s[^:]+)?(:\s*(.+?)\s*)?)$/)
865
963
  attr :name
866
964
 
867
965
  class << self
@@ -879,6 +977,7 @@ class Deplate::Element::Command < Deplate::Element
879
977
  Deplate::Core.log(['Command', cmd, text], :debug)
880
978
  begin
881
979
  args, text = deplate.input.parse_args(match[2])
980
+ args = args.merge(deplate.variables["args@#{cmd}"] || {})
882
981
  case cmd
883
982
  when 'IF'
884
983
  deplate.switches << !check_switch(deplate, text)
@@ -935,15 +1034,15 @@ class Deplate::Element::Command < Deplate::Element
935
1034
  if text =~ /^\(.*\)$/
936
1035
  text = text[1..-2]
937
1036
  end
938
- m = /^\s*([:]?\w+)\s*((!=~|=~|==|!=)\s*(.+)\s*|!)$/.match(text)
1037
+ m = /^\s*([:]?\w+(\[.+?\])?)\s*((!=~|=~|==|!=)\s*(.+)\s*|!)$/.match(text)
939
1038
  if m
940
1039
  var = m[1]
941
1040
  negate = /^no([A-Z].*)$/.match(var)
942
1041
  if negate
943
1042
  var = negate[1][0..0].downcase + negate[1][1..-1]
944
1043
  end
945
- val = m[4]
946
- op = val ? m[3] : m[2]
1044
+ val = m[5]
1045
+ op = val ? m[4] : m[3]
947
1046
  case val
948
1047
  when 'true'
949
1048
  val = true
@@ -953,8 +1052,17 @@ class Deplate::Element::Command < Deplate::Element
953
1052
  else
954
1053
  val = Deplate::Core.remove_backslashes(val.strip)
955
1054
  end
1055
+ case var
1056
+ when 'fmt'
1057
+ vvar = deplate.formatter.formatter_name
1058
+ else
1059
+ vvar = get_var_or_option(deplate, var)
1060
+ end
1061
+ # if vvar.nil? and val == false
1062
+ # vvar = false
1063
+ # end
956
1064
  if op == '!'
957
- switch = get_var_or_option(deplate, var)
1065
+ switch = vvar
958
1066
  if negate
959
1067
  return !switch
960
1068
  else
@@ -969,12 +1077,7 @@ class Deplate::Element::Command < Deplate::Element
969
1077
  else
970
1078
  raise 'Internal error'
971
1079
  end
972
- case var
973
- when 'fmt'
974
- switch = compare.call(deplate.formatter.formatter_name, val)
975
- else
976
- switch = compare.call(get_var_or_option(deplate, var), val)
977
- end
1080
+ switch = compare.call(vvar, val)
978
1081
  if op[0..0] == '!' or negate
979
1082
  return !switch
980
1083
  else
@@ -990,10 +1093,15 @@ class Deplate::Element::Command < Deplate::Element
990
1093
  end
991
1094
 
992
1095
  def get_var_or_option(deplate, key)
993
- if deplate.variables.has_key?(key)
994
- return deplate.variables[key]
995
- elsif deplate.options.allow.include?(':') && key =~ /^:(.*)$/
996
- return deplate.options.send($1)
1096
+ begin
1097
+ if deplate.options.allow.include?(':') && key =~ /^:(.*)$/
1098
+ return deplate.options.send($1)
1099
+ # elsif deplate.variables.has_key?(key)
1100
+ else
1101
+ return deplate.variables[key]
1102
+ end
1103
+ rescue Exception => e
1104
+ Deplate::Core.log(e, :error)
997
1105
  end
998
1106
  Deplate::Core.log(['Unknown variable or option', key])
999
1107
  return nil
@@ -1111,7 +1219,7 @@ class Deplate::Element::Table < Deplate::Element
1111
1219
  elsif parent
1112
1220
  parent.span_x += 1
1113
1221
  else
1114
- log(["Table: Can't join with left cell", x, y], :error)
1222
+ log(["Table: Cannot join with left cell", x, y], :error)
1115
1223
  end
1116
1224
  when :join_above
1117
1225
  parent = find_parent_cell(x, y, 0, 1)
@@ -1119,7 +1227,7 @@ class Deplate::Element::Table < Deplate::Element
1119
1227
  elsif parent
1120
1228
  parent.span_y += 1
1121
1229
  else
1122
- log(["Table: Can't join with above cell", x, y], :error)
1230
+ log(["Table: Cannot join with above cell", x, y], :error)
1123
1231
  end
1124
1232
  when :ruler, :noruler
1125
1233
  row.is_ruler = true
@@ -1169,7 +1277,7 @@ class Deplate::Element::Table < Deplate::Element
1169
1277
 
1170
1278
  def get_table_args(name)
1171
1279
  args = @args[name]
1172
- args ? args.split(/\s*,\s*/) : []
1280
+ args ? Deplate::Core.split_list(args, nil, nil, @source) : []
1173
1281
  end
1174
1282
 
1175
1283
  def find_parent_cell(x, y, delta_x, delta_y)
@@ -1231,11 +1339,11 @@ class Deplate::Element::Heading < Deplate::Element
1231
1339
  end
1232
1340
 
1233
1341
  def set_instance_top
1234
- ls = @deplate.variables["levelshift"]
1342
+ ls = @deplate.variables['levelshift']
1235
1343
  if ls
1236
1344
  @level += ls.to_i
1237
1345
  end
1238
- @deplate.increase_current_heading(@level)
1346
+ @deplate.increase_current_heading(self, @level)
1239
1347
  super
1240
1348
  end
1241
1349
 
@@ -1292,6 +1400,7 @@ class Deplate::Element::Heading < Deplate::Element
1292
1400
  end
1293
1401
  end
1294
1402
  if rv.is_top_heading?
1403
+ @deplate.output.simulate_reset
1295
1404
  @deplate.options.heading_names[@top_heading_idx] = rv.elt
1296
1405
  if @deplate.variables['subToC']
1297
1406
  args = {'sub' => true, 'plain' => true}
@@ -1449,27 +1558,6 @@ class Deplate::Element::PotentialPageBreak < Deplate::Element
1449
1558
  end
1450
1559
 
1451
1560
 
1452
- # Don't register Paragraph in @@elements -- it's assigned if nothing else
1453
- # matches
1454
- class Deplate::Element::Paragraph < Deplate::Element
1455
- set_formatter :format_paragraph
1456
- set_rx(/^([[:blank:]]*)(.+)[[:blank:]]*$/)
1457
- def_get :level, lambda {get_indent(@match[1]).size}
1458
- def_get :text, lambda {@deplate.options.keep_whitespace ? @match[0] : @match[2]}
1459
-
1460
- class << self
1461
- def from_text(deplate, src, text)
1462
- m = self.rx.match(text)
1463
- self.new(deplate, src, text, m)
1464
- end
1465
- end
1466
-
1467
- def setup
1468
- @multiliner = true
1469
- end
1470
- end
1471
-
1472
-
1473
1561
  class Deplate::Element::Clip < Deplate::BaseElement
1474
1562
  attr_reader :is_template
1475
1563
  # attr_accessor :prototype
@@ -1498,6 +1586,7 @@ class Deplate::Element::Clip < Deplate::BaseElement
1498
1586
 
1499
1587
  def format_clip(invoker, expected)
1500
1588
  unless @elt
1589
+ puts caller[0..10].join("\n")
1501
1590
  log("We shouldn't be here. If you can track down when this happens, please send an example to the author.", :anyway)
1502
1591
  process
1503
1592
  end