Skip to content

Commit

Permalink
fix: replace apostrophe with empty string in header slugification (#1618
Browse files Browse the repository at this point in the history
)

* Replace apostrophe with empty string in header

This change is to replicate the github behviour with respect to apostrophe in
headers. When there is an apostrophe in a header, github replaces it with empty string
when creating an anchor link to that header. Docusaurus should follow the same convention.
  • Loading branch information
parthpp authored and yangshun committed Jun 22, 2019
1 parent 9e84525 commit db44ecc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/docusaurus-1.x/lib/core/__tests__/toSlug.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const toSlug = require('../toSlug');
['Someting long ...', 'someting-long-'],
['foo_bar', 'foo_bar'],
['some _ heading', 'some-_-heading'],
["I'm good", 'im-good'],
['This is awes’ome', 'this-is-awesome'],
].forEach(([input, output]) => {
test(`toSlug('${input}') -> '${output}'`, () => {
expect(toSlug(input)).toBe(output);
Expand Down
4 changes: 2 additions & 2 deletions packages/docusaurus-1.x/lib/core/toSlug.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ module.exports = (string, context = {}) => {
.replace(new RegExp(`[${accents}]`, 'g'), c =>
without.charAt(accents.indexOf(c)),
)
// Replace `.`, `(` and `?` with blank string like Github does
.replace(/\.|\(|\?/g, '')
// Replace `'`, `’`, `.`, `(` and `?` with blank string like GitHub does
.replace(/'||\.|\(|\?/g, '')
// Dash special characters except '_' (underscore)
.replace(exceptAlphanumAndUnderscore, '-')
// Compress multiple dash
Expand Down

0 comments on commit db44ecc

Please sign in to comment.