如何从Markdown中的标题中删除锚链接? [英] How to remove anchor links from headers in Markdown?
问题描述
在Github中,当您创建h2或更小的标头(##,###,...)时,标头右侧会自动生成一个锚链接.单击此锚点后,它将链接到页面顶部具有该页眉的页面(www.myurl#myheader).
In Github, when you create an h2 or smaller header (##, ###, ...) there is an anchor link thing that is automatically generated to the right of the header. When you click this anchor, it links you to the page with that header at the top of the page (www.myurl#myheader).
是否可以删除此锚点?
推荐答案
You can disable Kramdown's auto-ids option. Depending on how you are using Kramdown, there are a number of ways in which to do so:
如果从命令行使用Kramdown,只需添加-no-auto-ids
选项:
If you are using Kramdown from the command line, simply include the --no-auto-ids
option:
kramdown --no-auto-ids
Ruby代码
如果要使用自己的Ruby代码调用Kramdown,请设置 auto_ids:false
:
Kramdown::Document.new(source_text, {auto_ids: false})
来自文档内部
您还可以仅在文档中覆盖文档中的默认设置.单独一行包含以下内容:
From within a document
You can also override the default settings from within a document for the document only. Include the following in the document on a line by itself:
{::options auto_ids="false" /}
GitHub页面
该问题提到了GitHub.假设这是指使用Jekyll的GitHub Pages(因为这是在您的 _config.yml
文件中设置Kramdown选项:
GitHub Pages
The question mentions GitHub. Assuming this is referring to GitHub Pages with Jekyll (as that is the only place GitHub makes use of Kramdown), you can set Kramdown options in your _config.yml
file:
markdown: kramdown
auto_ids: false
请注意,如果您在GitHub Pages上使用GFM,或者正在使用GitHub Pages以外的其他GitHub服务,则此选项不可用,因为GFM不提供此类选项.
Note that if you are using GFM on GitHub Pages, or if you are using any other GitHub service except GitHub Pages, this option is not available as GFM does not offer such an option.
这篇关于如何从Markdown中的标题中删除锚链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!