@astrojs/markdown-remark 0.14.1 → 1.1.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.
@@ -1,5 +1,5 @@
1
- @astrojs/markdown-remark:build: cache hit, replaying output f2df71f430c1c421
1
+ @astrojs/markdown-remark:build: cache hit, replaying output 2767636b7aea5828
2
2
  @astrojs/markdown-remark:build: 
3
- @astrojs/markdown-remark:build: > @astrojs/markdown-remark@0.14.1 build /home/runner/work/astro/astro/packages/markdown/remark
3
+ @astrojs/markdown-remark:build: > @astrojs/markdown-remark@1.1.0 build /home/runner/work/astro/astro/packages/markdown/remark
4
4
  @astrojs/markdown-remark:build: > astro-scripts build "src/**/*.ts" && tsc -p tsconfig.json
5
5
  @astrojs/markdown-remark:build: 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # @astrojs/markdown-remark
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#4474](https://github.com/withastro/astro/pull/4474) [`ac0321824`](https://github.com/withastro/astro/commit/ac03218247763e4782824e220a384fd20ae6d769) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Add "extends" to markdown plugin config to preserve Astro defaults
8
+
9
+ * [#4138](https://github.com/withastro/astro/pull/4138) [`839097c84`](https://github.com/withastro/astro/commit/839097c84e830542c17c18d8337a88de8885c356) Thanks [@gtnbssn](https://github.com/gtnbssn)! - Makes remark-rehype options available in astro.config.mjs
10
+
11
+ ## 1.1.0-next.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#4474](https://github.com/withastro/astro/pull/4474) [`ac0321824`](https://github.com/withastro/astro/commit/ac03218247763e4782824e220a384fd20ae6d769) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Add "extends" to markdown plugin config to preserve Astro defaults
16
+
17
+ * [#4138](https://github.com/withastro/astro/pull/4138) [`839097c84`](https://github.com/withastro/astro/commit/839097c84e830542c17c18d8337a88de8885c356) Thanks [@gtnbssn](https://github.com/gtnbssn)! - Makes remark-rehype options available in astro.config.mjs
18
+
19
+ ## 1.0.0
20
+
21
+ ### Major Changes
22
+
23
+ - [`04ad44563`](https://github.com/withastro/astro/commit/04ad445632c67bdd60c1704e1e0dcbcaa27b9308) - > Astro v1.0 is out! Read the [official announcement post](https://astro.build/blog/astro-1/).
24
+
25
+ **No breaking changes**. This package is now officially stable and compatible with `astro@1.0.0`!
26
+
27
+ ### Patch Changes
28
+
29
+ - Updated dependencies [[`04ad44563`](https://github.com/withastro/astro/commit/04ad445632c67bdd60c1704e1e0dcbcaa27b9308)]:
30
+ - @astrojs/prism@1.0.0
31
+
3
32
  ## 0.14.1
4
33
 
5
34
  ### Patch Changes
package/dist/index.js CHANGED
@@ -29,15 +29,17 @@ async function renderMarkdown(content, opts) {
29
29
  shikiConfig = {},
30
30
  remarkPlugins = [],
31
31
  rehypePlugins = [],
32
+ remarkRehype = {},
33
+ extendDefaultPlugins = false,
32
34
  isAstroFlavoredMd = false
33
35
  } = opts;
34
36
  const input = new VFile({ value: content, path: fileURL });
35
37
  const scopedClassName = (_a = opts.$) == null ? void 0 : _a.scopedClassName;
36
38
  const { headings, rehypeCollectHeadings } = createCollectHeadings();
37
39
  let parser = unified().use(markdown).use(remarkInitializeAstroData).use(isAstroFlavoredMd ? [remarkMdxish, remarkMarkAndUnravel, remarkUnwrap, remarkEscape] : []);
38
- if (remarkPlugins.length === 0 && rehypePlugins.length === 0) {
39
- remarkPlugins = [...DEFAULT_REMARK_PLUGINS];
40
- rehypePlugins = [...DEFAULT_REHYPE_PLUGINS];
40
+ if (extendDefaultPlugins || remarkPlugins.length === 0 && rehypePlugins.length === 0) {
41
+ remarkPlugins = [...DEFAULT_REMARK_PLUGINS, ...remarkPlugins];
42
+ rehypePlugins = [...DEFAULT_REHYPE_PLUGINS, ...rehypePlugins];
41
43
  }
42
44
  const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
43
45
  const loadedRehypePlugins = await Promise.all(loadPlugins(rehypePlugins));
@@ -63,7 +65,8 @@ async function renderMarkdown(content, opts) {
63
65
  "mdxJsxFlowElement",
64
66
  "mdxJsxTextElement",
65
67
  "mdxTextExpression"
66
- ] : []
68
+ ] : [],
69
+ ...remarkRehype
67
70
  }
68
71
  ]
69
72
  ]);
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import type * as hast from 'hast';
2
2
  import type * as mdast from 'mdast';
3
+ import type { all as Handlers, one as Handler, Options as RemarkRehypeOptions } from 'remark-rehype';
3
4
  import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
4
5
  import type * as unified from 'unified';
5
6
  import type { VFile } from 'vfile';
@@ -8,6 +9,11 @@ export declare type RemarkPlugin<PluginParameters extends any[] = any[]> = unifi
8
9
  export declare type RemarkPlugins = (string | [string, any] | RemarkPlugin | [RemarkPlugin, any])[];
9
10
  export declare type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugin<PluginParameters, hast.Root>;
10
11
  export declare type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
12
+ export declare type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandler'> & {
13
+ handlers: typeof Handlers;
14
+ } & {
15
+ handler: typeof Handler;
16
+ };
11
17
  export interface ShikiConfig {
12
18
  langs?: ILanguageRegistration[];
13
19
  theme?: Theme | IThemeRegistration;
@@ -20,6 +26,8 @@ export interface AstroMarkdownOptions {
20
26
  shikiConfig?: ShikiConfig;
21
27
  remarkPlugins?: RemarkPlugins;
22
28
  rehypePlugins?: RehypePlugins;
29
+ remarkRehype?: RemarkRehype;
30
+ extendDefaultPlugins?: boolean;
23
31
  }
24
32
  export interface MarkdownRenderingOptions extends AstroMarkdownOptions {
25
33
  /** @internal */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrojs/markdown-remark",
3
- "version": "0.14.1",
3
+ "version": "1.1.0",
4
4
  "type": "module",
5
5
  "author": "withastro",
6
6
  "license": "MIT",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "@astrojs/micromark-extension-mdx-jsx": "^1.0.3",
20
- "@astrojs/prism": "^0.7.0",
20
+ "@astrojs/prism": "^1.0.0",
21
21
  "acorn": "^8.7.1",
22
22
  "acorn-jsx": "^5.3.2",
23
23
  "github-slugger": "^1.4.0",
@@ -45,7 +45,7 @@
45
45
  "@types/mdast": "^3.0.10",
46
46
  "@types/mocha": "^9.1.1",
47
47
  "@types/unist": "^2.0.6",
48
- "astro-scripts": "0.0.6",
48
+ "astro-scripts": "0.0.7",
49
49
  "chai": "^4.3.6",
50
50
  "micromark-util-types": "^1.0.2",
51
51
  "mocha": "^9.2.2"
package/src/index.ts CHANGED
@@ -38,6 +38,8 @@ export async function renderMarkdown(
38
38
  shikiConfig = {},
39
39
  remarkPlugins = [],
40
40
  rehypePlugins = [],
41
+ remarkRehype = {},
42
+ extendDefaultPlugins = false,
41
43
  isAstroFlavoredMd = false,
42
44
  } = opts;
43
45
  const input = new VFile({ value: content, path: fileURL });
@@ -49,9 +51,9 @@ export async function renderMarkdown(
49
51
  .use(remarkInitializeAstroData)
50
52
  .use(isAstroFlavoredMd ? [remarkMdxish, remarkMarkAndUnravel, remarkUnwrap, remarkEscape] : []);
51
53
 
52
- if (remarkPlugins.length === 0 && rehypePlugins.length === 0) {
53
- remarkPlugins = [...DEFAULT_REMARK_PLUGINS];
54
- rehypePlugins = [...DEFAULT_REHYPE_PLUGINS];
54
+ if (extendDefaultPlugins || (remarkPlugins.length === 0 && rehypePlugins.length === 0)) {
55
+ remarkPlugins = [...DEFAULT_REMARK_PLUGINS, ...remarkPlugins];
56
+ rehypePlugins = [...DEFAULT_REHYPE_PLUGINS, ...rehypePlugins];
55
57
  }
56
58
 
57
59
  const loadedRemarkPlugins = await Promise.all(loadPlugins(remarkPlugins));
@@ -85,6 +87,7 @@ export async function renderMarkdown(
85
87
  'mdxTextExpression',
86
88
  ]
87
89
  : [],
90
+ ...remarkRehype,
88
91
  },
89
92
  ],
90
93
  ]);
