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

Relative links within the pdf #6

Open
elenalape opened this issue May 4, 2021 · 5 comments
Open

Relative links within the pdf #6

elenalape opened this issue May 4, 2021 · 5 comments

Comments

@elenalape
Copy link

To support GitHub flavoured markdown (along with #1), it would be nice to allow for relative links within the document. As a temporary solution, currently I'm changing them in the md file to web URLs using regex, and then passing it to mdpdf. Using sed:

#!/bin/bash
sed -i -e -r "s/(#[^ ][^\)]*)\)/https:\/\/example.org\/dir\1\)/g" file.md &
mdpdf -o file.pdf file.md

which finds bits such as #example-relative-link) and replaces them with https://example.org/dir#example-relative-link)

@normanlorrain
Copy link
Owner

It's something I've come across before (I see I left a TODO in the source). It would require maintaining a list of these links, and resolving them to their targets. I'm not sure CommonMark's AST code gives those targets.

https://spec.commonmark.org/0.29/#example-497

More information here and here

@elenalape
Copy link
Author

elenalape commented May 5, 2021

What do you think about using some regex to remove relative links then completely, so that no errors are thrown?
I could work on that change. Also, could remove the fancy badges (#1).

@normanlorrain
Copy link
Owner

I like that idea. "Explicit is better than implicit" etc.

If you want to take it on that would be great.

@elenalape
Copy link
Author

@normanlorrain do you have any advice on how to get the dev environment set up besides cheatsheet?
I'm having issues with the fitz/PyMuPDF imports (which you must have also had to navigate!) and would appreciate some pointers.

@normanlorrain
Copy link
Owner

I've updated the package. Sorry for the glitch, I missed some changes to PyMuPDF in their latest version.

If you upgrade your installation:
pip install --upgrade mdpdf
it should work now.

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

No branches or pull requests

2 participants