Skip to content

Instantly share code, notes, and snippets.

@lazypower
Created April 10, 2012 02:30
Show Gist options
  • Save lazypower/2347985 to your computer and use it in GitHub Desktop.
Save lazypower/2347985 to your computer and use it in GitHub Desktop.
source 'https://rubygems.org'
gem 'redcarpet'
gem 'pdfkit'
require 'redcarpet'
require 'pdfkit'
file = File.open(ARGV[0], "rb")
contents = file.read
options = [:hard_wrap => true, :space_after_headers => true, :autolink => true,
:fenced_code => true, :gh_blockcode => true]
markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, *options)
kit = PDFKit.new(markdown.render(contents),
:page_size => 'Letter')
if ARGV[1]
kit.stylesheets << ' #{ARGV[1]}'
end
saved_pdf = kit.to_file(ARGV[0] + ".pdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment