simov / markdown-viewer

Markdown Viewer / Browser Extension
MIT License
1.05k stars 133 forks source link

Feature Request: create Linux command-line version to do converting from markdown to HTML files and PDFs #129

Open ElectricRCAircraftGuy opened 3 years ago

ElectricRCAircraftGuy commented 3 years ago

Currently I use your tool manually to view a markdown file in Chrome then print it to a PDF from Chrome. See my answer here: https://superuser.com/questions/689056/how-can-i-convert-github-flavored-markdown-to-a-pdf/1591372#1591372.

However, I'd really like to be able to automate this by running a single command from the command-line. Perhaps you could help make this happen?

Example usage:

markdown2pdf readme.md  # convert readme.md to readme.pdf

If not, where should I begin in your code? If it is super simple I might be able to make time for it to do the PR myself.


Note: you may need to use Chrome's headless mode somehow to open and save a markdown to HTML file as PDF? See here and here and here: https://developers.google.com/web/updates/2017/04/headless-chrome.

simov commented 3 years ago

If you need it rendered with a specific theme before exporting, then yes, you need a renderer. So the way I would do it is by using https://www.npmjs.com/package/puppeteer to render the document and trigger the PDF export. Either way that's a tool outside of this project.