deplate 0.7.3 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. data/AUTHORS.TXT +3 -0
  2. data/CHANGES.TXT +248 -175
  3. data/LICENSE.TXT +0 -0
  4. data/NEWS.TXT +28 -24
  5. data/README.TXT +0 -0
  6. data/TODO.TXT +174 -88
  7. data/VERSION.TXT +1 -1
  8. data/bin/deplate +0 -0
  9. data/bin/deplate.bat +0 -0
  10. data/etc/deplate.ini +91 -3
  11. data/lib/action_view/helpers/deplate.rb +45 -0
  12. data/lib/deplate.rb +6 -1
  13. data/lib/deplate/abstract-class.rb +0 -0
  14. data/lib/deplate/bib.rb +576 -0
  15. data/lib/deplate/builtin.rb +0 -0
  16. data/lib/deplate/cache.rb +55 -5
  17. data/lib/deplate/commands.rb +346 -183
  18. data/lib/deplate/common.rb +209 -48
  19. data/lib/deplate/converter.rb +12 -6
  20. data/lib/deplate/core.rb +777 -378
  21. data/lib/deplate/counters.rb +254 -0
  22. data/lib/deplate/css/article.css +4 -3
  23. data/lib/deplate/css/deplate.css +121 -5
  24. data/lib/deplate/css/heading-navbar.css +0 -0
  25. data/lib/deplate/css/layout-deplate-print.css +0 -0
  26. data/lib/deplate/css/layout-deplate.css +0 -0
  27. data/lib/deplate/css/sans-serif.css +0 -0
  28. data/lib/deplate/css/serif-e.css +0 -0
  29. data/lib/deplate/css/serif-rel.css +0 -0
  30. data/lib/deplate/css/serif.css +9 -3
  31. data/lib/deplate/css/slides.css +0 -0
  32. data/lib/deplate/css/tabbar-left.css +0 -0
  33. data/lib/deplate/css/tabbar-right-ie.css +3 -9
  34. data/lib/deplate/css/tabbar-right.css +51 -18
  35. data/lib/deplate/css/tabbar-top.css +7 -1
  36. data/lib/deplate/css/tabbar.css +0 -0
  37. data/lib/deplate/css/text-sans-serif.css +0 -0
  38. data/lib/deplate/css/text-serif.css +0 -0
  39. data/lib/deplate/define.rb +183 -177
  40. data/lib/deplate/deplate-string.rb +82 -0
  41. data/lib/deplate/docbook.rb +236 -128
  42. data/lib/deplate/elements.rb +584 -417
  43. data/lib/deplate/etc.rb +163 -101
  44. data/lib/deplate/external.rb +42 -11
  45. data/lib/deplate/fmt/dbk-article-4.1.2.rb +0 -0
  46. data/lib/deplate/fmt/dbk-article.rb +0 -0
  47. data/lib/deplate/fmt/dbk-book.rb +0 -0
  48. data/lib/deplate/fmt/dbk-ref.rb +3 -3
  49. data/lib/deplate/fmt/dbk-slides.rb +0 -0
  50. data/lib/deplate/fmt/dbk-snippet.rb +0 -0
  51. data/lib/deplate/fmt/html-snippet.rb +0 -0
  52. data/lib/deplate/fmt/html.rb +783 -550
  53. data/lib/deplate/fmt/htmlsite.rb +192 -199
  54. data/lib/deplate/fmt/htmlslides.rb +0 -0
  55. data/lib/deplate/fmt/htmlwebsite.rb +3 -3
  56. data/lib/deplate/fmt/latex-snippet.rb +0 -0
  57. data/lib/deplate/fmt/latex.rb +242 -83
  58. data/lib/deplate/fmt/null.rb +32 -0
  59. data/lib/deplate/fmt/php.rb +4 -4
  60. data/lib/deplate/fmt/phpsite.rb +6 -5
  61. data/lib/deplate/fmt/plain.rb +160 -106
  62. data/lib/deplate/fmt/template.rb +0 -0
  63. data/lib/deplate/fmt/xhtml10t.rb +0 -0
  64. data/lib/deplate/formatter-snippet.rb +0 -0
  65. data/lib/deplate/formatter.rb +613 -301
  66. data/lib/deplate/input.rb +202 -142
  67. data/lib/deplate/input/deplate-headings.rb +4 -6
  68. data/lib/deplate/input/deplate-restricted.rb +15 -9
  69. data/lib/deplate/input/deplate.rb +2 -4
  70. data/lib/deplate/input/rdoc.rb +39 -38
  71. data/lib/deplate/input/template.rb +0 -0
  72. data/lib/deplate/lib/Makefile.config +29 -0
  73. data/lib/deplate/lib/latex/deplate.sty +54 -0
  74. data/lib/deplate/lib/latex/highlight-extra.sty +0 -0
  75. data/lib/deplate/lib/latex/highlight-typical.sty +0 -0
  76. data/lib/deplate/lib/php/page-comment.inc.php +216 -0
  77. data/lib/deplate/lib/tabmenu.js +0 -0
  78. data/lib/deplate/locale/de.latin1 +155 -17
  79. data/lib/deplate/locale/ru.koi8-r +0 -0
  80. data/lib/deplate/locale/zh_cn.gb2312 +0 -0
  81. data/lib/deplate/macros.rb +133 -82
  82. data/lib/deplate/messages.rb +6 -4
  83. data/lib/deplate/metadata.rb +0 -0
  84. data/lib/deplate/metadata/marshal.rb +0 -0
  85. data/lib/deplate/metadata/xml.rb +0 -0
  86. data/lib/deplate/metadata/yaml.rb +0 -0
  87. data/lib/deplate/mod/anyword.rb +3 -3
  88. data/lib/deplate/mod/babelfish.rb +4 -4
  89. data/lib/deplate/mod/code-gvim.rb +8 -4
  90. data/lib/deplate/mod/code-highlight.rb +3 -3
  91. data/lib/deplate/mod/colored-log.rb +0 -0
  92. data/lib/deplate/mod/de.rb +2 -2
  93. data/lib/deplate/mod/en.rb +0 -0
  94. data/lib/deplate/mod/endnotes.rb +0 -0
  95. data/lib/deplate/mod/fr.rb +0 -0
  96. data/lib/deplate/mod/html-asciimath.rb +0 -0
  97. data/lib/deplate/mod/html-deplate-button.rb +0 -0
  98. data/lib/deplate/mod/html-headings-navbar.rb +5 -13
  99. data/lib/deplate/mod/html-jsmath.rb +39 -0
  100. data/lib/deplate/mod/html-obfuscate-email.rb +3 -3
  101. data/lib/deplate/mod/html-sidebar.rb +0 -0
  102. data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -3
  103. data/lib/deplate/mod/iconv.rb +0 -0
  104. data/lib/deplate/mod/imgurl.rb +4 -4
  105. data/lib/deplate/mod/inlatex-compound.rb +7 -10
  106. data/lib/deplate/mod/koma.rb +0 -0
  107. data/lib/deplate/mod/latex-emph-table-head.rb +0 -0
  108. data/lib/deplate/mod/latex-styles.rb +7 -4
  109. data/lib/deplate/mod/latex-verbatim-small.rb +0 -0
  110. data/lib/deplate/mod/makefile.rb +23 -7
  111. data/lib/deplate/mod/mark-external-urls.rb +3 -3
  112. data/lib/deplate/mod/markup-1-warn.rb +10 -10
  113. data/lib/deplate/mod/markup-1.rb +0 -0
  114. data/lib/deplate/mod/navbar-png.rb +24 -8
  115. data/lib/deplate/mod/noindent.rb +0 -0
  116. data/lib/deplate/mod/numpara.rb +0 -0
  117. data/lib/deplate/mod/particle-math.rb +4 -4
  118. data/lib/deplate/mod/php-extra.rb +46 -6
  119. data/lib/deplate/mod/pstoedit.rb +0 -0
  120. data/lib/deplate/mod/recode.rb +0 -0
  121. data/lib/deplate/mod/ru_koi8-r.rb +0 -0
  122. data/lib/deplate/mod/smart-dash.rb +26 -0
  123. data/lib/deplate/mod/smiley.rb +69 -7
  124. data/lib/deplate/mod/soffice.rb +0 -0
  125. data/lib/deplate/mod/symbols-latin1.rb +14 -23
  126. data/lib/deplate/mod/symbols-od-utf-8.rb +5 -3
  127. data/lib/deplate/mod/symbols-plain.rb +5 -35
  128. data/lib/deplate/mod/symbols-sgml.rb +8 -9
  129. data/lib/deplate/mod/symbols-utf-8.rb +8 -9
  130. data/lib/deplate/mod/symbols-xml.rb +5 -9
  131. data/lib/deplate/mod/syntax-region-alt.rb +5 -5
  132. data/lib/deplate/mod/utf8.rb +0 -0
  133. data/lib/deplate/mod/validate-html.rb +0 -0
  134. data/lib/deplate/mod/xmlrpc.rb +0 -0
  135. data/lib/deplate/mod/zh-cn-autospace.rb +18 -20
  136. data/lib/deplate/mod/zh-cn.rb +4 -6
  137. data/lib/deplate/nukumi2.rb +71 -0
  138. data/lib/deplate/once-method.rb +0 -0
  139. data/lib/deplate/output.rb +19 -21
  140. data/lib/deplate/particles.rb +178 -116
  141. data/lib/deplate/regions.rb +99 -58
  142. data/lib/deplate/skeletons.rb +122 -0
  143. data/lib/deplate/structured.rb +164 -106
  144. data/lib/deplate/template.rb +67 -43
  145. data/lib/deplate/templates/html-doc.html +0 -0
  146. data/lib/deplate/templates/html-left-tabbar-js.html +0 -0
  147. data/lib/deplate/templates/html-left-tabbar.html +0 -0
  148. data/lib/deplate/templates/html-tabbar-right-pcomments.php +22 -0
  149. data/lib/deplate/templates/html-tabbar-right-step.html +24 -0
  150. data/lib/deplate/templates/html-tabbar-right-table.html +0 -0
  151. data/lib/deplate/templates/html-tabbar-right.html +2 -4
  152. data/lib/deplate/templates/html-tabbar-top.html +0 -9
  153. data/lib/deplate/templates/html-tabbar.html +0 -0
  154. data/lib/deplate/variables.rb +127 -0
  155. data/lib/deplate/wiki-markup.rb +99 -33
  156. data/lib/deplate/xml.rb +18 -18
  157. data/lib/deplate/zh-cn.rb +0 -0
  158. data/lib/ps2ppm.rb +0 -0
  159. data/man/man1/deplate.1 +564 -474
  160. metadata +201 -186