package/src/types.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import type * as hast from 'hast';
2
2
  import type * as mdast from 'mdast';
3
+ import type {
4
+ all as Handlers,
5
+ one as Handler,
6
+ Options as RemarkRehypeOptions,
7
+ } from 'remark-rehype';
3
8
  import type { ILanguageRegistration, IThemeRegistration, Theme } from 'shiki';
4
9
  import type * as unified from 'unified';
5
10
  import type { VFile } from 'vfile';
@@ -20,6 +25,10 @@ export type RehypePlugin<PluginParameters extends any[] = any[]> = unified.Plugi
20
25
 
21
26
  export type RehypePlugins = (string | [string, any] | RehypePlugin | [RehypePlugin, any])[];
22
27
 
28
+ export type RemarkRehype = Omit<RemarkRehypeOptions, 'handlers' | 'unknownHandler'> & {
29
+ handlers: typeof Handlers;
30
+ } & { handler: typeof Handler };
31
+
23
32
  export interface ShikiConfig {
24
33
  langs?: ILanguageRegistration[];
25
34
  theme?: Theme | IThemeRegistration;
@@ -33,6 +42,8 @@ export interface AstroMarkdownOptions {
33
42
  shikiConfig?: ShikiConfig;
34
43
  remarkPlugins?: RemarkPlugins;
35
44
  rehypePlugins?: RehypePlugins;
45
+ remarkRehype?: RemarkRehype;
46
+ extendDefaultPlugins?: boolean;
36
47
  }
37
48
 
38
49
  export interface MarkdownRenderingOptions extends AstroMarkdownOptions {