@astrojs/mdx 0.15.0-beta.0 → 1.0.0-beta.2

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.
@@ -1,5 +1,5 @@
1
- @astrojs/mdx:build: cache hit, replaying output a2df0a02dde16921
2
- @astrojs/mdx:build: 
3
- @astrojs/mdx:build: > @astrojs/mdx@0.15.0-beta.0 build /home/runner/work/astro/astro/packages/integrations/mdx
4
- @astrojs/mdx:build: > astro-scripts build "src/**/*.ts" && tsc
5
- @astrojs/mdx:build: 
1
+ @astrojs/mdx:build: cache hit, replaying output e3662492a73790a4
2
+ @astrojs/mdx:build: 
3
+ @astrojs/mdx:build: > @astrojs/mdx@1.0.0-beta.2 build /home/runner/work/astro/astro/packages/integrations/mdx
4
+ @astrojs/mdx:build: > astro-scripts build "src/**/*.ts" && tsc
5
+ @astrojs/mdx:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,72 @@
1
1
  # @astrojs/mdx
2
2
 
3
+ ## 1.0.0-beta.2
4
+
5
+ ### Major Changes
6
+
7
+ - [#5825](https://github.com/withastro/astro/pull/5825) [`52209ca2a`](https://github.com/withastro/astro/commit/52209ca2ad72a30854947dcb3a90ab4db0ac0a6f) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Baseline the experimental `contentCollections` flag. You're free to remove this from your astro config!
8
+
9
+ ```diff
10
+ import { defineConfig } from 'astro/config';
11
+
12
+ export default defineConfig({
13
+ - experimental: { contentCollections: true }
14
+ })
15
+ ```
16
+
17
+ ### Minor Changes
18
+
19
+ - [#5782](https://github.com/withastro/astro/pull/5782) [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Remove support for Node 14. Minimum supported Node version is now >=16.12.0
20
+
21
+ ### Patch Changes
22
+
23
+ - [#5837](https://github.com/withastro/astro/pull/5837) [`12f65a4d5`](https://github.com/withastro/astro/commit/12f65a4d55e3fd2993c2f67b18794dd536280c69) Thanks [@giuseppelt](https://github.com/giuseppelt)! - fix shiki css class replace logic
24
+
25
+ - Updated dependencies [[`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea35c03fec43aff64eaf704dc5a9eb30a), [`12f65a4d5`](https://github.com/withastro/astro/commit/12f65a4d55e3fd2993c2f67b18794dd536280c69), [`16107b6a1`](https://github.com/withastro/astro/commit/16107b6a10514ef1b563e585ec9add4b14f42b94), [`52209ca2a`](https://github.com/withastro/astro/commit/52209ca2ad72a30854947dcb3a90ab4db0ac0a6f), [`7572f7402`](https://github.com/withastro/astro/commit/7572f7402238da37de748be58d678fedaf863b53)]:
26
+ - @astrojs/prism@2.0.0-beta.0
27
+ - @astrojs/markdown-remark@2.0.0-beta.2
28
+
29
+ ## 0.15.0-beta.1
30
+
31
+ ### Minor Changes
32
+
33
+ - [#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.
34
+
35
+ ```js
36
+ {
37
+ markdown: {
38
+ smartypants: false,
39
+ }
40
+ }
41
+ ```
42
+
43
+ #### Migration
44
+
45
+ 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:
46
+
47
+ - `markdown.gfm` to disable GitHub-Flavored Markdown
48
+ - `markdown.smartypants` to disable SmartyPants
49
+
50
+ ```diff
51
+ // astro.config.mjs
52
+ import { defineConfig } from 'astro/config';
53
+
54
+ export default defineConfig({
55
+ markdown: {
56
+ - extendDefaultPlugins: false,
57
+ + smartypants: false,
58
+ + gfm: false,
59
+ }
60
+ });
61
+ ```
62
+
63
+ ### Patch Changes
64
+
65
+ - [#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
66
+
67
+ - Updated dependencies [[`93e633922`](https://github.com/withastro/astro/commit/93e633922c2e449df3bb2357b3683af1d3c0e07b)]:
68
+ - @astrojs/markdown-remark@2.0.0-beta.1
69
+
3
70
  ## 0.15.0-beta.0
4
71
 
5
72
  ### 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,10 +123,11 @@ async function getRemarkPlugins(mdxOptions, config) {
122
123
  if (mdxOptions.gfm) {
123
124
  remarkPlugins.push(remarkGfm);
124
125
  }
125
- remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];
126
- if (config.experimental.contentCollections) {
127
- remarkPlugins.push(toRemarkContentRelImageError(config));
126
+ if (mdxOptions.smartypants) {
127
+ remarkPlugins.push(remarkSmartypants);
128
128
  }
129
+ remarkPlugins = [...remarkPlugins, ...ignoreStringPlugins(mdxOptions.remarkPlugins)];
130
+ remarkPlugins.push(toRemarkContentRelImageError(config));
129
131
  return remarkPlugins;
130
132
  }
131
133
  function getRehypePlugins(mdxOptions) {
@@ -42,7 +42,7 @@ const remarkShiki = async ({ langs = [], theme = "github-dark", wrap = false })
42
42
  lang = "plaintext";
43
43
  }
44
44
  let html = highlighter.codeToHtml(node.value, { lang });
45
- html = html.replace('<pre class="shiki"', `<pre class="astro-code"`);
45
+ html = html.replace(/<pre class="(.*?)shiki(.*?)"/, `<pre class="$1astro-code$2"`);
46
46
  if (node.lang === "diff") {
47
47
  html = html.replace(
48
48
  /<span class="line"><span style="(.*?)">([\+|\-])/g,
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.0",
4
+ "version": "1.0.0-beta.2",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
7
7
  "author": "withastro",
@@ -23,8 +23,8 @@
23
23
  "./package.json": "./package.json"
24
24
  },
25
25
  "dependencies": {
26
- "@astrojs/markdown-remark": "^2.0.0-beta.0",
27
- "@astrojs/prism": "^1.0.2",
26
+ "@astrojs/markdown-remark": "^2.0.0-beta.2",
27
+ "@astrojs/prism": "^2.0.0-beta.0",
28
28
  "@mdx-js/mdx": "^2.1.2",
29
29
  "@mdx-js/rollup": "^2.1.1",
30
30
  "acorn": "^8.8.0",
@@ -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,8 +48,8 @@
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.0",
51
- "astro-scripts": "0.0.9",
51
+ "astro": "2.0.0-beta.2",
52
+ "astro-scripts": "0.0.10-beta.0",
52
53
  "chai": "^4.3.6",
53
54
  "cheerio": "^1.0.0-rc.11",
54
55
  "linkedom": "^0.14.12",
@@ -63,7 +64,7 @@
63
64
  "vite": "^4.0.3"
64
65
  },
65
66
  "engines": {
66
- "node": "^14.18.0 || >=16.12.0"
67
+ "node": ">=16.12.0"
67
68
  },
68
69
  "scripts": {
69
70
  "build": "astro-scripts build \"src/**/*.ts\" && tsc",
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,13 +154,15 @@ 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
 
159
163
  // Apply last in case user plugins resolve relative image paths
160
- if (config.experimental.contentCollections) {
161
- remarkPlugins.push(toRemarkContentRelImageError(config));
162
- }
164
+ remarkPlugins.push(toRemarkContentRelImageError(config));
165
+
163
166
  return remarkPlugins;
164
167
  }
165
168
 
@@ -66,7 +66,7 @@ const remarkShiki = async ({ langs = [], theme = 'github-dark', wrap = false }:
66
66
  // &lt;span class=&quot;line&quot;
67
67
 
68
68
  // Replace "shiki" class naming with "astro".
69
- html = html.replace('<pre class="shiki"', `<pre class="astro-code"`);
69
+ html = html.replace(/<pre class="(.*?)shiki(.*?)"/, `<pre class="$1astro-code$2"`);
70
70
  // Add "user-select: none;" for "+"/"-" diff symbols
71
71
  if (node.lang === 'diff') {
72
72
  html = html.replace(
@@ -21,3 +21,5 @@ Oh cool, more text!
21
21
  And section 2, with a hyperlink to check GFM is preserved: https://handle-me-gfm.com
22
22
 
23
23
  <div data-recma-plugin-works={recmaPluginWorking}></div>
24
+
25
+ > "Smartypants" is -- awesome
@@ -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
  }