Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to insert a link to a local file into a markdown cell?

Tags:

Dear ipython notebook users,

I want to insert a link to a local file located in the notebook directory, and no, it is not an image (the only example I've found). I want to insert this link within a markdown cell.

When clicked on the link, the file is to be opened with a local application (in this case, a molecule viewer)

I've tried to come up with the correct syntax, but no luck. Please, any help is greatly appreciated.

like image 399
jmborr Avatar asked Aug 08 '13 23:08

jmborr


People also ask

How do you include links and images within markdown cells?

First open a markdown cell in Jupyter - can be a new markdown cell or an existing markdown cell. Then copy and paste the actual web address into a markdown cell. This will provide an active link to that website from the Notebook. Step 2, from that website, copy the image that you want to view in the Notebook.

How do I put the file path in markdown?

If the file is in the same directory as the one where the . md is, then just putting [Click here](MY-FILE.md) should work. Otherwise, can create a path from the root directory of the project.

How do I embed code in markdown cell?

Just follow the same steps each time. Press Esc key, type m for markdown cell, press Enter key. The cursor is now in the markdown cell waiting for instructions. Type your code or paste a code block.


2 Answers

I want to insert a link to a local file located in the notebook directory

I want to insert this link within a markdown cell.

The path need to be relative to where the server has been started, and prefixed with files/. e.g: [my molecule](files/molecules/ethanol.mol)

the file is to be opened with a local application (in this case, a molecule viewer)

Not possible unless your application support custom links protocol like the itunes:// or apt-get:// one. the best that can append is that on link click you will be prompted to download the file. (keep in mind that the server can be on a different machine thant your browser)

like image 171
Matt Avatar answered Oct 15 '22 14:10

Matt


completenting the answer of Matt, it will work only in you import FileLink

from IPython.display import FileLink, FileLinks FileLink('path_to_file/filename.extension') 

Then in a markdown cell insert your links waterBox30.pdb

like image 38
moldovean Avatar answered Oct 15 '22 12:10

moldovean