diff options
Diffstat (limited to 'packages/markdown/remark/src/index.ts')
-rw-r--r-- | packages/markdown/remark/src/index.ts | 43 |
1 files changed, 3 insertions, 40 deletions
diff --git a/packages/markdown/remark/src/index.ts b/packages/markdown/remark/src/index.ts index a60ab88c0..143015847 100644 --- a/packages/markdown/remark/src/index.ts +++ b/packages/markdown/remark/src/index.ts @@ -1,10 +1,4 @@ -import type { - AstroMarkdownOptions, - MarkdownProcessor, - MarkdownRenderingOptions, - MarkdownRenderingResult, - MarkdownVFile, -} from './types.js'; +import type { AstroMarkdownOptions, MarkdownProcessor, MarkdownVFile } from './types.js'; import { InvalidAstroDataError, @@ -35,7 +29,7 @@ export { remarkShiki } from './remark-shiki.js'; export { createShikiHighlighter, replaceCssVariables, type ShikiHighlighter } from './shiki.js'; export * from './types.js'; -export const markdownConfigDefaults: Omit<Required<AstroMarkdownOptions>, 'drafts'> = { +export const markdownConfigDefaults: Required<AstroMarkdownOptions> = { syntaxHighlight: 'shiki', shikiConfig: { langs: [], @@ -102,7 +96,7 @@ export async function createMarkdownProcessor( } // Remark -> Rehype - parser.use(remarkRehype as any, { + parser.use(remarkRehype, { allowDangerousHtml: true, passThrough: [], ...remarkRehypeOptions, @@ -150,42 +144,11 @@ export async function createMarkdownProcessor( imagePaths: result.data.imagePaths ?? new Set(), frontmatter: astroData.frontmatter ?? {}, }, - // Compat for `renderMarkdown` only. Do not use! - __renderMarkdownCompat: { - result, - }, }; }, }; } -/** - * Shared utility for rendering markdown - * - * @deprecated Use `createMarkdownProcessor` instead for better performance - */ -export async function renderMarkdown( - content: string, - opts: MarkdownRenderingOptions -): Promise<MarkdownRenderingResult> { - const processor = await createMarkdownProcessor(opts); - - const result = await processor.render(content, { - fileURL: opts.fileURL, - frontmatter: opts.frontmatter, - }); - - return { - code: result.code, - metadata: { - headings: result.metadata.headings, - source: content, - html: result.code, - }, - vfile: (result as any).__renderMarkdownCompat.result, - }; -} - function prefixError(err: any, prefix: string) { // If the error is an object with a `message` property, attempt to prefix the message if (err?.message) { |