New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links are not created as links #30

Closed
sanitz opened this Issue May 16, 2014 · 33 comments

Comments

Projects
None yet
@sanitz

sanitz commented May 16, 2014

When I use links in markdown with the syntax [description](url) I only get blue highlighted text in the pdf, but not the actual link.

@cades

This comment has been minimized.

cades commented Aug 17, 2014

+1, and the link url is explicitly print out, becomes
text (http://url)

@jhawkinsatgood

This comment has been minimized.

jhawkinsatgood commented Aug 20, 2014

+1
I tried this on Mac and Debian and have the same problem. On Debian the address is selectable as text but it still appears twice, and isn't a link.

@software-engineering

This comment has been minimized.

software-engineering commented Aug 26, 2014

+1

@alanshaw

This comment has been minimized.

Owner

alanshaw commented Aug 26, 2014

The link appears as test (http://url) because of the html5bp stylesheet - https://github.com/alanshaw/markdown-pdf/blob/master/html5bp/css/main.css#L242-L244

As for the link not being a link, this is a phantomjs issue that markdown-pdf doesn't have any control over - ariya/phantomjs#10196.

@alanshaw alanshaw closed this Aug 26, 2014

@jhawkinsatgood

This comment has been minimized.

jhawkinsatgood commented Aug 26, 2014

My feeling is that this limitation should be documented on the front page of the markdown-pdf project, even though it is an inherited limitation from the phantomjs project. Same goes for the limitation that the PDF doesn't have selectable text with Mac.

@alanshaw

This comment has been minimized.

Owner

alanshaw commented Aug 26, 2014

Good idea

@jhawkinsatgood

This comment has been minimized.

jhawkinsatgood commented Aug 27, 2014

I happened to find out today that the setup with the best output is ... Microsoft Windows and Adobe Acrobat.
In that setup I get selectable text and clickable links. The link syntax is not quite correctly handled but it seems better than OS X and Debian.

@markau

This comment has been minimized.

markau commented Oct 29, 2014

Does anyone know of a workaround for this? It's a real shame the links look a bit messy.

In the PhantomJS issue thread, the point is made that the link in brackets is a good idea because the PDF is (arguably) designed for printing. In which case if we could just have the link name render as plain text (not underlined) followed by an underlined, clickable link in brackets that would perhaps be ideal. Either way the link name being underlined is what I would like to remove.

@jhawkinsatgood

This comment has been minimized.

jhawkinsatgood commented Oct 30, 2014

I haven't tried but you might be able to achieve that in CSS somehow

@JonathanMH

This comment has been minimized.

JonathanMH commented Jan 22, 2015

+1

@andyinabox

This comment has been minimized.

andyinabox commented Jan 24, 2015

+1 yeah this is a real bummer, not being able to use links with the expected behavior out of the box.

@brunowego

This comment has been minimized.

brunowego commented Mar 24, 2015

+1

1 similar comment
@mamachanko

This comment has been minimized.

mamachanko commented May 4, 2015

+1

@danielbayley

This comment has been minimized.

danielbayley commented Jul 8, 2015

As pointed out above, the full URL appearing in brackets is only down to the CSS content: rule/s, which can easily be overridden with your own CSS. The issue is that the links don't work. According to that PhantomJS issue thread, It looks like someone has actually fixed this now, but it's waiting to be pulled in. Could we get an update on here when it has please?

@anko

This comment has been minimized.

Collaborator

anko commented Sep 18, 2015

Could this issue be reopened? Upstream limitations that cause problems are still limitations that cause problems and should be tracked.

I didn't initially notice #63 was about this, because this was closed…

@biofractal

This comment has been minimized.

biofractal commented Sep 18, 2015

If I read it correctly then the PhantomJS issue at the root of the problem looks like it may well have been fixed: phantomjs/issues/10196?

@anko

This comment has been minimized.

Collaborator

anko commented Sep 18, 2015

@biofractal

This PR ariya/phantomjs#13250 is supposedly a fix, but it hasn't been merged and maintainers haven't commented—likely because PhantomJS is primarily a headless browser, which only happens to have a PDF renderer, so their priorities are elsewhere. (I don't know enough about Qt to comment on how likely it is to get merged.) The patch's author mentions that a Windows binary is available, else compile from source.

Another alternative might be wkhtmltopdf built with their Qt patches, which claims it can do links correctly. I tested the package in the Arch Linux repositories, and found it to have been built to the usual unpatched QtWebkit, and hence couldn't create hyperlinks in the output PDF. So again, have to compile from source.

Haven't tested either yet.

@biofractal

This comment has been minimized.

biofractal commented Sep 18, 2015

That is the can of worms officially opened - I have gone from idly wondering how to apply a CSS fix to compiling un-merged binaries from projects that are two upstreams removed. One more and we will be compiling Kevin Bacon from source.

I can see the argument that the link url should be rendered beside the link text because PDFs are intended for printing. At least I have a tech-excuse I can now wave at the punters. Still, links that don't work at all just because they look different is probably not too clever.

I will keep an eye on this and await developments.

@danielbayley

This comment has been minimized.

danielbayley commented Sep 18, 2015

One more and we will be compiling Kevin Bacon from source.

LOL

I can see the argument that the link url should be rendered beside the link text because PDFs are intended for printing.

Not at all always; there are plenty of situations where a PDF is intended only for [digital] presentation. Brand guidelines generated from the actual related web stylesheets say, for one example…

@jasonb-vbt

This comment has been minimized.

jasonb-vbt commented Nov 11, 2015

+1 to all of this. I accept that it's a phantomJS issue, but jeez, they coudl at least give us some kind of option to control the link formatting.

@ulidtko

This comment has been minimized.

ulidtko commented Dec 3, 2015

Still not solved? This issue is horrible!

@ghost

This comment has been minimized.

ghost commented Dec 26, 2015

As pointed out from @alanshaw its just a insane HTML5 Boildplate default for print styles. Just overwrite with your own CSS. For make any URL auto linked use linkable: true

abbr[title]:after,
a[href]:after {
    content: "";
}
.pipe(markdownpdf({
    cssPath:  'css/your-css-file.css',
    remarkable: {
        linkify: true,
    }
}))
@marinaserranomontes

This comment has been minimized.

marinaserranomontes commented Jan 18, 2016

@alanshaw any update about how a "description" line from a markdown file works in a converted pdf? Thanks

@alanshaw

This comment has been minimized.

Owner

alanshaw commented Jan 18, 2016

Description line?

@belyan

This comment has been minimized.

belyan commented Jan 28, 2016

Root cause of the problem was fixed in QT and included in release version 5.6:
https://bugreports.qt.io/browse/QTBUG-44563

Fix from QT was merged to PhantomJS and included in Release 2.1:
ariya/phantomjs#10196

@alanshaw Please, update PhantomJS to version 2.1 in your plugin. This will fix the problem with hyperlinks.

anko added a commit to anko/markdown-pdf that referenced this issue Jan 28, 2016

Update to phantomjs 2.1
The new PhantomJS version can create hyperlink data, so links in the
output PDF become clickable. Fixes alanshaw#30.

The package name "phantomjs" has been deprecated in favour of the name
"phantomjs-prebuilt": the package and its maintainers are the same.
@jasonb-vbt

This comment has been minimized.

jasonb-vbt commented Jan 28, 2016

Did anyone try this out? I did an npm update -g markdown-pdf, and so far as I can tell I now have v7.0.0, with phantomjs-prebuilt 2.1.3 under the covers, yet my PDFs still have un-clickable links. @belyan, @alanshaw, are there any other special steps I need to take?

@anko

This comment has been minimized.

Collaborator

anko commented Jan 28, 2016

@jasonb-vbt

As mentioned in #80, I found it to work on Linux.

Some things to check:

  • Does markdown-pdf --version say 7.0.0?
  • Do your URIs start with http:// or https:// at the start?
    [link text](https://github.com) works for me, but
    [link text](github.com) doesn't.
  • Are you perhaps using the --phantom-path/-p flag to point to an old phantomjs binary?

If still no cake:

  • Do you also have a phantomjs binary installed separately, with phantomjs --version 2.1.1 or greater? (The phantomjs-prebuilt package should correctly detect that and use it, but maybe something weird is going on.)
  • What OS are you on?
  • What PDF reader are you using? (I tested with zathura and Google Drive.)
  • Could you post a simple test case?
@belyan

This comment has been minimized.

belyan commented Jan 28, 2016

@anko Thank you for the quick feedback and the new release. I checked it - hyperlinks now work.
OS - Windows 7 SP1
PDF Reader - Adobe Reader 11.0.3

@jasonb-vbt

This comment has been minimized.

jasonb-vbt commented Jan 28, 2016

Thanks, all. I seem to have two installations of markdown-pdf on my machine. Not sure how that happened, but yeah, it was looking at the old one.

@anko

This comment has been minimized.

Collaborator

anko commented Jan 28, 2016

@belyan And thank you for the heads-up on Phantom's update. The release was all @alanshaw though; I only PR'd with a 2-line diff! 😛

@jasonb-vbt Perhaps you changed the global install directory between installs. Good to hear it works now.

@Nikolay-Kha

This comment has been minimized.

Nikolay-Kha commented Oct 24, 2016

Hello!
I still have such issue on linux mint 18 (i.e. ubuntu 16.04).

$ phantomjs -v
2.1.1
$ markdown-pdf --version
7.0.0

Command line for generating pdf is: markdown-pdf DeviceHiveESP8266.md -o $BUILD/DeviceHiveESP8266.pdf so there is no specified phantom path. I looked on output PDF with Xreader, google docs and even on another computer. Links like:

[Overview](#overview)

become links to <full original md document dir>/markdown-pdf.html and they don't work in viewers.
My MD file - https://github.com/devicehive/esp8266-firmware/blob/develop/DeviceHiveESP8266.md

image

@anko

This comment has been minimized.

Collaborator

anko commented Oct 29, 2016

@Nikolay-Kha I think #66 is the issue you're hitting. Intra-document links (like to #overview) are rendered as links, but not to the right place.

@Nikolay-Kha

This comment has been minimized.

Nikolay-Kha commented Oct 31, 2016

@anko Thank you for pointing it out. That is exactly my case. Hope phantomjs will add fragment identifiers support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment