jgallen23 / toc

Table of Contents Plugin
http://projects.jga.me/toc/
MIT License
531 stars 111 forks source link

Feature request: the hash tag should mirror the headline #2

Closed ghost closed 10 years ago

ghost commented 12 years ago

On your example page, if you click the "Contributors" link in the table of contents, instead of the url hash being #toc9, it would be cleaner and make more sense for a url if the headline was the hash. Just a suggestion.

jgallen23 commented 12 years ago

Yep, that's on the feature list.

dvberkel commented 12 years ago

I have related suggestion. It is similar enough that I did not start a new issues.

It would be great if the hash tag was generated by a function. The hash tag generator would have a default specified e.g

jQuery.fn.toc.defaults = {
  ...
  hashtag: function(i, heading, prefix){
      return '#'+prefix+i;
  },
  ...
};

and could be called with $.opts.hashtag(i,heading, $.opts.prefix).

I will fork the project and implement this feature. I will also provide an implementation which returns the heading text as an example.

jgallen23 commented 10 years ago

fixed in #36