From e613140ba83260bb2068267ca8cb3af1726b1915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Szyma=C5=84ski?= <141330+wszymanski@users.noreply.github.com> Date: Thu, 15 Jul 2021 13:50:21 +0200 Subject: [PATCH 1/2] Fix for the Table of Contents (fix #2896) It will be created properly when paragraph is a link - boosted `slugify` method. --- 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 05883e0072..70810365b7 100644 --- a/packages/@vuepress/shared-utils/src/slugify.ts +++ b/packages/@vuepress/shared-utils/src/slugify.ts @@ -9,6 +9,8 @@ const rCombining = /[\u0300-\u036F]/g export = function slugify (str: string): string { // Split accented characters into components return str.normalize('NFKD') + // Remove links, just leave hyperlink's text + .replace(/\[(.*)?]\(.*?\)/g,'$1') // Remove accents .replace(rCombining, '') // Remove control characters From 60c288e7c9e4ab0cab9d9caa6c46d7a4ac5faaec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wojciech=20Szyma=C5=84ski?= <141330+wszymanski@users.noreply.github.com> Date: Thu, 15 Jul 2021 14:39:16 +0200 Subject: [PATCH 2/2] I did RegExp yet more precise --- packages/@vuepress/shared-utils/src/slugify.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/@vuepress/shared-utils/src/slugify.ts b/packages/@vuepress/shared-utils/src/slugify.ts index 70810365b7..242845ab47 100644 --- a/packages/@vuepress/shared-utils/src/slugify.ts +++ b/packages/@vuepress/shared-utils/src/slugify.ts @@ -10,7 +10,7 @@ export = function slugify (str: string): string { // Split accented characters into components return str.normalize('NFKD') // Remove links, just leave hyperlink's text - .replace(/\[(.*)?]\(.*?\)/g,'$1') + .replace(/^\[(.*)?(]\(.*?\))$/g,'$1') // Remove accents .replace(rCombining, '') // Remove control characters