CHANGELOG.md 77 KB

@astrojs/markdown-remark

4.2.1

Patch Changes

4.2.0

Minor Changes

Patch Changes

4.1.0

Minor Changes

See Shikiji's documentation for more details about creating your own custom transformers, and a list of common transformers you can add directly to your project.

4.0.1

Patch Changes

  • #9349 270c6cc27 Thanks @lilnasy! - Fixes an issue where this package could not be installed alongside Astro 4.0.

4.0.0

Major Changes

  • #9138 abf601233 Thanks @bluwy! - Updates the unified, remark, and rehype dependencies to latest. Make sure to update your custom remark and rehype plugins as well to be compatible with the latest versions.

Potentially breaking change: The default value of markdown.remarkRehype.footnoteBackLabel is changed from "Back to content" to "Back to reference 1". See the mdast-util-to-hast commit for more information.

  • #9182 c7953645e Thanks @bluwy! - Removes deprecated APIs. All Astro packages had been refactored to not use these APIs.

Patch Changes

4.0.0-beta.0

Major Changes

  • #9138 abf601233 Thanks @bluwy! - Updates the unified, remark, and rehype dependencies to latest. Make sure to update your custom remark and rehype plugins as well to be compatible with the latest versions.

Potentially breaking change: The default value of markdown.remarkRehype.footnoteBackLabel is changed from "Back to content" to "Back to reference 1". See the mdast-util-to-hast commit for more information.

  • #9182 c7953645e Thanks @bluwy! - Removes deprecated APIs. All Astro packages had been refactored to not use these APIs.

Patch Changes

3.5.0

Minor Changes

  • #9083 4537ecf0d Thanks @bluwy! - Exports createShikiHighlighter for low-level syntax highlighting usage

3.4.0

Minor Changes

  • #8903 c5010aad3 Thanks @horo-fox! - Adds experimental support for multiple shiki themes with the new markdown.shikiConfig.experimentalThemes option.

3.3.0

Minor Changes

  • #8502 c4270e476 Thanks @bluwy! - Updates the internal shiki syntax highlighter to shikiji, an ESM-focused alternative that simplifies bundling and maintenance.

There are no new options and no changes to how you author code blocks and syntax highlighting.

Potentially breaking change: While this refactor should be transparent for most projects, the transition to shikiji now produces a smaller HTML markup by attaching a fallback color style to the pre or code element, instead of to the line span directly. For example:

Before:

  <code class="astro-code" style="background-color: #24292e">
    <pre>
      <span class="line" style="color: #e1e4e8">my code</span>
    </pre>
  </code>

After:

  <code class="astro-code" style="background-color: #24292e; color: #e1e4e8">
    <pre>
      <span class="line">my code<span>
    </pre>
  </code>

This does not affect the colors as the span will inherit the color from the parent, but if you're relying on a specific HTML markup, please check your site carefully after upgrading to verify the styles.

Patch Changes

3.2.1

Patch Changes

3.2.0

Minor Changes

  • #8475 d93987824 Thanks @webpro! - feat(markdown): Add support for imageReference paths when collecting images

  • #8532 7522bb491 Thanks @bluwy! - Export createMarkdownProcessor and deprecate renderMarkdown API

Patch Changes

3.1.0

Minor Changes

Patch Changes

3.0.0

Major Changes

  • #8179 6011d52d3 Thanks @matthewp! - Astro 3.0 Release Candidate

  • #8169 e79e3779d Thanks @bluwy! - Remove pre-shiki v0.14 theme names for compatibility. Please rename to the new theme names to migrate:

    • material-darker -> material-theme-darker
    • material-default -> material-theme
    • material-lighter -> material-theme-lighter
    • material-ocean -> material-theme-ocean
    • material-palenight -> material-theme-palenight

Patch Changes

3.0.0-rc.1

Major Changes

  • #8179 6011d52d3 Thanks @matthewp! - Astro 3.0 Release Candidate

  • #8169 e79e3779d Thanks @bluwy! - Remove pre-shiki v0.14 theme names for compatibility. Please rename to the new theme names to migrate:

    • material-darker -> material-theme-darker
    • material-default -> material-theme
    • material-lighter -> material-theme-lighter
    • material-ocean -> material-theme-ocean
    • material-palenight -> material-theme-palenight

Patch Changes

3.0.0-beta.0

Patch Changes

2.2.1

Patch Changes

2.2.0

Minor Changes

  • #6932 49514e4ce Thanks @bluwy! - Upgrade shiki to v0.14.1. This updates the shiki theme colors and adds the theme name to the pre tag, e.g. <pre class="astro-code github-dark">.

