Closed JanDW closed 2 years ago
Hey! Seems like a common demand for linkAfterHeader
to include a wrapper in the output, @nhoizey also wanted to do this in #100. I came up with a proposal solution in #111, it looks like this:
const anchor = require('markdown-it-anchor')
const md = require('markdown-it')()
md.use(anchor, {
permalink: anchor.permalink.linkAfterHeader({
style: 'visually-hidden',
assistiveText: title => `Permalink to “${title}”`,
visuallyHiddenClass: 'visually-hidden'
visuallyHiddenClass: 'visually-hidden',
wrapper: ['<div class="wrapper">', '</div>']
})
})
<div class="wrapper">
<h2 id="title">Title</h2>
<a class="header-anchor" href="#title">
<span class="visually-hidden">Permalink to “Title”</span>
<span aria-hidden="true">#</span>
</a>
</div>
Does this looks like a reasonable API?
Cheers!
Does this looks like a reasonable API?
Yes, that was exactly what I was hoping for—thanks!
Awesome, published with v8.5.0! Thank you for the Ko-fi :heart:
Thank you! 🏅
I'm late using this, but it rocks! Thanks @valeriangalliat
Hi Val,
I noticed that to add a container around the outputted HTML when using
linkAfterHeader
I'd need to implement my own render function. Would it make sense to provide an option for passing in a container?Best,
Jan