Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated APIs from @astrojs/markdown-remark #10629

Merged
merged 4 commits into from
Apr 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -156,10 +156,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;
}
Loading