Patch Changes

2.1.4

Patch Changes

2.1.3

Patch Changes

2.1.2

Patch Changes

2.1.1

Patch Changes

2.1.0

Minor Changes

This unlocks a few features:

  • A new built-in image component and JavaScript API to transform and optimize images.
  • Relative images with automatic optimization in Markdown.
  • Support for validating assets using content collections.
  • and more!

See Assets (Experimental) on our docs site for more information on how to use this feature!

Patch Changes

2.0.1

Patch Changes

2.0.0

Major Changes

  • #5687 e2019be6f Thanks @bholmesdev! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This means data.astro.frontmatter is now the complete Markdown or MDX document's frontmatter, rather than an empty object.

This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an imageSrc slug in your document frontmatter:

  export function remarkInjectSocialImagePlugin() {
    return function (tree, file) {
      const { frontmatter } = file.data.astro;
      frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname;
    };
  }

When using Content Collections, you can access this modified frontmatter using the remarkPluginFrontmatter property returned when rendering an entry.

Migration instructions

Plugin authors should now check for user frontmatter when applying defaults.

For example, say a remark plugin wants to apply a default title if none is present. Add a conditional to check if the property is present, and update if none exists:

  export function remarkInjectTitlePlugin() {
    return function (tree, file) {
      const { frontmatter } = file.data.astro;
  +    if (!frontmatter.title) {
        frontmatter.title = 'Default title';
  +    }
    }
  }

This differs from previous behavior, where a Markdown file's frontmatter would always override frontmatter injected via remark or reype.

  • #5785 16107b6a1 Thanks @delucis! - Drop support for legacy Astro-flavored Markdown

  • #5684 a9c292026 & #5769 93e633922 Thanks @bholmesdev! - Refine Markdown and MDX configuration options for ease-of-use.

    • Markdown

    • Replace the extendDefaultPlugins option with a gfm boolean and a smartypants boolean. These are enabled by default, and can be disabled to remove GitHub-Flavored Markdown and SmartyPants.

    • Ensure GitHub-Flavored Markdown and SmartyPants are applied whether or not custom remarkPlugins or rehypePlugins are configured. If you want to apply custom plugins and remove Astro's default plugins, manually set gfm: false and smartypants: false in your config.

    • Migrate extendDefaultPlugins to gfm and smartypants

    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:

    • markdown.gfm to disable GitHub-Flavored Markdown
    • markdown.smartypants to disable SmartyPants

      // astro.config.mjs
      import { defineConfig } from 'astro/config';
      
      export default defineConfig({
      markdown: {
      -   extendDefaultPlugins: false,
      +   smartypants: false,
      +   gfm: false,
      }
      });
      

    Additionally, applying remark and rehype plugins no longer disables gfm and smartypants. You will need to opt-out manually by setting gfm and smartypants to false.

    • MDX

    • Support all Markdown configuration options (except drafts) from your MDX integration config. This includes syntaxHighlighting and shikiConfig options to further customize the MDX renderer.

    • Simplify extendPlugins to an extendMarkdownConfig option. MDX options will default to their equivalent in your Markdown config. By setting extendMarkdownConfig to false, you can "eject" to set your own syntax highlighting, plugins, and more.

    • Migrate MDX's extendPlugins to extendMarkdownConfig

    You may have used the extendPlugins option to manage plugin defaults in MDX. This has been replaced by 3 flags:

    • extendMarkdownConfig (true by default) to toggle Markdown config inheritance. This replaces the extendPlugins: 'markdown' option.
    • gfm (true by default) and smartypants (true by default) to toggle GitHub-Flavored Markdown and SmartyPants in MDX. This replaces the extendPlugins: 'defaults' option.
  • #5825 52209ca2a Thanks @bholmesdev! - Baseline the experimental contentCollections flag. You're free to remove this from your astro config!

    import { defineConfig } from 'astro/config';
    
    export default defineConfig({
    - experimental: { contentCollections: true }
    })
    
    
  • #5806 7572f7402 Thanks @matthewp! - Make astro a peerDependency of integrations

This marks astro as a peerDependency of several packages that are already getting major version bumps. This is so we can more properly track the dependency between them and what version of Astro they are being used with.

Patch Changes

2.0.0-beta.2

