Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
google.pdf
yahoo.pdf
*.pdf
tests/shoflo.js
shoflo.js
google2.pdf
html.pdf
node_modules
6 changes: 5 additions & 1 deletion render.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ if (phantom.args.length < 2) {
console.log('incorrect args');
phantom.exit();
} else {
var options = JSON.parse(phantom.args[2]);
var optionsStr = phantom.args[2];
// fix various escapings
optionsStr = optionsStr.replace(/\\!/g, '!'); // fix escaping of exclamation mark
optionsStr = optionsStr.replace(/\\\\"/g, '\\"'); // fix double escape of quot chars
var options = JSON.parse(optionsStr);

contentsCb(options.paperSize.header);
contentsCb(options.paperSize.footer);
Expand Down
24 changes: 23 additions & 1 deletion tests/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,29 @@ describe('pdf#content', function() {
assert.ok(false);
d();
});
})
});

it('fixes shell escaping in content', function(d){
this.timeout(5000);
var args = { content: '<html><head><title>PDF</title></head><body class="test"><div></div><!-- some comment --></body></html>' };
var pdf = new Pdf(null, 'html2.pdf', args);
pdf.on('done', function(file){
assert.equal(FP + '/html2.pdf', file);
d();
});

});

it('fixes shell escaping in content (issue #33)', function(d){
this.timeout(5000);
var args = { content: '<html><body><img src="https://www.google.com/images/srpr/logo11w.png" alt="google"/></body></html>' };
var pdf = new Pdf(null, 'html3.pdf', args);
pdf.on('done', function(file){
assert.equal(FP + '/html3.pdf', file);
d();
});

});
});

describe('pdf#done() 2', function(){
Expand Down