docgen: use github-slugger to generate better slugs

This commit is contained in:
Patrik Oldsberg
2020-07-17 10:38:29 +02:00
parent 7e5451d8a9
commit 922c7296fd
3 changed files with 23 additions and 3 deletions
+4 -2
View File
@@ -29,11 +29,13 @@
"chalk": "^4.0.0",
"commander": "^4.1.1",
"fs-extra": "^9.0.0",
"typescript": "^3.9.3",
"ts-node": "^8.6.2"
"github-slugger": "^1.3.0",
"ts-node": "^8.6.2",
"typescript": "^3.9.3"
},
"devDependencies": {
"@types/fs-extra": "^9.0.1",
"@types/github-slugger": "^1.3.0",
"@types/node": "^13.7.2",
"nodemon": "^2.0.2"
},
@@ -14,6 +14,7 @@
* limitations under the License.
*/
import GithubSlugger from 'github-slugger';
import sortSelector from './sortSelector';
import { MarkdownPrinter, TypeLink } from './types';
import { execSync } from 'child_process';
@@ -46,7 +47,7 @@ export default class GithubMarkdownPrinter implements MarkdownPrinter {
}
headerLink(heading: string): string {
const slug = heading.replace(/[^a-z0-9]/gi, '-').toLowerCase();
const slug = GithubSlugger.slug(heading);
return `#${slug}`;
}