See changes in 2.0.0-beta.2 ### Major Changes - [#5785](https://github.com/withastro/astro/pull/5785) [`16107b6a1`](https://github.com/withastro/astro/commit/16107b6a10) Thanks [@delucis](https://github.com/delucis)! - Drop support for legacy Astro-flavored Markdown - [#5825](https://github.com/withastro/astro/pull/5825) [`52209ca2a`](https://github.com/withastro/astro/commit/52209ca2ad) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Baseline the experimental `contentCollections` flag. You're free to remove this from your astro config! ```diff import { defineConfig } from 'astro/config'; export default defineConfig({ - experimental: { contentCollections: true } }) ``` - [#5806](https://github.com/withastro/astro/pull/5806) [`7572f7402`](https://github.com/withastro/astro/commit/7572f74022) Thanks [@matthewp](https://github.com/matthewp)! - Make astro a peerDependency of integrations This marks `astro` as a peerDependency of several packages that are already getting `major` version bumps. This is so we can more properly track the dependency between them and what version of Astro they are being used with. ### Patch Changes - [#5837](https://github.com/withastro/astro/pull/5837) [`12f65a4d5`](https://github.com/withastro/astro/commit/12f65a4d55) Thanks [@giuseppelt](https://github.com/giuseppelt)! - fix shiki css class replace logic - Updated dependencies [[`01f3f463b`](https://github.com/withastro/astro/commit/01f3f463bf), [`1f92d64ea`](https://github.com/withastro/astro/commit/1f92d64ea3), [`c2180746b`](https://github.com/withastro/astro/commit/c2180746b4), [`ae8a012a7`](https://github.com/withastro/astro/commit/ae8a012a7b), [`cf2de5422`](https://github.com/withastro/astro/commit/cf2de5422c), [`ec09bb664`](https://github.com/withastro/astro/commit/ec09bb6642), [`665a2c222`](https://github.com/withastro/astro/commit/665a2c2225), [`f7aa1ec25`](https://github.com/withastro/astro/commit/f7aa1ec25d), [`302e0ef8f`](https://github.com/withastro/astro/commit/302e0ef8f5), [`840412128`](https://github.com/withastro/astro/commit/840412128b), [`1f49cddf9`](https://github.com/withastro/astro/commit/1f49cddf9e), [`4a1cabfe6`](https://github.com/withastro/astro/commit/4a1cabfe6b), [`c4b0cb8bf`](https://github.com/withastro/astro/commit/c4b0cb8bf2), [`23dc9ea96`](https://github.com/withastro/astro/commit/23dc9ea96a), [`63a6ceb38`](https://github.com/withastro/astro/commit/63a6ceb38d), [`52209ca2a`](https://github.com/withastro/astro/commit/52209ca2ad), [`2303f9514`](https://github.com/withastro/astro/commit/2303f95142)]: - astro@2.0.0-beta.2 - @astrojs/prism@2.0.0-beta.0

2.0.0-beta.1

See changes in 2.0.0-beta.1 ### Minor Changes - [#5769](https://github.com/withastro/astro/pull/5769) [`93e633922`](https://github.com/withastro/astro/commit/93e633922c) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Introduce a `smartypants` flag to opt-out of Astro's default SmartyPants plugin. ```js { markdown: { smartypants: false, } } ``` #### Migration 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: - `markdown.gfm` to disable GitHub-Flavored Markdown - `markdown.smartypants` to disable SmartyPants ```diff // astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { - extendDefaultPlugins: false, + smartypants: false, + gfm: false, } }); ```

2.0.0-beta.0

