Skip to content

Commit

Permalink
Remove deprecated APIs from @astrojs/markdown-remark (#10629)
Browse files Browse the repository at this point in the history
Co-authored-by: Florian Lefebvre <contact@florian-lefebvre.dev>
  • Loading branch information
bluwy and florian-lefebvre authored Apr 1, 2024
1 parent 374efcd commit 2cf116f
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 81 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-otters-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@astrojs/markdown-remark": major
---

Removes deprecated APIs including `remarkShiki`, `remarkPrism`, `replaceCssVariables` and several unused types
20 changes: 16 additions & 4 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -45,8 +44,6 @@ export { type AstroIntegrationLogger };

export type {
MarkdownHeading,
MarkdownMetadata,
MarkdownRenderingResult,
RehypePlugins,
RemarkPlugins,
ShikiConfig,
Expand Down Expand Up @@ -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'];
}
Expand Down
4 changes: 1 addition & 3 deletions packages/markdown/remark/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AstroMarkdownOptions> = {
Expand Down
22 changes: 0 additions & 22 deletions packages/markdown/remark/src/remark-prism.ts

This file was deleted.

24 changes: 0 additions & 24 deletions packages/markdown/remark/src/remark-shiki.ts

This file was deleted.

6 changes: 1 addition & 5 deletions packages/markdown/remark/src/shiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
23 changes: 0 additions & 23 deletions packages/markdown/remark/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<string>;
};
}

export interface MarkdownRenderingResult {
metadata: MarkdownMetadata;
vfile: MarkdownVFile;
code: string;
}

0 comments on commit 2cf116f

Please sign in to comment.