markdown-toc icon indicating copy to clipboard operation
markdown-toc copied to clipboard

Ignore links in headings

Open koppor opened this issue 9 years ago • 5 comments

When using the script with keep-a-changelog, the links are generated wrong.

The links render fine:

grabbed_20160912-120554

The target is wrong: E.g., "unreleased" points to https://github.com/olivierlacan/keep-a-changelog/compare/v0.3.0...HEAD instead of #unreleased

I assume that simply the the link brackets ( []) have to be removed from the output. E.g., [[Unreleased]](#unreleased) has to be [Unreleased](#unreleased)

The complete example is available at https://github.com/koppor/keep-a-changelog/blob/master/CHANGELOG.md

koppor avatar Sep 12 '16 10:09 koppor

You can use the slugify option to remove the [ ] from the headings.

doowb avatar Sep 12 '16 15:09 doowb

hmm, I use this with our changelogs and the headings always seem to work. Maybe the [] is indeed causing the issue.

I'll look into it and see what's happening

jonschlinkert avatar Sep 12 '16 18:09 jonschlinkert

I checked again today on Win 10:

  1. npm install --save markdown-toc
  2. node_modules\.bin\markdown-toc -i CHANGELOG.md
  3. Same result as above.

@doowb I cannot use slugify, because I am using the CLI

koppor avatar Feb 15 '17 15:02 koppor

Sorry for taking so long, I just wasn't sure how to handle this. How about if we just expose a --slugify flag or something?

jonschlinkert avatar Feb 16 '17 03:02 jonschlinkert

@koppor all of the command line arguments are passed as options now. slugify takes a function which cannot be passed via the command line, but you can pass false. Try that to see if it works for you. This is just a work-around but it might be useful for you.

markdown-toc -i CHANGELOG.md --slugify false

doowb avatar Sep 19 '17 13:09 doowb