I'm surprised Pandoc didn't fit the bill. It's quite configurable with fenced attributes. I switched from using MD-->(Pandoc-->(latex))--> PDF to using MD-->(Pandoc-->(typst))--> PDF.
Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
11–20 of 58 posts
Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#12I think you're overcomplicating it. I assume you created this markdown file and I assume you have a preview render that shows it the way you like it to be shown. So just hit the print button, and in the print dialog select save as PDF.
Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#13Does converting to HTML first and then to PDF help?
This is what I have done for a couple of books I wrote in Markdown ( https://deanebarker.net/books/ ). Convert to HTML, then use Prince ( https://www.princexml.com/ ) to style and convert to PDF.
Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#14Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#15What worked well for me: Pandoc with a custom LaTeX template, and a decent amount of inline LaTeX to handle edge cases. We had a LaTeX theme to use from our publisher, but we also needed our own totally separate theme for the free version version of the book.
For one-off things like really long code lines, I found it best to manually figure out how to handle them. Sometimes there was a bit of TeX magic but, more often, I just rewrote or reorganized the code. I see the presentation and structure of code and math snippets as an integral part of how I'm communicating the underlying ideas, so manually changing things around to read better was fundamentally no different from going back and editing prose.
Unfortunately, this also means that the process was relatively hands-on. If you need something ≈completed automated, I expect Pandoc → LaTeX is going to fall a bit short. Edge cases need manual intervention, and it's easy for formatting errors to sneak in—the free version of our book has some formatting mistakes like code bleeding into the margin because I ran out of energy to fix all of them!
Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#16Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#17Earlier quoted context omitted.
This is what I have done for a couple of books I wrote in Markdown ( https://deanebarker.net/books/ ). Convert to HTML, then use Prince ( https://www.princexml.com/ ) to style and convert to PDF.
Their licenses are pretty expensive. Any good free open source alternatives?
Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#18Keep in mind that you'll need to install custom fonts if you're using languages other than English.
Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#19I think you're overcomplicating it. I assume you created this markdown file and I assume you have a preview render that shows it the way you like it to be shown. So just hit the print button, and in the print dialog select save as PDF.
Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?
#20https://github.com/syntax-tree/mdast-util-from-markdown
It might work better if you parse it into an intermediary Mdast format first, do whatever processing you need to implement "pages" (not a part of any Markdown dialect I'm familiar with?" but it shouldn't be hard to write a custom parser for that in Mdast), output that to HTML (via https://github.com/syntax-tree/mdast-util-to-hast) and THEN convert the HTML to PDF.
The AST tools basically give you structured JSON that's much easier to work with programmatically than raw Markdown. Then you can render that semantic JSON into HTML or other outputs.