From 68dff2af8547ae70f6622ac826affd76f2f6378e Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sat, 15 Feb 2025 20:34:35 +0530 Subject: [PATCH 01/30] fix(markdown): include content of all tokens in heading ids closes #4561 BREAKING CHANGES: The heading ids might change in some cases if you're using special (non-html) elements in headings. Please update the broken links to fragments if you find any. To revert back to the older behavior you can customize `markdown.anchor.getTokensText`. --- src/node/markdown/markdown.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts index a39832a4..5d6d909d 100644 --- a/src/node/markdown/markdown.ts +++ b/src/node/markdown/markdown.ts @@ -263,6 +263,12 @@ export async function createMarkdownRenderer( // mdit-vue plugins md.use(anchorPlugin, { slugify, + getTokensText: (tokens) => { + return tokens + .filter((token) => token.type !== 'html_inline') + .map((token) => token.content) + .join('') + }, permalink: anchorPlugin.permalink.linkInsideHeader({ symbol: '​', renderAttrs: (slug, state) => { From f6243d1f3f71b5f508d5077c49a35040dc0448d4 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sat, 15 Feb 2025 21:48:03 +0530 Subject: [PATCH 02/30] chore: ignore emojis too from anchors --- src/node/markdown/markdown.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/node/markdown/markdown.ts b/src/node/markdown/markdown.ts index 5d6d909d..5050bebd 100644 --- a/src/node/markdown/markdown.ts +++ b/src/node/markdown/markdown.ts @@ -265,8 +265,8 @@ export async function createMarkdownRenderer( slugify, getTokensText: (tokens) => { return tokens - .filter((token) => token.type !== 'html_inline') - .map((token) => token.content) + .filter((t) => !['html_inline', 'emoji'].includes(t.type)) + .map((t) => t.content) .join('') }, permalink: anchorPlugin.permalink.linkInsideHeader({ From 68b1bcc680e2d7b3b26c8fe2a26e823b00dc7077 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Sun, 16 Feb 2025 00:24:40 +0800 Subject: [PATCH 03/30] fix: workaround for markdown embedded code highlighting (#4564) --- docs/.vitepress/config/shared.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/.vitepress/config/shared.ts b/docs/.vitepress/config/shared.ts index 1f4961d2..26ba1292 100644 --- a/docs/.vitepress/config/shared.ts +++ b/docs/.vitepress/config/shared.ts @@ -24,6 +24,9 @@ export const shared = defineConfig({ markdown: { math: true, + // Load these languages ahead of time for embedded code highlighting + // TODO: remove this when Shiki fixes markdown embedded language loading + languages: ['js', 'ts', 'html'], codeTransformers: [ // We use `[!!code` in demo to prevent transformation, here we revert it back. { From 809bb523b634ae60a5834486a52b3c0e5045c446 Mon Sep 17 00:00:00 2001 From: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> Date: Sat, 15 Feb 2025 22:20:17 +0530 Subject: [PATCH 04/30] docs: adjust preloaded shiki languages [lunaria-ignore] --- docs/.vitepress/config/shared.ts | 2 +- docs/en/guide/using-vue.md | 2 +- docs/es/guide/using-vue.md | 2 +- docs/es/reference/default-theme-sidebar.md | 3 +-- docs/fa/guide/asset-handling.md | 2 +- docs/fa/guide/frontmatter.md | 2 +- docs/fa/guide/migration-from-vitepress-0.md | 2 +- docs/fa/guide/migration-from-vuepress.md | 2 +- docs/fa/guide/mpa-mode.md | 2 +- docs/fa/guide/sitemap-generation.md | 2 +- docs/fa/guide/using-vue.md | 2 +- docs/fa/guide/what-is-vitepress.md | 2 +- docs/fa/reference/default-theme-badge.md | 2 +- docs/fa/reference/default-theme-carbon-ads.md | 2 +- docs/fa/reference/default-theme-config.md | 2 +- docs/fa/reference/default-theme-footer.md | 2 +- docs/fa/reference/default-theme-home-page.md | 2 +- docs/fa/reference/default-theme-last-updated.md | 2 +- docs/fa/reference/default-theme-layout.md | 2 +- docs/fa/reference/default-theme-sidebar.md | 2 +- docs/fa/reference/runtime-api.md | 2 +- docs/fa/reference/site-config.md | 2 +- docs/ru/guide/using-vue.md | 2 +- 23 files changed, 23 insertions(+), 24 deletions(-) diff --git a/docs/.vitepress/config/shared.ts b/docs/.vitepress/config/shared.ts index 26ba1292..0763ce69 100644 --- a/docs/.vitepress/config/shared.ts +++ b/docs/.vitepress/config/shared.ts @@ -26,7 +26,7 @@ export const shared = defineConfig({ math: true, // Load these languages ahead of time for embedded code highlighting // TODO: remove this when Shiki fixes markdown embedded language loading - languages: ['js', 'ts', 'html'], + languages: ['js', 'ts', 'html', 'vue-html', 'css', 'yaml', 'sh'], codeTransformers: [ // We use `[!!code` in demo to prevent transformation, here we revert it back. { diff --git a/docs/en/guide/using-vue.md b/docs/en/guide/using-vue.md index 5a82dc75..8420ea7f 100644 --- a/docs/en/guide/using-vue.md +++ b/docs/en/guide/using-vue.md @@ -288,4 +288,4 @@ Vue provides IntelliSense support out of the box via the [Vue - Official VS Code "vue.server.includeLanguages": ["vue", "markdown"] } ``` -::: \ No newline at end of file +::: diff --git a/docs/es/guide/using-vue.md b/docs/es/guide/using-vue.md index 9d18d92d..0131cc76 100644 --- a/docs/es/guide/using-vue.md +++ b/docs/es/guide/using-vue.md @@ -286,4 +286,4 @@ Vue ofrece soporte para IntelliSense de forma predeterminada mediante el [Plugin "vue.server.includeLanguages": ["vue", "markdown"] } ``` -::: \ No newline at end of file +::: diff --git a/docs/es/reference/default-theme-sidebar.md b/docs/es/reference/default-theme-sidebar.md index 05dd42f3..cf2af04b 100644 --- a/docs/es/reference/default-theme-sidebar.md +++ b/docs/es/reference/default-theme-sidebar.md @@ -211,7 +211,6 @@ const { hasSidebar } = useSidebar() ``` diff --git a/docs/fa/guide/asset-handling.md b/docs/fa/guide/asset-handling.md index 94554217..efa4710f 100644 --- a/docs/fa/guide/asset-handling.md +++ b/docs/fa/guide/asset-handling.md @@ -60,4 +60,4 @@ const { theme } = useData() -``` \ No newline at end of file +``` diff --git a/docs/fa/guide/frontmatter.md b/docs/fa/guide/frontmatter.md index 7f748b1e..4b4af163 100644 --- a/docs/fa/guide/frontmatter.md +++ b/docs/fa/guide/frontmatter.md @@ -45,4 +45,4 @@ editLink: true "editLink": true } --- -``` \ No newline at end of file +``` diff --git a/docs/fa/guide/migration-from-vitepress-0.md b/docs/fa/guide/migration-from-vitepress-0.md index 8a1380df..211bb0f9 100644 --- a/docs/fa/guide/migration-from-vitepress-0.md +++ b/docs/fa/guide/migration-from-vitepress-0.md @@ -20,4 +20,4 @@ ## پیکربندی Frontmatter - گزینه `home: true` به `layout: home` تغییر کرده است. همچنین، تنظیمات مربوط به صفحه اصلی بسیار تغییر کرده‌اند تا ویژگی‌های اضافی را ارائه دهند. برای جزئیات بیشتر، [راهنمای صفحه اصلی](../reference/default-theme-home-page) را ببینید. -- گزینه `footer` به [`themeConfig.footer`](../reference/default-theme-config#footer) منتقل شده است. \ No newline at end of file +- گزینه `footer` به [`themeConfig.footer`](../reference/default-theme-config#footer) منتقل شده است. diff --git a/docs/fa/guide/migration-from-vuepress.md b/docs/fa/guide/migration-from-vuepress.md index a7f8fbc8..536a37c5 100644 --- a/docs/fa/guide/migration-from-vuepress.md +++ b/docs/fa/guide/migration-from-vuepress.md @@ -27,4 +27,4 @@ --- -ادامه دارد... \ No newline at end of file +ادامه دارد... diff --git a/docs/fa/guide/mpa-mode.md b/docs/fa/guide/mpa-mode.md index 9e08e7b3..a18bb1c2 100644 --- a/docs/fa/guide/mpa-mode.md +++ b/docs/fa/guide/mpa-mode.md @@ -20,4 +20,4 @@ document.querySelector('h1').addEventListener('click', () => { `