medfreeman / markdown-it-toc-and-anchor

markdown-it plugin to add a toc and anchor links in headings
MIT License
60 stars 35 forks source link

feat: added a wrapHeadingTextInAnchor option #28

Closed jsepia closed 5 years ago

jsepia commented 7 years ago

When true, it bypasses anchorLinkSymbol and instead wraps the anchor link around the heading text:

require('markdown-it')()
  .use(require('markdown-it-toc-and-anchor'), { wrapHeadingTextInAnchor: true })
  .render(`# Heading`)
<h1 id="heading"><a class="markdownIt-Anchor" href="#heading">Heading</a></h1>

I needed this for my site and I figured it wouldn't hurt to merge this feature in.