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

file:///// links skipped in HTML output of Sphinx #435

Open
Mershl opened this issue Oct 1, 2021 · 3 comments
Open

file:///// links skipped in HTML output of Sphinx #435

Mershl opened this issue Oct 1, 2021 · 3 comments
Labels
enhancement New feature or request

Comments

@Mershl
Copy link

Mershl commented Oct 1, 2021

Describe the problem

The behaviour of an inline link to an external resource (access through file://///) does not work as expected for an .md input to MyST when generating in HTML through Sphinx. (e.g. for referencing files on network shares)

Given an inline link like:

[Click me](file://///foo.com/dataXYZ/documentation.pdf)

Results in the inline link being output unprocessed:
grafik

Creating the link manually in the built html using:

<a class="reference external" href="file://///foo.com/dataXYZ/documentation.pdf">Click me</a>

Results in the expected link and works as expected in our tested browsers.

I guess that file:///// links are disabled/ignored by MyST per default as the protocol is disabled by most modern web browsers. In companies this legacy feature often times still used and enabled for the used browser. Is it possible to enable MyST to generate the expected link for this input?

Steps to reproduce

Using Sphinx and MyST.

  1. Create an .md containing:
    [Click me](file://///foo.com/dataXYZ/documentation.pdf)
  2. Add the .md to your index.rst
  3. Call ./make html to start the HTML generation of Sphinx
  4. Open generated .html. The file will contain the link unprocessed, looking like this:
    grafik

The version of Python you're using

3.9.7

Your operating system

Windows 10

Versions of your packages

Sphinx==4.0.2
myst-parser==0.15.1
sphinx-rtd-theme==0.5.2

@Mershl Mershl added the bug Something isn't working label Oct 1, 2021
@welcome
Copy link

welcome bot commented Oct 1, 2021

Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗

If you haven't done so already, check out EBP's Code of Conduct. Also, please try to follow the issue template as it helps other community members to contribute more effectively.

If your issue is a feature request, others may react to it, to raise its prominence (see Feature Voting).

Welcome to the EBP community! 🎉

@chrisjsewell
Copy link
Member

Heya, yeh unfortunately this URL is not recognised by default in CommonMark, see e.g. this example
It might be difficult to override this behaviour

perhaps overriding: https://github.com/executablebooks/markdown-it-py/blob/cde6906489c570fd3912ed0a1a6e21ae058348f7/markdown_it/main.py#L313, but I'm not definite

@chrisjsewell chrisjsewell added enhancement New feature or request and removed bug Something isn't working labels Oct 1, 2021
@choldgraf
Copy link
Member

If you primarily need this in Sphinx, I think the download role could do the trick for you. Want to try that? https://www.sphinx-doc.org/en/master/usage/restructuredtext/roles.html#referencing-downloadable-files

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

No branches or pull requests

3 participants