-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
Refactor shikiji syntax highlighting code (#9083)
- create-astro@4.11.0
- create-astro@4.11.0-beta.1
- create-astro@4.11.0-beta.0
- create-astro@4.10.0
- create-astro@4.9.2
- create-astro@4.9.1
- create-astro@4.9.0
- create-astro@4.8.4
- create-astro@4.8.4-alpha.0
- create-astro@4.8.3
- create-astro@4.8.2
- create-astro@4.8.1
- create-astro@4.8.0
- create-astro@4.7.5
- create-astro@4.7.4
- create-astro@4.7.3
- create-astro@4.7.2
- create-astro@4.7.1
- create-astro@4.7.0
- create-astro@4.6.0
- create-astro@4.5.2
- create-astro@4.5.2-beta.0
- @astrojs/web-vitals@3.0.1
- @astrojs/web-vitals@3.0.0
- @astrojs/web-vitals@3.0.0-beta.1
- @astrojs/web-vitals@2.0.1-alpha.0
- @astrojs/web-vitals@2.0.0
- @astrojs/web-vitals@1.0.0
- @astrojs/web-vitals@0.2.1
- @astrojs/web-vitals@0.2.0
- @astrojs/web-vitals@0.1.1
- @astrojs/web-vitals@0.1.0
- @astrojs/vue@5.0.3
- @astrojs/vue@5.0.2
- @astrojs/vue@5.0.1
- @astrojs/vue@5.0.0
- @astrojs/vue@5.0.0-beta.3
- @astrojs/vue@5.0.0-beta.2
- @astrojs/vue@5.0.0-beta.1
- @astrojs/vue@5.0.0-beta.0
- @astrojs/vue@5.0.0-alpha.0
- @astrojs/vue@4.5.3
- @astrojs/vue@4.5.2
- @astrojs/vue@4.5.1
- @astrojs/vue@4.5.0
- @astrojs/vue@4.4.0
- @astrojs/vue@4.3.0
- @astrojs/vue@4.2.0
- @astrojs/vue@4.1.0
- @astrojs/vue@4.0.11
- @astrojs/vue@4.0.10
- @astrojs/vue@4.0.9
- @astrojs/vue@4.0.8
- @astrojs/vue@4.0.7
- @astrojs/vue@4.0.6
- @astrojs/vue@4.0.5
- @astrojs/vue@4.0.4
- @astrojs/vue@4.0.3
- @astrojs/vue@4.0.2
- @astrojs/vue@4.0.1
- @astrojs/vue@4.0.0
- @astrojs/vue@4.0.0-beta.0
- @astrojs/vercel@8.0.0-alpha.1
- @astrojs/vercel@8.0.0-alpha.0
- @astrojs/vercel@7.8.0
- @astrojs/vercel@7.7.2
- @astrojs/vercel@7.7.1
- @astrojs/vercel@7.7.0
- @astrojs/vercel@7.6.0
- @astrojs/vercel@7.5.4
- @astrojs/vercel@7.5.3
- @astrojs/vercel@7.5.2
- @astrojs/vercel@7.5.1
- @astrojs/vercel@7.5.0
- @astrojs/vercel@7.4.0
- @astrojs/vercel@7.3.6
- @astrojs/vercel@7.3.5
- @astrojs/vercel@7.3.4
- @astrojs/vercel@7.3.3
- @astrojs/vercel@7.3.2
- @astrojs/vercel@7.3.1
- @astrojs/vercel@7.3.0
- @astrojs/vercel@7.2.0
- @astrojs/vercel@7.1.1
- @astrojs/vercel@7.1.0
- @astrojs/vercel@7.0.2
- @astrojs/vercel@7.0.1
- @astrojs/vercel@7.0.0
- @astrojs/vercel@6.1.4
- @astrojs/vercel@6.1.3
- @astrojs/vercel@6.1.2
- @astrojs/vercel@6.1.1
- @astrojs/vercel@6.1.0
- @astrojs/vercel@6.0.2
- @astrojs/vercel@6.0.1
- @astrojs/vercel@6.0.0
- @astrojs/vercel@6.0.0-beta.2
- @astrojs/vercel@6.0.0-beta.1
- @astrojs/vercel@6.0.0-beta.0
- @astrojs/upgrade@0.4.2
- @astrojs/upgrade@0.4.1
- @astrojs/upgrade@0.4.0
- @astrojs/upgrade@0.4.0-beta.0
- @astrojs/upgrade@0.3.4
- @astrojs/upgrade@0.3.3
- @astrojs/upgrade@0.3.2
- @astrojs/upgrade@0.3.1
- @astrojs/upgrade@0.3.0
- @astrojs/upgrade@0.2.3
- @astrojs/upgrade@0.2.2
- @astrojs/upgrade@0.2.1
- @astrojs/upgrade@0.2.0
- @astrojs/upgrade@0.1.2
- @astrojs/upgrade@0.1.1
- @astrojs/upgrade@0.1.0
- @astrojs/upgrade@0.1.0-beta.0
- @astrojs/underscore-redirects@0.4.0
- @astrojs/underscore-redirects@0.4.0-beta.1
- @astrojs/underscore-redirects@0.4.0-alpha.0
- @astrojs/underscore-redirects@0.3.4
- @astrojs/telemetry@3.2.0
- @astrojs/telemetry@3.2.0-beta.0
- @astrojs/telemetry@3.1.0
- @astrojs/tailwind@6.0.0-beta.0
- @astrojs/tailwind@6.0.0-alpha.0
- @astrojs/tailwind@5.1.4
- @astrojs/tailwind@5.1.3
- @astrojs/tailwind@5.1.2
- @astrojs/tailwind@5.1.1
- @astrojs/tailwind@5.1.0
- @astrojs/tailwind@5.0.4
- @astrojs/tailwind@5.0.3
- @astrojs/svelte@7.0.2
- @astrojs/svelte@7.0.1
- @astrojs/svelte@7.0.0
- @astrojs/svelte@7.0.0-beta.1
- @astrojs/svelte@6.0.2
- @astrojs/svelte@6.0.2-beta.0
- @astrojs/svelte@6.0.1
- @astrojs/svelte@6.0.0
- @astrojs/svelte@6.0.0-beta.2
- @astrojs/svelte@6.0.0-beta.1
- @astrojs/svelte@6.0.0-beta.0
- @astrojs/svelte@6.0.0-alpha.0
- @astrojs/svelte@5.7.3
- @astrojs/svelte@5.7.2
- @astrojs/svelte@5.7.1
- @astrojs/svelte@5.7.0
- @astrojs/svelte@5.6.0
- @astrojs/svelte@5.5.0
- @astrojs/svelte@5.4.0
- @astrojs/svelte@5.3.0
- @astrojs/svelte@5.2.0
- @astrojs/svelte@5.1.0
- @astrojs/svelte@5.0.3
- @astrojs/svelte@5.0.2
- @astrojs/svelte@5.0.1
- @astrojs/svelte@5.0.0
- @astrojs/svelte@5.0.0-beta.0
- @astrojs/svelte@4.0.4
- @astrojs/studio@0.1.3
- @astrojs/studio@0.1.2
- @astrojs/studio@0.1.2-beta.0
- @astrojs/studio@0.1.1
- @astrojs/studio@0.1.0
- @astrojs/solid-js@5.0.1
- @astrojs/solid-js@5.0.0
- @astrojs/solid-js@5.0.0-beta.1
- @astrojs/solid-js@4.4.4
- @astrojs/solid-js@4.4.4-beta.0
- @astrojs/solid-js@4.4.3
- @astrojs/solid-js@4.4.2
- @astrojs/solid-js@4.4.1
- @astrojs/solid-js@4.4.0
- @astrojs/solid-js@4.3.0
- @astrojs/solid-js@4.2.0
- @astrojs/solid-js@4.1.0
- @astrojs/solid-js@4.0.1
- @astrojs/solid-js@4.0.0
- @astrojs/solid-js@3.0.3
- @astrojs/sitemap@3.2.1
- @astrojs/sitemap@3.2.0
- @astrojs/sitemap@3.1.6
- @astrojs/sitemap@3.1.5
- @astrojs/sitemap@3.1.4
- @astrojs/sitemap@3.1.3
- @astrojs/sitemap@3.1.2
- @astrojs/sitemap@3.1.1
- @astrojs/sitemap@3.1.0
- @astrojs/sitemap@3.0.5
- @astrojs/sitemap@3.0.4
- @astrojs/rss@4.0.10
- @astrojs/rss@4.0.9
- @astrojs/rss@4.0.8
- @astrojs/rss@4.0.7
- @astrojs/rss@4.0.6
- @astrojs/rss@4.0.5
- @astrojs/rss@4.0.4
- @astrojs/rss@4.0.3
- @astrojs/rss@4.0.2
- @astrojs/rss@4.0.1
- @astrojs/rss@4.0.0
- @astrojs/rss@4.0.0-beta.0
- @astrojs/react@4.1.2
- @astrojs/react@4.1.1
- @astrojs/react@4.1.0
- @astrojs/react@4.0.0
- @astrojs/react@4.0.0-beta.2
- @astrojs/react@3.7.0-beta.1
- @astrojs/react@3.6.3
- @astrojs/react@3.6.3-beta.0
- @astrojs/react@3.6.2
- @astrojs/react@3.6.1
- @astrojs/react@3.6.0
- @astrojs/react@3.5.0
- @astrojs/react@3.4.0
- @astrojs/react@3.3.4
- @astrojs/react@3.3.3
- @astrojs/react@3.3.2
- @astrojs/react@3.3.1
- @astrojs/react@3.3.0
- @astrojs/react@3.2.0
- @astrojs/react@3.1.1
- @astrojs/react@3.1.0
- @astrojs/react@3.0.10
- @astrojs/react@3.0.9
- @astrojs/react@3.0.8
- @astrojs/react@3.0.7
- @astrojs/react@3.0.7-beta.0
- @astrojs/react@3.0.6
- @astrojs/react@3.0.5
- @astrojs/prism@3.2.0
- @astrojs/prism@3.2.0-beta.0
- @astrojs/prism@3.1.0
- @astrojs/preact@4.0.1
- @astrojs/preact@4.0.0
- @astrojs/preact@4.0.0-beta.1
- @astrojs/preact@3.5.4
- @astrojs/preact@3.5.4-beta.0
- @astrojs/preact@3.5.3
- @astrojs/preact@3.5.2
- @astrojs/preact@3.5.1
- @astrojs/preact@3.5.0
- @astrojs/preact@3.4.0
- @astrojs/preact@3.3.0
- @astrojs/preact@3.2.0
- @astrojs/preact@3.1.2
- @astrojs/preact@3.1.1
- @astrojs/preact@3.1.0
- @astrojs/preact@3.0.2
- @astrojs/partytown@2.1.2
- @astrojs/partytown@2.1.1
- @astrojs/partytown@2.1.0
- @astrojs/partytown@2.0.4
- @astrojs/partytown@2.0.3
- @astrojs/node@9.0.0-alpha.1
- @astrojs/node@9.0.0-alpha.0
- @astrojs/node@8.3.3
- @astrojs/node@8.3.2
- @astrojs/node@8.3.1
- @astrojs/node@8.3.0
- @astrojs/node@8.2.6
- @astrojs/node@8.2.5
- @astrojs/node@8.2.4
- @astrojs/node@8.2.3
- @astrojs/node@8.2.2
- @astrojs/node@8.2.1
- @astrojs/node@8.2.0
- @astrojs/node@8.1.0
- @astrojs/node@8.0.0
- @astrojs/node@7.0.4
- @astrojs/node@7.0.3
- @astrojs/node@7.0.2
- @astrojs/node@7.0.1
- @astrojs/node@7.0.0
- @astrojs/node@7.0.0-beta.1
- @astrojs/node@7.0.0-beta.0
- @astrojs/node@6.1.0
- @astrojs/node@6.0.4
- @astrojs/mdx@4.0.3
- @astrojs/mdx@4.0.2
- @astrojs/mdx@4.0.1
- @astrojs/mdx@4.0.0
- @astrojs/mdx@4.0.0-beta.5
- @astrojs/mdx@4.0.0-beta.4
- @astrojs/mdx@4.0.0-beta.3
- @astrojs/mdx@4.0.0-beta.2
- @astrojs/mdx@4.0.0-beta.1
- @astrojs/mdx@4.0.0-alpha.2
- @astrojs/mdx@4.0.0-alpha.1
- @astrojs/mdx@4.0.0-alpha.0
- @astrojs/mdx@3.1.9
- @astrojs/mdx@3.1.8
- @astrojs/mdx@3.1.7
- @astrojs/mdx@3.1.6
- @astrojs/mdx@3.1.5
- @astrojs/mdx@3.1.4
- @astrojs/mdx@3.1.3
- @astrojs/mdx@3.1.2
- @astrojs/mdx@3.1.1
- @astrojs/mdx@3.1.0
- @astrojs/mdx@3.0.1
- @astrojs/mdx@3.0.0
- @astrojs/mdx@2.3.1
- @astrojs/mdx@2.3.0
- @astrojs/mdx@2.2.4
- @astrojs/mdx@2.2.3
- @astrojs/mdx@2.2.2
- @astrojs/mdx@2.2.1
- @astrojs/mdx@2.2.0
- @astrojs/mdx@2.1.1
- @astrojs/mdx@2.1.0
- @astrojs/mdx@2.0.6
- @astrojs/mdx@2.0.5
- @astrojs/mdx@2.0.4
- @astrojs/mdx@2.0.3
- @astrojs/mdx@2.0.2
- @astrojs/mdx@2.0.1
- @astrojs/mdx@2.0.0
- @astrojs/mdx@2.0.0-beta.0
- @astrojs/mdx@1.1.5
- @astrojs/markdown-remark@6.0.1
- @astrojs/markdown-remark@6.0.0
- @astrojs/markdown-remark@6.0.0-beta.3
- @astrojs/markdown-remark@6.0.0-beta.2
- @astrojs/markdown-remark@6.0.0-beta.1
- @astrojs/markdown-remark@6.0.0-alpha.1
- @astrojs/markdown-remark@6.0.0-alpha.0
- @astrojs/markdown-remark@5.3.0
- @astrojs/markdown-remark@5.2.0
- @astrojs/markdown-remark@5.1.1
- @astrojs/markdown-remark@5.1.0
- @astrojs/markdown-remark@5.0.0
- @astrojs/markdown-remark@4.3.2
- @astrojs/markdown-remark@4.3.1
- @astrojs/markdown-remark@4.3.0
- @astrojs/markdown-remark@4.2.1
- @astrojs/markdown-remark@4.2.0
- @astrojs/markdown-remark@4.1.0
- @astrojs/markdown-remark@4.0.1
- @astrojs/markdown-remark@4.0.0
- @astrojs/markdown-remark@4.0.0-beta.0
- @astrojs/markdown-remark@3.5.0
- @astrojs/markdoc@1.0.0-alpha.1
- @astrojs/markdoc@1.0.0-alpha.0
- @astrojs/markdoc@0.12.4
- @astrojs/markdoc@0.12.3
- @astrojs/markdoc@0.12.2
- @astrojs/markdoc@0.12.1
- @astrojs/markdoc@0.12.0
- @astrojs/markdoc@0.12.0-beta.1
- @astrojs/markdoc@0.12.0-beta.0
- @astrojs/markdoc@0.11.5
- @astrojs/markdoc@0.11.5-beta.1
- @astrojs/markdoc@0.11.5-beta.0
- @astrojs/markdoc@0.11.4
- @astrojs/markdoc@0.11.3
- @astrojs/markdoc@0.11.2
- @astrojs/markdoc@0.11.1
- @astrojs/markdoc@0.11.0
- @astrojs/markdoc@0.10.0
- @astrojs/markdoc@0.9.5
- @astrojs/markdoc@0.9.4
- @astrojs/markdoc@0.9.3
- @astrojs/markdoc@0.9.2
- @astrojs/markdoc@0.9.1
- @astrojs/markdoc@0.9.0
- @astrojs/markdoc@0.8.3
- @astrojs/markdoc@0.8.2
- @astrojs/markdoc@0.8.1
- @astrojs/markdoc@0.8.0
- @astrojs/markdoc@0.7.2
- @astrojs/lit@4.3.0
- @astrojs/lit@4.2.0
- @astrojs/lit@4.1.0
- @astrojs/lit@4.0.1
- @astrojs/lit@4.0.0
- @astrojs/internal-helpers@0.4.2
- @astrojs/internal-helpers@0.4.1
- @astrojs/internal-helpers@0.4.0
- @astrojs/internal-helpers@0.3.0
- @astrojs/db@0.14.5
- @astrojs/db@0.14.4
- @astrojs/db@0.14.3
- @astrojs/db@0.14.2
- @astrojs/db@0.14.1
- @astrojs/db@0.14.0
- @astrojs/db@0.14.0-beta.2
- @astrojs/db@0.14.0-beta.1
- @astrojs/db@0.13.2
- @astrojs/db@0.13.2-alpha.1
- @astrojs/db@0.13.2-alpha.0
- @astrojs/db@0.13.1
- @astrojs/db@0.13.0
- @astrojs/db@0.12.0
- @astrojs/db@0.11.7
- @astrojs/db@0.11.6
- @astrojs/db@0.11.5
- @astrojs/db@0.11.4
- @astrojs/db@0.11.3
- @astrojs/db@0.11.2
- @astrojs/db@0.11.1
- @astrojs/db@0.11.0
- @astrojs/db@0.10.7
- @astrojs/db@0.10.6
- @astrojs/db@0.10.5
- @astrojs/db@0.10.4
- @astrojs/db@0.10.3
- @astrojs/db@0.10.2
- @astrojs/db@0.10.1
- @astrojs/db@0.10.0
- @astrojs/db@0.9.11
- @astrojs/db@0.9.10
- @astrojs/db@0.9.9
- @astrojs/db@0.9.8
- @astrojs/db@0.9.7
- @astrojs/db@0.9.6
- @astrojs/db@0.9.5
- @astrojs/db@0.9.4
- @astrojs/db@0.9.3
- @astrojs/db@0.9.2
- @astrojs/db@0.9.1
- @astrojs/db@0.9.0
- @astrojs/db@0.8.8
- @astrojs/db@0.8.7
- @astrojs/db@0.8.6
- @astrojs/db@0.8.5
- @astrojs/db@0.8.4
- @astrojs/db@0.8.3
- @astrojs/db@0.8.2
- @astrojs/db@0.8.1
- @astrojs/db@0.8.0
- @astrojs/db@0.7.2
- @astrojs/db@0.7.1
- @astrojs/db@0.7.0
- @astrojs/db@0.6.5
- @astrojs/db@0.6.4
- @astrojs/db@0.6.3
- @astrojs/db@0.6.2
- @astrojs/db@0.6.1
- @astrojs/db@0.6.0
- @astrojs/db@0.5.0
- @astrojs/db@0.4.1
- @astrojs/db@0.4.0
- @astrojs/alpinejs@0.4.1
- @astrojs/alpinejs@0.4.0
- @astrojs/alpinejs@0.3.2
- astro@5.1.1
- astro@5.1.0
- astro@5.0.9
- astro@5.0.8
- astro@5.0.7
- astro@5.0.6
- astro@5.0.5
- astro@5.0.4
- astro@5.0.3
- astro@5.0.2
- astro@5.0.1
- astro@5.0.0
- astro@5.0.0-beta.12
- astro@5.0.0-beta.11
- astro@5.0.0-beta.10
- astro@5.0.0-beta.9
- astro@5.0.0-beta.8
- astro@5.0.0-beta.7
- astro@5.0.0-beta.6
- astro@5.0.0-beta.5
- astro@5.0.0-beta.4
- astro@5.0.0-beta.3
- astro@5.0.0-beta.2
- astro@5.0.0-beta.1
- astro@5.0.0-alpha.8
- astro@5.0.0-alpha.7
- astro@5.0.0-alpha.6
- astro@5.0.0-alpha.5
- astro@5.0.0-alpha.4
- astro@5.0.0-alpha.3
- astro@5.0.0-alpha.2
- astro@5.0.0-alpha.1
- astro@5.0.0-alpha.0
- astro@4.16.18
- astro@4.16.17
- astro@4.16.16
- astro@4.16.15
- astro@4.16.14
- astro@4.16.13
- astro@4.16.12
- astro@4.16.11
- astro@4.16.10
- astro@4.16.9
- astro@4.16.8
- astro@4.16.7
- astro@4.16.6
- astro@4.16.5
- astro@4.16.4
- astro@4.16.3
- astro@4.16.2
- astro@4.16.1
- astro@4.16.0
- astro@4.15.12
- astro@4.15.11
- astro@4.15.10
- astro@4.15.9
- astro@4.15.8
- astro@4.15.7
- astro@4.15.6
- astro@4.15.5
- astro@4.15.4
- astro@4.15.3
- astro@4.15.2
- astro@4.15.1
- astro@4.15.0
- astro@4.14.6
- astro@4.14.5
- astro@4.14.4
- astro@4.14.3
- astro@4.14.2
- astro@4.14.1
- astro@4.14.0
- astro@4.13.4
- astro@4.13.3
- astro@4.13.2
- astro@4.13.1
- astro@4.13.0
- astro@4.12.3
- astro@4.12.2
- astro@4.12.1
- astro@4.12.0
- astro@4.11.6
- astro@4.11.5
- astro@4.11.4
- astro@4.11.3
- astro@4.11.2
- astro@4.11.1
- astro@4.11.0
- astro@4.10.3
- astro@4.10.2
- astro@4.10.1
- astro@4.10.0
- astro@4.9.3
- astro@4.9.2
- astro@4.9.1
- astro@4.9.0
- astro@4.8.7
- astro@4.8.6
- astro@4.8.5
- astro@4.8.4
- astro@4.8.3
- astro@4.8.2
- astro@4.8.1
- astro@4.8.0
- astro@4.7.1
- astro@4.7.0
- astro@4.6.4
- astro@4.6.3
- astro@4.6.2
- astro@4.6.1
- astro@4.6.0
- astro@4.5.18
- astro@4.5.17
- astro@4.5.16
- astro@4.5.15
- astro@4.5.14
- astro@4.5.13
- astro@4.5.12
- astro@4.5.11
- astro@4.5.10
- astro@4.5.9
- astro@4.5.8
- astro@4.5.7
- astro@4.5.6
- astro@4.5.5
- astro@4.5.4
- astro@4.5.3
- astro@4.5.2
- astro@4.5.1
- astro@4.5.0
- astro@4.4.15
- astro@4.4.14
- astro@4.4.13
- astro@4.4.12
- astro@4.4.11
- astro@4.4.10
- astro@4.4.9
- astro@4.4.8
- astro@4.4.7
- astro@4.4.6
- astro@4.4.5
- astro@4.4.4
- astro@4.4.3
- astro@4.4.2
- astro@4.4.1
- astro@4.4.0
- astro@4.3.7
- astro@4.3.6
- astro@4.3.5
- astro@4.3.4
- astro@4.3.3
- astro@4.3.2
- astro@4.3.1
- astro@4.3.0
- astro@4.2.8
- astro@4.2.7
- astro@4.2.6
- astro@4.2.5
- astro@4.2.4
- astro@4.2.3
- astro@4.2.2
- astro@4.2.1
- astro@4.2.0
- astro@4.1.3
- astro@4.1.2
- astro@4.1.1
- astro@4.1.0
- astro@4.0.9
- astro@4.0.8
- astro@4.0.7
- astro@4.0.6
- astro@4.0.5
- astro@4.0.4
- astro@4.0.3
- astro@4.0.2
- astro@4.0.1
- astro@4.0.0
- astro@4.0.0-beta.7
- astro@4.0.0-beta.6
- astro@4.0.0-beta.5
- astro@4.0.0-beta.4
- astro@4.0.0-beta.3
- astro@4.0.0-beta.2
- astro@4.0.0-beta.1
- astro@4.0.0-beta.0
- astro@3.6.5
- astro@3.6.4
- astro@3.6.3
- astro@3.6.2
- astro@3.6.1
- astro@3.6.0
- astro@3.5.7
- astro@3.5.6
- astro@3.5.5
- astro@3.5.4
Showing
10 changed files
with
198 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/markdown-remark': minor | ||
--- | ||
|
||
Exports `createShikiHighlighter` for low-level syntax highlighting usage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
'@astrojs/markdoc': patch | ||
'astro': patch | ||
--- | ||
|
||
Uses new `createShikiHighlighter` API from `@astrojs/markdown-remark` to avoid code duplication |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,120 +1,21 @@ | ||
import { bundledLanguages, getHighlighter, type Highlighter } from 'shikiji'; | ||
import { visit } from 'unist-util-visit'; | ||
import type { RemarkPlugin, ShikiConfig } from './types.js'; | ||
import { createShikiHighlighter, type ShikiHighlighter } from './shiki.js'; | ||
|
||
const ASTRO_COLOR_REPLACEMENTS: Record<string, string> = { | ||
'#000001': 'var(--astro-code-color-text)', | ||
'#000002': 'var(--astro-code-color-background)', | ||
'#000004': 'var(--astro-code-token-constant)', | ||
'#000005': 'var(--astro-code-token-string)', | ||
'#000006': 'var(--astro-code-token-comment)', | ||
'#000007': 'var(--astro-code-token-keyword)', | ||
'#000008': 'var(--astro-code-token-parameter)', | ||
'#000009': 'var(--astro-code-token-function)', | ||
'#000010': 'var(--astro-code-token-string-expression)', | ||
'#000011': 'var(--astro-code-token-punctuation)', | ||
'#000012': 'var(--astro-code-token-link)', | ||
}; | ||
const COLOR_REPLACEMENT_REGEX = new RegExp( | ||
`(${Object.keys(ASTRO_COLOR_REPLACEMENTS).join('|')})`, | ||
'g' | ||
); | ||
|
||
/** | ||
* getHighlighter() is the most expensive step of Shiki. Instead of calling it on every page, | ||
* cache it here as much as possible. Make sure that your highlighters can be cached, state-free. | ||
* We make this async, so that multiple calls to parse markdown still share the same highlighter. | ||
*/ | ||
const highlighterCacheAsync = new Map<string, Promise<Highlighter>>(); | ||
|
||
export function remarkShiki({ | ||
langs = [], | ||
theme = 'github-dark', | ||
experimentalThemes = {}, | ||
wrap = false, | ||
}: ShikiConfig = {}): ReturnType<RemarkPlugin> { | ||
const themes = experimentalThemes; | ||
|
||
const cacheId = | ||
Object.values(themes) | ||
.map((t) => (typeof t === 'string' ? t : t.name ?? '')) | ||
.join(',') + | ||
(typeof theme === 'string' ? theme : theme.name ?? '') + | ||
langs.map((l) => l.name ?? (l as any).id).join(','); | ||
|
||
let highlighterAsync = highlighterCacheAsync.get(cacheId); | ||
if (!highlighterAsync) { | ||
highlighterAsync = getHighlighter({ | ||
langs: langs.length ? langs : Object.keys(bundledLanguages), | ||
themes: Object.values(themes).length ? Object.values(themes) : [theme], | ||
}); | ||
highlighterCacheAsync.set(cacheId, highlighterAsync); | ||
} | ||
export function remarkShiki(config?: ShikiConfig): ReturnType<RemarkPlugin> { | ||
let highlighterAsync: Promise<ShikiHighlighter> | undefined; | ||
|
||
return async (tree: any) => { | ||
const highlighter = await highlighterAsync!; | ||
highlighterAsync ??= createShikiHighlighter(config); | ||
const highlighter = await highlighterAsync; | ||
|
||
visit(tree, 'code', (node) => { | ||
let lang: string; | ||
|
||
if (typeof node.lang === 'string') { | ||
const langExists = highlighter.getLoadedLanguages().includes(node.lang); | ||
if (langExists) { | ||
lang = node.lang; | ||
} else { | ||
// eslint-disable-next-line no-console | ||
console.warn(`The language "${node.lang}" doesn't exist, falling back to plaintext.`); | ||
lang = 'plaintext'; | ||
} | ||
} else { | ||
lang = 'plaintext'; | ||
} | ||
|
||
let themeOptions = Object.values(themes).length ? { themes } : { theme }; | ||
let html = highlighter.codeToHtml(node.value, { ...themeOptions, lang }); | ||
|
||
// Q: Couldn't these regexes match on a user's inputted code blocks? | ||
// A: Nope! All rendered HTML is properly escaped. | ||
// Ex. If a user typed `<span class="line"` into a code block, | ||
// It would become this before hitting our regexes: | ||
// <span class="line" | ||
|
||
// Replace "shiki" class naming with "astro". | ||
html = html.replace(/<pre class="(.*?)shiki(.*?)"/, `<pre class="$1astro-code$2"`); | ||
// Add "user-select: none;" for "+"/"-" diff symbols | ||
if (node.lang === 'diff') { | ||
html = html.replace( | ||
/<span class="line"><span style="(.*?)">([\+|\-])/g, | ||
'<span class="line"><span style="$1"><span style="user-select: none;">$2</span>' | ||
); | ||
} | ||
// Handle code wrapping | ||
// if wrap=null, do nothing. | ||
if (wrap === false) { | ||
html = html.replace(/style="(.*?)"/, 'style="$1; overflow-x: auto;"'); | ||
} else if (wrap === true) { | ||
html = html.replace( | ||
/style="(.*?)"/, | ||
'style="$1; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;"' | ||
); | ||
} | ||
|
||
// theme.id for shiki -> shikiji compat | ||
const themeName = typeof theme === 'string' ? theme : theme.name; | ||
if (themeName === 'css-variables') { | ||
html = html.replace(/style="(.*?)"/g, (m) => replaceCssVariables(m)); | ||
} | ||
const lang = typeof node.lang === 'string' ? node.lang : 'plaintext'; | ||
const html = highlighter.highlight(node.value, lang); | ||
|
||
node.type = 'html'; | ||
node.value = html; | ||
node.children = []; | ||
}); | ||
}; | ||
} | ||
|
||
/** | ||
* shiki -> shikiji compat as we need to manually replace it | ||
*/ | ||
function replaceCssVariables(str: string) { | ||
return str.replace(COLOR_REPLACEMENT_REGEX, (match) => ASTRO_COLOR_REPLACEMENTS[match] || match); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import { bundledLanguages, getHighlighter } from 'shikiji'; | ||
import { visit } from 'unist-util-visit'; | ||
import type { ShikiConfig } from './types.js'; | ||
|
||
export interface ShikiHighlighter { | ||
highlight(code: string, lang?: string, options?: { inline?: boolean }): string; | ||
} | ||
|
||
const ASTRO_COLOR_REPLACEMENTS: Record<string, string> = { | ||
'#000001': 'var(--astro-code-color-text)', | ||
'#000002': 'var(--astro-code-color-background)', | ||
'#000004': 'var(--astro-code-token-constant)', | ||
'#000005': 'var(--astro-code-token-string)', | ||
'#000006': 'var(--astro-code-token-comment)', | ||
'#000007': 'var(--astro-code-token-keyword)', | ||
'#000008': 'var(--astro-code-token-parameter)', | ||
'#000009': 'var(--astro-code-token-function)', | ||
'#000010': 'var(--astro-code-token-string-expression)', | ||
'#000011': 'var(--astro-code-token-punctuation)', | ||
'#000012': 'var(--astro-code-token-link)', | ||
}; | ||
const COLOR_REPLACEMENT_REGEX = new RegExp( | ||
`(${Object.keys(ASTRO_COLOR_REPLACEMENTS).join('|')})`, | ||
'g' | ||
); | ||
|
||
export async function createShikiHighlighter({ | ||
langs = [], | ||
theme = 'github-dark', | ||
experimentalThemes = {}, | ||
wrap = false, | ||
}: ShikiConfig = {}): Promise<ShikiHighlighter> { | ||
const themes = experimentalThemes; | ||
|
||
const highlighter = await getHighlighter({ | ||
langs: langs.length ? langs : Object.keys(bundledLanguages), | ||
themes: Object.values(themes).length ? Object.values(themes) : [theme], | ||
}); | ||
|
||
const loadedLanguages = highlighter.getLoadedLanguages(); | ||
|
||
return { | ||
highlight(code, lang = 'plaintext', options) { | ||
if (lang !== 'plaintext' && !loadedLanguages.includes(lang)) { | ||
// eslint-disable-next-line no-console | ||
console.warn(`[Shiki] The language "${lang}" doesn't exist, falling back to "plaintext".`); | ||
lang = 'plaintext'; | ||
} | ||
|
||
const themeOptions = Object.values(themes).length ? { themes } : { theme }; | ||
const inline = options?.inline ?? false; | ||
|
||
return highlighter.codeToHtml(code, { | ||
...themeOptions, | ||
lang, | ||
transforms: { | ||
pre(node) { | ||
// Swap to `code` tag if inline | ||
if (inline) { | ||
node.tagName = 'code'; | ||
} | ||
|
||
// Cast to string as shikiji will always pass them as strings instead of any other types | ||
const classValue = (node.properties.class as string) ?? ''; | ||
const styleValue = (node.properties.style as string) ?? ''; | ||
|
||
// Replace "shiki" class naming with "astro-code" | ||
node.properties.class = classValue.replace(/shiki/g, 'astro-code'); | ||
|
||
// Handle code wrapping | ||
// if wrap=null, do nothing. | ||
if (wrap === false) { | ||
node.properties.style = styleValue + '; overflow-x: auto;'; | ||
} else if (wrap === true) { | ||
node.properties.style = | ||
styleValue + '; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;'; | ||
} | ||
}, | ||
line(node) { | ||
// Add "user-select: none;" for "+"/"-" diff symbols. | ||
// Transform `<span class="line"><span style="...">+ something</span></span> | ||
// into `<span class="line"><span style="..."><span style="user-select: none;">+</span> something</span></span>` | ||
if (lang === 'diff') { | ||
const innerSpanNode = node.children[0]; | ||
const innerSpanTextNode = | ||
innerSpanNode?.type === 'element' && innerSpanNode.children?.[0]; | ||
|
||
if (innerSpanTextNode && innerSpanTextNode.type === 'text') { | ||
const start = innerSpanTextNode.value[0]; | ||
if (start === '+' || start === '-') { | ||
innerSpanTextNode.value = innerSpanTextNode.value.slice(1); | ||
innerSpanNode.children.unshift({ | ||
type: 'element', | ||
tagName: 'span', | ||
properties: { style: 'user-select: none;' }, | ||
children: [{ type: 'text', value: start }], | ||
}); | ||
} | ||
} | ||
} | ||
}, | ||
code(node) { | ||
if (inline) { | ||
return node.children[0] as typeof node; | ||
} | ||
}, | ||
root(node) { | ||
if (Object.values(experimentalThemes).length) { | ||
return; | ||
} | ||
|
||
// theme.id for shiki -> shikiji compat | ||
const themeName = typeof theme === 'string' ? theme : theme.name; | ||
if (themeName === 'css-variables') { | ||
// Replace special color tokens to CSS variables | ||
visit(node as any, 'element', (child) => { | ||
if (child.properties?.style) { | ||
child.properties.style = replaceCssVariables(child.properties.style); | ||
} | ||
}); | ||
} | ||
}, | ||
}, | ||
}); | ||
}, | ||
}; | ||
} | ||
|
||
/** | ||
* shiki -> shikiji compat as we need to manually replace it | ||
* @internal Exported for error overlay use only | ||
*/ | ||
export function replaceCssVariables(str: string) { | ||
return str.replace(COLOR_REPLACEMENT_REGEX, (match) => ASTRO_COLOR_REPLACEMENTS[match] || match); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters