question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Integrate mdpdf as the primary converter

See original GitHub issue

Changing because the output of mdpdf looks so great. Finally now getting around to starting this.

I have one commit pushed to this branch, but am getting an error regarding atom’s content security policy, like this:

Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self'".


    at Object.createFunctionContext (/home/travis/github/markdown-pdf/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:254:23)
    at Object.compile (/home/travis/github/markdown-pdf/node_modules/handlebars/dist/cjs/handlebars/compiler/javascript-compiler.js:142:19)
    at compileInput (/home/travis/github/markdown-pdf/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:517:53)
    at ret (/home/travis/github/markdown-pdf/node_modules/handlebars/dist/cjs/handlebars/compiler/compiler.js:524:18)
    at readFile.then.then.then.then.md (/home/travis/github/markdown-pdf/node_modules/mdpdf/index.js:161:16)
    at tryCatcher (/home/travis/github/markdown-pdf/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/home/travis/github/markdown-pdf/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/home/travis/github/markdown-pdf/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/home/travis/github/markdown-pdf/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/home/travis/github/markdown-pdf/node_modules/bluebird/js/release/promise.js:693:18)
    at Promise._fulfill (/home/travis/github/markdown-pdf/node_modules/bluebird/js/release/promise.js:638:18)
    at /home/travis/github/markdown-pdf/node_modules/bluebird/js/release/nodeback.js:42:21
    at tryToString (fs.js:455:3)
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:442:12)

It appears that this is due to some eval call in mdpdf (most likely in one of its dependencies), but I couldn’t find such a call. I have tried wrapping the mdpdf usage in loophole to escape the CSP, but I still get the error.

I would much rather use the mdpdf API, but if I can’t get this resolved then we may have to resort to calling mdpdf from the command line in a child process (not a clean solution).

@BlueHatbRit Do you have any idea of where such a call may be in the mdpdf stack? If so, maybe I can help make a workaround that lets us use mdpdf inside atom given its current CSP.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:22 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
travscommented, Aug 31, 2017

@BlueHatbRit Looks great, thanks!

0reactions
BlueHatbRitcommented, Aug 30, 2017

@travs oh that’s great thanks, you did all the work so I wouldn’t want my name anywhere else haha.

Here’s the link back if you wanted to check it out -> https://github.com/BlueHatbRit/mdpdf/commit/8fade1b3db7fb23e6e244c9bd8cca1e0d6e14767. I’ll be pushing it to npm later on today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can not add a default header or footer using the markdown.js file ...
... find how to do a simple text footer and header to add to my markdown notes when i convert them to PDF....
Read more >
Markdown pages - export to PDF (#13932) · Issues - GitLab
For anyone interested, I created a CI integration that takes all markdown files and generates PDFs (and docx files) as artifacts. I use...
Read more >
mPDF – mPDF Manual
mPDF is a PHP library which generates PDF files from UTF-8 encoded HTML. It is based on FPDF and HTML2FPDF, with a number...
Read more >
mdpdf - PyPI
Python command line application to convert Markdown to PDF.
Read more >
How to convert Markdown to PDF - Crushing C.O.D.E
Although writing code is the primary focus for any developer, ... So I decided to write the integration guide as a markdown file....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found