@@ -0,0 +1,32 @@
1
+ # null.rb
2
+ # @Author: Thomas Link (samul AT web.de)
3
+ # @Website: http://deplate.sf.net/
4
+ # @License: GPL (see http://www.gnu.org/licenses/gpl.txt)
5
+ # @Created: 17-M�r-2004.
6
+ # @Last Change: 08-Jan-2006.
7
+ # @Revision: 0.3747
8
+
9
+ require 'deplate/formatter'
10
+
11
+ class Deplate::Formatter::NULL < Deplate::Formatter
12
+ self.myname = 'null'
13
+ self.rx = /null?/i
14
+
15
+ def format_particle(agent, invoker, *args)
16
+ ''
17
+ end
18
+
19
+ def format_element(agent, invoker, *args)
20
+ ''
21
+ end
22
+
23
+ def output(invoker, *body)
24
+ end
25
+ end
26
+
27
+
28
+ class Deplate::Core
29
+ def body_write
30
+ end
31
+ end
32
+
@@ -3,8 +3,8 @@
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: 23-Okt-2005.
7
- # @Revision: 0.911
6
+ # @Last Change: 21-Apr-2006.
7
+ # @Revision: 0.914
8
8
 
9
9
  require 'deplate/fmt/html'
10
10
  require 'deplate/mod/php-extra'
