deplate 0.7.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (145) hide show
  1. data/AUTHORS.TXT +26 -0
  2. data/CHANGES.TXT +177 -0
  3. data/LICENSE.TXT +340 -0
  4. data/NEWS.TXT +29 -0
  5. data/README.TXT +86 -0
  6. data/TODO.TXT +202 -0
  7. data/VERSION.TXT +1 -0
  8. data/bin/deplate +3 -0
  9. data/bin/deplate.bat +2 -0
  10. data/etc/deplate.ini +361 -0
  11. data/lib/deplate.rb +31 -0
  12. data/lib/deplate/abstract-class.rb +30 -0
  13. data/lib/deplate/builtin.rb +11 -0
  14. data/lib/deplate/cache.rb +59 -0
  15. data/lib/deplate/commands.rb +693 -0
  16. data/lib/deplate/common.rb +335 -0
  17. data/lib/deplate/converter.rb +99 -0
  18. data/lib/deplate/core.rb +2705 -0
  19. data/lib/deplate/css/article.css +545 -0
  20. data/lib/deplate/css/deplate.css +699 -0
  21. data/lib/deplate/css/heading-navbar.css +29 -0
  22. data/lib/deplate/css/layout-deplate-print.css +540 -0
  23. data/lib/deplate/css/layout-deplate.css +764 -0
  24. data/lib/deplate/css/sans-serif.css +160 -0
  25. data/lib/deplate/css/serif-e.css +170 -0
  26. data/lib/deplate/css/serif-rel.css +121 -0
  27. data/lib/deplate/css/serif.css +190 -0
  28. data/lib/deplate/css/slides.css +11 -0
  29. data/lib/deplate/css/tabbar-left.css +91 -0
  30. data/lib/deplate/css/tabbar-right-ie.css +14 -0
  31. data/lib/deplate/css/tabbar-right.css +118 -0
  32. data/lib/deplate/css/tabbar-top.css +64 -0
  33. data/lib/deplate/css/tabbar.css +81 -0
  34. data/lib/deplate/css/text-sans-serif.css +154 -0
  35. data/lib/deplate/css/text-serif.css +175 -0
  36. data/lib/deplate/define.rb +439 -0
  37. data/lib/deplate/docbook.rb +738 -0
  38. data/lib/deplate/elements.rb +1355 -0
  39. data/lib/deplate/etc.rb +199 -0
  40. data/lib/deplate/external.rb +135 -0
  41. data/lib/deplate/fmt/dbk-article-4.1.2.rb +21 -0
  42. data/lib/deplate/fmt/dbk-article.rb +46 -0
  43. data/lib/deplate/fmt/dbk-book.rb +46 -0
  44. data/lib/deplate/fmt/dbk-ref.rb +105 -0
  45. data/lib/deplate/fmt/dbk-slides.rb +47 -0
  46. data/lib/deplate/fmt/dbk-snippet.rb +21 -0
  47. data/lib/deplate/fmt/html-snippet.rb +21 -0
  48. data/lib/deplate/fmt/html.rb +1696 -0
  49. data/lib/deplate/fmt/htmlsite.rb +419 -0
  50. data/lib/deplate/fmt/htmlslides.rb +21 -0
  51. data/lib/deplate/fmt/htmlwebsite.rb +70 -0
  52. data/lib/deplate/fmt/latex-snippet.rb +22 -0
  53. data/lib/deplate/fmt/latex.rb +1242 -0
  54. data/lib/deplate/fmt/php.rb +19 -0
  55. data/lib/deplate/fmt/phpsite.rb +19 -0
  56. data/lib/deplate/fmt/plain.rb +598 -0
  57. data/lib/deplate/fmt/template.rb +34 -0
  58. data/lib/deplate/fmt/xhtml10t.rb +41 -0
  59. data/lib/deplate/formatter-snippet.rb +17 -0
  60. data/lib/deplate/formatter.rb +1210 -0
  61. data/lib/deplate/input.rb +492 -0
  62. data/lib/deplate/input/deplate-headings.rb +48 -0
  63. data/lib/deplate/input/deplate-restricted.rb +70 -0
  64. data/lib/deplate/input/deplate.rb +28 -0
  65. data/lib/deplate/input/rdoc.rb +277 -0
  66. data/lib/deplate/input/template.rb +29 -0
  67. data/lib/deplate/lib/latex/highlight-extra.sty +15 -0
  68. data/lib/deplate/lib/latex/highlight-typical.sty +15 -0
  69. data/lib/deplate/lib/tabmenu.js +146 -0
  70. data/lib/deplate/locale/de.latin1 +708 -0
  71. data/lib/deplate/locale/ru.koi8-r +48 -0
  72. data/lib/deplate/locale/zh_cn.gb2312 +35 -0
  73. data/lib/deplate/macros.rb +639 -0
  74. data/lib/deplate/messages.rb +120 -0
  75. data/lib/deplate/metadata.rb +77 -0
  76. data/lib/deplate/metadata/marshal.rb +24 -0
  77. data/lib/deplate/metadata/xml.rb +42 -0
  78. data/lib/deplate/metadata/yaml.rb +26 -0
  79. data/lib/deplate/mod/anyword.rb +56 -0
  80. data/lib/deplate/mod/babelfish.rb +27 -0
  81. data/lib/deplate/mod/code-gvim.rb +52 -0
  82. data/lib/deplate/mod/code-highlight.rb +91 -0
  83. data/lib/deplate/mod/colored-log.rb +17 -0
  84. data/lib/deplate/mod/de.rb +19 -0
  85. data/lib/deplate/mod/en.rb +17 -0
  86. data/lib/deplate/mod/endnotes.rb +60 -0
  87. data/lib/deplate/mod/fr.rb +46 -0
  88. data/lib/deplate/mod/html-asciimath.rb +40 -0
  89. data/lib/deplate/mod/html-deplate-button.rb +15 -0
  90. data/lib/deplate/mod/html-headings-navbar.rb +39 -0
  91. data/lib/deplate/mod/html-obfuscate-email.rb +47 -0
  92. data/lib/deplate/mod/html-sidebar.rb +232 -0
  93. data/lib/deplate/mod/htmlslides-navbar-fh.rb +32 -0
  94. data/lib/deplate/mod/iconv.rb +35 -0
  95. data/lib/deplate/mod/imgurl.rb +30 -0
  96. data/lib/deplate/mod/inlatex-compound.rb +69 -0
  97. data/lib/deplate/mod/koma.rb +109 -0
  98. data/lib/deplate/mod/latex-emph-table-head.rb +38 -0
  99. data/lib/deplate/mod/latex-styles.rb +461 -0
  100. data/lib/deplate/mod/latex-verbatim-small.rb +29 -0
  101. data/lib/deplate/mod/makefile.rb +194 -0
  102. data/lib/deplate/mod/mark-external-urls.rb +38 -0
  103. data/lib/deplate/mod/markup-1-warn.rb +37 -0
  104. data/lib/deplate/mod/markup-1.rb +41 -0
  105. data/lib/deplate/mod/navbar-png.rb +33 -0
  106. data/lib/deplate/mod/noindent.rb +32 -0
  107. data/lib/deplate/mod/numpara.rb +40 -0
  108. data/lib/deplate/mod/particle-math.rb +34 -0
  109. data/lib/deplate/mod/php-extra.rb +44 -0
  110. data/lib/deplate/mod/pstoedit.rb +71 -0
  111. data/lib/deplate/mod/recode.rb +57 -0
  112. data/lib/deplate/mod/ru_koi8-r.rb +20 -0
  113. data/lib/deplate/mod/smiley.rb +50 -0
  114. data/lib/deplate/mod/soffice.rb +23 -0
  115. data/lib/deplate/mod/symbols-latin1.rb +58 -0
  116. data/lib/deplate/mod/symbols-od-utf-8.rb +16 -0
  117. data/lib/deplate/mod/symbols-plain.rb +58 -0
  118. data/lib/deplate/mod/symbols-sgml.rb +97 -0
  119. data/lib/deplate/mod/symbols-utf-8.rb +81 -0
  120. data/lib/deplate/mod/symbols-xml.rb +34 -0
  121. data/lib/deplate/mod/syntax-region-alt.rb +37 -0
  122. data/lib/deplate/mod/utf8.rb +49 -0
  123. data/lib/deplate/mod/validate-html.rb +35 -0
  124. data/lib/deplate/mod/xmlrpc.rb +233 -0
  125. data/lib/deplate/mod/zh-cn-autospace.rb +108 -0
  126. data/lib/deplate/mod/zh-cn.rb +59 -0
  127. data/lib/deplate/once-method.rb +44 -0
  128. data/lib/deplate/output.rb +249 -0
  129. data/lib/deplate/particles.rb +815 -0
  130. data/lib/deplate/regions.rb +1076 -0
  131. data/lib/deplate/structured.rb +763 -0
  132. data/lib/deplate/template.rb +430 -0
  133. data/lib/deplate/templates/html-doc.html +28 -0
  134. data/lib/deplate/templates/html-left-tabbar-js.html +37 -0
  135. data/lib/deplate/templates/html-left-tabbar.html +31 -0
  136. data/lib/deplate/templates/html-tabbar-right-table.html +43 -0
  137. data/lib/deplate/templates/html-tabbar-right.html +23 -0
  138. data/lib/deplate/templates/html-tabbar-top.html +43 -0
  139. data/lib/deplate/templates/html-tabbar.html +31 -0
  140. data/lib/deplate/wiki-markup.rb +117 -0
  141. data/lib/deplate/xml.rb +109 -0
  142. data/lib/deplate/zh-cn.rb +59 -0
  143. data/lib/ps2ppm.rb +239 -0
  144. data/man/man1/deplate.1 +692 -0
  145. metadata +210 -0
