Skip to content

Commit

Permalink
Fix non-alphanumeric start/end characters in TOC (preactjs#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
developit authored May 11, 2021
1 parent bf5a328 commit ec0be0b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lib/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ function generateToc(markdown) {
// Note: character range in regex is roughly "word characters including accented" (eg: bublé)
const id = text
.toLowerCase()
.replace(/[\s-!()<>`'"&,]+/g, '-');
.replace(/[\s-!()<>`'"&,]+/g, '-')
.replace(/(?:^-|-$)/g, '');
toc.push({ text, id, level });
}
return toc;
Expand Down

0 comments on commit ec0be0b

Please sign in to comment.