@astrojs/mdx 0.15.0-beta.0 → 0.15.0-beta.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 +41 -0
- package/README.md +3 -3
- package/dist/index.js +1 -0
- package/dist/plugins.js +4 -0
- package/package.json +4 -3
- package/src/index.ts +1 -0
- package/src/plugins.ts +4 -0
- package/test/fixtures/mdx-plugins/src/pages/with-plugins.mdx +2 -0
- package/test/mdx-plugins.test.js +35 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
1
|
+
[34m@astrojs/mdx:build: [0mcache hit, replaying output [2m60f6ddcdbc2ddb72[0m
|
|
2
|
+
[34m@astrojs/mdx:build: [0m
|
|
3
|
+
[34m@astrojs/mdx:build: [0m> @astrojs/mdx@0.15.0-beta.1 build /home/runner/work/astro/astro/packages/integrations/mdx
|
|
4
|
+
[34m@astrojs/mdx:build: [0m> astro-scripts build "src/**/*.ts" && tsc
|
|
5
|
+
[34m@astrojs/mdx:build: [0m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,46 @@
|
|
|
1
1
|
# @astrojs/mdx
|
|
2
2
|
|
|
3
|
+
## 0.15.0-beta.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#5769](https://github.com/withastro/astro/pull/5769) [`93e633922`](https://github.com/withastro/astro/commit/93e633922c2e449df3bb2357b3683af1d3c0e07b) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Introduce a `smartypants` flag to opt-out of Astro's default SmartyPants plugin.
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
{
|
|
11
|
+
markdown: {
|
|
12
|
+
smartypants: false,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
#### Migration
|
|
18
|
+
|
|
19
|
+
You may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the `extendDefaultPlugins` option. This has now been split into 2 flags to disable each plugin individually:
|
|
20
|
+
|
|
21
|
+
- `markdown.gfm` to disable GitHub-Flavored Markdown
|
|
22
|
+
- `markdown.smartypants` to disable SmartyPants
|
|
23
|
+
|
|
24
|
+
```diff
|
|
25
|
+
// astro.config.mjs
|
|
26
|
+
import { defineConfig } from 'astro/config';
|
|
27
|
+
|
|
28
|
+
export default defineConfig({
|
|
29
|
+
markdown: {
|
|
30
|
+
- extendDefaultPlugins: false,
|
|
31
|
+
+ smartypants: false,
|
|
32
|
+
+ gfm: false,
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- [#5741](https://github.com/withastro/astro/pull/5741) [`000d3e694`](https://github.com/withastro/astro/commit/000d3e6940839c2aebba1984e6fb3b133cec6749) Thanks [@delucis](https://github.com/delucis)! - Fix broken links in README
|
|
40
|
+
|
|
41
|
+
- Updated dependencies [[`93e633922`](https://github.com/withastro/astro/commit/93e633922c2e449df3bb2357b3683af1d3c0e07b)]:
|
|
42
|
+
- @astrojs/markdown-remark@2.0.0-beta.1
|
|
43
|
+
|
|
3
44
|
## 0.15.0-beta.0
|
|
4
45
|
|
|
5
46
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -66,7 +66,7 @@ export default defineConfig({
|
|
|
66
66
|
|
|
67
67
|
## Usage
|
|
68
68
|
|
|
69
|
-
With the Astro MDX integration, you can [add MDX pages to your project](/en/guides/markdown-content/#markdown-and-mdx-pages) by adding `.mdx` files within your `src/pages/` directory. You can also [import `.mdx` files](https://docs.astro.build/en/guides/markdown-content/#importing-markdown) into `.astro` files.
|
|
69
|
+
With the Astro MDX integration, you can [add MDX pages to your project](https://docs.astro.build/en/guides/markdown-content/#markdown-and-mdx-pages) by adding `.mdx` files within your `src/pages/` directory. You can also [import `.mdx` files](https://docs.astro.build/en/guides/markdown-content/#importing-markdown) into `.astro` files.
|
|
70
70
|
|
|
71
71
|
Astro's MDX integration adds extra features to standard MDX, including Markdown-style frontmatter. This allows you to use most of Astro's built-in Markdown features like a [special frontmatter `layout` property](https://docs.astro.build/en/guides/markdown-content/#frontmatter-layout) and a [property for marking a page as a draft](https://docs.astro.build/en/guides/markdown-content/#draft-pages).
|
|
72
72
|
|
|
@@ -198,6 +198,6 @@ This package is maintained by Astro's Core team. You're welcome to submit an iss
|
|
|
198
198
|
|
|
199
199
|
See [CHANGELOG.md](https://github.com/withastro/astro/tree/main/packages/integrations/mdx/CHANGELOG.md) for a history of changes to this integration.
|
|
200
200
|
|
|
201
|
-
[astro-integration]: /en/guides/integrations-guide/
|
|
201
|
+
[astro-integration]: https://docs.astro.build/en/guides/integrations-guide/
|
|
202
202
|
|
|
203
|
-
[astro-ui-frameworks]: /en/core-concepts/framework-components/#using-framework-components
|
|
203
|
+
[astro-ui-frameworks]: https://docs.astro.build/en/core-concepts/framework-components/#using-framework-components
|
package/dist/index.js
CHANGED
|
@@ -144,6 +144,7 @@ function applyDefaultOptions({
|
|
|
144
144
|
recmaPlugins: options.recmaPlugins ?? defaults.recmaPlugins,
|
|
145
145
|
remarkRehype: options.remarkRehype ?? defaults.remarkRehype,
|
|
146
146
|
gfm: options.gfm ?? defaults.gfm,
|
|
147
|
+
smartypants: options.smartypants ?? defaults.smartypants,
|
|
147
148
|
remarkPlugins: options.remarkPlugins ?? defaults.remarkPlugins,
|
|
148
149
|
rehypePlugins: options.rehypePlugins ?? defaults.rehypePlugins,
|
|
149
150
|
shikiConfig: options.shikiConfig ?? defaults.shikiConfig
|
package/dist/plugins.js
CHANGED
|
@@ -9,6 +9,7 @@ import { bold, yellow } from "kleur/colors";
|
|
|
9
9
|
import { pathToFileURL } from "node:url";
|
|
10
10
|
import rehypeRaw from "rehype-raw";
|
|
11
11
|
import remarkGfm from "remark-gfm";
|
|
12
|
+
import remarkSmartypants from "remark-smartypants";
|
|
12
13
|
import { visit } from "unist-util-visit";
|
|
13
14
|
import { rehypeInjectHeadingsExport } from "./rehype-collect-headings.js";
|
|
14
15
|
import rehypeMetaString from "./rehype-meta-string.js";
|
|
@@ -122,6 +123,9 @@ async function getRemarkPlugins(mdxOptions, config) {
|
|
|
122
123
|
if (mdxOptions.gfm) {
|
|
123
124
|
remarkPlugins.push(remarkGfm);
|
|
124
125
|
}
|
|
126
|
+
if (mdxOptions.smartypants) {
|
|
127
|
+
remarkPlugins.push(remarkSmartypants);
|
|
128
|
+
}
|
|
125
129
|
remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];
|
|
126
130
|
if (config.experimental.contentCollections) {
|
|
127
131
|
remarkPlugins.push(toRemarkContentRelImageError(config));
|
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.15.0-beta.
|
|
4
|
+
"version": "0.15.0-beta.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"author": "withastro",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"./package.json": "./package.json"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@astrojs/markdown-remark": "^2.0.0-beta.
|
|
26
|
+
"@astrojs/markdown-remark": "^2.0.0-beta.1",
|
|
27
27
|
"@astrojs/prism": "^1.0.2",
|
|
28
28
|
"@mdx-js/mdx": "^2.1.2",
|
|
29
29
|
"@mdx-js/rollup": "^2.1.1",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"rehype-raw": "^6.1.1",
|
|
37
37
|
"remark-frontmatter": "^4.0.1",
|
|
38
38
|
"remark-gfm": "^3.0.1",
|
|
39
|
+
"remark-smartypants": "^2.0.0",
|
|
39
40
|
"shiki": "^0.11.1",
|
|
40
41
|
"unist-util-visit": "^4.1.0",
|
|
41
42
|
"vfile": "^5.3.2"
|
|
@@ -47,7 +48,7 @@
|
|
|
47
48
|
"@types/mdast": "^3.0.10",
|
|
48
49
|
"@types/mocha": "^9.1.1",
|
|
49
50
|
"@types/yargs-parser": "^21.0.0",
|
|
50
|
-
"astro": "2.0.0-beta.
|
|
51
|
+
"astro": "2.0.0-beta.1",
|
|
51
52
|
"astro-scripts": "0.0.9",
|
|
52
53
|
"chai": "^4.3.6",
|
|
53
54
|
"cheerio": "^1.0.0-rc.11",
|
package/src/index.ts
CHANGED
|
@@ -186,6 +186,7 @@ function applyDefaultOptions({
|
|
|
186
186
|
recmaPlugins: options.recmaPlugins ?? defaults.recmaPlugins,
|
|
187
187
|
remarkRehype: options.remarkRehype ?? defaults.remarkRehype,
|
|
188
188
|
gfm: options.gfm ?? defaults.gfm,
|
|
189
|
+
smartypants: options.smartypants ?? defaults.smartypants,
|
|
189
190
|
remarkPlugins: options.remarkPlugins ?? defaults.remarkPlugins,
|
|
190
191
|
rehypePlugins: options.rehypePlugins ?? defaults.rehypePlugins,
|
|
191
192
|
shikiConfig: options.shikiConfig ?? defaults.shikiConfig,
|
package/src/plugins.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { Image } from 'mdast';
|
|
|
14
14
|
import { pathToFileURL } from 'node:url';
|
|
15
15
|
import rehypeRaw from 'rehype-raw';
|
|
16
16
|
import remarkGfm from 'remark-gfm';
|
|
17
|
+
import remarkSmartypants from 'remark-smartypants';
|
|
17
18
|
import { visit } from 'unist-util-visit';
|
|
18
19
|
import type { VFile } from 'vfile';
|
|
19
20
|
import { MdxOptions } from './index.js';
|
|
@@ -153,6 +154,9 @@ export async function getRemarkPlugins(
|
|
|
153
154
|
if (mdxOptions.gfm) {
|
|
154
155
|
remarkPlugins.push(remarkGfm);
|
|
155
156
|
}
|
|
157
|
+
if (mdxOptions.smartypants) {
|
|
158
|
+
remarkPlugins.push(remarkSmartypants);
|
|
159
|
+
}
|
|
156
160
|
|
|
157
161
|
remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];
|
|
158
162
|
|
package/test/mdx-plugins.test.js
CHANGED
|
@@ -36,6 +36,19 @@ describe('MDX plugins', () => {
|
|
|
36
36
|
expect(selectGfmLink(document)).to.not.be.null;
|
|
37
37
|
});
|
|
38
38
|
|
|
39
|
+
it('Applies SmartyPants by default', async () => {
|
|
40
|
+
const fixture = await buildFixture({
|
|
41
|
+
integrations: [mdx()],
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const html = await fixture.readFile(FILE);
|
|
45
|
+
const { document } = parseHTML(html);
|
|
46
|
+
|
|
47
|
+
const quote = selectSmartypantsQuote(document);
|
|
48
|
+
expect(quote).to.not.be.null;
|
|
49
|
+
expect(quote.textContent).to.contain('“Smartypants” is — awesome');
|
|
50
|
+
});
|
|
51
|
+
|
|
39
52
|
it('supports custom rehype plugins', async () => {
|
|
40
53
|
const fixture = await buildFixture({
|
|
41
54
|
integrations: [
|
|
@@ -88,6 +101,7 @@ describe('MDX plugins', () => {
|
|
|
88
101
|
markdown: {
|
|
89
102
|
remarkPlugins: [remarkToc],
|
|
90
103
|
gfm: false,
|
|
104
|
+
smartypants: false,
|
|
91
105
|
},
|
|
92
106
|
integrations: [
|
|
93
107
|
mdx({
|
|
@@ -129,6 +143,23 @@ describe('MDX plugins', () => {
|
|
|
129
143
|
expect(selectGfmLink(document), 'Respects `markdown.gfm` unexpectedly.').to.not.be.null;
|
|
130
144
|
}
|
|
131
145
|
});
|
|
146
|
+
|
|
147
|
+
it('Handles smartypants', async () => {
|
|
148
|
+
const html = await fixture.readFile(FILE);
|
|
149
|
+
const { document } = parseHTML(html);
|
|
150
|
+
|
|
151
|
+
const quote = selectSmartypantsQuote(document);
|
|
152
|
+
|
|
153
|
+
if (extendMarkdownConfig === true) {
|
|
154
|
+
expect(quote.textContent, 'Does not respect `markdown.smartypants` option.').to.contain(
|
|
155
|
+
'"Smartypants" is -- awesome'
|
|
156
|
+
);
|
|
157
|
+
} else {
|
|
158
|
+
expect(quote.textContent, 'Respects `markdown.smartypants` unexpectedly.').to.contain(
|
|
159
|
+
'“Smartypants” is — awesome'
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
132
163
|
});
|
|
133
164
|
}
|
|
134
165
|
|
|
@@ -202,6 +233,10 @@ function selectGfmLink(document) {
|
|
|
202
233
|
return document.querySelector('a[href="https://handle-me-gfm.com"]');
|
|
203
234
|
}
|
|
204
235
|
|
|
236
|
+
function selectSmartypantsQuote(document) {
|
|
237
|
+
return document.querySelector('blockquote');
|
|
238
|
+
}
|
|
239
|
+
|
|
205
240
|
function selectRemarkExample(document) {
|
|
206
241
|
return document.querySelector('div[data-remark-plugin-works]');
|
|
207
242
|
}
|