Skip to content

Commit

Permalink
call the "org-file-to-pdf" emacs function from acts_as_org.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
Francesco Pizzolante authored and eschulte committed Nov 23, 2009
1 parent 9f90d66 commit fdca7a2
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions lib/acts_as_org.rb
Expand Up @@ -80,6 +80,24 @@ def clean_latex?(path)
l_path = self.latex_path(path) l_path = self.latex_path(path)
File.exist?(l_path) and File.mtime(l_path) > File.mtime(path) File.exist?(l_path) and File.mtime(l_path) > File.mtime(path)
end end

def pdf_path(path)
File.join(File.dirname(path),
ActiveFile::Acts::Org::EXP_PREFIX + File.basename(path) + ".pdf")
end

def to_pdf(path, options = {})
p_path = self.pdf_path(path)
options = {:postamble => false}.merge(options)
self.emacs_run("(org-file-to-pdf \"#{path}\")") unless self.clean_pdf?(path)
return nil unless File.exist?(p_path)
html = File.read(p_path)
end

def clean_pdf?(path)
p_path = self.pdf_path(path)
File.exist?(p_path) and File.mtime(p_path) > File.mtime(path)
end
end end


module InstanceMethods module InstanceMethods
Expand Down Expand Up @@ -107,6 +125,19 @@ def to_latex(options = {})
self.class.to_latex(self.full_path, options) self.class.to_latex(self.full_path, options)
end end
alias :to_tex :to_latex alias :to_tex :to_latex

def pdf_path
self.class.pdf_path(self.full_path)
end

def clean_pdf?
self.class.clean_pdf?(self.full_path)
end

def to_pdf(options = {})
self.class.to_pdf(self.full_path, options)
end

end end
end end
end end
Expand Down

0 comments on commit fdca7a2

Please sign in to comment.