Skip to content

Commit

Permalink
Non-PDFKit specific meta tags are simply skipped.
Browse files Browse the repository at this point in the history
  • Loading branch information
huerlisi committed Jan 10, 2011
1 parent c7149a2 commit 7fd74e3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/pdfkit/pdfkit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ def find_options_in_meta(content)

found = {}
content.scan(/<meta [^>]*>/) do |meta|
puts PDFKit.configuration.meta_tag_prefix
name = meta.scan(/name=["']#{PDFKit.configuration.meta_tag_prefix}([^"']*)/)[0][0]
found[name] = meta.scan(/content=["']([^"']*)/)[0][0]
if meta.match(/name=["']#{PDFKit.configuration.meta_tag_prefix}/)
name = meta.scan(/name=["']#{PDFKit.configuration.meta_tag_prefix}([^"']*)/)[0][0]
found[name] = meta.scan(/content=["']([^"']*)/)[0][0]
end
end

found
Expand Down
14 changes: 14 additions & 0 deletions spec/pdfkit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@
pdfkit.command[pdfkit.command.index('"--orientation"') + 1].should == '"Landscape"'
end

it "should skip non-pdfkit meta tags" do
body = %{
<html>
<head>
<meta name="test-page_size" content="Legal"/>
<meta name="pdfkit-orientation" content="Landscape"/>
</head>
<br>
</html>
}
pdfkit = PDFKit.new(body)
pdfkit.command[pdfkit.command.index('"--orientation"') + 1].should == '"Landscape"'
end

end

context "#to_pdf" do
Expand Down

0 comments on commit 7fd74e3

Please sign in to comment.