diff --git a/.changeset/khaki-otters-return.md b/.changeset/khaki-otters-return.md new file mode 100644 index 000000000000..8d0873fe96be --- /dev/null +++ b/.changeset/khaki-otters-return.md @@ -0,0 +1,5 @@ +--- +"@astrojs/markdown-remark": major +--- + +Removes deprecated APIs including `remarkShiki`, `remarkPrism`, `replaceCssVariables` and several unused types diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index dbf929320af0..df45fa410748 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -2,8 +2,7 @@ import type { OutgoingHttpHeaders } from 'node:http'; import type { AddressInfo } from 'node:net'; import type { MarkdownHeading, - MarkdownMetadata, - MarkdownRenderingResult, + MarkdownVFile, RehypePlugins, RemarkPlugins, RemarkRehype, @@ -45,8 +44,6 @@ export { type AstroIntegrationLogger }; export type { MarkdownHeading, - MarkdownMetadata, - MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, @@ -2188,6 +2185,21 @@ export interface ManifestData { routes: RouteData[]; } +/** @deprecated Type is no longer used by exported APIs */ +export interface MarkdownMetadata { + headings: MarkdownHeading[]; + source: string; + html: string; +} + +/** @deprecated Type is no longer used by exported APIs */ +export interface MarkdownRenderingResult { + metadata: MarkdownMetadata; + vfile: MarkdownVFile; + code: string; +} + +/** @deprecated Type is no longer used by exported APIs */ export interface MarkdownParserResponse extends MarkdownRenderingResult { frontmatter: MD['frontmatter']; } diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index ef1afc8fba18..00d6d64ca127 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -26,9 +26,7 @@ export { rehypeHeadingIds } from './rehype-collect-headings.js'; export { remarkCollectImages } from './remark-collect-images.js'; export { rehypePrism } from './rehype-prism.js'; export { rehypeShiki } from './rehype-shiki.js'; -export { remarkPrism } from './remark-prism.js'; -export { remarkShiki } from './remark-shiki.js'; -export { createShikiHighlighter, replaceCssVariables, type ShikiHighlighter } from './shiki.js'; +export { createShikiHighlighter, type ShikiHighlighter } from './shiki.js'; export * from './types.js'; export const markdownConfigDefaults: Required = { diff --git a/packages/markdown/remark/src/remark-prism.ts b/packages/markdown/remark/src/remark-prism.ts deleted file mode 100644 index 49e38d73cfd7..000000000000 --- a/packages/markdown/remark/src/remark-prism.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { runHighlighterWithAstro } from '@astrojs/prism/dist/highlighter'; -import { visit } from 'unist-util-visit'; -import type { RemarkPlugin } from './types.js'; - -/** - * @deprecated Use `rehypePrism` instead - */ -export function remarkPrism(): ReturnType { - return function (tree: any) { - visit(tree, 'code', (node) => { - let { lang, value } = node; - node.type = 'html'; - - let { html, classLanguage } = runHighlighterWithAstro(lang, value); - let classes = [classLanguage]; - node.value = `
${html}
`; - return node; - }); - }; -} diff --git a/packages/markdown/remark/src/remark-shiki.ts b/packages/markdown/remark/src/remark-shiki.ts deleted file mode 100644 index 512cd453aa38..000000000000 --- a/packages/markdown/remark/src/remark-shiki.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { visit } from 'unist-util-visit'; -import { type ShikiHighlighter, createShikiHighlighter } from './shiki.js'; -import type { RemarkPlugin, ShikiConfig } from './types.js'; - -/** - * @deprecated Use `rehypeShiki` instead - */ -export function remarkShiki(config?: ShikiConfig): ReturnType { - let highlighterAsync: Promise | undefined; - - return async (tree: any) => { - highlighterAsync ??= createShikiHighlighter(config); - const highlighter = await highlighterAsync; - - visit(tree, 'code', (node) => { - const lang = typeof node.lang === 'string' ? node.lang : 'plaintext'; - const html = highlighter.highlight(node.value, lang); - - node.type = 'html'; - node.value = html; - node.children = []; - }); - }; -} diff --git a/packages/markdown/remark/src/shiki.ts b/packages/markdown/remark/src/shiki.ts index c4fef6f7a4f7..f3f9d63bf414 100644 --- a/packages/markdown/remark/src/shiki.ts +++ b/packages/markdown/remark/src/shiki.ts @@ -167,10 +167,6 @@ function normalizePropAsString(value: Properties[string]): string | null { return Array.isArray(value) ? value.join(' ') : (value as string | null); } -/** - * shiki -> shikiji compat as we need to manually replace it - * @internal Exported for error overlay use only - */ -export function replaceCssVariables(str: string) { +function replaceCssVariables(str: string) { return str.replace(COLOR_REPLACEMENT_REGEX, (match) => ASTRO_COLOR_REPLACEMENTS[match] || match); } diff --git a/packages/markdown/remark/src/types.ts b/packages/markdown/remark/src/types.ts index 1fb89316d60e..5861f9e6f9c6 100644 --- a/packages/markdown/remark/src/types.ts +++ b/packages/markdown/remark/src/types.ts @@ -53,13 +53,6 @@ export interface AstroMarkdownOptions { smartypants?: boolean; } -export interface ImageMetadata { - src: string; - width: number; - height: number; - type: string; -} - export interface MarkdownProcessor { render: ( content: string, @@ -83,31 +76,15 @@ export interface MarkdownProcessorRenderResult { }; } -export interface MarkdownRenderingOptions - extends AstroMarkdownOptions, - MarkdownProcessorRenderOptions {} - export interface MarkdownHeading { depth: number; slug: string; text: string; } -export interface MarkdownMetadata { - headings: MarkdownHeading[]; - source: string; - html: string; -} - export interface MarkdownVFile extends VFile { data: { __astroHeadings?: MarkdownHeading[]; imagePaths?: Set; }; } - -export interface MarkdownRenderingResult { - metadata: MarkdownMetadata; - vfile: MarkdownVFile; - code: string; -}