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

纵然是瞬间 提交于 2020-05-11 04:03:32

问题


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.


回答1:


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)




回答2:


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



来源:https://stackoverflow.com/questions/18137913/how-to-insert-a-link-to-a-local-file-into-a-markdown-cell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!