@@ -12,8 +12,8 @@ require 'deplate/mod/php-extra'
12
12
  # A variant of the html-formatter that is suited for php output.
13
13
 
14
14
  class Deplate::Formatter::Php < Deplate::Formatter::HTML
15
- self.myname = "php"
15
+ self.myname = 'php'
16
16
  self.rx = /php[0-9]?/i
17
- self.suffix = ".php"
17
+ self.suffix = '.php'
18
18
  end
19
19
 
@@ -3,8 +3,8 @@
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: 29-Okt-2005.
7
- # @Revision: 0.916
6
+ # @Last Change: 21-Apr-2006.
7
+ # @Revision: 0.918
8
8
 
9
9
  require 'deplate/fmt/htmlsite'
10
10
  require 'deplate/mod/php-extra'
@@ -12,8 +12,9 @@ require 'deplate/mod/php-extra'
12
12
  # A variant of the htmlsite-formatter that is suited for php output.
13
13
 
14
14
  class Deplate::Formatter::PhpSite < Deplate::Formatter::HTML_Site
15
- self.myname = "phpsite"
16
- self.rx = /php[0-9]?/i
17
- self.suffix = ".php"
15
+ self.myname = 'phpsite'
16
+ self.related = ['php']
17
+ self.rx = /php[0-9]?/i
18
+ self.suffix = '.php'
18
19
  end
