awhyte-rtex 2.1.2 → 2.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rtex +6 -6
- data/lib/rtex/document.rb +36 -7
- data/lib/rtex/version.rb +2 -2
- data/rtex.gemspec +1 -1
- metadata +1 -1
data/bin/rtex
CHANGED
@@ -41,12 +41,12 @@ opts = OptionParser.new do |opts|
|
|
41
41
|
STDERR.puts "Could not find application at #{path}"
|
42
42
|
exit 1
|
43
43
|
end
|
44
|
-
|
45
|
-
FileUtils.
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
STDERR.puts "Installed at #{
|
44
|
+
|
45
|
+
dest_dir = FileUtils.mkdir_p(File.join(plugins, 'rtex'))
|
46
|
+
plugin_file = File.join(File.dirname(__FILE__), "..", "rails", "init.rb")
|
47
|
+
FileUtils.cp plugin_file, dest_dir
|
48
|
+
|
49
|
+
STDERR.puts "Installed at #{dest_dir}"
|
50
50
|
exit
|
51
51
|
end
|
52
52
|
|
data/lib/rtex/document.rb
CHANGED
@@ -51,6 +51,8 @@ module RTeX
|
|
51
51
|
# [+:tmpdir+] Location of temporary directory (default: +Dir.getwd+)
|
52
52
|
# [+:shell_redirect+] Option redirection for shell output,
|
53
53
|
# e.g. +"> /dev/null 2>&1"+ (default: +nil+).
|
54
|
+
# [+:command_prefix+] String (or array) of environment variable settings
|
55
|
+
# for the +:processor+ and +:preprocessor+ commands.
|
54
56
|
#
|
55
57
|
def initialize(content, options={})
|
56
58
|
@options = self.class.options.merge(options)
|
@@ -115,10 +117,13 @@ module RTeX
|
|
115
117
|
:processor => 'pdflatex',
|
116
118
|
:shell_redirect => nil,
|
117
119
|
:tex_inputs => nil,
|
120
|
+
:command_prefix => nil,
|
118
121
|
:tempdir => Dir.getwd # Current directory unless otherwise set
|
119
122
|
}
|
120
123
|
end
|
121
124
|
|
125
|
+
attr_reader :options
|
126
|
+
|
122
127
|
private
|
123
128
|
|
124
129
|
# Verify existence of executable in search path
|
@@ -155,16 +160,20 @@ module RTeX
|
|
155
160
|
File.open(source_file, 'wb') { |f| f.puts input }
|
156
161
|
end
|
157
162
|
|
163
|
+
def command(executable)
|
164
|
+
"#{environment_vars}#{executable} --output-directory='#{tempdir}' --interaction=nonstopmode '#{File.basename(source_file)}' #{@options[:shell_redirect]}"
|
165
|
+
end
|
166
|
+
|
158
167
|
# Run LaTeX pre-processing step on the source file
|
159
168
|
def preprocess!
|
160
|
-
unless `#{
|
169
|
+
unless `#{command(preprocessor)}`
|
161
170
|
raise GenerationError, "Could not preprocess using #{preprocessor}"
|
162
171
|
end
|
163
172
|
end
|
164
173
|
|
165
174
|
# Run LaTeX output generation step on the source file
|
166
175
|
def process!
|
167
|
-
unless `#{
|
176
|
+
unless `#{command(processor)}`
|
168
177
|
raise GenerationError, "Could not generate PDF using #{processor}"
|
169
178
|
end
|
170
179
|
end
|
@@ -197,6 +206,14 @@ module RTeX
|
|
197
206
|
end
|
198
207
|
end
|
199
208
|
|
209
|
+
# Produce a list of environment variables to prefix the process and
|
210
|
+
# preprocess commands.
|
211
|
+
#
|
212
|
+
def environment_vars
|
213
|
+
list = [tex_inputs, command_prefix].compact
|
214
|
+
list.empty? ? "" : list.join(" ") + " "
|
215
|
+
end
|
216
|
+
|
200
217
|
# Compile list of extra directories to search for LaTeX packages, using
|
201
218
|
# the file or array of files held in the :tex_inputs option.
|
202
219
|
#
|
@@ -209,12 +226,24 @@ module RTeX
|
|
209
226
|
end
|
210
227
|
end
|
211
228
|
|
212
|
-
#
|
213
|
-
#
|
229
|
+
# Occasionally it is useful to be able to prefix the LaTeX commands with
|
230
|
+
# extra environment variables, for example the +rlatex+ program,
|
214
231
|
#
|
215
|
-
|
216
|
-
|
217
|
-
|
232
|
+
# LATEXPRG=pdflatex rlatex [FILE...]
|
233
|
+
#
|
234
|
+
# which runs the command +pdflatex+ repeatedly until LaTeX is satisfied all
|
235
|
+
# cross-references etc. are stable.
|
236
|
+
#
|
237
|
+
# To achieve this with RTeX, use
|
238
|
+
#
|
239
|
+
# :processor => "rlatex", :command_prefix => "LATEXPRG=pdflatex"
|
240
|
+
#
|
241
|
+
def command_prefix
|
242
|
+
if prefix = @options[:command_prefix]
|
243
|
+
prefix = [prefix].flatten.join(" ")
|
244
|
+
else
|
245
|
+
nil
|
246
|
+
end
|
218
247
|
end
|
219
248
|
|
220
249
|
def source_file
|
data/lib/rtex/version.rb
CHANGED
data/rtex.gemspec
CHANGED