Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: render a nbsp instead of a space #88

Closed
jamesplease opened this issue May 2, 2021 · 2 comments
Closed

Improvement: render a nbsp instead of a space #88

jamesplease opened this issue May 2, 2021 · 2 comments

Comments

@jamesplease
Copy link

Hi! Thanks for the great library. I noticed that regular spaces are used, which means that the permalink can be wrapped separately from the header text. If this is switched to a non-breaking space ( ) then it ensures that the final word and the permalink will always appear side-to-side.

For folks who may be reading this issue, this can currently be solved in user-land as follows:

 md.use(require('markdown-it-anchor'), {
  permalink: true,
  permalinkSpace: false,
  permalinkSymbol: ' #',
});
@valeriangalliat
Copy link
Owner

The permalinkSymbol trick is a pretty good workaround! I wouldn't want to make   the default since it would be quite a breaking change, but I just released v8.6.1 with a way to customize the space option, so you can now do this:

const anchor = require('markdown-it-anchor')
const md = require('markdown-it')()

md.use(anchor, {
  permalink: anchor.permalink.linkInsideHeader({
    permalink: true,
    space: ' ',
  })
})

Sorry for the late reply!

@jamesplease
Copy link
Author

Thanks so much @valeriangalliat !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants