diff --git a/packages/@vuepress/shared-utils/src/parseHeaders.ts b/packages/@vuepress/shared-utils/src/parseHeaders.ts index 2665b6c29b..a242fb6964 100644 --- a/packages/@vuepress/shared-utils/src/parseHeaders.ts +++ b/packages/@vuepress/shared-utils/src/parseHeaders.ts @@ -15,9 +15,10 @@ import parseEmojis from './parseEmojis' // wrapped by (markdown token: '`') tag. const removeMarkdownTokens = (str: string): string => String(str) + .replace(/(^| )\$\S*?\$( |$)/g, '') // ` ${t}$ ` .replace(/\[(.*)\]\(.*\)/, '$1') // []() - .replace(/(`|\*{1,3}|_)(.*?[^\\])\1/g, '$2') // `{t}` | *{t}* | **{t}** | ***{t}*** | _{t}_ - .replace(/(\\)(\*|_|`|\!)/g, '$2') // remove escape char '\' + .replace(/(`|\*{1,3}|_|~|\^)(.*?[^\\])\1/g, '$2') // `{t}` | *{t}* | **{t}** | ***{t}*** | _{t}_ | ^{t}^ | ~{t}~ + .replace(/(\\)(\*|_|`|!|\$)/g, '$2') // remove escape char '\' const trim = (str: string): string => str.trim()