0
@@ -16,12 +16,17 @@ module RTeX
0
class GenerationError < ::StandardError; end
0
class ExecutableNotFoundError < ::StandardError; end
0
+ # [+:preprocess+] Are we preprocessing? Default is +false+
0
+ # [+:preprocessor+] Executable to use during preprocessing (generating TOCs, etc). Default is +latex+
0
+ # [+:shell_redirect+] Option redirection for shell output (eg, +"> /dev/null 2>&1"+ ). Default is +nil+.
0
+ # [+:tmpdir+] Location of temporary directory (default: +Dir.tmpdir+)
0
:preprocessor => 'latex',
0
:processor => 'pdflatex',
0
- # Option redirection for shell output (eg, set to '> /dev/null 2>&1' )
0
:shell_redirect => nil,
0
@@ -37,13 +42,15 @@ module RTeX
0
- def source(binding=nil)
0
+ # Get the source for the entire
0
+ def source(binding=nil) #:nodoc:
0
@source ||= wrap_in_layout do
0
filter @erb.result(binding)
0
+ # Process through defined filter
0
+ def filter(text) #:nodoc:
0
return text unless @options[:filter]
0
if (process = RTeX.filters[@options[:filter]])
0
@@ -52,7 +59,8 @@ module RTeX
0
+ # Wrap content in optional layout
0
+ def wrap_in_layout #:nodoc:
0
ERB.new(@options[:layout]).result(binding)
0
@@ -60,19 +68,23 @@ module RTeX
0
+ # to_pdf # => PDF in a String
0
+ # to_pdf { |filename| ... }
0
def to_pdf(binding=nil, &file_handler)
0
process_pdf_from(source(binding), &file_handler)
0
+ def processor #:nodoc:
0
@processor ||= check_path_for @options[:processor]
0
+ def preprocessor #:nodoc:
0
@preprocessor ||= check_path_for @options[:preprocessor]
0
+ def system_path #:nodoc:
0
@@ -80,6 +92,7 @@ module RTeX
0
+ # Verify existence of executable in search path
0
def check_path_for(command)
0
unless FileTest.executable?(command) || system_path.split(":").any?{ |path| FileTest.executable?(File.join(path, command))}
0
raise ExecutableNotFoundError, command
0
@@ -87,6 +100,7 @@ module RTeX
0
def process_pdf_from(input, &file_handler)
0
Tempdir.open(@options[:tempdir]) do |tempdir|
0
@@ -103,7 +117,7 @@ module RTeX
0
unless `#{processor} --interaction=nonstopmode '#{source_file}' #{@options[:shell_redirect]}`
0
raise GenerationError, "Could not generate PDF using #{processor}"
Comments
No one has commented yet.