See changes in 2.0.0-beta.0 ### Major Changes - [#5687](https://github.com/withastro/astro/pull/5687) [`e2019be6f`](https://github.com/withastro/astro/commit/e2019be6ff) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Give remark and rehype plugins access to user frontmatter via frontmatter injection. This means `data.astro.frontmatter` is now the _complete_ Markdown or MDX document's frontmatter, rather than an empty object. This allows plugin authors to modify existing frontmatter, or compute new properties based on other properties. For example, say you want to compute a full image URL based on an `imageSrc` slug in your document frontmatter: ```ts export function remarkInjectSocialImagePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; frontmatter.socialImageSrc = new URL(frontmatter.imageSrc, 'https://my-blog.com/').pathname; }; } ``` #### Content Collections - new `remarkPluginFrontmatter` property We have changed _inject_ frontmatter to _modify_ frontmatter in our docs to improve discoverability. This is based on support forum feedback, where "injection" is rarely the term used. To reflect this, the `injectedFrontmatter` property has been renamed to `remarkPluginFrontmatter`. This should clarify this plugin is still separate from the `data` export Content Collections expose today. #### Migration instructions Plugin authors should now **check for user frontmatter when applying defaults.** For example, say a remark plugin wants to apply a default `title` if none is present. Add a conditional to check if the property is present, and update if none exists: ```diff export function remarkInjectTitlePlugin() { return function (tree, file) { const { frontmatter } = file.data.astro; + if (!frontmatter.title) { frontmatter.title = 'Default title'; + } } } ``` This differs from previous behavior, where a Markdown file's frontmatter would _always_ override frontmatter injected via remark or reype. - [#5684](https://github.com/withastro/astro/pull/5684) [`a9c292026`](https://github.com/withastro/astro/commit/a9c2920264) Thanks [@bholmesdev](https://github.com/bholmesdev)! - Refine Markdown and MDX configuration options for ease-of-use. #### Markdown - **Remove `remark-smartypants`** from Astro's default Markdown plugins. - **Replace the `extendDefaultPlugins` option** with a simplified `gfm` boolean. This is enabled by default, and can be disabled to remove GitHub-Flavored Markdown. - Ensure GitHub-Flavored Markdown is applied whether or not custom `remarkPlugins` or `rehypePlugins` are configured. If you want to apply custom plugins _and_ remove GFM, manually set `gfm: false` in your config. #### MDX - Support _all_ Markdown configuration options (except `drafts`) from your MDX integration config. This includes `syntaxHighlighting` and `shikiConfig` options to further customize the MDX renderer. - Simplify `extendDefaults` to an `extendMarkdownConfig` option. MDX options will default to their equivalent in your Markdown config. By setting `extendMarkdownConfig` to false, you can "eject" to set your own syntax highlighting, plugins, and more. #### Migration To preserve your existing Markdown and MDX setup, you may need some configuration changes: ##### Smartypants manual installation [Smartypants](https://github.com/silvenon/remark-smartypants) has been removed from Astro's default setup. If you rely on this plugin, [install `remark-smartypants`](https://github.com/silvenon/remark-smartypants#installing) and apply to your `astro.config.*`: ```diff // astro.config.mjs import { defineConfig } from 'astro/config'; + import smartypants from 'remark-smartypants'; export default defineConfig({ markdown: { + remarkPlugins: [smartypants], } }); ``` ##### Migrate `extendDefaultPlugins` to `gfm` You may have disabled Astro's built-in plugins (GitHub-Flavored Markdown and Smartypants) with the `extendDefaultPlugins` option. Since Smartypants has been removed, this has been renamed to `gfm`. ```diff // astro.config.mjs import { defineConfig } from 'astro/config'; export default defineConfig({ markdown: { - extendDefaultPlugins: false, + gfm: false, } }); ``` Additionally, applying remark and rehype plugins **no longer disables** `gfm`. You will need to opt-out manually by setting `gfm` to `false`. ##### Migrate MDX's `extendPlugins` to `extendMarkdownConfig` You may have used the `extendPlugins` option to manage plugin defaults in MDX. This has been replaced by 2 flags: - `extendMarkdownConfig` (`true` by default) to toggle Markdown config inheritance. This replaces the `extendPlugins: 'markdown'` option. - `gfm` (`true` by default) to toggle GitHub-Flavored Markdown in MDX. This replaces the `extendPlugins: 'defaults'` option.

1.2.0

Minor Changes

The rehypeHeadingIds plugin injects IDs for all headings in a Markdown document and can now also handle MDX inputs if needed. You can import and use this plugin if you need heading IDs to be injected before other rehype plugins run.

Patch Changes

1.1.3

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

1.1.0-next.0

Minor Changes

1.0.0

Major Changes

No breaking changes. This package is now officially stable and compatible with astro@1.0.0!

Patch Changes

0.14.1

Patch Changes

0.14.0

Minor Changes

  • #4114 64432bcb8 Thanks @Princesseuh! - Refactor @astrojs/mdx and @astrojs/markdown-remark to use @astrojs/prism instead of duplicating the code

Patch Changes

0.13.0

Minor Changes

For long term support, migrate to the @astrojs/mdx integration for MDX support (including .mdx pages!).

Not ready to migrate to MDX? Add the legacy flag to your Astro config to re-enable the previous Markdown support.

  // https://astro.build/config
  export default defineConfig({
    legacy: {
      astroFlavoredMarkdown: true,
    },
  });

Patch Changes

  • #4008 399d7e269 Thanks @bholmesdev! - Avoid parsing JSX, components, and Astro islands when using "plain" md mode. This brings markdown.mode: 'md' in-line with our docs description.

0.12.0

Minor Changes

Patch Changes

0.11.7

Patch Changes

0.11.6

