gitbook icon indicating copy to clipboard operation
gitbook copied to clipboard

Problems in heading id generation

Open orelby opened this issue 12 years ago • 1 comments

The custom heading rendering in the renderer adds id attributes to headings. That's what it adds (after it adds the prefix):

raw.toLowerCase().replace(/[^\w -]+/g, '').replace(/ /g, '-');

The problems:

  1. \w matches only ASCII characters in JS. What about other languages?
  2. Not only hyphens might be in headings, but also dashes (en dashes).

My suggestion is to change the first replace from [^\w -] to something like [,;].

Any comments?

orelby avatar Jul 12 '14 14:07 orelby

I think you're right, Can you please do a PR for this ;)

SamyPesse avatar Jul 12 '14 15:07 SamyPesse