I'm trying to convert a very large Markdown file (a couple hundred pages) to PDF.
It contains lots of code in code blocks and has a table of contents at the start with internal links to later pages.
I've tried lots of different Markdown-PDF converters like md2pdf and Pandoc, even trying converting it through LaTeX first, however none of them produce working internal PDF links, have effective syntax highlighting for HTML, CSS, JavaScript and Python, and wrap code to fit it on the page.
I have a very long regular expression (email validation of course) that doesn't fit on one line but no solutions I have found properly break the lines on page overflow.
What tools does everyone recommend?
What 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!
[1]: https://github.com/TikhonJelvis/RL-book