@astrojs/mdx 0.11.0 → 0.11.1
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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +6 -0
- package/dist/utils.js +5 -2
- package/package.json +2 -2
- package/src/utils.ts +9 -2
- package/test/mdx-plugins.test.js +11 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
1
|
+
[35m@astrojs/mdx:build: [0mcache hit, replaying output [2m604c52682e125e09[0m
|
|
2
|
+
[35m@astrojs/mdx:build: [0m
|
|
3
|
+
[35m@astrojs/mdx:build: [0m> @astrojs/mdx@0.11.1 build /home/runner/work/astro/astro/packages/integrations/mdx
|
|
4
|
+
[35m@astrojs/mdx:build: [0m> astro-scripts build "src/**/*.ts" && tsc
|
|
5
|
+
[35m@astrojs/mdx:build: [0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @astrojs/mdx
|
|
2
2
|
|
|
3
|
+
## 0.11.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4588](https://github.com/withastro/astro/pull/4588) [`db38f61b2`](https://github.com/withastro/astro/commit/db38f61b2b2dc55f03b28797d19b163b1940f1c8) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Fix: Add GFM and Smartypants to MDX by default
|
|
8
|
+
|
|
3
9
|
## 0.11.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/dist/utils.js
CHANGED
|
@@ -83,7 +83,7 @@ async function getRemarkPlugins(mdxOptions, config) {
|
|
|
83
83
|
default:
|
|
84
84
|
remarkPlugins = [
|
|
85
85
|
...remarkPlugins,
|
|
86
|
-
...config
|
|
86
|
+
...markdownShouldExtendDefaultPlugins(config) ? DEFAULT_REMARK_PLUGINS : [],
|
|
87
87
|
...ignoreStringPlugins(config.markdown.remarkPlugins ?? [])
|
|
88
88
|
];
|
|
89
89
|
break;
|
|
@@ -111,7 +111,7 @@ function getRehypePlugins(mdxOptions, config) {
|
|
|
111
111
|
default:
|
|
112
112
|
rehypePlugins = [
|
|
113
113
|
...rehypePlugins,
|
|
114
|
-
...config
|
|
114
|
+
...markdownShouldExtendDefaultPlugins(config) ? DEFAULT_REHYPE_PLUGINS : [],
|
|
115
115
|
...ignoreStringPlugins(config.markdown.rehypePlugins ?? [])
|
|
116
116
|
];
|
|
117
117
|
break;
|
|
@@ -119,6 +119,9 @@ function getRehypePlugins(mdxOptions, config) {
|
|
|
119
119
|
rehypePlugins = [...rehypePlugins, ...mdxOptions.rehypePlugins ?? []];
|
|
120
120
|
return rehypePlugins;
|
|
121
121
|
}
|
|
122
|
+
function markdownShouldExtendDefaultPlugins(config) {
|
|
123
|
+
return config.markdown.extendDefaultPlugins || config.markdown.remarkPlugins.length === 0 && config.markdown.rehypePlugins.length === 0;
|
|
124
|
+
}
|
|
122
125
|
function ignoreStringPlugins(plugins) {
|
|
123
126
|
let validPlugins = [];
|
|
124
127
|
let hasInvalidPlugin = false;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astrojs/mdx",
|
|
3
3
|
"description": "Use MDX within Astro",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@types/chai": "^4.3.1",
|
|
44
44
|
"@types/mocha": "^9.1.1",
|
|
45
45
|
"@types/yargs-parser": "^21.0.0",
|
|
46
|
-
"astro": "1.1.
|
|
46
|
+
"astro": "1.1.4",
|
|
47
47
|
"astro-scripts": "0.0.7",
|
|
48
48
|
"chai": "^4.3.6",
|
|
49
49
|
"linkedom": "^0.14.12",
|
package/src/utils.ts
CHANGED
|
@@ -127,7 +127,7 @@ export async function getRemarkPlugins(
|
|
|
127
127
|
default:
|
|
128
128
|
remarkPlugins = [
|
|
129
129
|
...remarkPlugins,
|
|
130
|
-
...(config
|
|
130
|
+
...(markdownShouldExtendDefaultPlugins(config) ? DEFAULT_REMARK_PLUGINS : []),
|
|
131
131
|
...ignoreStringPlugins(config.markdown.remarkPlugins ?? []),
|
|
132
132
|
];
|
|
133
133
|
break;
|
|
@@ -162,7 +162,7 @@ export function getRehypePlugins(
|
|
|
162
162
|
default:
|
|
163
163
|
rehypePlugins = [
|
|
164
164
|
...rehypePlugins,
|
|
165
|
-
...(config
|
|
165
|
+
...(markdownShouldExtendDefaultPlugins(config) ? DEFAULT_REHYPE_PLUGINS : []),
|
|
166
166
|
...ignoreStringPlugins(config.markdown.rehypePlugins ?? []),
|
|
167
167
|
];
|
|
168
168
|
break;
|
|
@@ -172,6 +172,13 @@ export function getRehypePlugins(
|
|
|
172
172
|
return rehypePlugins;
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
function markdownShouldExtendDefaultPlugins(config: AstroConfig): boolean {
|
|
176
|
+
return (
|
|
177
|
+
config.markdown.extendDefaultPlugins ||
|
|
178
|
+
(config.markdown.remarkPlugins.length === 0 && config.markdown.rehypePlugins.length === 0)
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
175
182
|
function ignoreStringPlugins(plugins: any[]) {
|
|
176
183
|
let validPlugins: PluggableList = [];
|
|
177
184
|
let hasInvalidPlugin = false;
|
package/test/mdx-plugins.test.js
CHANGED
|
@@ -24,6 +24,17 @@ describe('MDX plugins', () => {
|
|
|
24
24
|
expect(selectTocLink(document)).to.not.be.null;
|
|
25
25
|
});
|
|
26
26
|
|
|
27
|
+
it('Applies GFM by default', async () => {
|
|
28
|
+
const fixture = await buildFixture({
|
|
29
|
+
integrations: [mdx()],
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const html = await fixture.readFile(FILE);
|
|
33
|
+
const { document } = parseHTML(html);
|
|
34
|
+
|
|
35
|
+
expect(selectGfmLink(document)).to.not.be.null;
|
|
36
|
+
});
|
|
37
|
+
|
|
27
38
|
it('supports custom rehype plugins', async () => {
|
|
28
39
|
const fixture = await buildFixture({
|
|
29
40
|
integrations: [
|