19
20
 
@@ -3,8 +3,8 @@
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: 28-Okt-2005.
7
- # @Revision: 0.3450
6
+ # @Last Change: 05-Jun-2006.
7
+ # @Revision: 0.3577
8
8
 
9
9
  require "deplate/formatter"
10
10
 
@@ -13,7 +13,7 @@ require "deplate/formatter"
13
13
  class Deplate::Formatter::Plain < Deplate::Formatter
14
14
  self.myname = "plain"
15
15
  self.rx = /plain/i
16
- self.suffix = ".txt"
16
+ self.suffix = '.text'
17
17
 
18
18
  self.label_mode = :delegate
19
19
  self.label_delegate = []
@@ -21,6 +21,7 @@ class Deplate::Formatter::Plain < Deplate::Formatter
21
21
 
22
22
  def initialize(deplate, args)
23
23
  super
24
+ @color = deplate.variables['ansiColor'] && defined?(Deplate::Color)
24
25
  @list_counter = {}
25
26
  end
26
27
 
@@ -29,18 +30,17 @@ class Deplate::Formatter::Plain < Deplate::Formatter
29
30
  end
30
31
 
31
32
  def format_label(invoker, mode=nil, label=nil)
32
- ""
33
+ ''
33
34
  end
34
35
 
35
36
  def format_figure(invoker, inline=false, elt=nil)
36
- if elt
37
- if inline
38
- elt
39
- else
40
- "\n#{elt}\n"
41
- end
42
- elsif inline
43
- include_image(invoker.elt, invoker.args)
37
+ elt ||= invoker.elt
38
+ unless elt.kind_of?(String)
39
+ invoker.log(['Unexpected argument', elt.class], :error)
40
+ elt = elt.to_s
41
+ end
42
+ if inline or invoker.args['inline']
43
+ include_image(invoker, elt, invoker.args, true)
44
44
  else
45
45
  acc = []
46
46
  fig = @deplate.msg("Figure")
@@ -55,7 +55,7 @@ class Deplate::Formatter::Plain < Deplate::Formatter
55
55
  if caption and capAbove
56
56
  acc << cap
57
57
  end
58
- acc << include_image(invoker.elt, invoker.args)
58
+ acc << include_image(invoker, elt, invoker.args)
59
59
  if caption and !capAbove
60
60
  acc << cap
61
61
  end
@@ -64,10 +64,26 @@ class Deplate::Formatter::Plain < Deplate::Formatter
64
64
  end
65
65
  end
66
66
 
