From b82578fd5227eccf0a55fecb10cf3cadbcade8e0 Mon Sep 17 00:00:00 2001 From: dwdv Date: Fri, 24 May 2019 23:22:52 +0200 Subject: [PATCH] fix slugify: markdown header sections containing only special chars Markdown header sections that contain only specials characters like `<<`, `->` or even `?` (as used for function descriptions in the Gerbil Scheme Reference Docs) end up empty, breaking scrolling, search and sidebar navigation. Replacing the empty result with an underscore, similar to what happens with numbers in the front position, fixes all of these problems. --- packages/@vuepress/shared-utils/src/slugify.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/@vuepress/shared-utils/src/slugify.ts b/packages/@vuepress/shared-utils/src/slugify.ts index 5b6801aeaf..dd1f9cff34 100644 --- a/packages/@vuepress/shared-utils/src/slugify.ts +++ b/packages/@vuepress/shared-utils/src/slugify.ts @@ -19,6 +19,8 @@ export = function slugify (str: string): string { .replace(/^\-+|\-+$/g, '') // ensure it doesn't start with a number (#121) .replace(/^(\d)/, '_$1') + // ensure it isn't empty, breaking scrolling and sidebar + .replace(/^$/, '_') // lowercase .toLowerCase() }