@astrojs/markdown-remark 0.4.0 → 0.5.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/CHANGELOG.md +12 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +8 -7
- package/package.json +14 -15
- package/src/index.ts +8 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,15 @@
|
|
|
1
|
-
# @astrojs/markdown-
|
|
1
|
+
# @astrojs/markdown-remark
|
|
2
|
+
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 679d4395: - Upgraded dependencies
|
|
8
|
+
- Replaced `remark-slug` with `rehype-slug` because [it was deprecated](https://github.com/remarkjs/remark-slug)
|
|
9
|
+
- Replaced `@silvenon/remark-smartypants` with `remark-smartypants` because its name was changed
|
|
10
|
+
- Disable **all** built-in plugins when custom remark and/or rehype plugins are added
|
|
11
|
+
- Removed `remark-footnotes` because [`remark-gfm` now supports footnotes](https://github.com/remarkjs/remark-gfm/releases/tag/3.0.0)
|
|
12
|
+
- Re-added `remark-smartypants` and `rehype-slug` to the default plugins list
|
|
2
13
|
|
|
3
14
|
## 0.4.0
|
|
4
15
|
|
package/dist/index.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare function renderMarkdownWithFrontmatter(contents: string, opts?: M
|
|
|
13
13
|
code: string;
|
|
14
14
|
}>;
|
|
15
15
|
export declare const DEFAULT_REMARK_PLUGINS: string[];
|
|
16
|
-
export declare const DEFAULT_REHYPE_PLUGINS:
|
|
16
|
+
export declare const DEFAULT_REHYPE_PLUGINS: string[];
|
|
17
17
|
/** Shared utility for rendering markdown */
|
|
18
18
|
export declare function renderMarkdown(content: string, opts?: MarkdownRenderingOptions | null): Promise<{
|
|
19
19
|
metadata: {
|
package/dist/index.js
CHANGED
|
@@ -39,20 +39,21 @@ async function renderMarkdownWithFrontmatter(contents, opts) {
|
|
|
39
39
|
const value = await renderMarkdown(content, opts);
|
|
40
40
|
return __spreadProps(__spreadValues({}, value), { frontmatter });
|
|
41
41
|
}
|
|
42
|
-
const DEFAULT_REMARK_PLUGINS = [
|
|
43
|
-
|
|
44
|
-
"remark-footnotes"
|
|
45
|
-
];
|
|
46
|
-
const DEFAULT_REHYPE_PLUGINS = [];
|
|
42
|
+
const DEFAULT_REMARK_PLUGINS = ["remark-gfm", "remark-smartypants"];
|
|
43
|
+
const DEFAULT_REHYPE_PLUGINS = ["rehype-slug"];
|
|
47
44
|
async function renderMarkdown(content, opts) {
|
|
48
45
|
var _a, _b;
|
|
49
|
-
|
|
46
|
+
let { remarkPlugins = [], rehypePlugins = [] } = opts != null ? opts : {};
|
|
50
47
|
const scopedClassName = (_a = opts == null ? void 0 : opts.$) == null ? void 0 : _a.scopedClassName;
|
|
51
48
|
const mode = (_b = opts == null ? void 0 : opts.mode) != null ? _b : "mdx";
|
|
52
49
|
const isMDX = mode === "mdx";
|
|
53
50
|
const { headers, rehypeCollectHeaders } = createCollectHeaders();
|
|
54
51
|
await Promise.all([loadRemarkExpressions(), loadRemarkJsx()]);
|
|
55
52
|
let parser = unified().use(markdown).use(isMDX ? [remarkJsx] : []).use(isMDX ? [remarkExpressions] : []).use([remarkUnwrap]);
|
|
53
|
+
if (remarkPlugins.length === 0 && rehypePlugins.length === 0) {
|
|
54
|
+
remarkPlugins = [...DEFAULT_REMARK_PLUGINS];
|
|
55
|
+
rehypePlugins = [...DEFAULT_REHYPE_PLUGINS];
|
|
56
|
+
}
|
|
56
57
|
const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
|
|
57
58
|
const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
|
|
58
59
|
loadedRemarkPlugins.forEach(([plugin, opts2]) => {
|
|
@@ -88,4 +89,4 @@ export {
|
|
|
88
89
|
renderMarkdown,
|
|
89
90
|
renderMarkdownWithFrontmatter
|
|
90
91
|
};
|
|
91
|
-
//# sourceMappingURL=data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iOiBbXQp9Cg==
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/markdown-remark",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -19,25 +19,24 @@
|
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@astrojs/prism": "^0.3.0",
|
|
22
|
-
"@silvenon/remark-smartypants": "^1.0.0",
|
|
23
22
|
"assert": "^2.0.0",
|
|
24
|
-
"github-slugger": "^1.
|
|
23
|
+
"github-slugger": "^1.4.0",
|
|
25
24
|
"gray-matter": "^4.0.3",
|
|
26
25
|
"mdast-util-mdx-expression": "^1.1.1",
|
|
27
|
-
"mdast-util-mdx-jsx": "^1.1.
|
|
28
|
-
"micromark-extension-mdx-expression": "^1.0.
|
|
29
|
-
"micromark-extension-mdx-jsx": "^1.0.
|
|
26
|
+
"mdast-util-mdx-jsx": "^1.1.3",
|
|
27
|
+
"micromark-extension-mdx-expression": "^1.0.3",
|
|
28
|
+
"micromark-extension-mdx-jsx": "^1.0.2",
|
|
30
29
|
"prismjs": "^1.25.0",
|
|
31
|
-
"rehype-raw": "^6.
|
|
32
|
-
"rehype-
|
|
33
|
-
"
|
|
34
|
-
"remark-gfm": "^
|
|
35
|
-
"remark-parse": "^10.0.
|
|
36
|
-
"remark-rehype": "^
|
|
37
|
-
"remark-
|
|
38
|
-
"unified": "^10.1.
|
|
30
|
+
"rehype-raw": "^6.1.0",
|
|
31
|
+
"rehype-slug": "^5.0.0",
|
|
32
|
+
"rehype-stringify": "^9.0.2",
|
|
33
|
+
"remark-gfm": "^3.0.1",
|
|
34
|
+
"remark-parse": "^10.0.1",
|
|
35
|
+
"remark-rehype": "^10.0.1",
|
|
36
|
+
"remark-smartypants": "^2.0.0",
|
|
37
|
+
"unified": "^10.1.1",
|
|
39
38
|
"unist-util-map": "^3.0.0",
|
|
40
|
-
"unist-util-visit": "^4.
|
|
39
|
+
"unist-util-visit": "^4.1.0"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
43
42
|
"@types/github-slugger": "^1.3.0",
|
package/src/index.ts
CHANGED
|
@@ -28,20 +28,13 @@ export async function renderMarkdownWithFrontmatter(contents: string, opts?: Mar
|
|
|
28
28
|
return { ...value, frontmatter };
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export const DEFAULT_REMARK_PLUGINS = [
|
|
32
|
-
'remark-gfm',
|
|
33
|
-
'remark-footnotes',
|
|
34
|
-
// TODO: reenable smartypants!
|
|
35
|
-
// '@silvenon/remark-smartypants'
|
|
36
|
-
];
|
|
31
|
+
export const DEFAULT_REMARK_PLUGINS = ['remark-gfm', 'remark-smartypants'];
|
|
37
32
|
|
|
38
|
-
export const DEFAULT_REHYPE_PLUGINS = [
|
|
39
|
-
// empty
|
|
40
|
-
];
|
|
33
|
+
export const DEFAULT_REHYPE_PLUGINS = ['rehype-slug'];
|
|
41
34
|
|
|
42
35
|
/** Shared utility for rendering markdown */
|
|
43
36
|
export async function renderMarkdown(content: string, opts?: MarkdownRenderingOptions | null) {
|
|
44
|
-
|
|
37
|
+
let { remarkPlugins = [], rehypePlugins = [] } = opts ?? {};
|
|
45
38
|
const scopedClassName = opts?.$?.scopedClassName;
|
|
46
39
|
const mode = opts?.mode ?? 'mdx';
|
|
47
40
|
const isMDX = mode === 'mdx';
|
|
@@ -55,6 +48,11 @@ export async function renderMarkdown(content: string, opts?: MarkdownRenderingOp
|
|
|
55
48
|
.use(isMDX ? [remarkExpressions] : [])
|
|
56
49
|
.use([remarkUnwrap]);
|
|
57
50
|
|
|
51
|
+
if (remarkPlugins.length === 0 && rehypePlugins.length === 0) {
|
|
52
|
+
remarkPlugins = [...DEFAULT_REMARK_PLUGINS];
|
|
53
|
+
rehypePlugins = [...DEFAULT_REHYPE_PLUGINS];
|
|
54
|
+
}
|
|
55
|
+
|
|
58
56
|
const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
|
|
59
57
|
const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
|
|
60
58
|
|