Skip to content

Commit addb57c

Browse files
authored
Fix RemarkRehype types (#9147)
1 parent 0fe3a7e commit addb57c

5 files changed

Lines changed: 7 additions & 13 deletions

File tree

.changeset/khaki-fans-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@astrojs/markdown-remark': patch
3+
---
4+
5+
Fixes `RemarkRehype` type's `handler` and `handlers` properties

packages/markdown/remark/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"github-slugger": "^2.0.0",
3636
"import-meta-resolve": "^4.0.0",
3737
"mdast-util-definitions": "^6.0.0",
38-
"mdast-util-to-hast": "13.0.2",
3938
"rehype-raw": "^7.0.0",
4039
"rehype-stringify": "^10.0.0",
4140
"remark-gfm": "^4.0.0",

packages/markdown/remark/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export async function createMarkdownProcessor(
102102
}
103103

104104
// Remark -> Rehype
105-
parser.use(remarkRehype as any, {
105+
parser.use(remarkRehype, {
106106
allowDangerousHtml: true,
107107
passThrough: [],
108108
...remarkRehypeOptions,

packages/markdown/remark/src/types.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type * as hast from 'hast';
22
import type * as mdast from 'mdast';
33
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
4-
import type { State } from 'mdast-util-to-hast';
54
import type {
65
BuiltinTheme,
76
LanguageRegistration,
@@ -11,9 +10,6 @@ import type {
1110
import type * as unified from 'unified';
1211
import type { VFile } from 'vfile';
1312

14-
type Handler = State['one'];
15-
type Handlers = State['all'];
16-
1713
export type { Node } from 'unist';
1814

1915
export type MarkdownAstroData = {
@@ -34,10 +30,7 @@ export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugi
3430

3531
export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
3632

37-
export type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandler'> & {
38-
handlers?: Handlers;
39-
handler?: Handler;
40-
};
33+
export type RemarkRehype = RemarkRehypeOptions;
4134

4235
export interface ShikiConfig {
4336
langs?: LanguageRegistration[];

pnpm-lock.yaml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)