<commit_before>require 'prawn'

if Prawn::VERSION == "0.8.4"
  require 'prawn/layout'
  require 'prawn/security'
end

module Prawn
  module Rails
    
    module PrawnHelper
      
      def prawn_document(opts={})
        download = opts.delete(:force_download)
        filename = opts.delete(:filename)
        pdf = (opts.delete(:renderer) || Prawn::Document).new(opts)
        yield pdf if block_given?
        
        disposition(download, filename) if (download || filename)
        
        pdf
      end
      
      def disposition(download, filename)
        download = true if (filename && download == nil)
        disposition = download ? "attachment;" : "inline;"
        disposition += " filename=#{filename}" if filename
        headers["Content-Disposition"]=disposition
      end
      
    end
    
    class TemplateHandler < ActionView::Template::Handler
      self.default_format = :pdf
      
      def self.call(template)
        "#{template.source.strip}.render"        
      end
      
    end
    
  end
end

Mime::Type.register_alias "application/pdf", :pdf
ActionView::Template.register_template_handler(:prawn, Prawn::Rails::TemplateHandler)
ActionView::Base.send(:include, Prawn::Rails::PrawnHelper)<commit_msg>The filename now is quoted<commit_after>require 'prawn'

if Prawn::VERSION == "0.8.4"
  require 'prawn/layout'
  require 'prawn/security'
end

module Prawn
  module Rails
    
    module PrawnHelper
      
      def prawn_document(opts={})
        download = opts.delete(:force_download)
        filename = opts.delete(:filename)
        pdf = (opts.delete(:renderer) || Prawn::Document).new(opts)
        yield pdf if block_given?
        
        disposition(download, filename) if (download || filename)
        
        pdf
      end
      
      def disposition(download, filename)
        download = true if (filename && download == nil)
        disposition = download ? "attachment;" : "inline;"
        disposition += " filename=\"#{filename}\"" if filename
        headers["Content-Disposition"] = disposition
      end
      
    end
    
    class TemplateHandler < ActionView::Template::Handler
      self.default_format = :pdf
      
      def self.call(template)
        "#{template.source.strip}.render"        
      end
      
    end
    
  end
end

Mime::Type.register_alias "application/pdf", :pdf
ActionView::Template.register_template_handler(:prawn, Prawn::Rails::TemplateHandler)
ActionView::Base.send(:include, Prawn::Rails::PrawnHelper)
{'fraction_non_alphanumeric': 0.11177644710578842, 'fraction_numerical': 0.0023952095808383233, 'mean_word_length': 2.6266280752532563, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '306079', 'n_tokens_mistral': 712, 'n_tokens_neox': 718, 'n_words': 154}