deplate 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.TXT +26 -0
- data/CHANGES.TXT +177 -0
- data/LICENSE.TXT +340 -0
- data/NEWS.TXT +29 -0
- data/README.TXT +86 -0
- data/TODO.TXT +202 -0
- data/VERSION.TXT +1 -0
- data/bin/deplate +3 -0
- data/bin/deplate.bat +2 -0
- data/etc/deplate.ini +361 -0
- data/lib/deplate.rb +31 -0
- data/lib/deplate/abstract-class.rb +30 -0
- data/lib/deplate/builtin.rb +11 -0
- data/lib/deplate/cache.rb +59 -0
- data/lib/deplate/commands.rb +693 -0
- data/lib/deplate/common.rb +335 -0
- data/lib/deplate/converter.rb +99 -0
- data/lib/deplate/core.rb +2705 -0
- data/lib/deplate/css/article.css +545 -0
- data/lib/deplate/css/deplate.css +699 -0
- data/lib/deplate/css/heading-navbar.css +29 -0
- data/lib/deplate/css/layout-deplate-print.css +540 -0
- data/lib/deplate/css/layout-deplate.css +764 -0
- data/lib/deplate/css/sans-serif.css +160 -0
- data/lib/deplate/css/serif-e.css +170 -0
- data/lib/deplate/css/serif-rel.css +121 -0
- data/lib/deplate/css/serif.css +190 -0
- data/lib/deplate/css/slides.css +11 -0
- data/lib/deplate/css/tabbar-left.css +91 -0
- data/lib/deplate/css/tabbar-right-ie.css +14 -0
- data/lib/deplate/css/tabbar-right.css +118 -0
- data/lib/deplate/css/tabbar-top.css +64 -0
- data/lib/deplate/css/tabbar.css +81 -0
- data/lib/deplate/css/text-sans-serif.css +154 -0
- data/lib/deplate/css/text-serif.css +175 -0
- data/lib/deplate/define.rb +439 -0
- data/lib/deplate/docbook.rb +738 -0
- data/lib/deplate/elements.rb +1355 -0
- data/lib/deplate/etc.rb +199 -0
- data/lib/deplate/external.rb +135 -0
- data/lib/deplate/fmt/dbk-article-4.1.2.rb +21 -0
- data/lib/deplate/fmt/dbk-article.rb +46 -0
- data/lib/deplate/fmt/dbk-book.rb +46 -0
- data/lib/deplate/fmt/dbk-ref.rb +105 -0
- data/lib/deplate/fmt/dbk-slides.rb +47 -0
- data/lib/deplate/fmt/dbk-snippet.rb +21 -0
- data/lib/deplate/fmt/html-snippet.rb +21 -0
- data/lib/deplate/fmt/html.rb +1696 -0
- data/lib/deplate/fmt/htmlsite.rb +419 -0
- data/lib/deplate/fmt/htmlslides.rb +21 -0
- data/lib/deplate/fmt/htmlwebsite.rb +70 -0
- data/lib/deplate/fmt/latex-snippet.rb +22 -0
- data/lib/deplate/fmt/latex.rb +1242 -0
- data/lib/deplate/fmt/php.rb +19 -0
- data/lib/deplate/fmt/phpsite.rb +19 -0
- data/lib/deplate/fmt/plain.rb +598 -0
- data/lib/deplate/fmt/template.rb +34 -0
- data/lib/deplate/fmt/xhtml10t.rb +41 -0
- data/lib/deplate/formatter-snippet.rb +17 -0
- data/lib/deplate/formatter.rb +1210 -0
- data/lib/deplate/input.rb +492 -0
- data/lib/deplate/input/deplate-headings.rb +48 -0
- data/lib/deplate/input/deplate-restricted.rb +70 -0
- data/lib/deplate/input/deplate.rb +28 -0
- data/lib/deplate/input/rdoc.rb +277 -0
- data/lib/deplate/input/template.rb +29 -0
- data/lib/deplate/lib/latex/highlight-extra.sty +15 -0
- data/lib/deplate/lib/latex/highlight-typical.sty +15 -0
- data/lib/deplate/lib/tabmenu.js +146 -0
- data/lib/deplate/locale/de.latin1 +708 -0
- data/lib/deplate/locale/ru.koi8-r +48 -0
- data/lib/deplate/locale/zh_cn.gb2312 +35 -0
- data/lib/deplate/macros.rb +639 -0
- data/lib/deplate/messages.rb +120 -0
- data/lib/deplate/metadata.rb +77 -0
- data/lib/deplate/metadata/marshal.rb +24 -0
- data/lib/deplate/metadata/xml.rb +42 -0
- data/lib/deplate/metadata/yaml.rb +26 -0
- data/lib/deplate/mod/anyword.rb +56 -0
- data/lib/deplate/mod/babelfish.rb +27 -0
- data/lib/deplate/mod/code-gvim.rb +52 -0
- data/lib/deplate/mod/code-highlight.rb +91 -0
- data/lib/deplate/mod/colored-log.rb +17 -0
- data/lib/deplate/mod/de.rb +19 -0
- data/lib/deplate/mod/en.rb +17 -0
- data/lib/deplate/mod/endnotes.rb +60 -0
- data/lib/deplate/mod/fr.rb +46 -0
- data/lib/deplate/mod/html-asciimath.rb +40 -0
- data/lib/deplate/mod/html-deplate-button.rb +15 -0
- data/lib/deplate/mod/html-headings-navbar.rb +39 -0
- data/lib/deplate/mod/html-obfuscate-email.rb +47 -0
- data/lib/deplate/mod/html-sidebar.rb +232 -0
- data/lib/deplate/mod/htmlslides-navbar-fh.rb +32 -0
- data/lib/deplate/mod/iconv.rb +35 -0
- data/lib/deplate/mod/imgurl.rb +30 -0
- data/lib/deplate/mod/inlatex-compound.rb +69 -0
- data/lib/deplate/mod/koma.rb +109 -0
- data/lib/deplate/mod/latex-emph-table-head.rb +38 -0
- data/lib/deplate/mod/latex-styles.rb +461 -0
- data/lib/deplate/mod/latex-verbatim-small.rb +29 -0
- data/lib/deplate/mod/makefile.rb +194 -0
- data/lib/deplate/mod/mark-external-urls.rb +38 -0
- data/lib/deplate/mod/markup-1-warn.rb +37 -0
- data/lib/deplate/mod/markup-1.rb +41 -0
- data/lib/deplate/mod/navbar-png.rb +33 -0
- data/lib/deplate/mod/noindent.rb +32 -0
- data/lib/deplate/mod/numpara.rb +40 -0
- data/lib/deplate/mod/particle-math.rb +34 -0
- data/lib/deplate/mod/php-extra.rb +44 -0
- data/lib/deplate/mod/pstoedit.rb +71 -0
- data/lib/deplate/mod/recode.rb +57 -0
- data/lib/deplate/mod/ru_koi8-r.rb +20 -0
- data/lib/deplate/mod/smiley.rb +50 -0
- data/lib/deplate/mod/soffice.rb +23 -0
- data/lib/deplate/mod/symbols-latin1.rb +58 -0
- data/lib/deplate/mod/symbols-od-utf-8.rb +16 -0
- data/lib/deplate/mod/symbols-plain.rb +58 -0
- data/lib/deplate/mod/symbols-sgml.rb +97 -0
- data/lib/deplate/mod/symbols-utf-8.rb +81 -0
- data/lib/deplate/mod/symbols-xml.rb +34 -0
- data/lib/deplate/mod/syntax-region-alt.rb +37 -0
- data/lib/deplate/mod/utf8.rb +49 -0
- data/lib/deplate/mod/validate-html.rb +35 -0
- data/lib/deplate/mod/xmlrpc.rb +233 -0
- data/lib/deplate/mod/zh-cn-autospace.rb +108 -0
- data/lib/deplate/mod/zh-cn.rb +59 -0
- data/lib/deplate/once-method.rb +44 -0
- data/lib/deplate/output.rb +249 -0
- data/lib/deplate/particles.rb +815 -0
- data/lib/deplate/regions.rb +1076 -0
- data/lib/deplate/structured.rb +763 -0
- data/lib/deplate/template.rb +430 -0
- data/lib/deplate/templates/html-doc.html +28 -0
- data/lib/deplate/templates/html-left-tabbar-js.html +37 -0
- data/lib/deplate/templates/html-left-tabbar.html +31 -0
- data/lib/deplate/templates/html-tabbar-right-table.html +43 -0
- data/lib/deplate/templates/html-tabbar-right.html +23 -0
- data/lib/deplate/templates/html-tabbar-top.html +43 -0
- data/lib/deplate/templates/html-tabbar.html +31 -0
- data/lib/deplate/wiki-markup.rb +117 -0
- data/lib/deplate/xml.rb +109 -0
- data/lib/deplate/zh-cn.rb +59 -0
- data/lib/ps2ppm.rb +239 -0
- data/man/man1/deplate.1 +692 -0
- metadata +210 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
# php.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: 23-Okt-2005.
|
7
|
+
# @Revision: 0.911
|
8
|
+
|
9
|
+
require 'deplate/fmt/html'
|
10
|
+
require 'deplate/mod/php-extra'
|
11
|
+
|
12
|
+
# A variant of the html-formatter that is suited for php output.
|
13
|
+
|
14
|
+
class Deplate::Formatter::Php < Deplate::Formatter::HTML
|
15
|
+
self.myname = "php"
|
16
|
+
self.rx = /php[0-9]?/i
|
17
|
+
self.suffix = ".php"
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# phpsite.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: 29-Okt-2005.
|
7
|
+
# @Revision: 0.916
|
8
|
+
|
9
|
+
require 'deplate/fmt/htmlsite'
|
10
|
+
require 'deplate/mod/php-extra'
|
11
|
+
|
12
|
+
# A variant of the htmlsite-formatter that is suited for php output.
|
13
|
+
|
14
|
+
class Deplate::Formatter::PhpSite < Deplate::Formatter::HTML_Site
|
15
|
+
self.myname = "phpsite"
|
16
|
+
self.rx = /php[0-9]?/i
|
17
|
+
self.suffix = ".php"
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,598 @@
|
|
1
|
+
# fmt-html.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: 28-Okt-2005.
|
7
|
+
# @Revision: 0.3450
|
8
|
+
|
9
|
+
require "deplate/formatter"
|
10
|
+
|
11
|
+
# No formatter.
|
12
|
+
|
13
|
+
class Deplate::Formatter::Plain < Deplate::Formatter
|
14
|
+
self.myname = "plain"
|
15
|
+
self.rx = /plain/i
|
16
|
+
self.suffix = ".txt"
|
17
|
+
|
18
|
+
self.label_mode = :delegate
|
19
|
+
self.label_delegate = []
|
20
|
+
self.label_once = []
|
21
|
+
|
22
|
+
def initialize(deplate, args)
|
23
|
+
super
|
24
|
+
@list_counter = {}
|
25
|
+
end
|
26
|
+
|
27
|
+
def read_bib(bibfiles)
|
28
|
+
simple_bibtex_reader(bibfiles)
|
29
|
+
end
|
30
|
+
|
31
|
+
def format_label(invoker, mode=nil, label=nil)
|
32
|
+
""
|
33
|
+
end
|
34
|
+
|
35
|
+
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)
|
44
|
+
else
|
45
|
+
acc = []
|
46
|
+
fig = @deplate.msg("Figure")
|
47
|
+
caption = invoker.caption
|
48
|
+
if caption
|
49
|
+
capAbove = !(caption && caption.args && caption.args.include?("below"))
|
50
|
+
lev = invoker.level_as_string
|
51
|
+
cap = %{#{fig} #{lev}: #{caption.elt}}
|
52
|
+
else
|
53
|
+
capAbove = false
|
54
|
+
end
|
55
|
+
if caption and capAbove
|
56
|
+
acc << cap
|
57
|
+
end
|
58
|
+
acc << include_image(invoker.elt, invoker.args)
|
59
|
+
if caption and !capAbove
|
60
|
+
acc << cap
|
61
|
+
end
|
62
|
+
acc << ""
|
63
|
+
join_blocks(acc)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def include_image(file, args, inline=false)
|
68
|
+
# alt = args["alt"]
|
69
|
+
# alt ? "[#{alt}]" : "[IMG:#{file}]"
|
70
|
+
"[#{args["alt"] || file}]"
|
71
|
+
end
|
72
|
+
|
73
|
+
alias :format_IMG :format_figure
|
74
|
+
|
75
|
+
alias :format_MAKETITLE :format_title
|
76
|
+
|
77
|
+
def format_note(invoker)
|
78
|
+
indent = " #{invoker.marker * 3} "
|
79
|
+
wrap_text(indent + invoker.elt, :indent => indent) + "\n"
|
80
|
+
end
|
81
|
+
|
82
|
+
def format_table(invoker)
|
83
|
+
elt = invoker.elt
|
84
|
+
args = invoker.args
|
85
|
+
level_as_string = invoker.level_as_string
|
86
|
+
caption = invoker.caption
|
87
|
+
capAbove = !(caption && caption.args && caption.args.include?("below"))
|
88
|
+
|
89
|
+
widths = []
|
90
|
+
elt.each_with_index do |row, y|
|
91
|
+
row.cols.each_with_index do |cell, x|
|
92
|
+
case cell
|
93
|
+
when :join_left, :join_above
|
94
|
+
when :ruler, :noruler
|
95
|
+
else
|
96
|
+
t = cell.cell.split(/\n/).collect {|l| l.size}
|
97
|
+
s = t.max || 0
|
98
|
+
w = widths[x]
|
99
|
+
if !w or w < s
|
100
|
+
widths[x] = s
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
ruler = ["+-", widths.collect {|w| "-" * w}.join("-+-"), "-+"].join
|
107
|
+
acc = []
|
108
|
+
|
109
|
+
if caption and capAbove
|
110
|
+
acc << %{#{@deplate.msg("Table")} #{level_as_string}: #{caption.elt}}
|
111
|
+
end
|
112
|
+
|
113
|
+
acc_head = []
|
114
|
+
acc_foot = []
|
115
|
+
acc_body = []
|
116
|
+
elt.each_with_index do |r, n|
|
117
|
+
if r.is_ruler
|
118
|
+
# acc_body << ruler
|
119
|
+
elsif r.head
|
120
|
+
acc_head << formatted_table_row(n, r, widths)
|
121
|
+
elsif r.foot
|
122
|
+
acc_foot << formatted_table_row(n, r, widths)
|
123
|
+
else
|
124
|
+
acc_body << formatted_table_row(n, r, widths)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
acc << ruler
|
129
|
+
unless acc_head.empty?
|
130
|
+
acc << acc_head << ruler
|
131
|
+
end
|
132
|
+
acc << acc_body
|
133
|
+
unless acc_foot.empty?
|
134
|
+
acc << ruler << acc_foot
|
135
|
+
end
|
136
|
+
acc << ruler
|
137
|
+
|
138
|
+
note = invoker.args["note"]
|
139
|
+
if note
|
140
|
+
acc << @deplate.parse_and_format(invoker, note)
|
141
|
+
end
|
142
|
+
|
143
|
+
if caption and !capAbove
|
144
|
+
acc << %{#{@deplate.msg("Table")} #{level_as_string}: #{caption.elt}}
|
145
|
+
end
|
146
|
+
|
147
|
+
acc << ""
|
148
|
+
join_blocks(acc)
|
149
|
+
end
|
150
|
+
|
151
|
+
def formatted_table_row(y, r, widths)
|
152
|
+
n = 1
|
153
|
+
i = 0
|
154
|
+
acc = []
|
155
|
+
cols = r.cols.collect do |c|
|
156
|
+
if c.kind_of?(Symbol)
|
157
|
+
c
|
158
|
+
else
|
159
|
+
c.cell.gsub(/\n*(.*)\n*/, "\\1")
|
160
|
+
end
|
161
|
+
end
|
162
|
+
while i < n
|
163
|
+
row = []
|
164
|
+
r.cols.each_with_index do |c, x|
|
165
|
+
case c
|
166
|
+
when :join_left
|
167
|
+
when :join_above
|
168
|
+
w = widths[x]
|
169
|
+
row << %{%-#{w}s} % " "
|
170
|
+
when :ruler, :noruler
|
171
|
+
w = get_width(x, c.span_x, widths)
|
172
|
+
row << %{%-#{w}s} % (i == 0 ? "-" : " ")
|
173
|
+
else
|
174
|
+
w = get_width(x, c.span_x, widths)
|
175
|
+
t = c.cell.split(/\n/)
|
176
|
+
ts = t.size
|
177
|
+
if ts > n
|
178
|
+
n = ts
|
179
|
+
end
|
180
|
+
row << %{%-#{w}s} % (t[i] || " ")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
acc << "| #{row.join(" | ")} |"
|
184
|
+
i += 1
|
185
|
+
end
|
186
|
+
acc.join("\n")
|
187
|
+
end
|
188
|
+
private :formatted_table_row
|
189
|
+
|
190
|
+
def get_width(x, span, widths)
|
191
|
+
w = widths[x]
|
192
|
+
for j in 1..(span - 1)
|
193
|
+
w += 3 + widths[x + j]
|
194
|
+
end
|
195
|
+
w
|
196
|
+
end
|
197
|
+
private :get_width
|
198
|
+
|
199
|
+
def format_heading(invoker, level=nil, elt=nil)
|
200
|
+
level ||= invoker.level
|
201
|
+
elt ||= invoker.elt
|
202
|
+
ul = ["", "=", "~", "-", '"', "'"][level]
|
203
|
+
if invoker and invoker.level_as_string
|
204
|
+
elt = [invoker.level_as_string, elt].join(" ")
|
205
|
+
end
|
206
|
+
if ul
|
207
|
+
[nil, elt, ul * elt.size, nil].join("\n")
|
208
|
+
# [elt, ul * elt.size].join("\n")
|
209
|
+
else
|
210
|
+
# "\n#{elt}\n"
|
211
|
+
elt
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
def format_list(invoker)
|
216
|
+
printable_list(invoker) + "\n"
|
217
|
+
end
|
218
|
+
|
219
|
+
def format_list_env(invoker, type, level, what, subtype=nil)
|
220
|
+
case what
|
221
|
+
when :open
|
222
|
+
@list_counter[type] ||= []
|
223
|
+
@list_counter[type].push(0)
|
224
|
+
when :close
|
225
|
+
@list_counter[type].pop
|
226
|
+
end
|
227
|
+
nil
|
228
|
+
end
|
229
|
+
|
230
|
+
LIST_ITEMIZE_MARKERS = ['*', '*', '+', '+', '-', '-']
|
231
|
+
LIST_ITEMIZE_MARKERS_N = LIST_ITEMIZE_MARKERS.size
|
232
|
+
# <+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)
|
234
|
+
# indent = format_indent(level, true)
|
235
|
+
indent = " " * level
|
236
|
+
case type
|
237
|
+
when "Numbered"
|
238
|
+
if explicit or item.explicit and item.item
|
239
|
+
# and !item.item.empty?
|
240
|
+
i = item.item
|
241
|
+
else
|
242
|
+
i = @list_counter[type][-1] += 1
|
243
|
+
case list_subtype(type, item.item)
|
244
|
+
when "a"
|
245
|
+
i = "%c" % (96 + i)
|
246
|
+
when "A"
|
247
|
+
i = "%c" % (64 + i)
|
248
|
+
else
|
249
|
+
i = i.to_s
|
250
|
+
end
|
251
|
+
end
|
252
|
+
unless i.empty?
|
253
|
+
i += ". "
|
254
|
+
end
|
255
|
+
return wrap_text([indent, i, item.body].join, :hanging => 2), :none
|
256
|
+
when "Itemize"
|
257
|
+
if explicit or item.explicit and item.item
|
258
|
+
# and !item.item.empty?
|
259
|
+
i = item.item
|
260
|
+
else
|
261
|
+
i = LIST_ITEMIZE_MARKERS[level % LIST_ITEMIZE_MARKERS_N]
|
262
|
+
end
|
263
|
+
unless i.empty?
|
264
|
+
i += " "
|
265
|
+
end
|
266
|
+
return wrap_text([indent, i, item.body].join, :hanging => 2), :none
|
267
|
+
when "Description"
|
268
|
+
accum = [indent, item.item, "\n"]
|
269
|
+
accum << indent << " " << item.body if item.body
|
270
|
+
return wrap_text(accum.join), :none
|
271
|
+
when "Paragraph"
|
272
|
+
# t = "\n" + wrap_text(indent + item.body)
|
273
|
+
t = wrap_text(indent + item.body)
|
274
|
+
return t, nil
|
275
|
+
else
|
276
|
+
raise "Unknown list type: #{item.inspect}"
|
277
|
+
end
|
278
|
+
end
|
279
|
+
|
280
|
+
def format_verbatim(invoker, text=nil)
|
281
|
+
text = invoker.elt
|
282
|
+
indent_text(text) + "\n"
|
283
|
+
end
|
284
|
+
|
285
|
+
def format_abstract(invoker)
|
286
|
+
text = invoker.elt
|
287
|
+
wrap_text(" " + text) + "\n"
|
288
|
+
end
|
289
|
+
|
290
|
+
def format_quote(invoker)
|
291
|
+
text = invoker.elt
|
292
|
+
wrap_text("> " + text, :indent => "> ") + "\n"
|
293
|
+
end
|
294
|
+
|
295
|
+
def format_title(invoker)
|
296
|
+
acc = []
|
297
|
+
for i, c in [["title", %{%s}],
|
298
|
+
["author", %{%s}],
|
299
|
+
["authornote", %{%s}],
|
300
|
+
["date", %{%s}]]
|
301
|
+
ii = @deplate.get_clip(i)
|
302
|
+
acc << wrap_text(c % ii.elt) if ii
|
303
|
+
end
|
304
|
+
acc = acc.join("\n\n")
|
305
|
+
s = acc.collect {|l| l.size}.max
|
306
|
+
r = "~" * s
|
307
|
+
[r, acc, r, nil].join("\n\n")
|
308
|
+
end
|
309
|
+
|
310
|
+
def format_MAKEBIB(invoker)
|
311
|
+
format_bibliography(invoker) do |key, labels, text|
|
312
|
+
wrap_text(" " + text, :hanging => 4)
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
def format_IDX(invoker)
|
317
|
+
nil
|
318
|
+
end
|
319
|
+
|
320
|
+
def format_emphasize(invoker, text)
|
321
|
+
text
|
322
|
+
end
|
323
|
+
|
324
|
+
def format_code(invoker, text)
|
325
|
+
text
|
326
|
+
end
|
327
|
+
|
328
|
+
# <+TBD+> [1] + urls at the bottom
|
329
|
+
def format_url(invoker, name, dest, anchor, literal=false)
|
330
|
+
idx = @deplate.footnote_last_idx += 1
|
331
|
+
fn = "[#{idx}]"
|
332
|
+
# invoker.container.postponed_format << Proc.new do |container|
|
333
|
+
output_at(:body, :footnotes, %{#{fn} #{Deplate::HyperLink.url_anchor(dest, anchor)}})
|
334
|
+
# end
|
335
|
+
if name and !(name.empty?)
|
336
|
+
[name, fn].join
|
337
|
+
else
|
338
|
+
fn
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
alias :format_wiki :format_url
|
343
|
+
# def format_wiki(invoker, name, dest, anchor)
|
344
|
+
# idx = @deplate.footnote_last_idx += 1
|
345
|
+
# fn = "[#{idx}]"
|
346
|
+
# invoker.container.postponed_format << Proc.new do |container|
|
347
|
+
# output_at(:body, :footnotes, %{#{fn} #{Deplate::HyperLink.url_anchor(dest, anchor)}})
|
348
|
+
# end
|
349
|
+
# [name, fn].join(" ")
|
350
|
+
# end
|
351
|
+
|
352
|
+
def format_symbol(invoker, text)
|
353
|
+
text
|
354
|
+
end
|
355
|
+
|
356
|
+
def format_index(invoker, idx)
|
357
|
+
""
|
358
|
+
end
|
359
|
+
|
360
|
+
def format_footnote(invoker)
|
361
|
+
elt = invoker.elt
|
362
|
+
if elt and elt.elt and elt.elt.consumed
|
363
|
+
fn = elt.elt
|
364
|
+
lab = fn.label
|
365
|
+
if !@deplate.footnotes_used.include?(lab)
|
366
|
+
idx = @deplate.footnote_last_idx +=1
|
367
|
+
lab = "[#{idx}]"
|
368
|
+
fn.n = idx
|
369
|
+
fn.label = lab
|
370
|
+
@deplate.footnotes_used << lab
|
371
|
+
text = wrap_text("#{lab} #{fn.body}", :hanging => 4)
|
372
|
+
# invoker.container.postponed_format << Proc.new do |container|
|
373
|
+
output_at(:body, :footnotes, text)
|
374
|
+
# end
|
375
|
+
end
|
376
|
+
end
|
377
|
+
return fn.label
|
378
|
+
end
|
379
|
+
|
380
|
+
def format_ref(invoker)
|
381
|
+
" " + @deplate.labels[invoker.text]
|
382
|
+
end
|
383
|
+
|
384
|
+
def format_break(invoker)
|
385
|
+
"-" * 72
|
386
|
+
end
|
387
|
+
|
388
|
+
def format_anchor(invoker)
|
389
|
+
""
|
390
|
+
end
|
391
|
+
|
392
|
+
def format_paragraph(invoker)
|
393
|
+
wrap_text(invoker.elt) + "\n"
|
394
|
+
end
|
395
|
+
|
396
|
+
def format_header(invoker)
|
397
|
+
format_header_or_footer(invoker, :pre, :header)
|
398
|
+
nil
|
399
|
+
end
|
400
|
+
|
401
|
+
def format_footer(invoker)
|
402
|
+
format_header_or_footer(invoker, :post, :footer)
|
403
|
+
nil
|
404
|
+
end
|
405
|
+
|
406
|
+
def format_header_or_footer(invoker, type, slot)
|
407
|
+
args = invoker.args
|
408
|
+
acc = [""]
|
409
|
+
for e in invoker.elt
|
410
|
+
e.args[:dontWrapTable] = true
|
411
|
+
acc << e.format_current
|
412
|
+
end
|
413
|
+
acc << ""
|
414
|
+
output_at(type, slot, *acc)
|
415
|
+
nil
|
416
|
+
end
|
417
|
+
private :format_header_or_footer
|
418
|
+
|
419
|
+
def format_pagebreak(invoker, style=nil, major=false)
|
420
|
+
""
|
421
|
+
end
|
422
|
+
|
423
|
+
def doublequote_open(invoker)
|
424
|
+
'"'
|
425
|
+
end
|
426
|
+
|
427
|
+
def doublequote_close(invoker)
|
428
|
+
'"'
|
429
|
+
end
|
430
|
+
|
431
|
+
def singlequote_open(invoker)
|
432
|
+
"'"
|
433
|
+
end
|
434
|
+
|
435
|
+
def singlequote_close(invoker)
|
436
|
+
"'"
|
437
|
+
end
|
438
|
+
|
439
|
+
def format_linebreak(invoker)
|
440
|
+
"\n"
|
441
|
+
end
|
442
|
+
|
443
|
+
def format_subscript(invoker)
|
444
|
+
invoker.elt
|
445
|
+
end
|
446
|
+
|
447
|
+
def format_superscript(invoker)
|
448
|
+
invoker.elt
|
449
|
+
end
|
450
|
+
|
451
|
+
def format_stacked(invoker)
|
452
|
+
invoker.elt
|
453
|
+
end
|
454
|
+
|
455
|
+
def format_pagenumber(invoker)
|
456
|
+
return ""
|
457
|
+
end
|
458
|
+
|
459
|
+
def format_list_of_contents(invoker)
|
460
|
+
format_list_of(invoker, "Table of Contents", @deplate.table_of_contents, "hd",
|
461
|
+
:flat => false)
|
462
|
+
end
|
463
|
+
|
464
|
+
alias :format_list_of_toc :format_list_of_contents
|
465
|
+
|
466
|
+
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|
|
470
|
+
hd.args["shortcaption"] || hd.args["id"]
|
471
|
+
end
|
472
|
+
end
|
473
|
+
|
474
|
+
def format_list_of_tables(invoker)
|
475
|
+
format_list_of(invoker, "List of Tables", @deplate.table_of_tables, "tab",
|
476
|
+
:flat => true)
|
477
|
+
end
|
478
|
+
|
479
|
+
def format_list_of_figures(invoker)
|
480
|
+
format_list_of(invoker, "List of Figures", @deplate.table_of_figures, "fig",
|
481
|
+
:flat => true)
|
482
|
+
end
|
483
|
+
|
484
|
+
def format_list_of_index(invoker)
|
485
|
+
format_the_index(invoker, "Index", @deplate.index, "idx", true)
|
486
|
+
end
|
487
|
+
|
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
|
514
|
+
end
|
515
|
+
acc << printable_list(invoker, accData) << ""
|
516
|
+
join_blocks(acc)
|
517
|
+
end
|
518
|
+
|
519
|
+
def format_the_index(invoker, name, data, prefix="", flat=false, other_args={})
|
520
|
+
accum = []
|
521
|
+
chars = []
|
522
|
+
|
523
|
+
# accum << format_list_env(invoker, "Description", 0, :open)
|
524
|
+
for n, arr in sort_index_entries(data)
|
525
|
+
cht = get_first_char(n, true)
|
526
|
+
if !chars.include?(cht)
|
527
|
+
chars << cht
|
528
|
+
accum << format_list_env(invoker, "Description", 0, :close) unless accum.empty?
|
529
|
+
accum << format_heading(nil, 2, cht)
|
530
|
+
accum << format_list_env(invoker, "Description", 0, :open)
|
531
|
+
end
|
532
|
+
acc = []
|
533
|
+
for i in arr
|
534
|
+
ff = @deplate.dest
|
535
|
+
if i.file || i.level_as_string
|
536
|
+
f = i.file || invoker.output_file_name(:level_as_string => i.level_as_string,
|
537
|
+
:relative => invoker)
|
538
|
+
if f == ff
|
539
|
+
f = ""
|
540
|
+
l = i.level_as_string
|
541
|
+
if l and !l.empty?
|
542
|
+
t = l
|
543
|
+
elsif @deplate.options.multi_file_output
|
544
|
+
t = "<>"
|
545
|
+
else
|
546
|
+
t = "I"
|
547
|
+
end
|
548
|
+
else
|
549
|
+
t = @deplate.file_with_suffix(f, "", true)
|
550
|
+
end
|
551
|
+
acc << t
|
552
|
+
else
|
553
|
+
log(["Index: Neither file nor level defined: dropping", i.label], :error)
|
554
|
+
end
|
555
|
+
end
|
556
|
+
s = Deplate::ListItem.new(plain_text(n), acc.join(", "))
|
557
|
+
ot, et = format_list_item(invoker, "Description", 0, s)
|
558
|
+
accum << ot
|
559
|
+
accum << et unless et == :none
|
560
|
+
end
|
561
|
+
accum << format_list_env(invoker, "Description", 0, :close)
|
562
|
+
acc = []
|
563
|
+
acc << chars.join(" ")
|
564
|
+
acc << accum.compact.join("\n")
|
565
|
+
acc << ""
|
566
|
+
join_blocks(acc)
|
567
|
+
end
|
568
|
+
end
|
569
|
+
|
570
|
+
|
571
|
+
class Deplate::Command::MAKEBIB
|
572
|
+
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]
|
576
|
+
o = Deplate::Element::Heading.new(deplate, src, n, m).finish
|
577
|
+
o.update_options(args)
|
578
|
+
deplate.options.html_makebib_heading = o
|
579
|
+
array << o
|
580
|
+
end
|
581
|
+
end
|
582
|
+
end
|
583
|
+
|
584
|
+
|
585
|
+
class Deplate::Command::LIST
|
586
|
+
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]
|
590
|
+
h = Deplate::Element::Heading.new(deplate, src, n, m).finish
|
591
|
+
h.update_options(args)
|
592
|
+
array << h
|
593
|
+
end
|
594
|
+
end
|
595
|
+
end
|
596
|
+
|
597
|
+
|
598
|
+
# vim: ff=unix
|