67
- def include_image(file, args, inline=false)
68
- # alt = args["alt"]
69
- # alt ? "[#{alt}]" : "[IMG:#{file}]"
70
- "[#{args["alt"] || file}]"
67
+ def include_image(invoker, file, args, inline=false)
68
+ file = args['file'] if args['file']
69
+ if inline or !@deplate.variables['asciiArt']
70
+ return "[#{args["alt"] || @deplate.variables['imgAlt'] || file}]"
71
+ else
72
+ file = use_image_filename(file, args)
73
+ if File.exist?(file)
74
+ acc = [file]
75
+ args[:deplate] ||= @deplate
76
+ # case @deplate.variables['asciiArt']
77
+ # else
78
+ return Deplate::External.jave(invoker, file, args)
79
+ # end
80
+ end
81
+ end
82
+ end
83
+
84
+ def image_suffixes
85
+ # [".png", ".jpeg", ".jpg", ".gif", ".bmp"]
86
+ ['.jpeg', '.jpg', '.gif', '.bmp']
71
87
  end
72
88
 
73
89
  alias :format_IMG :format_figure
@@ -204,12 +220,13 @@ class Deplate::Formatter::Plain < Deplate::Formatter
204
220
  elt = [invoker.level_as_string, elt].join(" ")
205
221
  end
206
222
  if ul
207
- [nil, elt, ul * elt.size, nil].join("\n")
223
+ elt = [nil, elt, ul * elt.size, nil].join("\n")
208
224
  # [elt, ul * elt.size].join("\n")
209
- else
210
- # "\n#{elt}\n"
211
- elt
212
225
  end
226
+ if @color
227
+ elt = Deplate::Color.bold(elt)
228
+ end
229
+ elt
213
230
  end
214
231
 
215
232
  def format_list(invoker)
@@ -230,17 +247,18 @@ class Deplate::Formatter::Plain < Deplate::Formatter
230
247
  LIST_ITEMIZE_MARKERS = ['*', '*', '+', '+', '-', '-']
231
248
  LIST_ITEMIZE_MARKERS_N = LIST_ITEMIZE_MARKERS.size
232
249
  # <+TBD+>Alphabethic lists give strange counters if the index passes beyond 'z'
233
- def format_list_item(invoker, type, level, item, html_class=nil, explicit=false)
250
+ def format_list_item(invoker, type, level, item, args={})
234
251
  # indent = format_indent(level, true)
235
- indent = " " * level
252
+ indent = " " * level
253
+ explicit = args[:explicit]
236
254
  case type
237
- when "Numbered"
255
+ when "Ordered"
238
256
  if explicit or item.explicit and item.item
239
257
  # and !item.item.empty?
240
258
  i = item.item
241
259
  else
242
260
  i = @list_counter[type][-1] += 1
243
- case list_subtype(type, item.item)
261
+ case list_subtype(type, item)
244
262
  when "a"
245
263
  i = "%c" % (96 + i)
246
264
  when "A"
@@ -264,16 +282,34 @@ class Deplate::Formatter::Plain < Deplate::Formatter
264
282
  i += " "
265
283
  end
266
284
  return wrap_text([indent, i, item.body].join, :hanging => 2), :none
285
+ when 'Task'
286
+ pri = item.opts[:priority]
287
+ cat = item.opts[:category]
288
+ done = item.opts[:done] ? 'done' : nil
289
+ due = item.opts[:due]
290
+ task = [cat, pri]
291
+ task << " #{due}" if due
292
+ body = ['{', task, '} ', item.body].join
293
+ body = indent_text(wrap_text(body),
294
+ :mult => level,
295
+ :hanging => true,
296
+ :indent => indent
297
+ )
298
+ return body, :none
267
299
  when "Description"
268
300
  accum = [indent, item.item, "\n"]
269
301
  accum << indent << " " << item.body if item.body
270
302
  return wrap_text(accum.join), :none
271
303
  when "Paragraph"
304
+ t = "\n" + wrap_text(indent + item.body)
305
+ # t = wrap_text(indent + item.body)
306
+ return t, nil
307
+ when 'Container'
272
308
  # t = "\n" + wrap_text(indent + item.body)
