Add toc link when enable set to true.
Enable display a link svg when set Markd::Options.new(toc: true), like following screenshot.
Anchor link is a part of toc, full toc feature needs to generate the table of content or provide a method to get the toc.
generate the table of content
Yes, this is one of feature of toc, but i thought it's optional.
But, i consider anchor link is necessary for a HTML rendered markdown title.
I think this is something best implemented in a custom renderer rather than upstream
I think this is something best implemented in a custom renderer rather than upstream
Yes, I use it on my fork, if we make the § string configurable, it is PR acceptable?
I'm not sure. On one hand this is useful; on the other this isn't something specified in the commonmark or gfm specs, which leads me towards it being something implemented by those who want it. How do we feel about out of spec extensions?
I think anchor links for every heading are a very valuable UX feature.
However, it's a bit tricky getting the HTML right. The current implementation for example creates an anchor element adjacent to the header element. But they're not directly grouped together, which can make it hard to style properly. A commonly used structure wraps them into a div:
<div class="header-wrapper">
<h2 id="title">Title</h2>
<a href="#title">§</a>
</div>
Improving accessibility requires some further enhancements to make sense of the anchor link.
IMO a decent default implementation could very well fit into upstream. But it should also be easily customizable with custom renderers.
So maybe it's best to start with that to make sure it's simple to override the details without changing the overall structure?
Maybe we can add a new option instead of toc for enable this PR feature, leave the toc only for original topic purpose.