Forwarding options to remarkPlugins/rehypePlugins can break them
See original GitHub issueSubject of the issue
Currently @mdx-js/mdx
forwards its options to every plugin in remarkPlugins
and rehypePlugins
, which can easily lead to some of them breaking. Is there a specific reason why we’re doing this? If it’s a behavior left over from something else, I can remove it.
Your environment
- Name and version of operating system: macOS 10.14.4
- Names and version of required packages: 1.0.18
- Version of node, npm, yarn, or names and versions of browser: yarn 1.16.0
Steps to reproduce
import mdx from '@mdx-js/mdx'
import detectFrontmatter from 'remark-frontmatter'
const content = `
---
title: Hello World!
---
`
mdx(content, {
remarkPlugins: [
detectFrontmatter,
],
})
Expected behaviour
remark-frontmatter shouldn’t be getting unexpected options.
Actual behaviour
Options from the mdx()
call get forwarded to remark-frontmatter, which thinks we’re passing the definition for detecting frontmatter, but the shape of the object doesn’t satisfy its criteria so it crashes.
Temporary workaround
Passing undefined
as an option to all plugins, which results in default, i.e. expected behavior.
mdx(content, {
remarkPlugins: [
[detectFrontmatter, undefined],
],
})
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Transforming Markdown with Remark & Rehype - ryanfiller.com
Writing custom plugins to give extra powers to Markdown syntax using the Unified ecosystem.
Read more >Improving My Next.js MDX Blog - Lee Robinson
MDX Plugins. mdx-bundler allows you to extend remark and rehype, providing external plugins to hook into the compilation process. Some plugins I ...
Read more >mdast-util-to-hast - npm
It turns HTML into markdown. The remark plugin remark-rehype wraps this utility to also turn markdown to HTML at a higher-level (easier) ...
Read more >markdown – CSS-Tricks
Mermaid goes well with Markdown because it presents itself as just another fenced code block, only using the mermaid language syntax set.
Read more >Rewriting my blog with Next.js - Dimitrios Lytras
I've been using Gatsby since v0, and it's perfect for my use case. ... I just don't like the GraphQL layer and its...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I suspect there is a teeny tiny extremely slim chance someone depends and we’d break something if we patch it up. If we do a major (or wait for one) the chance of someone being on
^1.0.0
and trying to use a plugin that breaks is much much much larger.I also think @silvenon has a good enough understanding of remark and MDX that he can figure out what happened rather easily, but I don’t think many other persons using MDX can figure out what’s failing, resulting in a pretty bad debugging experience.
Therefore I propose patching this up instead of a major release. We can add a note about this in releases though.
Released as https://github.com/mdx-js/mdx/releases/tag/v1.0.19