273
- t = wrap_text(indent + item.body)
309
+ t = "\n" + item.body
274
310
  return t, nil
275
311
  else
276
- raise "Unknown list type: #{item.inspect}"
312
+ invoker.log(['Unknown list type', type], :error)
277
313
  end
278
314
  end
279
315
 
@@ -284,12 +320,14 @@ class Deplate::Formatter::Plain < Deplate::Formatter
284
320
 
285
321
  def format_abstract(invoker)
286
322
  text = invoker.elt
287
- wrap_text(" " + text) + "\n"
323
+ # wrap_text(" " + text) + "\n"
324
+ indent_text(text) + "\n"
288
325
  end
289
326
 
290
327
  def format_quote(invoker)
291
328
  text = invoker.elt
292
- wrap_text("> " + text, :indent => "> ") + "\n"
329
+ # wrap_text("> " + text, :indent => "> ") + "\n"
330
+ indent_text(text, :indent => '> ') + "\n"
293
331
  end
294
332
 
295
333
  def format_title(invoker)
@@ -317,11 +355,18 @@ class Deplate::Formatter::Plain < Deplate::Formatter
317
355
  nil
318
356
  end
319
357
 
320
- def format_emphasize(invoker, text)
321
- text
358
+ def format_emphasize(invoker, text=nil)
359
+ text ||= invoker.elt || invoker.text
360
+ if @color
361
+ # Deplate::Color.italic(text)
362
+ Deplate::Color.bold(text)
363
+ else
364
+ text
365
+ end
322
366
  end
323
367
 
324
- def format_code(invoker, text)
368
+ def format_code(invoker, text=nil)
369
+ text ||= invoker.elt || invoker.text
325
370
  text
326
371
  end
327
372
 
@@ -330,13 +375,21 @@ class Deplate::Formatter::Plain < Deplate::Formatter
330
375
  idx = @deplate.footnote_last_idx += 1
331
376
  fn = "[#{idx}]"
332
377
  # invoker.container.postponed_format << Proc.new do |container|
