38

I've written a load of technical documentation in Markdown. I chose to use this for versioning and so we can view in on GitHub.

We now need to share this with external users (who aren't as comfortable with Markdown), so I would like to convert it to PDF.

Gimli seems to be the best tool I have found for the conversion (it uses the same stylesheet as GitHub so it looks the same), however it doesn't convert the links as well. Is there anything that'll also do this?

Luca Spiller
  • 2,248
  • 4
  • 24
  • 28

3 Answers3

33

I don't know with which type of links you have problems (inline links, reference links, HTML links, image links, automatic links...), but you can try to use Pandoc:

pandoc *.md -o result.pdf

This will convert all files with the *.md file extension to a single pdf.

Sonson123
  • 10,879
  • 12
  • 54
  • 72
  • 6
    It doesn't work for internal links, but it seems to be the best tool so far. Thanks. – Luca Spiller Apr 29 '13 at 14:18
  • 4
    How does pandoc work out page ordering? Say I have 10 *.md files, how do I specify the order they are rendered? – CadentOrange Feb 20 '17 at 16:27
  • 1
    In bash it is a alphabetically sorted list. See f.ex. the [Is it possible to change the order of a glob?](http://unix.stackexchange.com/questions/34063/is-it-possible-to-change-the-order-of-a-glob) answers for other possibilities. – Sonson123 Feb 21 '17 at 07:18
  • 6
    Note: This worked for me on my mac, but using `*.md` (e.g. wildcards) does NOT yet work on pandoc for Windows. You have to sum up all the .md files separately; as I found out today for a student of mine. But 'catting' them as @PerfectlyRock describes in his answer. – Bart Apr 05 '18 at 14:17
  • 2
    How to make *.md work for Windows 10 powershell or cmdline? – Zony Zhao Aug 13 '22 at 04:00
  • 2
    pandoc: *.md: openBinaryFile: invalid argument (Invalid argument) – scrollout Oct 24 '22 at 01:41
  • @scrollout Use this command in advance: type *.md > allfiles.md . Then pandoc allfiles.md -o result.pdf – jumpjack Jan 10 '23 at 12:05
1

I use named anchor tags in my markdown document. And I make links to these names. For example,

<a name="#1-overview"></a>
##1. Overview

......

Reference: [1. Overview](#1-overview)

Then I use Typora to open the markdown document and export it to PDF. The resulting PDF preserves these internal links properly.

jkjung13
  • 926
  • 7
  • 10
  • That's one type of internal link, another type are links *between* the different md files included in the output. – Att Righ Nov 19 '20 at 16:21
-14

NO!!! You really don't have to do this!!! Simply " cat *.md > allpages.md " (you may want to organize the order manually or setup each file in a proper name to let cat work) then open the allpages.md then choose print / export in any markdown editor!!!!

You don't have to install ANYTHING!!!!

PerfectlyRock
  • 405
  • 2
  • 7
  • 10
    Yeah, that's a pretty crappy way. No TOC, no internal links, no proper sectioning. Just a long run of concatenated pages. – DennisK Jul 13 '18 at 06:25
  • I do not know why people hate this method while it is better than any other methods that I came across – Polla A. Fattah Jul 18 '18 at 18:25
  • 2
    Because the method is not "better", Polla - PerfectlyRock just distracted from the original question. It is also a bit unfortunate that we depend on pandoc, since this pulls in the haskell stack. :( – shevy Apr 14 '19 at 13:26
  • This way you loose all important metadata like TOC, pages, etc. If you just want jumbled up data then yeah cat all day. – thefern Oct 14 '20 at 03:02