ml-engineering icon indicating copy to clipboard operation
ml-engineering copied to clipboard

convert markdown to pdf

Open pengzhangzhi opened this issue 2 years ago • 7 comments

Hi, I had a good read of this book! Wondering if we can convert the markdown files to PDF so that we can print it out to read. I would like to submit a pr for that! Let me know if you are interested!

pengzhangzhi avatar Oct 23 '23 15:10 pengzhangzhi

That's an excellent idea, Zhangzhi.

If it can be automated for sure I'd be happy to receive such a PR.

Have you checked whether the github market perhaps already has an app to do that automatically?

stas00 avatar Oct 23 '23 15:10 stas00

Agreed, @pengzhangzhi. A PDF copy would be nice. For locally converting markdown to a PDF, pandoc seems pretty well known. However, in terms of GitHub automation for this, solutions seem a bit sparse. Perhaps the easiest way to do this would be to add a small blurb at the end of this project's README.md that instructs readers who would like to make a PDF copy of this repo to run the following commands mentioned in this post.

amorehead avatar Oct 23 '23 16:10 amorehead

Awesome! Let's do it step by step. I will first write a script to generate pdf locally and then figure out ways to automate this by GitHub automation.

pengzhangzhi avatar Oct 23 '23 16:10 pengzhangzhi

the grip recipe won't work well since this is a multi-file situation. the SO answer @amorehead linked to mentions https://wkhtmltopdf.org/downloads.html which is probably a much better tool for building pdfs from a set of files. So probably need to convert to html first with pandoc and then wkhtmltopdf that.

stas00 avatar Oct 23 '23 16:10 stas00

I would consider to build the pdf through Latex. In terms of advantages, its rendering is best; it is also way more stable and consistent than html-based solutions (weasyprint and wkhtml2pdf have very different looking results, wkhtml2pdf has not been supported for a while, it's a mess). In terms of inconvenient its install size is terrible. It's not also technically 'reproducible build' unless you follow a similar approach to what is done by https://github.com/hendricius/the-sourdough-framework (even without that it's much better than the html-based alternatives). Their pdf result (https://www.the-bread-code.io/book.pdf) is kind of perfect too.

len-foss avatar Jan 23 '24 10:01 len-foss

Thanks! How to convert markdown to latex... Any framework?

pengzhangzhi avatar Jan 23 '24 13:01 pengzhangzhi

The PDF is almost ready, please give me a few more weeks.

The building workflow is ready, but I need to finish the stylesheets and restructuring the chapters.

If you're impatient, the instructions are here https://github.com/stas00/ml-engineering/tree/master/build - but as I said the stylesheet needs a bit more work.

stas00 avatar Jan 23 '24 16:01 stas00

the pdf is finally done:

https://github.com/stas00/ml-engineering#pdf-version

stas00 avatar Jan 26 '24 18:01 stas00

@stas00 Thanks for making this happen! I had a good read!

pengzhangzhi avatar Jan 26 '24 21:01 pengzhangzhi

Thank you for validating that it is a good read, @pengzhangzhi

stas00 avatar Jan 26 '24 21:01 stas00