diff options
Diffstat (limited to 'packages/integrations/markdoc/src/extensions')
-rw-r--r-- | packages/integrations/markdoc/src/extensions/prism.ts | 7 | ||||
-rw-r--r-- | packages/integrations/markdoc/src/extensions/shiki.ts | 28 |
2 files changed, 4 insertions, 31 deletions
diff --git a/packages/integrations/markdoc/src/extensions/prism.ts b/packages/integrations/markdoc/src/extensions/prism.ts index e28112c9a..5cfd628ca 100644 --- a/packages/integrations/markdoc/src/extensions/prism.ts +++ b/packages/integrations/markdoc/src/extensions/prism.ts @@ -1,8 +1,5 @@ -// leave space, so organize imports doesn't mess up comments -// @ts-expect-error Cannot find module 'astro/runtime/server/index.js' or its corresponding type declarations. -import { unescapeHTML } from 'astro/runtime/server/index.js'; - import { runHighlighterWithAstro } from '@astrojs/prism/dist/highlighter'; +import { unescapeHTML } from 'astro/runtime/server/index.js'; import { Markdoc, type AstroMarkdocConfig } from '../config.js'; export default function prism(): AstroMarkdocConfig { @@ -16,7 +13,7 @@ export default function prism(): AstroMarkdocConfig { // Use `unescapeHTML` to return `HTMLString` for Astro renderer to inline as HTML return unescapeHTML( `<pre class="${classLanguage}"><code class="${classLanguage}">${html}</code></pre>` - ); + ) as any; }, }, }, diff --git a/packages/integrations/markdoc/src/extensions/shiki.ts b/packages/integrations/markdoc/src/extensions/shiki.ts index 1229a09fb..df3e79cf7 100644 --- a/packages/integrations/markdoc/src/extensions/shiki.ts +++ b/packages/integrations/markdoc/src/extensions/shiki.ts @@ -1,32 +1,10 @@ -// leave space, so organize imports doesn't mess up comments -// @ts-expect-error Cannot find module 'astro/runtime/server/index.js' or its corresponding type declarations. -import { unescapeHTML } from 'astro/runtime/server/index.js'; - import Markdoc from '@markdoc/markdoc'; import type { ShikiConfig } from 'astro'; +import { unescapeHTML } from 'astro/runtime/server/index.js'; import type * as shikiTypes from 'shiki'; import { getHighlighter } from 'shiki'; import type { AstroMarkdocConfig } from '../config.js'; -// Map of old theme names to new names to preserve compatibility when we upgrade shiki -const compatThemes: Record<string, string> = { - 'material-darker': 'material-theme-darker', - 'material-default': 'material-theme', - 'material-lighter': 'material-theme-lighter', - 'material-ocean': 'material-theme-ocean', - 'material-palenight': 'material-theme-palenight', -}; - -const normalizeTheme = (theme: string | shikiTypes.IShikiTheme) => { - if (typeof theme === 'string') { - return compatThemes[theme] || theme; - } else if (compatThemes[theme.name]) { - return { ...theme, name: compatThemes[theme.name] }; - } else { - return theme; - } -}; - const ASTRO_COLOR_REPLACEMENTS = { '#000001': 'var(--astro-code-color-text)', '#000002': 'var(--astro-code-color-background)', @@ -56,8 +34,6 @@ export default async function shiki({ theme = 'github-dark', wrap = false, }: ShikiConfig = {}): Promise<AstroMarkdocConfig> { - theme = normalizeTheme(theme); - const cacheID: string = typeof theme === 'string' ? theme : theme.name; if (!highlighterCache.has(cacheID)) { highlighterCache.set( @@ -123,7 +99,7 @@ export default async function shiki({ } // Use `unescapeHTML` to return `HTMLString` for Astro renderer to inline as HTML - return unescapeHTML(html); + return unescapeHTML(html) as any; }, }, }, |