Created
          April 10, 2012 02:30 
        
      - 
      
- 
        Save lazypower/2347985 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | source 'https://rubygems.org' | |
| gem 'redcarpet' | |
| gem 'pdfkit' | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | 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