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,48 @@
1
+ # @Author: Maxim Komar (komar from ukr.net)
2
+ # @Website: http://komar.org.ua
3
+
4
+ Bibliography
5
+ ������������
6
+
7
+ Figure
8
+ �������
9
+
10
+ Footnotes
11
+ ������
12
+
13
+ Index
14
+ ���������� ���������
15
+
16
+ List of Figures
17
+ ������ ��������
18
+
19
+ List of Tables
20
+ ������ ������
21
+
22
+ p.\\
23
+ ���.\\
24
+
25
+ Table of Contents
26
+ ������� ����������
27
+
28
+ Contents
29
+ ����������
30
+
31
+ Table
32
+ �������
33
+
34
+ Notes
35
+ ���������
36
+
37
+ Note
38
+ ���������
39
+
40
+ Elaborate
41
+ ���������
42
+
43
+ Discussion
44
+ ���������
45
+
46
+ Important
47
+ �����
48
+
@@ -0,0 +1,35 @@
1
+ # Localization by
2
+ # Author: Jjgod Jiang (gzjjgod@21cn.com)
3
+ # Website: http://www.niub.com/jjgod/
4
+ # this assumes gb2312 encoding
5
+
6
+ Bibliography
7
+ �����
8
+
9
+ Figure
10
+ ��ͼ
11
+
12
+ Footnotes
13
+ ��ע
14
+
15
+ Index
16
+ ����
17
+
18
+ List of Figures
19
+ ��ͼ�б�
20
+
21
+ List of Tables
22
+ �����б�
23
+
24
+ p.\\
25
+ p.\\
26
+
27
+ Table of Contents
28
+ Ŀ¼
29
+
30
+ Contents
31
+ ����
32
+
33
+ Table
34
+ ����
35
+
@@ -0,0 +1,639 @@
1
+ # macros.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: 25-M�r-2004.
6
+ # @Last Change: 01-Nov-2005.
7
+ # @Revision: 0.1104
8
+
9
+ require 'forwardable'
10
+
11
+ # Deplate::Macro is responsible for dealing with macros in curly braces
12
+ # like {fn: foo} or {cite p=42: bar}.
13
+
14
+ class Deplate::Macro < Deplate::BaseParticle
15
+ extend Forwardable
16
+
17
+ @@macros = {}
18
+
19
+ class << self
20
+ def macros
21
+ @@macros
22
+ end
23
+
24
+ def register_as(name, c=self)
25
+ @@macros[name] = c
26
+ end
27
+
28
+ def exec(deplate, container, context, cmd, *args)
29
+ c = deplate.input.macros[cmd]
30
+ if c
31
+ begin
32
+ return c.new(deplate, container, context, *args)
33
+ rescue Exception => e
34
+ puts e.backtrace[0..10].join("\n")
35
+ puts "Internal error when initializing " + c.name
36
+ raise e
37
+ end
38
+ else
39
+ container.log(["Unknown macro", cmd, args.inspect], :unknown_macro)
40
+ end
41
+ end
42
+ end
43
+
44
+ def initialize(deplate, container, context, args, alt, text)
45
+ super(deplate,
46
+ :container => container,
47
+ :source => container.source,
48
+ :args => args
49
+ )
50
+ @args[:self] ||= self
51
+ @context = context
52
+ @alt = alt
53
+ update_styles
54
+ setup(text)
55
+ end
56
+
57
+ # def_delegator(:@container, :out)
58
+ #
59
+ def log(*args)
60
+ @container.log(*args)
61
+ end
62
+
63
+ def setup(text)
64
+ end
65
+
66
+ def process_elt
67
+ @elt.collect!{|e| e.process; e.elt}
68
+ @elt = @elt.compact
69
+ end
70
+
71
+ def join_elt(sep="")
72
+ process_elt
73
+ if block_given?
74
+ yield
75
+ end
76
+ @elt = @elt.join(sep)
77
+ end
78
+
79
+ # #process gives a macro the opportunity to do something after the whole
80
+ # file was read in and parsed. It returns the ready format result.
81
+ def process
82
+ if @elt
83
+ return join_elt
84
+ elsif @text
85
+ return @text
86
+ else
87
+ return ""
88
+ end
89
+ end
90
+ end
91
+
92
+
93
+ class Deplate::Macro::Unknown < Deplate::Macro
94
+ def setup(text)
95
+ text = @args[:match][0][1..-2]
96
+ # @elt = plain_text(text)
97
+ @elt = @deplate.parse(@container, text)
98
+ end
99
+
100
+ def process
101
+ join_elt
102
+ return format_particle(:format_unknown_macro, self)
103
+ end
104
+ end
105
+
106
+
107
+ class Deplate::Macro::Footnote < Deplate::Macro
108
+ register_as 'fn'
109
+ attr_reader :fnId
110
+
111
+ # Quack like Deplate::Region
112
+ attr_reader :accum, :regNote, :label, :level, :caption, :captionOptions
113
+
114
+ def setup(text)
115
+ if text
116
+ @fnId = @args["id"]
117
+ if @fnId and text and !text.empty?
118
+ @regNote = @fnId
119
+ @accum = text
120
+ # @level = @container.level
121
+ fn = Deplate::Regions::Footnote.new(@deplate, @source, @regNote, {}, self)
122
+ fn.finish
123
+ else
124
+ @fnId ||= text
125
+ end
126
+ if @container.kind_of?(Deplate::Element::Table)
127
+ @container.contains_footnotes = true
128
+ end
129
+ else
130
+ log("No footnote id", :error)
131
+ end
132
+ end
133
+
134
+ def process
135
+ fn = @deplate.footnotes[@fnId]
136
+ if fn
137
+ fn.elt.consumed = true
138
+ @elt = fn
139
+ else
140
+ log(["Unknown footnote", @fnId, @deplate.footnotes.keys.inspect], :error)
141
+ @elt = nil
142
+ end
143
+ return format_particle(:format_footnote, self)
144
+ end
145
+ end
146
+
147
+
148
+ class Deplate::Macro::Cite < Deplate::Macro
149
+ register_as 'cite'
150
+ attr :elt
151
+
152
+ def setup(text)
153
+ @deplate.options.citations << self
154
+ @elt = text.split(/\s*;\s*/)
155
+ for c in @elt
156
+ @container.add_metadata(@source,
157
+ "type" => "citation",
158
+ "name" => c
159
+ )
160
+ end
161
+ end
162
+
163
+ def process
164
+ return format_particle(:format_cite, self)
165
+ end
166
+ end
167
+
168
+
169
+ class Deplate::Macro::Attr < Deplate::Macro
170
+ register_as 'attr'
171
+ register_as 'attrib'
172
+
173
+ def setup(text)
174
+ attrib, text = @deplate.input.parse_args(text, @container)
175
+ context.last.args.update(attrib)
176
+ context.last.update_args
177
+ end
178
+ end
179
+
180
+
181
+ class Deplate::Macro::Date < Deplate::Macro
182
+ register_as 'date'
183
+
184
+ def setup(text)
185
+ @text = plain_text(Deplate::Element.get_date(text, @args))
186
+ end
187
+ end
188
+
189
+
190
+ # Access document options set with DOC.
191
+ class Deplate::Macro::Doc < Deplate::Macro
192
+ register_as 'doc'
193
+ register_as 'var'
194
+
195
+ def setup(text)
196
+ @text = plain_text(@deplate.variables[text].inspect)
197
+ end
198
+ end
199
+
200
+
201
+ # Access template arguments or document options set with DOC and parse.
202
+ class Deplate::Macro::Arg < Deplate::Macro
203
+ register_as 'arg'
204
+ register_as 'val'
205
+
206
+ def setup(text)
207
+ @deplate = @deplate.options.master if @deplate.options.master
208
+ val = @deplate.variables[text]
209
+ val = @args["default"] if val.nil?
210
+ if val.nil?
211
+ log(['Unknown variable', '{arg}', text])
212
+ else
213
+ @text = val.to_s
214
+ if !@args['asString']
215
+ @elt = @deplate.parse(@container, @text)
216
+ end
217
+ end
218
+ end
219
+ end
220
+
221
+
222
+ # Access template arguments or document options set with DOC and parse.
223
+ class Deplate::Macro::XArg < Deplate::Macro
224
+ register_as 'xarg'
225
+ register_as 'xval'
226
+
227
+ def setup(text)
228
+ c = @deplate.variables[text] || @args["default"]
229
+ if c
230
+ @elt = @deplate.parse(@container, c)
231
+ else
232
+ log(["Unknown variable", '{xarg}', text])
233
+ end
234
+ end
235
+ end
236
+
237
+
238
+ # Access element options set with OPT
239
+ class Deplate::Macro::Opt < Deplate::Macro
240
+ register_as 'opt'
241
+
242
+ def setup(text)
243
+ @text = plain_text(@container.args[text])
244
+ end
245
+ end
246
+
247
+
248
+ # Access clips (probably requires some processing?)
249
+ class Deplate::Macro::Clip < Deplate::Macro
250
+ register_as 'clip'
251
+ register_as 'get'
252
+
253
+ def setup(text)
254
+ @id = text
255
+ # @clip = @deplate.get_clip(@id)
256
+ end
257
+
258
+ def process
259
+ if @id
260
+ # ???<+TBD+>
261
+ # @elt = @clip || @deplate.get_clip(@id)
262
+ @elt = @deplate.get_clip(@id)
263
+ if @elt
264
+ return @elt.format_clip(self, Deplate::Particle)
265
+ # elsif (var = @deplate.variables[@id])
266
+ # return @deplate.parse_and_format(@container, var.to_s)
267
+ elsif (default = @args["default"])
268
+ return default
269
+ else
270
+ log(["Unknown clip", @id], :error) unless @elt
271
+ end
272
+ else
273
+ log(["No id given", @id], :error)
274
+ end
275
+ end
276
+ end
277
+
278
+
279
+ # Insert some native text
280
+ class Deplate::Macro::Insert < Deplate::Macro
281
+ register_as 'ins'
282
+ register_as 'native'
283
+
284
+ def setup(text)
285
+ @text = text
286
+ end
287
+ end
288
+
289
+
290
+ # Evaluate some ruby code
291
+ class Deplate::Macro::Ruby < Deplate::Macro
292
+ register_as 'ruby'
293
+
294
+ def setup(text)
295
+ @text = @deplate.eval_ruby(self, @args, text)
296
+ end
297
+ end
298
+
299
+
300
+ # Reference to an anchor in the current document
301
+ # {ref: label}, {ref p!: label}
302
+ class Deplate::Macro::Ref < Deplate::Macro
303
+ register_as 'ref'
304
+
305
+ def setup(text)
306
+ @text = text
307
+ end
308
+
309
+ def process
310
+ id = @args["byId"]
311
+ if id
312
+ @text = @deplate.get_label_by_id(self, id)
313
+ unless @text
314
+ log(["Can't refer to id", id], :error)
315
+ end
316
+ end
317
+ return format_particle(:format_ref, self)
318
+ end
319
+ end
320
+
321
+
322
+ class Deplate::Macro::Label < Deplate::Macro
323
+ register_as 'anchor'
324
+ register_as 'label'
325
+ register_as 'lab'
326
+
327
+ def setup(text)
328
+ @deplate.add_label(self, text, @level_as_string, :container => @container)
329
+ @text = format_particle(:format_label, self, :string, [text])
330
+ end
331
+ end
332
+
333
+
334
+ class Deplate::Macro::LineBreak < Deplate::Macro
335
+ register_as 'nl'
336
+
337
+ def process
338
+ return format_particle(:format_linebreak, self)
339
+ end
340
+ end
341
+
342
+
343
+ class Deplate::Macro::Latex < Deplate::Macro
344
+ register_as 'ltx'
345
+ set_formatter :format_ltx
346
+
347
+ class << self
348
+ attr_reader :formatter
349
+ end
350
+
351
+ attr_reader :accum, :caption
352
+
353
+ def setup(text)
354
+ prelude = @deplate.formatter.prelude('ltxPrelude')
355
+ @accum = [ prelude, text ].flatten.compact
356
+ @text = text
357
+ @deplate.formatter.inlatex(self)
358
+ end
359
+
360
+ def process
361
+ format_particle(self.class.formatter, self)
362
+ end
363
+ end
364
+
365
+ class Deplate::Macro::Math < Deplate::Macro::Latex
366
+ register_as 'math'
367
+ register_as '$'
368
+ set_formatter :format_math
369
+
370
+ def setup(text)
371
+ prelude = @deplate.formatter.prelude('mathPrelude')
372
+ @text = [prelude, "$%s$" % text].flatten.compact.join("\n")
373
+ super(@text)
374
+ end
375
+ end
376
+
377
+ class Deplate::Macro::List < Deplate::Macro
378
+ attr_reader :type
379
+
380
+ register_as 'list'
381
+
382
+ def setup(text)
383
+ @elt = @deplate.parse(self, text, @alt)
384
+ case @args["type"]
385
+ when "dl"
386
+ @type = "Description"
387
+ when "ol"
388
+ @type = "Numbered"
389
+ else
390
+ @type = "Itemize"
391
+ end
392
+ end
393
+
394
+ def process
395
+ b = format_particle(:format_list_env, self, @type, 0, :open)
396
+ join_elt("\n") do
397
+ @elt.delete_if {|x| x =~ /^\s*$/}
398
+ end
399
+ e = format_particle(:format_list_env, self, @type, 0, :close)
400
+ if @elt =~ /\S/m
401
+ return [b, @elt, e].flatten.compact.join
402
+ else
403
+ return ""
404
+ end
405
+ end
406
+ end
407
+
408
+
409
+ class Deplate::Macro::Item < Deplate::Macro
410
+ register_as 'item'
411
+
412
+ def setup(text)
413
+ @elt = @deplate.parse(@container, text, @alt)
414
+ end
415
+
416
+ def process
417
+ join_elt
418
+ type = @container.type
419
+ @elt = Deplate::ListItem.new(nil, @elt, type, type)
420
+ rv = format_particle(:format_list_item, self, type, 0, @elt)
421
+ rv.delete(:none)
422
+ rv
423
+ end
424
+ end
425
+
426
+
427
+ class Deplate::Macro::Term < Deplate::Macro
428
+ register_as 'term'
429
+
430
+ def setup(text)
431
+ @elt = @deplate.parse(@container, text, @alt)
432
+ end
433
+
434
+ def process
435
+ join_elt
436
+ type = @container.type
437
+ @elt = Deplate::ListItem.new(plain_text(@args["id"]), @elt, type, type)
438
+ rv = format_particle(:format_list_item, self, type, 0, @elt)
439
+ rv.delete(:none)
440
+ rv
441
+ end
442
+ end
443
+
444
+
445
+ class Deplate::Macro::Subscript < Deplate::Macro
446
+ register_as ','
447
+ register_as 'sub'
448
+
449
+ def setup(text)
450
+ @elt = @deplate.parse(@container, text, @alt)
451
+ end
452
+
453
+ def process
454
+ join_elt
455
+ return format_particle(:format_subscript, self)
456
+ end
457
+ end
458
+
459
+
460
+ class Deplate::Macro::Superscript < Deplate::Macro
461
+ register_as '^'
462
+ register_as 'sup'
463
+ register_as 'super'
464
+
465
+ def setup(text)
466
+ @elt = @deplate.parse(@container, text, @alt)
467
+ end
468
+
469
+ def process
470
+ join_elt
471
+ return format_particle(:format_superscript, self)
472
+ end
473
+ end
474
+
475
+
476
+ class Deplate::Macro::Stacked < Deplate::Macro
477
+ register_as '%'
478
+ register_as 'stacked'
479
+
480
+ def setup(text)
481
+ @elt = @deplate.parse(@container, text, @alt)
482
+ end
483
+
484
+ def process
485
+ process_elt
486
+ @elt.delete("")
487
+ log(["Size of stacked macro's element != 2", @text], :error) if @elt.size != 2
488
+ return format_particle(:format_stacked, self)
489
+ end
490
+ end
491
+
492
+
493
+ class Deplate::Macro::Text < Deplate::Macro
494
+ register_as ':'
495
+ register_as 'text'
496
+
497
+ def setup(text)
498
+ @elt = @deplate.parse(@container, text, @alt)
499
+ end
500
+
501
+ # def process
502
+ # join_elt
503
+ # return @elt
504
+ # end
505
+ end
506
+
507
+
508
+ class Deplate::Macro::Plain < Deplate::Macro
509
+ register_as 'plain'
510
+ register_as '\\'
511
+
512
+ def setup(text)
513
+ @text = plain_text(text)
514
+ end
515
+ end
516
+
517
+
518
+ class Deplate::Macro::FormattedText < Deplate::Macro
519
+ def setup(text)
520
+ @elt = @deplate.parse(@container, text, @alt)
521
+ end
522
+ end
523
+
524
+
525
+
526
+ class Deplate::Macro::Emphasize < Deplate::Macro::FormattedText
527
+ register_as 'em'
528
+ register_as 'emph'
529
+ register_as '_'
530
+
531
+ def process
532
+ format_particle(:format_emphasize, self, super)
533
+ end
534
+ end
535
+
536
+
537
+ class Deplate::Macro::Code < Deplate::Macro
538
+ register_as 'code'
539
+ register_as 'verb'
540
+ register_as "'"
541
+
542
+ def setup(text)
543
+ @text = format_particle(:format_code, self, text)
544
+ end
545
+ end
546
+
547
+
548
+ class Deplate::Macro::Image < Deplate::Macro
549
+ register_as 'img'
550
+
551
+ def setup(text)
552
+ @text = text
553
+ end
554
+
555
+ def process
556
+ return @deplate.formatter.include_image(@text, @args, true)
557
+ end
558
+ end
559
+
560
+
561
+ class Deplate::Macro::Comment < Deplate::Macro
562
+ register_as 'cmt'
563
+ end
564
+
565
+
566
+ class Deplate::Macro::Pagenumber < Deplate::Macro
567
+ register_as 'pagenumber'
568
+ register_as 'pagenum'
569
+
570
+ def setup(text)
571
+ @elt = @deplate.parse(@container, text, @alt)
572
+ end
573
+
574
+ def process
575
+ rv = format_particle(:format_pagenumber, self)
576
+ unless rv.empty?
577
+ join_elt
578
+ rv += @elt
579
+ end
580
+ return rv
581
+ end
582
+ end
583
+
584
+
585
+ class Deplate::Macro::Idx < Deplate::Macro
586
+ register_as 'idx'
587
+
588
+ def setup(text)
589
+ # auto = @args["auto"]
590
+ # auto = @deplate.variables["autoindex"] if auto.nil?
591
+ # @acc = []
592
+ # for i in text.split(/\s*;\s*/)
593
+ # @acc << @deplate.add_index(self, i)
594
+ # end
595
+ @acc = Deplate::Command::IDX.get_indices(@container, @deplate, @args, text, @source)
596
+ end
597
+
598
+ def process
599
+ @text = []
600
+ for i in @acc
601
+ @text << format_particle(:format_index, self, i)
602
+ end
603
+ @text = @text.join
604
+ super
605
+ end
606
+ end
607
+
608
+
609
+ class Deplate::Macro::Let < Deplate::Macro
610
+ register_as 'let'
611
+
612
+ def setup(text)
613
+ args = {}
614
+ for key, val in @args
615
+ val1 = @deplate.variables[val]
616
+ args[key] = val1 || val
617
+ end
618
+ Deplate::Define.let_variables(@deplate, args) do
619
+ @elt = @deplate.parse(@container, text)
620
+ end
621
+ end
622
+ end
623
+
624
+
625
+ class Deplate::Core
626
+ def self.simple_macro(name, body)
627
+ cn = name.capitalize
628
+ eval %{
629
+ class Deplate::Macro::#{cn} < Deplate::Macro
630
+ register_as #{name.inspect}
631
+ def setup(text)
632
+ @text = plain_text(#{body})
633
+ end
634
+ end
635
+ }
636
+ end
637
+ end
638
+
639
+ # vim: ff=unix