@astrojs/markdown-remark 3.5.0 → 4.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/frontmatter-injection.d.ts +0 -6
- package/dist/frontmatter-injection.js +1 -11
- package/dist/index.d.ts +2 -8
- package/dist/index.js +0 -21
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +2 -7
- package/dist/types.d.ts +2 -6
- package/package.json +19 -19
|
@@ -4,9 +4,3 @@ export declare class InvalidAstroDataError extends TypeError {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function safelyGetAstroData(vfileData: Data): MarkdownAstroData | InvalidAstroDataError;
|
|
6
6
|
export declare function setVfileFrontmatter(vfile: VFile, frontmatter: Record<string, any>): void;
|
|
7
|
-
/**
|
|
8
|
-
* @deprecated Use `setVfileFrontmatter` instead
|
|
9
|
-
*/
|
|
10
|
-
export declare function toRemarkInitializeAstroData({ userFrontmatter, }: {
|
|
11
|
-
userFrontmatter: Record<string, any>;
|
|
12
|
-
}): () => (tree: any, vfile: VFile) => void;
|
|
@@ -24,18 +24,8 @@ function setVfileFrontmatter(vfile, frontmatter) {
|
|
|
24
24
|
vfile.data.astro ??= {};
|
|
25
25
|
vfile.data.astro.frontmatter = frontmatter;
|
|
26
26
|
}
|
|
27
|
-
function toRemarkInitializeAstroData({
|
|
28
|
-
userFrontmatter
|
|
29
|
-
}) {
|
|
30
|
-
return () => function(tree, vfile) {
|
|
31
|
-
if (!vfile.data.astro) {
|
|
32
|
-
vfile.data.astro = { frontmatter: userFrontmatter };
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
27
|
export {
|
|
37
28
|
InvalidAstroDataError,
|
|
38
29
|
safelyGetAstroData,
|
|
39
|
-
setVfileFrontmatter
|
|
40
|
-
toRemarkInitializeAstroData
|
|
30
|
+
setVfileFrontmatter
|
|
41
31
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AstroMarkdownOptions, MarkdownProcessor
|
|
1
|
+
import type { AstroMarkdownOptions, MarkdownProcessor } from './types.js';
|
|
2
2
|
export { InvalidAstroDataError, setVfileFrontmatter } from './frontmatter-injection.js';
|
|
3
3
|
export { rehypeHeadingIds } from './rehype-collect-headings.js';
|
|
4
4
|
export { remarkCollectImages } from './remark-collect-images.js';
|
|
@@ -6,14 +6,8 @@ export { remarkPrism } from './remark-prism.js';
|
|
|
6
6
|
export { remarkShiki } from './remark-shiki.js';
|
|
7
7
|
export { createShikiHighlighter, replaceCssVariables, type ShikiHighlighter } from './shiki.js';
|
|
8
8
|
export * from './types.js';
|
|
9
|
-
export declare const markdownConfigDefaults:
|
|
9
|
+
export declare const markdownConfigDefaults: Required<AstroMarkdownOptions>;
|
|
10
10
|
/**
|
|
11
11
|
* Create a markdown preprocessor to render multiple markdown files
|
|
12
12
|
*/
|
|
13
13
|
export declare function createMarkdownProcessor(opts?: AstroMarkdownOptions): Promise<MarkdownProcessor>;
|
|
14
|
-
/**
|
|
15
|
-
* Shared utility for rendering markdown
|
|
16
|
-
*
|
|
17
|
-
* @deprecated Use `createMarkdownProcessor` instead for better performance
|
|
18
|
-
*/
|
|
19
|
-
export declare function renderMarkdown(content: string, opts: MarkdownRenderingOptions): Promise<MarkdownRenderingResult>;
|
package/dist/index.js
CHANGED
|
@@ -103,31 +103,11 @@ async function createMarkdownProcessor(opts) {
|
|
|
103
103
|
headings: result.data.__astroHeadings ?? [],
|
|
104
104
|
imagePaths: result.data.imagePaths ?? /* @__PURE__ */ new Set(),
|
|
105
105
|
frontmatter: astroData.frontmatter ?? {}
|
|
106
|
-
},
|
|
107
|
-
// Compat for `renderMarkdown` only. Do not use!
|
|
108
|
-
__renderMarkdownCompat: {
|
|
109
|
-
result
|
|
110
106
|
}
|
|
111
107
|
};
|
|
112
108
|
}
|
|
113
109
|
};
|
|
114
110
|
}
|
|
115
|
-
async function renderMarkdown(content, opts) {
|
|
116
|
-
const processor = await createMarkdownProcessor(opts);
|
|
117
|
-
const result = await processor.render(content, {
|
|
118
|
-
fileURL: opts.fileURL,
|
|
119
|
-
frontmatter: opts.frontmatter
|
|
120
|
-
});
|
|
121
|
-
return {
|
|
122
|
-
code: result.code,
|
|
123
|
-
metadata: {
|
|
124
|
-
headings: result.metadata.headings,
|
|
125
|
-
source: content,
|
|
126
|
-
html: result.code
|
|
127
|
-
},
|
|
128
|
-
vfile: result.__renderMarkdownCompat.result
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
111
|
function prefixError(err, prefix) {
|
|
132
112
|
if (err?.message) {
|
|
133
113
|
try {
|
|
@@ -154,7 +134,6 @@ export {
|
|
|
154
134
|
remarkCollectImages2 as remarkCollectImages,
|
|
155
135
|
remarkPrism2 as remarkPrism,
|
|
156
136
|
remarkShiki2 as remarkShiki,
|
|
157
|
-
renderMarkdown,
|
|
158
137
|
replaceCssVariables,
|
|
159
138
|
setVfileFrontmatter2 as setVfileFrontmatter
|
|
160
139
|
};
|
package/dist/internal.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InvalidAstroDataError, safelyGetAstroData
|
|
1
|
+
export { InvalidAstroDataError, safelyGetAstroData } from './frontmatter-injection.js';
|
package/dist/internal.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
InvalidAstroDataError,
|
|
3
|
-
safelyGetAstroData,
|
|
4
|
-
toRemarkInitializeAstroData
|
|
5
|
-
} from "./frontmatter-injection.js";
|
|
1
|
+
import { InvalidAstroDataError, safelyGetAstroData } from "./frontmatter-injection.js";
|
|
6
2
|
export {
|
|
7
3
|
InvalidAstroDataError,
|
|
8
|
-
safelyGetAstroData
|
|
9
|
-
toRemarkInitializeAstroData
|
|
4
|
+
safelyGetAstroData
|
|
10
5
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as hast from 'hast';
|
|
2
2
|
import type * as mdast from 'mdast';
|
|
3
|
-
import type {
|
|
3
|
+
import type { Options as RemarkRehypeOptions } from 'remark-rehype';
|
|
4
4
|
import type { BuiltinTheme, LanguageRegistration, ThemeRegistration, ThemeRegistrationRaw } from 'shikiji';
|
|
5
5
|
import type * as unified from 'unified';
|
|
6
6
|
import type { VFile } from 'vfile';
|
|
@@ -12,10 +12,7 @@ export type RemarkPlugin<PluginParameters extends any[] = any[]> = unified.Plugi
|
|
|
12
12
|
export type RemarkPlugins = (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
|
|
13
13
|
export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugin<PluginParameters, hast.Root>;
|
|
14
14
|
export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
|
|
15
|
-
export type RemarkRehype =
|
|
16
|
-
handlers?: typeof Handlers;
|
|
17
|
-
handler?: typeof Handler;
|
|
18
|
-
};
|
|
15
|
+
export type RemarkRehype = RemarkRehypeOptions;
|
|
19
16
|
export interface ShikiConfig {
|
|
20
17
|
langs?: LanguageRegistration[];
|
|
21
18
|
theme?: BuiltinTheme | ThemeRegistration | ThemeRegistrationRaw;
|
|
@@ -23,7 +20,6 @@ export interface ShikiConfig {
|
|
|
23
20
|
wrap?: boolean | null;
|
|
24
21
|
}
|
|
25
22
|
export interface AstroMarkdownOptions {
|
|
26
|
-
drafts?: boolean;
|
|
27
23
|
syntaxHighlight?: 'shiki' | 'prism' | false;
|
|
28
24
|
shikiConfig?: ShikiConfig;
|
|
29
25
|
remarkPlugins?: RemarkPlugins;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdown-remark",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"author": "withastro",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,33 +20,33 @@
|
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"astro": "^
|
|
23
|
+
"astro": "^4.0.0-beta.0"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@astrojs/prism": "^3.0.0",
|
|
27
27
|
"github-slugger": "^2.0.0",
|
|
28
|
-
"import-meta-resolve": "^
|
|
28
|
+
"import-meta-resolve": "^4.0.0",
|
|
29
29
|
"mdast-util-definitions": "^6.0.0",
|
|
30
|
-
"rehype-raw": "^
|
|
31
|
-
"rehype-stringify": "^
|
|
32
|
-
"remark-gfm": "^
|
|
33
|
-
"remark-parse": "^
|
|
34
|
-
"remark-rehype": "^
|
|
30
|
+
"rehype-raw": "^7.0.0",
|
|
31
|
+
"rehype-stringify": "^10.0.0",
|
|
32
|
+
"remark-gfm": "^4.0.0",
|
|
33
|
+
"remark-parse": "^11.0.0",
|
|
34
|
+
"remark-rehype": "^11.0.0",
|
|
35
35
|
"remark-smartypants": "^2.0.0",
|
|
36
|
-
"shikiji": "^0.6.
|
|
37
|
-
"unified": "^
|
|
38
|
-
"unist-util-visit": "^
|
|
39
|
-
"vfile": "^
|
|
36
|
+
"shikiji": "^0.6.13",
|
|
37
|
+
"unified": "^11.0.4",
|
|
38
|
+
"unist-util-visit": "^5.0.0",
|
|
39
|
+
"vfile": "^6.0.1"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@types/chai": "^4.3.
|
|
43
|
-
"@types/estree": "^1.0.
|
|
44
|
-
"@types/hast": "^
|
|
45
|
-
"@types/mdast": "^
|
|
46
|
-
"@types/mocha": "^10.0.
|
|
47
|
-
"@types/unist": "^
|
|
42
|
+
"@types/chai": "^4.3.10",
|
|
43
|
+
"@types/estree": "^1.0.5",
|
|
44
|
+
"@types/hast": "^3.0.3",
|
|
45
|
+
"@types/mdast": "^4.0.3",
|
|
46
|
+
"@types/mocha": "^10.0.4",
|
|
47
|
+
"@types/unist": "^3.0.2",
|
|
48
48
|
"chai": "^4.3.7",
|
|
49
|
-
"mdast-util-mdx-expression": "^
|
|
49
|
+
"mdast-util-mdx-expression": "^2.0.0",
|
|
50
50
|
"mocha": "^10.2.0",
|
|
51
51
|
"astro-scripts": "0.0.14"
|
|
52
52
|
},
|