问题
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).
Is it possible to remove this anchor?
回答1:
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:
Command Line
If you are using Kramdown from the command line, simply include the --no-auto-ids
option:
kramdown --no-auto-ids
Ruby Code
If you are calling Kramdown from your own Ruby code, set 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 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
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.
来源:https://stackoverflow.com/questions/58785061/how-to-remove-anchor-links-from-headers-in-markdown