MyST-Parser icon indicating copy to clipboard operation
MyST-Parser copied to clipboard

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

Open Mershl opened this issue 4 years ago • 3 comments

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 avatar Oct 01 '21 13:10 Mershl

Thanks for opening your first issue here! Engagement like this is essential for open source projects! :hugs:
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! :tada:

welcome[bot] avatar Oct 01 '21 13:10 welcome[bot]

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 avatar Oct 01 '21 13:10 chrisjsewell

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

choldgraf avatar Oct 02 '21 21:10 choldgraf