333
- output_at(:body, :footnotes, %{#{fn} #{Deplate::HyperLink.url_anchor(dest, anchor)}})
378
+ hlink = Deplate::HyperLink.url_anchor(dest, anchor)
379
+ if @color
380
+ hlink = Deplate::Color.underline(hlink)
381
+ end
382
+ output_at(:body, :footnotes, %{#{fn} #{hlink}})
334
383
  # end
335
384
  if name and !(name.empty?)
336
- [name, fn].join
385
+ rv = [name, fn].join
337
386
  else
338
- fn
387
+ rv = fn
339
388
  end
389
+ if @color
390
+ rv = Deplate::Color.underline(rv)
391
+ end
392
+ rv
340
393
  end
341
394
 
342
395
  alias :format_wiki :format_url
@@ -354,39 +407,43 @@ class Deplate::Formatter::Plain < Deplate::Formatter
354
407
  end
355
408
 
356
409
  def format_index(invoker, idx)
357
- ""
410
+ ''
358
411
  end
359
412
 
360
413
  def format_footnote(invoker)
361
414
  elt = invoker.elt
362
- if elt and elt.elt and elt.elt.consumed
363
- fn = elt.elt
364
- lab = fn.label
415
+ if elt and elt.elt and elt.fn_consumed
416
+ lab = elt.fn_label
365
417
  if !@deplate.footnotes_used.include?(lab)
366
- idx = @deplate.footnote_last_idx +=1
367
- lab = "[#{idx}]"
368
- fn.n = idx
369
- fn.label = lab
418
+ idx = @deplate.footnote_last_idx +=1
419
+ lab = "[#{idx}]"
420
+ elt.fn_n = idx
421
+ elt.fn_label = lab
370
422
  @deplate.footnotes_used << lab
371
- text = wrap_text("#{lab} #{fn.body}", :hanging => 4)
423
+ # text = wrap_text("#{lab} #{elt.format_current}", :hanging => 4)
424
+ text = [
425
+ lab,
426
+ indent_text(elt.format_current, :indent => '', :hanging => 4)
427
+ ].join(' ')
372
428
  # invoker.container.postponed_format << Proc.new do |container|
373
429
  output_at(:body, :footnotes, text)
374
430
  # end
375
431
  end
376
432
  end
377
- return fn.label
433
+ return elt.fn_label
378
434
  end
379
435
 
380
436
  def format_ref(invoker)
381
- " " + @deplate.labels[invoker.text]
437
+ prefix = invoker.args['prefix'] || ' '
438
+ prefix + @deplate.labels[invoker.text]
382
439
  end
383
440
 
384
441
  def format_break(invoker)
385
- "-" * 72
442
+ '-' * 72
386
443
  end
387
444
 
388
445
  def format_anchor(invoker)
389
- ""
446
+ ''
390
447
  end
391
448
 
392
449
  def format_paragraph(invoker)
@@ -456,64 +513,61 @@ class Deplate::Formatter::Plain < Deplate::Formatter
456
513
  return ""
457
514
  end
458
515
 
459
- def format_list_of_contents(invoker)
460
- format_list_of(invoker, "Table of Contents", @deplate.table_of_contents, "hd",
461
- :flat => false)
516
+ def format_list_of_toc(invoker)
517
+ format_list_of(invoker,
518
+ :title => "Table of Contents",
519
+ :prefix => "hd",
520
+ :listing => 'toc', :flat => false)
462
521
  end
463
522
 
464
- alias :format_list_of_toc :format_list_of_contents
465
-
466
523
  def format_list_of_minitoc(invoker)
467
- data = @deplate.table_of_contents.find_all {|e| e.level == 1}
468
- format_list_of(invoker, "Contents", data, "hd",
469
- :flat => false) do |hd|
524
+ data = @deplate.options.listings.get('toc').find_all {|e| e.level == 1}
525
+ format_list_of(invoker,
526
+ :title => "Contents",
527
+ :prefix => "hd",
528
+ :data => data, :flat => false,
529
+ :img => @variables["navGif"],
530
+ :html_class => "minitoc") do |hd|
470
531
  hd.args["shortcaption"] || hd.args["id"]
471
532
  end
472
533
  end
473
534
 
474
- def format_list_of_tables(invoker)
475
- format_list_of(invoker, "List of Tables", @deplate.table_of_tables, "tab",
476
- :flat => true)
535
+ def format_list_of_lot(invoker)
536
+ format_list_of(invoker,
537
+ :title => "List of Tables",
538
+ :prefix => "tab",
539
+ :listing => 'lot', :flat => true)
477
540
  end
478
541
 
479
- def format_list_of_figures(invoker)
480
- format_list_of(invoker, "List of Figures", @deplate.table_of_figures, "fig",
481
- :flat => true)
542
+ def format_list_of_lof(invoker)
543
+ format_list_of(invoker,
544
+ :title => "List of Figures",
545
+ :prefix => "fig",
546
+ :listing => 'lof', :flat => true)
482
547
  end
483
548
 
484
549
  def format_list_of_index(invoker)
485
550
  format_the_index(invoker, "Index", @deplate.index, "idx", true)
486
551
  end
487
552
 
488
- def format_list_of(invoker, name, data, prefix, other_args)
489
- args = invoker.args
490
- flat = other_args[:flat] || false
491
- name = args["title"] || name
492
- id = name.gsub(/\W/, "_")
493
-
494
- acc = []
495
- unless args["plain"] || args["noTitle"]
496
- acc << format_heading(nil, 1, @deplate.msg(name))
497
- end
498
- ll = 1
499
- accData = []
500
- for hd in data
501
- unless hd.nil? or hd.args["noList"]
502
- l = if flat then 1 else hd.level end
503
- v = nil
504
- if block_given?
505
- v = yield(hd)
506
- end
507
- unless v
508
- v = if hd.caption then hd.caption.elt else v = hd.elt.dup end
509
- end
510
- v = [hd.level_as_string, v].join(" ") unless hd.plain_caption?
511
- s = Deplate::ListItem.new("", v, "Itemize", "Itemize", l, 0, true)
512
- accData << s
513
- end
553
+ def listing_prematter(invoker, args, id)
554
+ nil
555
+ end
556
+
557
+ def listing_postmatter(invoker, args)
558
+ ''
559
+ end
560
+
561
+ def listing_title(invoker, args, name)
562
+ if name
563
+ format_heading(nil, 1, @deplate.msg(name))
514
564
  end
515
- acc << printable_list(invoker, accData) << ""
516
- join_blocks(acc)
565
+ end
566
+
567
+ def listing_item(invoker, args, prefix, title, heading, level, other_args)
568
+ v = [heading.level_as_string, title].join(' ') unless heading.plain_caption?
569
+ s = Deplate::ListItem.new('', v, 'Itemize', 'Itemize', level, 0, true)
570
+ s
517
571
  end
518
572
 
519
573
  def format_the_index(invoker, name, data, prefix="", flat=false, other_args={})
@@ -536,33 +590,33 @@ class Deplate::Formatter::Plain < Deplate::Formatter
536
590
  f = i.file || invoker.output_file_name(:level_as_string => i.level_as_string,
537
591
  :relative => invoker)
538
592
  if f == ff
539
- f = ""
593
+ f = ''
540
594
  l = i.level_as_string
541
595
  if l and !l.empty?
542
596
  t = l
543
597
  elsif @deplate.options.multi_file_output
544
- t = "<>"
598
+ t = '<>'
545
599
  else
546
- t = "I"
600
+ t = 'I'
547
601
  end
548
602
  else
549
- t = @deplate.file_with_suffix(f, "", true)
603
+ t = @deplate.file_with_suffix(f, '', true)
550
604
  end
551
605
  acc << t
552
606
  else
553
- log(["Index: Neither file nor level defined: dropping", i.label], :error)
607
+ invoker.log(['Index: Neither file nor level defined: dropping', i.label], :error)
554
608
  end
555
609
  end
556
- s = Deplate::ListItem.new(plain_text(n), acc.join(", "))
557
- ot, et = format_list_item(invoker, "Description", 0, s)
610
+ s = Deplate::ListItem.new(plain_text(n), acc.join(', '))
611
+ ot, et = format_list_item(invoker, 'Description', 0, s)
558
612
  accum << ot
559
613
  accum << et unless et == :none
560
614
  end
561
- accum << format_list_env(invoker, "Description", 0, :close)
615
+ accum << format_list_env(invoker, 'Description', 0, :close)
562
616
  acc = []
563
- acc << chars.join(" ")
617
+ acc << chars.join(' ')
564
618
  acc << accum.compact.join("\n")
565
- acc << ""
619
+ acc << ''
566
620
  join_blocks(acc)
567
621
  end
568
622
  end
@@ -570,9 +624,9 @@ end
570
624
 
571
625
  class Deplate::Command::MAKEBIB
572
626
  accumulate_pre(self, Deplate::Formatter::Plain) do |src, array, deplate, text, match, args, cmd|
573
- unless args["plain"]
574
- n = deplate.msg("Bibliography")
575
- m = [nil, "*", n]
627
+ unless args['plain']
628
+ n = deplate.msg('Bibliography')
629
+ m = [nil, '*', n]
576
630
  o = Deplate::Element::Heading.new(deplate, src, n, m).finish
577
631
  o.update_options(args)
578
632
  deplate.options.html_makebib_heading = o
@@ -584,9 +638,9 @@ end
584
638
 
585
639
  class Deplate::Command::LIST
586
640
  accumulate_pre(self, Deplate::Formatter::Plain) do |src, array, deplate, text, match, args, cmd|
587
- if text == "index" and !args["plain"] and !args["noTitle"]
588
- n = deplate.msg("Index")
589
- m = [nil, "*", n]
641
+ if text == 'index' and !args['plain'] and !args['noTitle']
642
+ n = deplate.msg('Index')
643
+ m = [nil, '*', n]
590
644
  h = Deplate::Element::Heading.new(deplate, src, n, m).finish
591
645
  h.update_options(args)
592
646
  array << h