如何使用 Markdown 语法链接到任何本地文件? [英] How link to any local file with markdown syntax?

查看:95
本文介绍了如何使用 Markdown 语法链接到任何本地文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含多个链接的本地 Markdown 文件,我希望这些链接指向本地文件,例如 pdf.

I have a local markdown file containing several links and I want that links head to local file like pdf.

我使用以下语法:

[my link](file:///C:/my_file.pdf)

但是当我在 Firefox 页面中打开我的 Markdown 文件并点击链接时,没有任何反应.

But when I open my markdown file into a Firefox page and click on the link, nothing happens.

我到底错过了什么?是否可以打开本地文件?

What exactly have I missed? Is it possible to open local file?

推荐答案

你是如何打开渲染出来的 Markdown 的?

How are you opening the rendered Markdown?

如果您通过 HTTP 托管它,即通过 http://https:// 访问它,大多数现代浏览器将拒绝打开本地链接,例如使用 file://.这是一项安全功能:

If you host it over HTTP, i.e. you access it via http:// or https://, most modern browsers will refuse to open local links, e.g. with file://. This is a security feature:

出于安全目的,Mozilla 应用程序会阻止从远程文件到本地文件(和目录)的链接.这包括链接到您的硬盘驱动器上、映射网络驱动器上的文件,以及可通过 Uniform 访问的文件命名约定 (UNC) 路径.这防止许多不愉快的可能性,包括:

For security purposes, Mozilla applications block links to local files (and directories) from remote files. This includes linking to files on your hard drive, on mapped network drives, and accessible via Uniform Naming Convention (UNC) paths. This prevents a number of unpleasant possibilities, including:

  • 允许网站通过检查默认安装路径来检测您的操作系统
  • 允许网站利用系统漏洞(例如,Windows 95/98 中的 C:concon)
  • 允许网站检测浏览器偏好或读取敏感数据

该页面上列出了一些解决方法,但我的建议是尽可能避免这样做.

There are some workarounds listed on that page, but my recommendation is to avoid doing this if you can.

这篇关于如何使用 Markdown 语法链接到任何本地文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