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

Mark Text doesn't open link to non markdown files #2396

Closed
raphaelhuleux opened this issue Nov 20, 2020 · 15 comments · Fixed by #2563
Closed

Mark Text doesn't open link to non markdown files #2396

raphaelhuleux opened this issue Nov 20, 2020 · 15 comments · Fixed by #2563
Labels
🐮 good first issue Good for new comers 🦄 feature request New feature or request

Comments

@raphaelhuleux
Copy link

Hi,

In my markdown files, I have link to pdf files written as
[name](/path/to/pdf.pdf). Those links are recognized by when I click them, nothing happens. In Typora, clicking on those links open them in my default pdf reader app.

@brainchild0
Copy link
Contributor

brainchild0 commented Nov 21, 2020

Do you want a relative link to appear in a PDF document?

@raphaelhuleux
Copy link
Author

I am not sure what you mean by this. The expected behaviour would be that when clicking on the link (cmd + click, more precisely), the pdf file would be opened in the default app.

@brainchild0
Copy link
Contributor

Perhaps your expectation is accurate for links given as a fully-qualified URL to a web page. Your example takes the form of a path to a file on your local system, whereas PDF documents are generally, and by design, standalone, or self contained.

I would not personally expect any PDF to feature a link that is relative, or as in the form of your example (and despite my earlier incorrect characterization) absolute but local to some system.

One question is whether you do get the desired behavior if you use a full URL (e.g. https://www.github.com. (A second question whether, if the first answer is affirmative, then whether you really do believe that a bug or useful enhancement has been identified.)

@raphaelhuleux
Copy link
Author

raphaelhuleux commented Nov 22, 2020 via email

@brainchild0
Copy link
Contributor

Simply opening the linked file in the default PDF app.

I think I understand, but it appears to me that for this feature, separate from what Typora might do, whether by design or accident, the current behavior might be more desirable. If you attach a PDF file for example to an e-mail message, then the local link is not available to the recipient. PDF documents are by design generally standalone, for example, with respect to media being embedded, and similarly, I tend to expect that links will be limited to fully-qualified URIs.

Perhaps describing a full use case would bring better light to the subject.

@raphaelhuleux
Copy link
Author

raphaelhuleux commented Nov 22, 2020 via email

@brainchild0
Copy link
Contributor

Maybe I have misunderstood. Are you referring to issues in PDF documents generated by the application from Markdown, or links to PDF documents in the Markdown editor?

@raphaelhuleux
Copy link
Author

Links to PDF documents in the Markdown editor. Maybe I'll be clearer if I explain my workflow more precisely:

  • I have a list of markdown files, connected between themselves with links [title](title.md).
  • When I want to make a reference to a certain pdf file I just read, I also create a link to those files as such [name_pdf](path/to/pdf.pdf).
    Right now, if I click in Mark Text on a link to a markdown file, this file is opened in Mark Text. If I click on a link to a pdf file, nothing happens. I would to change this behavior to open the file in a pdf app.

@brainchild0
Copy link
Contributor

I see. Unfortunately, I misunderstood the original problem.

However, I am still wondering whether many of the same observations are relevant. Creating a Markdown document that is tied to the layout of a local system seems very unfamiliar to me, even if Typora allows the specific behavior.

@fxha
Copy link
Contributor

fxha commented Nov 22, 2020

@raphaelhuleux Thanks for creating this issue. There's currently no handler implemented for local relative paths but feel free to create a PR, the code is located here.

I'm thinking of the following: Open a local relative path iff the document/file is saved or an absolute path if the file exists on disk and it's safe to open the file. We have to consider that we might open a bad path such as a script or launch an application.

Edit: There is also an issue in line 400, we first need to check that dirname is not empty.

@fxha fxha added 🐮 good first issue Good for new comers 🦄 feature request New feature or request labels Nov 22, 2020
@brainchild0
Copy link
Contributor

There's currently no handler implemented for local relative paths but feel free to create a PR, the code is located here.

Isn't this issue primarily about absolute paths? (Or are you using relative in the loose sense, of local?)

@fxha
Copy link
Contributor

fxha commented Nov 22, 2020

Sorry, I was thinking about relative images before but it doesn't matter. If we find a valid path that isn't a URL or markdown file, try to open it with the default application. Relative paths are often used in blog pages and absolute if you manage your notes with Mark Text. It shouldn't be to hard to implement this but we need take care of bad paths.

@brainchild0
Copy link
Contributor

Sorry, I was thinking about relative images before but it doesn't matter. If we find a valid path that isn't a URL or markdown file, try to open it with the default application. Relative paths are often used in blog pages and absolute if you manage your notes with Mark Text. It shouldn't be to hard to implement this but we need take care of bad paths.

I feel cautious about giving the same behavior to absolute links versus relative. Absolute links seem to erode the principles of Markdown.

@FrancoisEx
Copy link

This feature would be very helpful. I use Markdown notes to organize my work and the possibility to link to local files is quintessential for that. It is easy to do in Typora, impossible yet in Mark Text. I strongly support the development and the integration of this feature request.
An alternative is to use Obsidian.

@xiongmao86
Copy link

xiongmao86 commented Jan 9, 2021

I would like to take a stab, but I am not sure what to do when dirname is empty? Show a message box or simply do nothing? @fxha?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐮 good first issue Good for new comers 🦄 feature request New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants