markdown-pdf icon indicating copy to clipboard operation
markdown-pdf copied to clipboard

How can I create links to other parts of the document?

Open brunoshine opened this issue 10 years ago • 11 comments

Hi all, If a markdown as a link to another page (markdown), can I also make it work inside PDF?

thanks. Bruno

brunoshine avatar Oct 29 '15 12:10 brunoshine

Not currently.

At the moment, we don't have any clickable links in output PDFs yet: that's issue #30. We're waiting on upstream ariya/phantomjs to release v2.0.1 which would enable this. I asked the applicable PR for clarification on whether we can expect intra-document links to work.

anko avatar Oct 29 '15 23:10 anko

+1 I need this too. As well, clarification on how the links should be authored. E.g. the if test1.md is trying to link to test2.md, what should go in the parens for the link? Should it be link text? That seems weird, since in the context of the pdf, the target isn't actually test1.md anymore, but some internal PDF reference. Except there's no way for me to know what that reference would be ahead of time. Maybe it should be some kind of explicit anchor authored with remarkable-classy? I don't know. Anyway, need guidance.

jasonb-vbt avatar Nov 11 '15 18:11 jasonb-vbt

We now have clickable links thanks to phantomjs2 - it would be awesome if someone could do some research on this to see if it's possible and and document it on the README if it is!?

alanshaw avatar Jan 29 '16 12:01 alanshaw

@alanshaw

An unsuccessful test:

I tried linking to a fragment identifier (#something) and defining the target heading as HTML:

[link to heading?](#heading)

<div style="page-break-after:always"></div> <!-- Push to next page -->

<h1 id="heading">head</h1>

Compile with --remarkable-options '{"html":true}'.

The link which PhantomJS creates is to $DIR/markdown-pdf.html#heading, where $DIR is an absolute path to the project directory where I ran markdown-pdf… which is entirely useless.

Looks like the new code in PhantomJS that creates links doesn't yet treat fragment identifiers (links to parts of the same document) particularly sensibly.

anko avatar Jan 29 '16 14:01 anko

Ah. @anko's latest comment explains why my intra-document links aren't working. External links seem to work fine, but fat lot of good that does me when writing a lengthy piece of self-cross-referencing documentation.

jasonb-vbt avatar Jan 29 '16 17:01 jasonb-vbt

What's the status of this?

mic-e avatar Jul 19 '17 11:07 mic-e

@mic-e We're blocked on https://github.com/ariya/phantomjs/issues/13959 upstream. The issue looks to be still deeper: in qtbase. If you know C and want to have a go, try @astefanutti's implementation hints.

Potential future fix: Use Headless Chrome as a renderer instead. It won't support Windows until Chrome 60. It uses a different rendering engine, but I don't know if it's better about rendering links. But maybe it is.

Current workaround: Use a separate tool.

anko avatar Jul 19 '17 13:07 anko

Slightly related: https://github.com/jonschlinkert/remarkable/issues/284 Header anchors So headlines become link anchors automatically.

luckydonald avatar Nov 17 '17 16:11 luckydonald

This project is great! But I can confirm from the future that this is still an issue.

I'm writing documentation in markdown that I'd like to share as a pdf, and this limitation makes it impossible to have a working table of contents in the generated PDF.

Adding my +1 for solving this.

kgreenek avatar May 04 '18 23:05 kgreenek

I replaced markdown-pdf with mdpdf where links (from markdown-toc) inside the document worked in the generated pdf.

hacker112 avatar Oct 25 '19 12:10 hacker112

You can put the mouse over the chain icon at the left side of any title, do rigth click, copy the link address and use it as the link for your hiperlink. In that way you can use links to other parts of the document.

image

MichaelOsorio2017 avatar Nov 08 '19 02:11 MichaelOsorio2017