Live data from Hacker News

Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?

news.ycombinator.com

51–58 of 58 posts

Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?

#51
post #9

I 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.

You are right if OP want to do this manually. If not I guess it is much more complicated, you would need some tool that allows you to print rendered markdown. Add one more step: convert print to PDF and effectively you have tool to convert markdown to PDF.

I do this with Chrome for my resume. Write it in Markdown, convert to HTML using Pandoc and then print it to PDF using Chrome.

Google\ Chrome --no-sandbox --headless --print-to-pdf-no-header --no-pdf-header-footer --enable-logging=stderr --log-level=2 --in-process-gpu --disable-gpu --print-to-pdf=resume.pdf "file://path/to/resume.html"

Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?

#52

Earlier quoted context omitted.

I wonder how the Mdast and pandoc ASTs compare? I did a customized-MD pipeline which normalized to pandoc (extra features got encoded to pass through pandoc), obtained the pandoc JSON ast, and emitted html/latex/etc using Julia pattern matching. The code was small, and the yak shave and husbandry was worth escaping the struggle with sea of crufty candidate tools, each with assorted one-chosen-point in a high-dimensio…

I am not familiar with Pandoc, but it looks like a command-line tool that can do the same things? (Edit: I suspect this is probably one of those situations where different industries/domains end up developing similar tools in different ecosystems... Pandoc probably makes sense in academia, LaTex workflows, etc.? Mdast is used for web apps. I can see both realms wanting to do Markdown conversions, so I'm not surprised…

Let's see. So there are parsers in various languages, parsing various MD dialects, with varied internal representations, and surrounding ecosystems. And there are attempts at more turnkey document processing systems, often with a more extended dialect, and some collection of feature plugins. Often you can write pipeline AST filters in the given language, and sometimes get out an AST as JSON, and sometimes reinject JSON AST (allowing writing a filter in any language). Which leaves questions like: what dialect is the parser; is that extensible; how robustly correct is it; how clean and easily used and fragile is the AST; how well do the plugins/ecosystem already support your needed features. That AST one, I think of as a big deal, and hard to get a handle on. Aside from manipulation pragmatics, the asts resulting from parsing can get richly creative in quirkiness, that you then may need to regularize.

So I guess two main observations. On build-vs-buy for backend features, given the breadth of possible "we want it like this, and not that", if one can easily play with ASTs, I was surprised by how quickly reinventing the wheel became a plausible call. Possibly skimming existing backend code for insight and templates, but mostly not using it (aka struggling to configure it to give you "this and not that"). The other observation, is once you have ast and don't care about existing backends, your choice of parser and backend language/ecosystem decouple. One might use `pandoc --to=json` and then JS generic-ast tooling to emit HTML.

For parsing, a glance suggests Mdast emphasizes CommonMark and Github-flavored dialects. Pandoc-flavored MD is a bit broader.[1] My fuzzy recollection is I chose a pandoc parse for that, and an expectation of robustness ("it's haskell, and popular"), despite the then less that wonderful docs. IIRC, the resulting asts were fine. For backend, I wanted simple and concise to minimize burden, thus pattern matching (IIRC, most node types ended up a line or two), and chose road-less-traveled Julia for off-topic reasons (was thinking of using Julia for a compiler backend).

Thanks for your thoughts on Mdast - I'm tempted to play with it.

[1] https://garrettgman.github.io/rmarkdown/authoring_pandoc_mar...

Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?

#54
post #51

Earlier quoted context omitted.

You are right if OP want to do this manually. If not I guess it is much more complicated, you would need some tool that allows you to print rendered markdown. Add one more step: convert print to PDF and effectively you have tool to convert markdown to PDF.

I do this with Chrome for my resume. Write it in Markdown, convert to HTML using Pandoc and then print it to PDF using Chrome. Google\ Chrome --no-sandbox --headless --print-to-pdf-no-header --no-pdf-header-footer --enable-logging=stderr --log-level=2 --in-process-gpu --disable-gpu --print-to-pdf=resume.pdf "file://path/to/resume.html"

Pretty neat. Did not thought that it is possible. Thanks.

Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?

#55

It's not marketed as a markdown-to-pdf tool, but I've found that Obsidian ( https://obsidian.md ) does an excellent job. Just create a new "vault", paste your markdown into a new note, and export to PDF.

I love Obsidian too, however I found that internal links didn't work when exporting it. Do you know what format works? My internal links work in the Obsidian preview but not in the PDF export.

How should the internal links work when converting into a PDF? They are obviously intended to enable a wiki-like structure in your notes, but I don't see a ways they could work upon export.

Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?

#57

I've been saving Markdown transcripts of my more involved AI chats, and I was unhappy with how any tool rendered to PDF. In either Cursor or Windsurf, I had Claude 3.5 Sonnet code a Ruby script for me that converts Markdown to Typst, a LaTeX alternative that looks a lot like Markdown. Typst offers beautiful formatting control for the output PDFs.

In your opinion, does Typst male better pdfs than LaTex and if so, why?

Re: Ask HN: Where are the good Markdown to PDF tools (that meet these requirements)?

#58

It's not marketed as a markdown-to-pdf tool, but I've found that Obsidian ( https://obsidian.md ) does an excellent job. Just create a new "vault", paste your markdown into a new note, and export to PDF.

I love Obsidian too, however I found that internal links didn't work when exporting it. Do you know what format works? My internal links work in the Obsidian preview but not in the PDF export.

Do you mean internal links within the page, or within your vault? I can't say I've relied on either in a pdf export, but I would expect the former to work and the latter to fail. I suppose links to other notes in your vault could use the obsidian:// protocol but that would be weird to say the least.
Post reply on HN