@@ -0,0 +1,430 @@
1
+ # template.rb -- simple templates for deplate
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: 10-Aug-2004.
6
+ # @Last Change: 23-Okt-2005.
7
+ # @Revision: 0.445
8
+ #
9
+ # Description:
10
+ #
11
+ # Usage:
12
+ #
13
+ # TODO:
14
+ #
15
+ # CHANGES:
16
+ #
17
+
18
+ require 'ostruct'
19
+ require 'deplate/formatter'
20
+ require 'deplate/fmt/template'
21
+
22
+
23
+ class Deplate::TemplateError < Exception
24
+ end
25
+
26
+
27
+ class Deplate::Command::Matter < Deplate::Command
28
+ def process
29
+ id = @args["id"] || @accum[0]
30
+ @elt = template_get_content(id)
31
+ if @elt
32
+ return self
33
+ else
34
+ log(["PREMATTER: No content found", id], :error)
35
+ return nil
36
+ end
37
+ end
38
+ end
39
+
40
+ class Deplate::Command::PREMATTER < Deplate::Command::Matter
41
+ @formatter = :fill_in_template
42
+ def template_get_content(arg)
43
+ @deplate.options.template_manager.template_get_content(:pre, arg)
44
+ end
45
+ end
46
+
47
+ class Deplate::Command::POSTMATTER < Deplate::Command::Matter
48
+ @formatter = :fill_in_template
49
+ def template_get_content(arg)
50
+ @deplate.options.template_manager.template_get_content(:post, arg)
51
+ end
52
+ end
53
+
54
+ class Deplate::Command::BODY < Deplate::Command::Matter
55
+ @formatter = :fill_in_template
56
+ def template_get_content(arg)
57
+ @deplate.options.template_manager.template_get_content(:body, arg)
58
+ end
59
+ end
60
+
61
+ class Deplate::Regions::Mingle < Deplate::Region
62
+ @line_cont = false
63
+
64
+ def finish
65
+ finish_accum
66
+ @doc_slot = nil
67
+ @doc_type = nil
68
+ slot = doc_slot
69
+ type = doc_type
70
+ case type
71
+ when "pre", :pre
72
+ array = @deplate.options.content_pre_matter
73
+ when "body", :body
74
+ array = @deplate.options.content_body
75
+ when "post", :post
76
+ array = @deplate.options.content_post_matter
77
+ else
78
+ log("Shouldn't be here", :error)
79
+ end
80
+ if array
81
+ mingle_at(array, @deplate.slot_by_name(slot), @deplate.formatter.join_blocks(@accum))
82
+ end
83
+ return nil
84
+ end
85
+
86
+ def mingle_at(array, slot, text)
87
+ if array[slot]
88
+ array[slot] << text unless array[slot].include?(text)
89
+ else
90
+ array[slot] = [text]
91
+ end
92
+ end
93
+ end
94
+
95
+ class Deplate::DeplateForTemplates < Deplate::Core
96
+ @log_treshhold = 4
97
+ @log_events = []
98
+ end
99
+
100
+ class Deplate::Template
101
+ attr_reader :mingled
102
+
103
+ @@templateKeys = ["pre", "body", "post", "doc", "ARG", "arg", "clip"]
104
+ @@deplate_for_template = nil
105
+ @@deplate_options = {
106
+ :formatter => Deplate::Formatter::Template,
107
+ :onthefly_particles => false,
108
+ :vanilla => true,
109
+ :inherit_options => true,
110
+
111
+ :elements => [
112
+ Deplate::Element::Region,
113
+ Deplate::Element::Command,
114
+ Deplate::Element::Whitespace,
115
+ ],
116
+ :commands => {
117
+ "INC" => Deplate::Command::INC,
118
+ "INCLUDE" => Deplate::Command::INC,
119
+ "GET" => Deplate::Command::GET,
120
+ "ARG" => Deplate::Command::ARG,
121
+ "XARG" => Deplate::Command::XARG,
122
+ "VAL" => Deplate::Command::ARG,
123
+ "XVAL" => Deplate::Command::XARG,
124
+ "DOC" => Deplate::Command::DOC,
125
+ "VAR" => Deplate::Command::DOC,
126
+ "OPT" => Deplate::Command::OPT,
127
+ "PREMATTER" => Deplate::Command::PREMATTER,
128
+ "POSTMATTER" => Deplate::Command::POSTMATTER,
129
+ "BODY" => Deplate::Command::BODY,
130
+ },
131
+ :regions => {
132
+ "Foreach" => Deplate::Regions::Foreach,
133
+ "Mingle" => Deplate::Regions::Mingle,
134
+ "Native" => Deplate::Regions::Native,
135
+ "Ruby" => Deplate::Regions::Ruby,
136
+ "Doc" => Deplate::Regions::Doc,
137
+ "Var" => Deplate::Regions::Doc,
138
+ },
139
+
140
+ :particles => [
141
+ Deplate::Particle::Escaped,
142
+ Deplate::Particle::Macro,
143
+ Deplate::Particle::Whitespace,
144
+ ],
145
+ :macros => {
146
+ "get" => Deplate::Macro::Clip,
147
+ "clip" => Deplate::Macro::Clip,
148
+ "opt" => Deplate::Macro::Opt,
149
+ "arg" => Deplate::Macro::Arg,
150
+ "xarg" => Deplate::Macro::XArg,
151
+ "val" => Deplate::Macro::Arg,
152
+ "xval" => Deplate::Macro::XArg,
153
+ "doc" => Deplate::Macro::Doc,
154
+ "var" => Deplate::Macro::Doc,
155
+ "ruby" => Deplate::Macro::Ruby,
156
+ },
157
+ }
158
+
159
+ class << self
160
+ def deplate_options
161
+ @@deplate_options
162
+ end
163
+ end
164
+
165
+ attr_reader :template, :pre, :body, :post
166
+
167
+ def initialize(args)
168
+ @source = args[:source]
169
+ @template = args[:template]
170
+ @container = args[:container]
171
+ @master = args[:master]
172
+ if @master
173
+ @@deplate_options[:options] = @master.options
174
+ else
175
+ @@deplate_options[:options] = OpenStruct.new
176
+ end
177
+
178
+ if @template
179
+ return
180
+ end
181
+ file = args[:file]
182
+ if file
183
+ if File.exists?(file)
184
+ File.open(file) do |io|
185
+ @template = io.read
186
+ end
187
+ else
188
+ Deplate::DeplateForTemplates.log(["Template not found", file], :error, @source)
189
+ end
190
+ else
191
+ Deplate::DeplateForTemplates.log("No template defined", :error, @source)
192
+ end
193
+ end
194
+
195
+ def fill_in(deplate, args={})
196
+ @deplate = deplate
197
+ @output = args[:output]
198
+ @pre = args[:pre]
199
+ @body = args[:body]
200
+ @post = args[:post]
201
+ @source = args[:source]
202
+ @consumed = {
203
+ :pre => [],
204
+ :body => [],
205
+ :post => [],
206
+ }
207
+ @keep_whitespace = args.has_key?(:keep_whitespace) ? args[:keep_whitespace] : true
208
+ if deplate.variables["template_version"] == "1"
209
+ fill_in_1
210
+ else
211
+ fill_in_2
212
+ end
213
+ end
214
+
215
+ def fill_in_2
216
+ if @@deplate_for_template
217
+ d = @@deplate_for_template
218
+ else
219
+ d = @@deplate_for_template = Deplate::DeplateForTemplates.new("", @@deplate_options)
220
+ end
221
+ keep_whitespace = d.options.keep_whitespace
222
+ master = d.options.master
223
+ template_manager = d.options.template_manager
224
+ begin
225
+ d.reset
226
+ d.variables = @deplate.variables.dup
227
+ d.doc_services = @deplate.doc_services
228
+ d.set_all_clips(@deplate.get_unprocessed_clips)
229
+ d.options.template_manager = self
230
+ d.options.keep_whitespace = @keep_whitespace
231
+ d.options.master = @master
232
+ d.options.content_output = @output
233
+ d.options.content_pre_matter = @pre
234
+ d.options.content_body = @body
235
+ d.options.content_post_matter = @post
236
+ @mingled = {}
237
+ if @source
238
+ ln = @source.begin
239
+ fn = @source.file
240
+ else
241
+ ln = nil
242
+ fn = nil
243
+ end
244
+ rv = [d.printable_strings(@template, ln, fn)]
245
+ return rv
246
+ ensure
247
+ d.options.keep_whitespace = keep_whitespace
248
+ d.options.master = master
249
+ d.options.template_manager = template_manager
250
+ end
251
+ end
252
+
253
+ def fill_in_1
254
+ accum = []
255
+ template = @template
256
+ for key in @@templateKeys
257
+ loop do
258
+ m = send("rx_" + key).match(template)
259
+ if m
260
+ accum << m.pre_match
261
+ template = m.post_match
262
+ begin
263
+ accum << send("process_" + key, m[3])
264
+ rescue Deplate::TemplateError
265
+ Deplate::DeplateForTemplates.log(["Template definition error", m[0]], :error, @source)
266
+ rescue Exception => err
267
+ Deplate::DeplateForTemplates.log(["Template error", m[0], err], :error, @source)
268
+ end
269
+ else
270
+ accum << template
271
+ break
272
+ end
273
+ end
274
+ template = accum.join
275
+ accum = []
276
+ end
277
+
278
+ template.gsub!(/\\([{}])/, "\\1")
279
+ return [template]
280
+ end
281
+
282
+ def template_get_content(type, ranges)
283
+ case type
284
+ when :pre
285
+ content = @pre
286
+ when :post
287
+ content = @post
288
+ when :body
289
+ content = @body
290
+ end
291
+
292
+ acc = []
293
+ cnt = content.dup
294
+ for r in @consumed[type]
295
+ cnt[r] = nil
296
+ end
297
+ add, del = gen_range(ranges)
298
+ if add.empty?
299
+ for i in del
300
+ cnt[i] = nil
301
+ end
302
+ acc = cnt
303
+ else
304
+ @consumed[type] += add
305
+ for i in add
306
+ acc << cnt[i]
307
+ end
308
+ end
309
+
310
+ return acc.flatten.compact.join("\n")
311
+ end
312
+
313
+ def gen_range(string)
314
+ add = []
315
+ del = []
316
+ if string and !string.empty?
317
+ for i in string.split(/\s+/)
318
+ n = i.split(/\.\./).collect do |s|
319
+ negative = s =~ /^-/
320
+ s = s[1..-1] if negative
321
+ unless s =~ /^\d+$/
322
+ s = @deplate.slot_names[s.intern]
323
+ if s == 0
324
+ Deplate::DeplateForTemplates.log("Slot is zero, which is most likely an error", :anyway, @source)
325
+ end
326
+ end
327
+ s = s.to_i
328
+ negative ? -s : s
329
+ end
330
+ a, b, rest = n
331
+ if rest
332
+ Deplate::DeplateForTemplates.log(["Bad range definition", i], :error, @source)
333
+ else
334
+ if b == 0
335
+ b = 100
336
+ end
337
+ if a < 0
338
+ arr = del
339
+ else
340
+ arr = add
341
+ end
342
+ case n.size
343
+ when 1
344
+ arr << a.abs
345
+ when 2
346
+ arr << Range.new(a.abs, b.abs)
347
+ else
348
+ Deplate::DeplateForTemplates.log(["Bad range definition", i], :error, @source)
349
+ end
350
+ end
351
+ end
352
+ end
353
+ return add.compact, del.compact
354
+ end
355
+
356
+
357
+ def rx_pre
358
+ /^[ \t]*#(PREMATTER)(:\s*([^}\s]+)\s*)?$/
359
+ end
360
+ def process_pre(arg)
361
+ template_get_content(@pre, arg)
362
+ end
363
+
364
+ def rx_post
365
+ /^[ \t]*#(POSTMATTER)(:\s*([^}\s]+)\s*)?$/
366
+ end
367
+ def process_post(arg)
368
+ template_get_content(@post, arg)
369
+ end
370
+
371
+ def rx_body
372
+ /^[ \t]*#(BODY)(:\s*([^}\s]+)\s*)?$/
373
+ end
374
+ def process_body(arg)
375
+ template_get_content(@body, arg)
376
+ end
377
+
378
+ def rx_doc
379
+ /\{(doc)(:\s*([^}\s]+)\s*)\}/
380
+ end
381
+ def process_doc(arg)
382
+ if arg
383
+ @deplate.variables[arg]
384
+ else
385
+ raise Deplate::TemplateError.new
386
+ end
387
+ end
388
+
389
+ def rx_ARG
390
+ /^[ \t]*#(ARG)(:\s*([^}\s]+)\s*)?$/
391
+ end
392
+ def process_ARG(arg)
393
+ if arg
394
+ text = @deplate.variables[arg]
395
+ if text
396
+ return @deplate.printable_strings(text, @source.begin, @source.file)
397
+ end
398
+ end
399
+ raise Deplate::TemplateError.new
400
+ end
401
+
402
+ def rx_arg
403
+ /\{(arg)(:\s*([^}\s]+)\s*)\}/
404
+ end
405
+ # alias :process_arg :process_doc
406
+ def process_arg(arg)
407
+ if arg
408
+ text = @deplate.variables[arg]
409
+ if text
410
+ container = @container || Deplate::PseudoContainer.new(@deplate, :source => @source)
411
+ return @deplate.parse_and_format(container, text)
412
+ end
413
+ end
414
+ raise Deplate::TemplateError.new
415
+ end
416
+
417
+ def rx_clip
418
+ /\{(get)(:\s*([^}\s]+)\s*)\}/
419
+ end
420
+ def process_clip(arg)
421
+ if arg
422
+ c = @deplate.get_clip(arg)
423
+ if c
424
+ return c.elt
425
+ end
426
+ end
427
+ raise Deplate::TemplateError.new
428
+ end
429
+ end
430
+
@@ -0,0 +1,28 @@
1
+ #Mingle type=pre slot=css:
2
+ <style type="text/css">
3
+ <!--
4
+ @media screen {
5
+ table.navbar {
6
+ border-left:10px solid #ffdf70;
7
+ background-color: #fff0c0;
8
+ }
9
+ body {
10
+ background-color: #dfdfff;
11
+ }
12
+ }
13
+ -->
14
+ </style>
15
+ #End
16
+ #PREMATTER
17
+
18
+ <div id="tabFrame">
19
+ <div class="tabBodyFrame" style="max-width:650pt; text-align:left">
20
+ <div class="tabBody">
21
+ #BODY: -navbar_top -navbar_bottom
22
+ </div>
23
+ #POSTMATTER: html_pageicons_beg..html_pageicons_end
24
+ </div>
25
+ </div>
26
+
27
+ #POSTMATTER
28
+