lib/pdfkit/pdfkit.rb in pdfkit-0.8.4.3.2 vs lib/pdfkit/pdfkit.rb in pdfkit-0.8.5

- old
+ new

@@ -112,11 +112,13 @@ found end def style_tag_for(stylesheet) - "<style>#{File.read(stylesheet)}</style>" + style = "<style>#{File.read(stylesheet)}</style>" + style = style.html_safe if style.respond_to?(:html_safe) + style end def preprocess_html if @source.html? processed_html = PDFKit::HTMLPreprocessor.process(@source.to_s, @root_url, @protocol) @@ -127,10 +129,12 @@ def append_stylesheets raise ImproperSourceError, 'Stylesheets may only be added to an HTML source' if stylesheets.any? && !@source.html? stylesheets.each do |stylesheet| if @source.to_s.match(/<\/head>/) - @source = Source.new(@source.to_s.gsub(/(<\/head>)/) {|s| style_tag_for(stylesheet) + s }) + @source = Source.new(@source.to_s.gsub(/(<\/head>)/) {|s| + style_tag_for(stylesheet) + (s.respond_to?(:html_safe) ? s.html_safe : s) + }) else @source.to_s.insert(0, style_tag_for(stylesheet)) end end end