nok / markdown-toc

Generate and update magically a table of contents based on the headlines of a parsed markdown file.
MIT License
68 stars 37 forks source link

Hyphens in title are deleted, they shouldn't #81

Open cdlhub opened 8 years ago

cdlhub commented 8 years ago

For instance, if my title is # My - Title, then the link should be (#my---title) where markdown-toc generates (#my-title).

See https://gist.github.com/asabaylus/3071099#gistcomment-1593627:

The code that creates the anchors is here: https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/toc_filter.rb

  • It downcases the string
  • remove anything that is not a letter, number, space or hyphen (see the source for how Unicode is handled)
  • changes any space to a hyphen.
  • If that is not unique, add "-1", "-2", "-3",... to make it unique