mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
fix: replace apostrophe with empty string in header slugification (#1618)
* 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.
This commit is contained in:
parent
9e84525bcf
commit
db44eccac3
2 changed files with 4 additions and 2 deletions
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue