Skip to content

Instantly share code, notes, and snippets.

@tdreyno
Created August 3, 2011 23:22
Show Gist options
  • Save tdreyno/1124121 to your computer and use it in GitHub Desktop.
Save tdreyno/1124121 to your computer and use it in GitHub Desktop.
Latex 2 PDF Middleman
# Find all markdown files
path = File.join(File.dirname(__FILE__), "source", "**/*.html.markdown")
# Also generate .latex files along side
Dir[path].each do |markdown_file|
http_path = markdown_file.split("source").last.gsub(".html.markdown", "")
page "#{http_path}.latex", :proxy => "#{http_path}.html", :latex => true, :layout => false
end
require "fileutils"
Middleman::Builder.after_run do
# Find all latex files
path = File.join(File.dirname(__FILE__), "build", "**/*.latex")
Dir[path].each do |latex_file|
`pandoc #{latex_file} -o #{latex_file.gsub(".latex", ".pdf")}`
FileUtils.rm(latext_file)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment