deplate 0.7.3 → 0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS.TXT +3 -0
- data/CHANGES.TXT +248 -175
- data/LICENSE.TXT +0 -0
- data/NEWS.TXT +28 -24
- data/README.TXT +0 -0
- data/TODO.TXT +174 -88
- data/VERSION.TXT +1 -1
- data/bin/deplate +0 -0
- data/bin/deplate.bat +0 -0
- data/etc/deplate.ini +91 -3
- data/lib/action_view/helpers/deplate.rb +45 -0
- data/lib/deplate.rb +6 -1
- data/lib/deplate/abstract-class.rb +0 -0
- data/lib/deplate/bib.rb +576 -0
- data/lib/deplate/builtin.rb +0 -0
- data/lib/deplate/cache.rb +55 -5
- data/lib/deplate/commands.rb +346 -183
- data/lib/deplate/common.rb +209 -48
- data/lib/deplate/converter.rb +12 -6
- data/lib/deplate/core.rb +777 -378
- data/lib/deplate/counters.rb +254 -0
- data/lib/deplate/css/article.css +4 -3
- data/lib/deplate/css/deplate.css +121 -5
- data/lib/deplate/css/heading-navbar.css +0 -0
- data/lib/deplate/css/layout-deplate-print.css +0 -0
- data/lib/deplate/css/layout-deplate.css +0 -0
- data/lib/deplate/css/sans-serif.css +0 -0
- data/lib/deplate/css/serif-e.css +0 -0
- data/lib/deplate/css/serif-rel.css +0 -0
- data/lib/deplate/css/serif.css +9 -3
- data/lib/deplate/css/slides.css +0 -0
- data/lib/deplate/css/tabbar-left.css +0 -0
- data/lib/deplate/css/tabbar-right-ie.css +3 -9
- data/lib/deplate/css/tabbar-right.css +51 -18
- data/lib/deplate/css/tabbar-top.css +7 -1
- data/lib/deplate/css/tabbar.css +0 -0
- data/lib/deplate/css/text-sans-serif.css +0 -0
- data/lib/deplate/css/text-serif.css +0 -0
- data/lib/deplate/define.rb +183 -177
- data/lib/deplate/deplate-string.rb +82 -0
- data/lib/deplate/docbook.rb +236 -128
- data/lib/deplate/elements.rb +584 -417
- data/lib/deplate/etc.rb +163 -101
- data/lib/deplate/external.rb +42 -11
- data/lib/deplate/fmt/dbk-article-4.1.2.rb +0 -0
- data/lib/deplate/fmt/dbk-article.rb +0 -0
- data/lib/deplate/fmt/dbk-book.rb +0 -0
- data/lib/deplate/fmt/dbk-ref.rb +3 -3
- data/lib/deplate/fmt/dbk-slides.rb +0 -0
- data/lib/deplate/fmt/dbk-snippet.rb +0 -0
- data/lib/deplate/fmt/html-snippet.rb +0 -0
- data/lib/deplate/fmt/html.rb +783 -550
- data/lib/deplate/fmt/htmlsite.rb +192 -199
- data/lib/deplate/fmt/htmlslides.rb +0 -0
- data/lib/deplate/fmt/htmlwebsite.rb +3 -3
- data/lib/deplate/fmt/latex-snippet.rb +0 -0
- data/lib/deplate/fmt/latex.rb +242 -83
- data/lib/deplate/fmt/null.rb +32 -0
- data/lib/deplate/fmt/php.rb +4 -4
- data/lib/deplate/fmt/phpsite.rb +6 -5
- data/lib/deplate/fmt/plain.rb +160 -106
- data/lib/deplate/fmt/template.rb +0 -0
- data/lib/deplate/fmt/xhtml10t.rb +0 -0
- data/lib/deplate/formatter-snippet.rb +0 -0
- data/lib/deplate/formatter.rb +613 -301
- data/lib/deplate/input.rb +202 -142
- data/lib/deplate/input/deplate-headings.rb +4 -6
- data/lib/deplate/input/deplate-restricted.rb +15 -9
- data/lib/deplate/input/deplate.rb +2 -4
- data/lib/deplate/input/rdoc.rb +39 -38
- data/lib/deplate/input/template.rb +0 -0
- data/lib/deplate/lib/Makefile.config +29 -0
- data/lib/deplate/lib/latex/deplate.sty +54 -0
- data/lib/deplate/lib/latex/highlight-extra.sty +0 -0
- data/lib/deplate/lib/latex/highlight-typical.sty +0 -0
- data/lib/deplate/lib/php/page-comment.inc.php +216 -0
- data/lib/deplate/lib/tabmenu.js +0 -0
- data/lib/deplate/locale/de.latin1 +155 -17
- data/lib/deplate/locale/ru.koi8-r +0 -0
- data/lib/deplate/locale/zh_cn.gb2312 +0 -0
- data/lib/deplate/macros.rb +133 -82
- data/lib/deplate/messages.rb +6 -4
- data/lib/deplate/metadata.rb +0 -0
- data/lib/deplate/metadata/marshal.rb +0 -0
- data/lib/deplate/metadata/xml.rb +0 -0
- data/lib/deplate/metadata/yaml.rb +0 -0
- data/lib/deplate/mod/anyword.rb +3 -3
- data/lib/deplate/mod/babelfish.rb +4 -4
- data/lib/deplate/mod/code-gvim.rb +8 -4
- data/lib/deplate/mod/code-highlight.rb +3 -3
- data/lib/deplate/mod/colored-log.rb +0 -0
- data/lib/deplate/mod/de.rb +2 -2
- data/lib/deplate/mod/en.rb +0 -0
- data/lib/deplate/mod/endnotes.rb +0 -0
- data/lib/deplate/mod/fr.rb +0 -0
- data/lib/deplate/mod/html-asciimath.rb +0 -0
- data/lib/deplate/mod/html-deplate-button.rb +0 -0
- data/lib/deplate/mod/html-headings-navbar.rb +5 -13
- data/lib/deplate/mod/html-jsmath.rb +39 -0
- data/lib/deplate/mod/html-obfuscate-email.rb +3 -3
- data/lib/deplate/mod/html-sidebar.rb +0 -0
- data/lib/deplate/mod/htmlslides-navbar-fh.rb +3 -3
- data/lib/deplate/mod/iconv.rb +0 -0
- data/lib/deplate/mod/imgurl.rb +4 -4
- data/lib/deplate/mod/inlatex-compound.rb +7 -10
- data/lib/deplate/mod/koma.rb +0 -0
- data/lib/deplate/mod/latex-emph-table-head.rb +0 -0
- data/lib/deplate/mod/latex-styles.rb +7 -4
- data/lib/deplate/mod/latex-verbatim-small.rb +0 -0
- data/lib/deplate/mod/makefile.rb +23 -7
- data/lib/deplate/mod/mark-external-urls.rb +3 -3
- data/lib/deplate/mod/markup-1-warn.rb +10 -10
- data/lib/deplate/mod/markup-1.rb +0 -0
- data/lib/deplate/mod/navbar-png.rb +24 -8
- data/lib/deplate/mod/noindent.rb +0 -0
- data/lib/deplate/mod/numpara.rb +0 -0
- data/lib/deplate/mod/particle-math.rb +4 -4
- data/lib/deplate/mod/php-extra.rb +46 -6
- data/lib/deplate/mod/pstoedit.rb +0 -0
- data/lib/deplate/mod/recode.rb +0 -0
- data/lib/deplate/mod/ru_koi8-r.rb +0 -0
- data/lib/deplate/mod/smart-dash.rb +26 -0
- data/lib/deplate/mod/smiley.rb +69 -7
- data/lib/deplate/mod/soffice.rb +0 -0
- data/lib/deplate/mod/symbols-latin1.rb +14 -23
- data/lib/deplate/mod/symbols-od-utf-8.rb +5 -3
- data/lib/deplate/mod/symbols-plain.rb +5 -35
- data/lib/deplate/mod/symbols-sgml.rb +8 -9
- data/lib/deplate/mod/symbols-utf-8.rb +8 -9
- data/lib/deplate/mod/symbols-xml.rb +5 -9
- data/lib/deplate/mod/syntax-region-alt.rb +5 -5
- data/lib/deplate/mod/utf8.rb +0 -0
- data/lib/deplate/mod/validate-html.rb +0 -0
- data/lib/deplate/mod/xmlrpc.rb +0 -0
- data/lib/deplate/mod/zh-cn-autospace.rb +18 -20
- data/lib/deplate/mod/zh-cn.rb +4 -6
- data/lib/deplate/nukumi2.rb +71 -0
- data/lib/deplate/once-method.rb +0 -0
- data/lib/deplate/output.rb +19 -21
- data/lib/deplate/particles.rb +178 -116
- data/lib/deplate/regions.rb +99 -58
- data/lib/deplate/skeletons.rb +122 -0
- data/lib/deplate/structured.rb +164 -106
- data/lib/deplate/template.rb +67 -43
- data/lib/deplate/templates/html-doc.html +0 -0
- data/lib/deplate/templates/html-left-tabbar-js.html +0 -0
- data/lib/deplate/templates/html-left-tabbar.html +0 -0
- data/lib/deplate/templates/html-tabbar-right-pcomments.php +22 -0
- data/lib/deplate/templates/html-tabbar-right-step.html +24 -0
- data/lib/deplate/templates/html-tabbar-right-table.html +0 -0
- data/lib/deplate/templates/html-tabbar-right.html +2 -4
- data/lib/deplate/templates/html-tabbar-top.html +0 -9
- data/lib/deplate/templates/html-tabbar.html +0 -0
- data/lib/deplate/variables.rb +127 -0
- data/lib/deplate/wiki-markup.rb +99 -33
- data/lib/deplate/xml.rb +18 -18
- data/lib/deplate/zh-cn.rb +0 -0
- data/lib/ps2ppm.rb +0 -0
- data/man/man1/deplate.1 +564 -474
- metadata +201 -186
File without changes
|
@@ -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:
|
7
|
-
# @Revision: 0.
|
6
|
+
# @Last Change: 02-Apr-2006.
|
7
|
+
# @Revision: 0.442
|
8
8
|
|
9
9
|
require "deplate/fmt/htmlslides"
|
10
10
|
|
@@ -47,7 +47,7 @@ EOF
|
|
47
47
|
idx, _, _ = navbar_output_index(invoker, first, last)
|
48
48
|
navextra = @deplate.get_clip("navextra")
|
49
49
|
navmenu = [%{<span class="navmenuhead">#{navextra.elt if navextra}</span>} ]
|
50
|
-
@deplate.each_heading(
|
50
|
+
@deplate.each_heading(:top) do |section, title|
|
51
51
|
unless section.args["noList"]
|
52
52
|
f = section.output_file_name(:basename => true)
|
53
53
|
v = section.description.gsub(/<\/?[^>]*>/, "")
|
File without changes
|
data/lib/deplate/fmt/latex.rb
CHANGED
@@ -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:
|
7
|
-
# @Revision: 0.
|
6
|
+
# @Last Change: 05-Jun-2006.
|
7
|
+
# @Revision: 0.2042
|
8
8
|
|
9
9
|
require "deplate/formatter"
|
10
10
|
|
@@ -65,26 +65,29 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def prepare
|
68
|
-
@document_class = @deplate.variables[
|
68
|
+
@document_class = @deplate.variables['class'] || @@latexDocClass
|
69
69
|
|
70
|
-
lco = @deplate.variables[
|
70
|
+
lco = @deplate.variables['classOptions']
|
71
71
|
lco = lco ? lco.strip.split(/[, ]/) : @@latexVariables
|
72
72
|
lang = @deplate.options.messages.prop('lang', self)
|
73
73
|
if lang
|
74
74
|
lco << lang
|
75
75
|
end
|
76
|
-
lco = lco.uniq.join(",")
|
77
76
|
|
77
|
+
div = @deplate.variables['DIV']
|
78
|
+
if div
|
79
|
+
# add_package("typearea", "DIV#{div}")
|
80
|
+
add_package('typearea')
|
81
|
+
lco.unshift("DIV#{div}")
|
82
|
+
end
|
83
|
+
|
84
|
+
lco = lco.uniq.join(',')
|
78
85
|
output_at(:pre, :doc_def, "\\documentclass[#{lco}]{#{@document_class}}")
|
79
86
|
|
80
87
|
set_document_encoding
|
81
88
|
|
82
|
-
@booktabs = @deplate.variables[
|
83
|
-
add_package(
|
84
|
-
|
85
|
-
|
86
|
-
div = @deplate.variables["DIV"]
|
87
|
-
add_package("typearea", "DIV#{div}") if div
|
89
|
+
@booktabs = @deplate.variables['useBooktabs']
|
90
|
+
add_package('booktabs') if @booktabs
|
88
91
|
|
89
92
|
lang_cmd = @deplate.options.messages.prop('lang_cmd', self)
|
90
93
|
if lang_cmd
|
@@ -103,13 +106,112 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
103
106
|
|
104
107
|
def prepare_headings
|
105
108
|
case @document_class
|
106
|
-
when
|
107
|
-
@headings = [
|
109
|
+
when 'book'
|
110
|
+
@headings = ['chapter', 'section', 'subsection', 'subsubsection', 'paragraph', 'subparagraph']
|
108
111
|
else
|
109
|
-
@headings = [
|
112
|
+
@headings = ['section', 'subsection', 'subsubsection', 'paragraph', 'subparagraph']
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def initialize_deplate_sty
|
117
|
+
unless @deplate.variables[:deplate_sty]
|
118
|
+
add_package('color')
|
119
|
+
# add_package('ulem')
|
120
|
+
add_package('deplate')
|
121
|
+
pkg = 'deplate.sty'
|
122
|
+
fn = @deplate.find_in_lib(pkg, :pwd => true)
|
123
|
+
dir = File.dirname(output_destination)
|
124
|
+
dest = File.join(dir, pkg)
|
125
|
+
# @deplate.copy_file(fn, dest)
|
126
|
+
Deplate::Template.copy(@deplate, fn, dest)
|
127
|
+
# if fn
|
128
|
+
# lines = File.read(fn) {|io| io.readlines}
|
129
|
+
# output_at(:pre, :styles, lines)
|
130
|
+
# end
|
131
|
+
@deplate.variables[:deplate_sty] = true
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
def wrap_formatted_particle_styles(invoker, value, args)
|
136
|
+
s = args[:styles]
|
137
|
+
unless s.empty?
|
138
|
+
initialize_deplate_sty
|
139
|
+
# if preferred_style_markup(invoker, 'particle', 'span')
|
140
|
+
value = wrap_inject(value, s,
|
141
|
+
:spre => '\\%sSpan{',
|
142
|
+
:post => '}') do |s, pre, post|
|
143
|
+
ltx = '%s}' % pre.strip
|
144
|
+
@deplate.endmessage(ltx, %{You might need to define #{ltx} in deplate.sty.})
|
145
|
+
end
|
146
|
+
# else
|
147
|
+
# value = wrap_accumulate(value, args[:styles]) do |s, ltx|
|
148
|
+
# ltx = ltx.strip
|
149
|
+
# @deplate.endmessage(ltx, %{You might need to define #{ltx} in deplate.sty.})
|
150
|
+
# end
|
151
|
+
# end
|
152
|
+
end
|
153
|
+
value
|
154
|
+
end
|
155
|
+
|
156
|
+
def wrap_formatted_element_styles(invoker, value, args)
|
157
|
+
s = args[:styles]
|
158
|
+
unless s.empty?
|
159
|
+
initialize_deplate_sty
|
160
|
+
# if preferred_style_markup(invoker, 'element', 'block')
|
161
|
+
value = wrap_inject(value, s,
|
162
|
+
:spre => "\\begin{%sBlock}\n",
|
163
|
+
:spost => "\\end{%sBlock}\n") do |s, pre, post|
|
164
|
+
ltx = '%sBlock' % s.strip
|
165
|
+
@deplate.endmessage(ltx, %{You might need to define the #{ltx} environment in deplate.sty.})
|
166
|
+
end
|
167
|
+
# else
|
168
|
+
# value = wrap_accumulate(value, args[:styles]) do |s, ltx|
|
169
|
+
# ltx = ltx.strip
|
170
|
+
# @deplate.endmessage(ltx, %{You might need to define #{ltx} in deplate.sty.})
|
171
|
+
# end
|
172
|
+
# end
|
173
|
+
end
|
174
|
+
value
|
175
|
+
end
|
176
|
+
|
177
|
+
def preferred_style_markup(invoker, what, style)
|
178
|
+
what = "#{what}Style"
|
179
|
+
(invoker.args[what] || @deplate.variables[what]) == style
|
180
|
+
end
|
181
|
+
private :preferred_style_markup
|
182
|
+
|
183
|
+
def wrap_inject(text, styles, args={})
|
184
|
+
styles.inject(text) do |v, s|
|
185
|
+
pfx = args[:pre]
|
186
|
+
unless pfx
|
187
|
+
pfx = args[:spre] % s
|
188
|
+
end
|
189
|
+
sfx = args[:post]
|
190
|
+
unless sfx
|
191
|
+
sfx = args[:spost] % s
|
192
|
+
end
|
193
|
+
if block_given?
|
194
|
+
yield(s, pfx, sfx)
|
195
|
+
end
|
196
|
+
[pfx, v, sfx].join
|
110
197
|
end
|
111
198
|
end
|
199
|
+
private :wrap_inject
|
112
200
|
|
201
|
+
def wrap_accumulate(text, styles, template='\\%sStyle{}')
|
202
|
+
styles = styles.collect do |s|
|
203
|
+
l = template % s
|
204
|
+
if block_given?
|
205
|
+
yield(s, l)
|
206
|
+
end
|
207
|
+
l
|
208
|
+
end
|
209
|
+
text.sub(/\A(\s*)(.*?)(\s*)\Z/m) do |m|
|
210
|
+
%{#$1{#{styles}#$2}#$3}
|
211
|
+
end
|
212
|
+
end
|
213
|
+
private :wrap_accumulate
|
214
|
+
|
113
215
|
def wrap_text(text, args={})
|
114
216
|
args[:check] ||= lambda do |line|
|
115
217
|
mt = /\\verb(.)/.match(line)
|
@@ -154,7 +256,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
154
256
|
|
155
257
|
|
156
258
|
################################################ Lists {{{1
|
157
|
-
def format_list_item(invoker, type, level, item)
|
259
|
+
def format_list_item(invoker, type, level, item, args={})
|
158
260
|
indent = format_indent(level, true)
|
159
261
|
ctag = list_wide? ? '' : :empty
|
160
262
|
explv = list_item_explicit_value(item)
|
@@ -162,17 +264,36 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
162
264
|
explv = %{[#{explv}]}
|
163
265
|
end
|
164
266
|
case type
|
165
|
-
when "
|
267
|
+
when "Ordered"
|
166
268
|
return wrap_text("#{indent}\\item#{explv} #{item.body}", :indent => " "), ctag
|
167
269
|
when "Itemize"
|
168
270
|
return wrap_text("#{indent}\\item #{item.body}", :indent => " "), ctag
|
169
271
|
when "Description"
|
170
272
|
return wrap_text("#{indent}\\item[#{item.item}] #{item.body}", :indent => " "), ctag
|
273
|
+
when 'Custom'
|
274
|
+
t = item.opts[:custom]
|
275
|
+
return wrap_text("#{indent}\\#{t}Item{#{item.item}}{#{item.body}}", :indent => " "), ctag
|
276
|
+
when 'Task'
|
277
|
+
pri = item.opts[:priority]
|
278
|
+
cat = item.opts[:category]
|
279
|
+
due = item.opts[:due]
|
280
|
+
due = " (#{due})" if due
|
281
|
+
lab = cat ? "\\task#{cat}{#{cat}#{pri}#{due}}" : "#{cat}#{pri}"
|
282
|
+
body = item.body
|
283
|
+
if item.opts[:done]
|
284
|
+
lab = "\\taskdone{#{lab}}"
|
285
|
+
body = "\\taskdone{#{body}}"
|
286
|
+
end
|
287
|
+
it = "#{indent}\\task{#{lab}}{#{body}}"
|
288
|
+
return wrap_text(it, :indent => " "), nil
|
171
289
|
when "Paragraph"
|
172
290
|
fs = list_wide? ? "\n%s\n" : "\n%s"
|
173
291
|
return fs % wrap_text("#{indent}#{item.body}", :indent => " "), nil
|
292
|
+
when 'Container'
|
293
|
+
fs = list_wide? ? "\n%s\n" : "\n%s"
|
294
|
+
return fs % item.body, nil
|
174
295
|
else
|
175
|
-
|
296
|
+
invoker.log(['Unknown list type', type], :error)
|
176
297
|
end
|
177
298
|
end
|
178
299
|
|
@@ -194,7 +315,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
194
315
|
post = ""
|
195
316
|
end
|
196
317
|
case type
|
197
|
-
when "
|
318
|
+
when "Ordered"
|
198
319
|
case subtype
|
199
320
|
when "a", "A"
|
200
321
|
return format_list_enumerate_alpha(invoker, what, subtype, w, pre, post)
|
@@ -203,10 +324,16 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
203
324
|
end
|
204
325
|
when "Itemize"
|
205
326
|
return "#{pre}\\#{w}{itemize}#{post}"
|
327
|
+
when 'Task'
|
328
|
+
initialize_deplate_sty
|
329
|
+
return "#{pre}\\#{w}{tasklist}#{post}"
|
330
|
+
when 'Custom'
|
331
|
+
initialize_deplate_sty
|
332
|
+
return "#{pre}\\#{w}{#{subtype}List}#{post}"
|
206
333
|
when "Description"
|
207
334
|
return "#{pre}\\#{w}{description}#{post}"
|
208
335
|
else
|
209
|
-
|
336
|
+
invoker.log(['Unknown list type', type], :error)
|
210
337
|
end
|
211
338
|
end
|
212
339
|
|
@@ -241,17 +368,17 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
241
368
|
caption = invoker.caption
|
242
369
|
acc = []
|
243
370
|
if inline
|
244
|
-
acc << include_image(elt, args, true)
|
371
|
+
acc << include_image(invoker, elt, args, true)
|
245
372
|
else
|
246
373
|
floatPos, alignCmd = float_options(invoker)
|
247
374
|
in_env = !(args["inline"] || @deplate.variables["imgInline"])
|
248
375
|
in_env &&= floatPos || alignCmd || caption
|
249
376
|
if in_env
|
250
377
|
acc << figure_top(invoker)
|
251
|
-
acc << include_image(elt, args)
|
378
|
+
acc << include_image(invoker, elt, args)
|
252
379
|
acc << figure_bottom(invoker)
|
253
380
|
else
|
254
|
-
acc << include_image(elt, args)
|
381
|
+
acc << include_image(invoker, elt, args)
|
255
382
|
acc << format_label(invoker, :once)
|
256
383
|
end
|
257
384
|
end
|
@@ -283,25 +410,18 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
283
410
|
join_blocks(acc)
|
284
411
|
end
|
285
412
|
|
286
|
-
def include_image(file,
|
287
|
-
|
288
|
-
|
413
|
+
def include_image(invoker, file, args, inline=false)
|
414
|
+
file = args['file'] if args['file']
|
415
|
+
if file =~ Deplate::HyperLink::Url.rx
|
416
|
+
Deplate::Core.log([%{Can't include remote images in current document}, file], :error)
|
417
|
+
file = File.basename(file)
|
418
|
+
end
|
419
|
+
ff = use_image_filename(file, args)
|
420
|
+
o = []
|
289
421
|
bw, bh, bx, by, desc = nil
|
290
422
|
@deplate.in_working_dir do
|
291
|
-
|
292
|
-
|
293
|
-
suffixes = image_suffixes
|
294
|
-
catch(:found) do
|
295
|
-
for sfx in suffixes
|
296
|
-
ff = f + sfx
|
297
|
-
if ls.include?(ff)
|
298
|
-
throw :found
|
299
|
-
end
|
300
|
-
end
|
301
|
-
ff = file
|
302
|
-
end
|
303
|
-
bw = options["bw"]
|
304
|
-
bh = options["bh"]
|
423
|
+
bw = args['bw']
|
424
|
+
bh = args['bh']
|
305
425
|
desc = Deplate::External.image_dimension(ff)
|
306
426
|
unless (bw and bh) or @deplate.options.pdftex
|
307
427
|
bw, bh, bx, by = desc[:bw]
|
@@ -310,7 +430,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
310
430
|
unless @deplate.options.pdftex
|
311
431
|
o << "bb=0 0 #{bw || "100"} #{bh || "100"}"
|
312
432
|
end
|
313
|
-
width =
|
433
|
+
width = args['w'] || args['width']
|
314
434
|
if width
|
315
435
|
if width =~ /^\d+%$/
|
316
436
|
width = width.to_f / 100
|
@@ -331,7 +451,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
331
451
|
end
|
332
452
|
end
|
333
453
|
end
|
334
|
-
height =
|
454
|
+
height = args['h']
|
335
455
|
if height
|
336
456
|
if height =~ /^\d+%$/
|
337
457
|
height = height.to_f / 100
|
@@ -342,13 +462,13 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
342
462
|
o << "height=#{height}pt"
|
343
463
|
end
|
344
464
|
end
|
345
|
-
o = o.join(
|
465
|
+
o = o.join(',')
|
346
466
|
if !o.empty?
|
347
|
-
o = "[
|
467
|
+
o = "[#{o}]"
|
348
468
|
end
|
349
|
-
add_package(
|
469
|
+
add_package('graphicx')
|
350
470
|
rv = "\\includegraphics#{o}{#{ff}}"
|
351
|
-
rot =
|
471
|
+
rot = args['rotate'] || @deplate.variables['imgRotate']
|
352
472
|
if rot
|
353
473
|
rv = %{\\rotatebox{#{rot}}{#{rv}}}
|
354
474
|
end
|
@@ -357,9 +477,9 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
357
477
|
|
358
478
|
def image_suffixes
|
359
479
|
if @deplate.options.pdftex
|
360
|
-
[
|
480
|
+
['.pdf', '.jpeg', '.jpg', '.png', '.gif', '.bmp']
|
361
481
|
else
|
362
|
-
[
|
482
|
+
['.eps', '.ps', '.jpeg', '.jpg', '.png', '.gif', '.bmp']
|
363
483
|
end
|
364
484
|
end
|
365
485
|
|
@@ -367,20 +487,20 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
367
487
|
pkg_previous = @packages[pkg]
|
368
488
|
if pkg_previous
|
369
489
|
if options != pkg_previous
|
370
|
-
log([
|
490
|
+
log(['Already required package with different options', pkg, pkg_previous, options], :error)
|
371
491
|
end
|
372
492
|
return
|
373
493
|
else
|
374
494
|
@packages[pkg] = options.dup
|
375
495
|
case pkg
|
376
|
-
when
|
496
|
+
when 'hyperref', 'graphicx'
|
377
497
|
if @deplate.options.pdftex
|
378
|
-
options <<
|
498
|
+
options << 'pdftex'
|
379
499
|
end
|
380
500
|
end
|
381
501
|
|
382
502
|
unless options.empty?
|
383
|
-
options = "[
|
503
|
+
options = "[#{options.join(',')}]"
|
384
504
|
end
|
385
505
|
if pkg =~ /\.\w+$/
|
386
506
|
output_at(:pre, :user_packages, "\\input{#{pkg}}")
|
@@ -405,7 +525,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
405
525
|
when "!"
|
406
526
|
note = "Important"
|
407
527
|
else
|
408
|
-
|
528
|
+
invoker.log(["Unknown marker", marker], :error)
|
409
529
|
note = "Note"
|
410
530
|
end
|
411
531
|
note = "%s: " % @deplate.msg(note)
|
@@ -466,11 +586,18 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
466
586
|
join_blocks(acc)
|
467
587
|
end
|
468
588
|
|
469
|
-
def format_heading(invoker)
|
470
|
-
args
|
471
|
-
|
472
|
-
|
473
|
-
|
589
|
+
def format_heading(invoker, level=nil, elt=nil, args=nil)
|
590
|
+
args ||= invoker.args
|
591
|
+
level ||= invoker.level
|
592
|
+
elt ||= invoker.elt
|
593
|
+
if invoker
|
594
|
+
caption = invoker.caption
|
595
|
+
invoker.label << args[:id]
|
596
|
+
labels = format_label(invoker, :string)
|
597
|
+
else
|
598
|
+
caption = nil
|
599
|
+
labels = nil
|
600
|
+
end
|
474
601
|
if caption
|
475
602
|
cap = "[#{caption.elt}]"
|
476
603
|
else
|
@@ -482,8 +609,6 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
482
609
|
else
|
483
610
|
mode = ""
|
484
611
|
end
|
485
|
-
invoker.label << args[:id]
|
486
|
-
labels = format_label(invoker, :string)
|
487
612
|
if hd
|
488
613
|
join_blocks(["\n\\#{hd}#{mod}#{cap}{#{elt}}", labels])
|
489
614
|
else
|
@@ -542,7 +667,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
542
667
|
header = e.format_current
|
543
668
|
elsif e.kind_of?(Deplate::Element::Table)
|
544
669
|
if e.elt.size > 1
|
545
|
-
log("Only the header's first row will be used", :error)
|
670
|
+
invoker.log("Only the header's first row will be used", :error)
|
546
671
|
end
|
547
672
|
header = e.elt[0].cols.collect{|c| c.cell}
|
548
673
|
while header.last.empty?
|
@@ -558,7 +683,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
558
683
|
end
|
559
684
|
end
|
560
685
|
elts = "%s %s" % [elt.size, elt.collect {|e| e.class}.join(", ")]
|
561
|
-
log(["Header must contain only 1 element (a paragraph or a table)", elts], :error)
|
686
|
+
invoker.log(["Header must contain only 1 element (a paragraph or a table)", elts], :error)
|
562
687
|
end
|
563
688
|
|
564
689
|
def format_footer(invoker)
|
@@ -609,7 +734,8 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
609
734
|
acc << c % elt
|
610
735
|
end
|
611
736
|
end
|
612
|
-
acc << "\\maketitle\n" if elts.include?("title")
|
737
|
+
acc << "\\maketitle\n" if elts.include?("title")
|
738
|
+
# and elts.include?("author")
|
613
739
|
kw = keywords
|
614
740
|
acc << %{#{@deplate.msg("Keywords:")} #{kw.join(", ")}} << "" if kw
|
615
741
|
# end
|
@@ -622,7 +748,10 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
622
748
|
|
623
749
|
def format_MAKEBIB(invoker)
|
624
750
|
style = invoker.elt
|
625
|
-
|
751
|
+
if style.empty?
|
752
|
+
style = @deplate.variables['bibStyle']
|
753
|
+
end
|
754
|
+
bib = @deplate.options.bib.collect{|f| File.basename(f, ".bib")}.join(",")
|
626
755
|
"\\bibliographystyle{#{style}}\n\\bibliography{#{bib}}\n"
|
627
756
|
end
|
628
757
|
alias :format_bibliography :format_MAKEBIB
|
@@ -637,11 +766,13 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
637
766
|
|
638
767
|
|
639
768
|
################################################ Particles {{{1
|
640
|
-
def format_emphasize(invoker, text)
|
769
|
+
def format_emphasize(invoker, text=nil)
|
770
|
+
text ||= invoker.elt || invoker.text
|
641
771
|
"\\emph{%s}" % text
|
642
772
|
end
|
643
773
|
|
644
|
-
def format_code(invoker, text)
|
774
|
+
def format_code(invoker, text=nil)
|
775
|
+
text ||= invoker.elt || invoker.text
|
645
776
|
"\\texttt{%s}" % plain_text(text, true)
|
646
777
|
end
|
647
778
|
|
@@ -658,7 +789,7 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
658
789
|
def format_wiki(invoker, name, dest, anchor)
|
659
790
|
add_package("hyperref")
|
660
791
|
if dest and !dest.empty?
|
661
|
-
log(["Wiki name as url", dest], :debug)
|
792
|
+
invoker.log(["Wiki name as url", dest], :debug)
|
662
793
|
format_url(invoker, name, dest, anchor)
|
663
794
|
else
|
664
795
|
# "%s~($\\Rightarrow{}$\\pageref{%s})" % [plain_text(name), anchor]
|
@@ -745,22 +876,24 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
745
876
|
def format_footnote(invoker)
|
746
877
|
elt = invoker.elt
|
747
878
|
if elt
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
879
|
+
body = elt.format_current
|
880
|
+
if body
|
881
|
+
return "\\footnote{#{body.rstrip}}"
|
882
|
+
end
|
752
883
|
end
|
884
|
+
return ''
|
753
885
|
end
|
754
886
|
|
755
887
|
def format_ref(invoker)
|
756
|
-
add_package(
|
888
|
+
add_package('hyperref')
|
757
889
|
args = invoker.args
|
758
890
|
text = invoker.text
|
759
|
-
p = args[
|
891
|
+
p = args['p']
|
892
|
+
prefix = invoker.args['prefix'] || '~'
|
760
893
|
if p
|
761
|
-
return "
|
894
|
+
return "#{prefix}\\pageref{#{text}}"
|
762
895
|
else
|
763
|
-
return "
|
896
|
+
return "#{prefix}\\ref{#{text}}"
|
764
897
|
end
|
765
898
|
end
|
766
899
|
|
@@ -772,11 +905,11 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
772
905
|
def format_cite(invoker)
|
773
906
|
args = invoker.args
|
774
907
|
elt = invoker.elt
|
775
|
-
add_package(
|
776
|
-
n = args[
|
777
|
-
p = args[
|
778
|
-
np = args[
|
779
|
-
y = args[
|
908
|
+
add_package('natbib', 'round')
|
909
|
+
n = args['n']
|
910
|
+
p = args['p']
|
911
|
+
np = args['np']
|
912
|
+
y = args['y']
|
780
913
|
c = elt
|
781
914
|
o = []
|
782
915
|
o << "[#{n}]" if n
|
@@ -867,16 +1000,15 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
867
1000
|
|
868
1001
|
|
869
1002
|
################################################ List of ... {{{1
|
870
|
-
def
|
1003
|
+
def format_list_of_toc(invoker)
|
871
1004
|
"\\tableofcontents{}"
|
872
1005
|
end
|
873
|
-
alias format_list_of_toc format_list_of_contents
|
874
1006
|
|
875
|
-
def
|
1007
|
+
def format_list_of_lot(invoker)
|
876
1008
|
"\\listoftables{}"
|
877
1009
|
end
|
878
1010
|
|
879
|
-
def
|
1011
|
+
def format_list_of_lof(invoker)
|
880
1012
|
"\\listoffigures{}"
|
881
1013
|
end
|
882
1014
|
|
@@ -886,6 +1018,33 @@ class Deplate::Formatter::LaTeX < Deplate::Formatter
|
|
886
1018
|
"\\printindex{}"
|
887
1019
|
end
|
888
1020
|
|
1021
|
+
def listing_prematter(invoker, args, id)
|
1022
|
+
type = args[:prefix]
|
1023
|
+
@deplate.endmessage("listing_#{type}", %{You might need to edit deplate.sty and define the environment #{type}List and the command \\#{type}Item.}
|
1024
|
+
)
|
1025
|
+
nil
|
1026
|
+
end
|
1027
|
+
|
1028
|
+
def listing_postmatter(invoker, args)
|
1029
|
+
''
|
1030
|
+
end
|
1031
|
+
|
1032
|
+
def listing_title(invoker, args, name)
|
1033
|
+
if name
|
1034
|
+
format_heading(nil, 1, @deplate.msg(name), {'noList' => true})
|
1035
|
+
end
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
def listing_item(invoker, args, prefix, title, heading, level, other_args)
|
1039
|
+
b = title
|
1040
|
+
# <+TBD+> Hyperlinks
|
1041
|
+
# use latex contents infrastructure?
|
1042
|
+
i = heading.plain_caption? ? nil : heading.level_as_string
|
1043
|
+
s = Deplate::ListItem.new(i, b, "Custom", "Custom", level, 0, true)
|
1044
|
+
s.opts = {:subtype => prefix, :custom => prefix}
|
1045
|
+
s
|
1046
|
+
end
|
1047
|
+
|
889
1048
|
|
890
1049
|
################################################ Table {{{1
|
891
1050
|
def table_indented_row(invoker, row, indent, cells)
|