pandoc: how to make links work in Markdown across single-PDF PDF output AND Markdown multi-file output?

Viewed 418

I am using a single set of (multiple) Markdown files to produce both (a) single-file PDF output, via pandoc, and (b) multi-web-page WWW output, using markdown directly (with docsify, https://docsify.js.org/#/).

The problem is how to specify a link within my document.

  • For pdf, I'd like to use markdown that looks like [link](#id1). Because the PDF is a single-file output, I need to specify an internal link.
  • But for md/html, I'd like to use markdown that looks like [link](otherfile).

I am totally willing to handcode these, e.g.:

#if PDF
[link](#id1)
#elsif MD
[link](otherfile)
#endif

because they don't occur very often (but I don't know any construct of the above sort within markdown). The main goal is to write the md files once and never change them, even if it takes a little gymnastics within the md files themselves.

I could imagine this could be done with a (custom) pandoc filter, but I can't imagine this isn't a problem someone else has encountered (and solved) before.

0 Answers
Related