Skip to content
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

Handling relative URLs with Decktape #238

Open
btjanaka opened this issue Dec 18, 2021 · 4 comments
Open

Handling relative URLs with Decktape #238

btjanaka opened this issue Dec 18, 2021 · 4 comments
Labels

Comments

@btjanaka
Copy link

Hi! I am trying to convert a reveal.js presentation which includes relative links on the slides, e.g.

<a href="./foobar.html">Text</a>

When I convert via the ?print-pdf URL with reveal.js, such links are converted into absolute links, e.g. https://btjanaka.net/foobar.html, such that when I open the PDF, I can click on the link and be taken to the correct website.

Currently, I am trying to convert a local presentation on my filesystem to a PDF with decktape, e.g.

decktape ./build/index.html slides.pdf

The conversion works fine, but when I click on the link, it remains a relative URL and does not work. Of course, this makes sense, since I did everything locally.

I am wondering, is there some way to turn relative URLs into absolute URLs when performing a conversion with Decktape?

If not, would it be advisable to try something like developing a script that iterates through and changes every link? Thanks!

@astefanutti
Copy link
Owner

Hi, indeed the link URLs are not processed and exported as is.

Obviously, you could develop a pre-processing step that would change all the links and then run Decktape.

An other alternative could be to have an option in Decktape, that would activate the logic of iterating over all the relative links in every PDF page, and changing them to absolute links. We already iterate over images and fonts, so iterating over links would perfectly fit there:

function parseResources(dictionary) {

@btjanaka
Copy link
Author

Wow, thank you for such a prompt response. Unfortunately, I don't think I have bandwidth to implement this, but I will definitely keep an eye on this issue.

@psimm
Copy link

psimm commented Feb 18, 2024

Hi, indeed the link URLs are not processed and exported as is.

Obviously, you could develop a pre-processing step that would change all the links and then run Decktape.

Could you please explain what this pre-processing step would have to do?

For example, I have an internal link:

<a href="#/section-1">Section 1</a>

What would the processed link be? I attempted to use an absolute link to the local file:

<a href="file:///Users/me/Documents/presentation.html#section-1>Section 1</a>

but that didn't work.

@astefanutti
Copy link
Owner

@psimm based on your example, I think your use case is about internal links rather than relative links. There is another issue #49 open for handling the former.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants