使用 target="_blank" 在带有 github markdown 的新标签页中打开 link
open link in new tab with github markdown using target="_blank"
有没有办法让用 githubs markdown 编写的 Link 在新标签页中打开?
我发现与此相关的所有帖子都建议使用 HTML 和 target="_blank"
,这对我来说没问题,但那行不通。
例如这个 link:
<a href="http://whosebug.com" target="_blank">Go</a>
不在新标签页中打开。
我对各种不同的降价语法的回复不感兴趣,但只对当我在 github 上写我的降价时有效的解决方案感兴趣。
好吧,似乎简单的答案是“这不可能”。 Github 不包含 target 属性,即使您使用普通的 HTML,因此它不在最终的 HTML 锚标记中。烦人,但没关系,用户只需在 link 上按 CTRL+单击(在 Windows 和 Linux 上)或 CMD+单击(在 MacOS 上),即可获得相同的行为。
答案应该是@Idavid 在评论中发表的内容。
[go](http://whosebug.com){:target="_blank"}.
你还应该添加 rel="noopener"
[go](http://whosebug.com){:target="_blank" rel="noopener"}
有一个针对使用 GitHub 页面的网站的解决方案:添加行
markdown: kramdown
到文件 _config.yml
,您可以使用 [go](http://whosebug.com){:target="_blank" rel="noopener"}
,因为 GitHub 页面引擎使用另一个名为 kramdown 的降价来生成 html。但是,它不适用于 GitHub 直接在项目存储库中呈现的预览和降价。
根据我的阅读和研究,这是不可能的。我想做类似的事情,但很快意识到它不是 git md 中的一个功能,不幸的是。
Github Pages 用户(Jekyll)是可以的,正确的方法(2022 年 3 月) 是添加到您的 _config.yml
文件这些行:
kramdown:
input: Kramdown
这是指定的 in the documentation:
You can also change the processor used by Kramdown (as specified for the input key in the Kramdown RDoc). For example, to use the non-GFM Kramdown processor in Jekyll, add the following to your configuration.
使用 Kramdown 处理器而不是 GFM 将允许您将 {:target="_blank" rel="noopener"}
添加到 markdown links 以告诉浏览器在新选项卡中打开 link。
例子
[Whosebug The Key](https://Whosebug.blog/2021/03/31/the-key-copy-paste/){:target="_blank" rel="noopener"}
/!\免责声明
将降价处理器从 GFM(默认值)更改为 kramdown 会在 HTML 结果中产生问题,因为GitHub Flavored Markdown (GFM) 的所有特定功能将不再有效。
有没有办法让用 githubs markdown 编写的 Link 在新标签页中打开?
我发现与此相关的所有帖子都建议使用 HTML 和 target="_blank"
,这对我来说没问题,但那行不通。
例如这个 link:
<a href="http://whosebug.com" target="_blank">Go</a>
不在新标签页中打开。 我对各种不同的降价语法的回复不感兴趣,但只对当我在 github 上写我的降价时有效的解决方案感兴趣。
好吧,似乎简单的答案是“这不可能”。 Github 不包含 target 属性,即使您使用普通的 HTML,因此它不在最终的 HTML 锚标记中。烦人,但没关系,用户只需在 link 上按 CTRL+单击(在 Windows 和 Linux 上)或 CMD+单击(在 MacOS 上),即可获得相同的行为。
答案应该是@Idavid 在评论中发表的内容。
[go](http://whosebug.com){:target="_blank"}.
你还应该添加 rel="noopener"
[go](http://whosebug.com){:target="_blank" rel="noopener"}
有一个针对使用 GitHub 页面的网站的解决方案:添加行
markdown: kramdown
到文件 _config.yml
,您可以使用 [go](http://whosebug.com){:target="_blank" rel="noopener"}
,因为 GitHub 页面引擎使用另一个名为 kramdown 的降价来生成 html。但是,它不适用于 GitHub 直接在项目存储库中呈现的预览和降价。
根据我的阅读和研究,这是不可能的。我想做类似的事情,但很快意识到它不是 git md 中的一个功能,不幸的是。
Github Pages 用户(Jekyll)是可以的,正确的方法(2022 年 3 月) 是添加到您的 _config.yml
文件这些行:
kramdown:
input: Kramdown
这是指定的 in the documentation:
You can also change the processor used by Kramdown (as specified for the input key in the Kramdown RDoc). For example, to use the non-GFM Kramdown processor in Jekyll, add the following to your configuration.
使用 Kramdown 处理器而不是 GFM 将允许您将 {:target="_blank" rel="noopener"}
添加到 markdown links 以告诉浏览器在新选项卡中打开 link。
例子
[Whosebug The Key](https://Whosebug.blog/2021/03/31/the-key-copy-paste/){:target="_blank" rel="noopener"}
/!\免责声明
将降价处理器从 GFM(默认值)更改为 kramdown 会在 HTML 结果中产生问题,因为GitHub Flavored Markdown (GFM) 的所有特定功能将不再有效。