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

Add support of ß (a German letter) #118

Open 271289 opened 4 years ago

271289 commented 4 years ago

Behavior

My headline "Preußen" results in the link [Preußen](#preuen).

Background information

The letter "ß" is used very often in German.

Solution

Change

hash = hash.replace /[^a-z0-9\u4e00-\u9fa5äüö\-]/g, ""

to

hash = hash.replace /[^a-z0-9\u4e00-\u9fa5äüö\u00df\-]/g, ""

Explanation

ß has the character code \u00df.

271289 commented 4 years ago

Even simpler... hash = hash.replace /[^a-z0-9\u4e00-\u9fa5äüöß\-]/g, ""