gfranko / jquery.tocify.js

A jQuery Table of Contents plugin that can be themed with Twitter Bootstrap or jQueryUI.
http://gregfranko.com/jquery.tocify.js/
MIT License
927 stars 217 forks source link

Enhancement request: Ensure URLs are still readable #16

Closed matryer closed 11 years ago

matryer commented 11 years ago

Currently Tocify removes whitespace from headings in order to generate the hash values (i.e. the bookmark after the # in the URL), which is sensible. So "Tell me About It" becomes #TellmeAboutIt.

What if it replaced the spaces with hyphens - and made it all lowercase, so you would end up with #tell-me-about-it.

Pros:

Cons:

gfranko commented 11 years ago

I'll add this in the next version as an option. Good idea!

matryer commented 11 years ago

Ohh in that case, how about this.

{
  "hashGenerator": "pretty"
}

or even

{
  "hashGenerator": function(text) {
    // do my own hash generation here!
  }
}
gfranko commented 11 years ago

I think it would be nice to have the ability to either supply a string option or a custom function. Do you think people would only want underscore separated words? Or are there other formats as well? Also, feel free to send a PR if you are up for it. No pressure!

gfranko commented 11 years ago

Thanks again for your PR!