Patch Changes

0.11.5

Patch Changes

0.11.4

Patch Changes

0.11.3

Patch Changes

0.11.2

Patch Changes

0.11.1

Patch Changes

0.11.0

Minor Changes

Patch Changes

0.10.2

Patch Changes

0.10.1

Patch Changes

0.10.0

Minor Changes

  • #3410 cfae9760 Thanks @natemoo-re! - Significantally more stable behavior for "Markdown + Components" usage, which now handles component serialization much more similarly to MDX. Also supports switching between Components and Markdown without extra newlines, removes wrapping <p> tags from standalone components, and improves JSX expression handling.

0.9.4

Patch Changes

0.9.3

Patch Changes

  • #3234 de123b28 Thanks @JuanM04! - Removed rehype-slug in favor of our own implementation. The behavior of the slugging should remain the same

  • #3234 de123b28 Thanks @JuanM04! - Moved some type from astro to @astrojs/markdown-remark

0.9.2

Patch Changes

0.9.1

Patch Changes

0.9.0

Minor Changes

  • 53162534 Thanks @FredKSchott! - - Removed renderMarkdownWithFrontmatter because it wasn't being used
    • All options of renderMarkdown are now required — see the exported interface AstroMarkdownOptions
    • New types: RemarkPlugin, RehypePlugin and ShikiConfig

0.8.2

Patch Changes

0.8.1

Patch Changes

0.8.0

Minor Changes

0.7.0

Minor Changes

  • #2824 0a3d3e51 Thanks @bholmesdev! - Change shiki to our default markdown syntax highlighter. This includes updates to all relevant starter projects that used Prism-specific styles.

Patch Changes

0.7.0-next.1

Patch Changes

0.7.0-next.0

Minor Changes

  • #2824 0a3d3e51 Thanks @bholmesdev! - Change shiki to our default markdown syntax highlighter. This includes updates to all relevant starter projects that used Prism-specific styles.

0.6.4

Patch Changes

0.6.3

Patch Changes

0.6.2

Patch Changes

0.6.1

Patch Changes

0.6.1-next.2

Patch Changes

0.6.1-next.1

Patch Changes

0.6.1-next.0

Patch Changes

0.6.0

Minor Changes

Patch Changes

0.5.0

Minor Changes

  • 679d4395: - Upgraded dependencies
    • Replaced remark-slug with rehype-slug because it was deprecated
    • Replaced @silvenon/remark-smartypants with remark-smartypants because its name was changed
    • Disable all built-in plugins when custom remark and/or rehype plugins are added
    • Removed remark-footnotes because remark-gfm now supports footnotes
    • Re-added remark-smartypants and rehype-slug to the default plugins list

0.4.0

Minor Changes

Patch Changes

0.4.0-next.2

Patch Changes

0.4.0-next.1

Patch Changes

  • 7eaabbb0: Fix bug where code blocks would not be escaped properly

0.4.0-next.0

Minor Changes

  • d84bfe71: Adds prism support within the Markdown plugin.

Patch Changes

0.3.1

Patch Changes

  • b03f8771: Fix parsing of an empty <pre></pre> tag in markdown files, which expected the pre tag to have a child
  • b03f8771: Fix the importing of unified Plugin and UnifiedPlugin types

0.3.0

Minor Changes

  • 397d8f3d: Upgrade @astrojs/markdown-support dependencies. The remark-rehype@9 upgrade enables accessible footnotes with remark-footnotes.

0.2.4

Patch Changes

0.2.3

Patch Changes

  • 460e625: Move remaining missing dependencies

0.2.2

Patch Changes

  • 7015356: Move rehype-raw to a dependency

0.2.1

Patch Changes

  • 70f0a09: Added remark-slug to default plugins

0.2.0

Minor Changes

For example, the astro.config.mjs could be updated to include the following. Read the Markdown documentation for more information.

Note Enabling custom remarkPlugins or rehypePlugins removes Astro's built-in support for GitHub-flavored Markdown support, Footnotes syntax, Smartypants. You must explicitly add these plugins to your astro.config.mjs file, if desired.

  export default {
    markdownOptions: {
      remarkPlugins: ['remark-slug', ['remark-autolink-headings', { behavior: 'prepend' }]],
      rehypePlugins: ['rehype-slug', ['rehype-autolink-headings', { behavior: 'prepend' }]],
    },
  };

Patch Changes

0.1.2

Patch Changes

  • f9f2da4: Add repository key to all package.json

0.1.1

Patch Changes

  • 50e6f49: Fixes issues with using astro via the create script