Hack out distributable notes in markdown
Using ruby to convert your markdown to a consistent, styled, and distributable PDF is super simple. I use this particular hack to convert everything from company memos to my resume
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")
Use of the script: convertthis file.md path/to/stylesheet
Written by Charles Butler
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Ruby
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#