-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[gatsby-plugin-mdx] Remark plugins using mutateSource seems to be ignored #23409
Comments
Real-world use case: Remark plugin for finding and replacing, something like https://github.com/angeloashmore/gatsby-remark-find-replace, but with support for markdown and HTML in replacing text, eg: {
COMPANY: "The Company" // Supported in mention plugin
NOTE: "This is a note with **markdown**" // Not Supported
TOP: "Go to <a href="#top" style=''>top</a>" // Not Supported
} |
Just to clarify - is this a recent break? Or was it working like this for a long time now? |
I don't think it ever worked |
@vladar @mathieudutour even though I don't use Gatsby for a long time, I agree with @mathieudutour that it probably never worked –– that commented out code is there from October 2018 Was not sure if this issue should be Feature request or Bug |
mdxにしたことで、 `:smile:`のような形式で絵文字が変換されなかった。 こちらを参考に解決。 ChristopherBiscardi/gatsby-mdx#118 (comment) また、新しいissueもあったので要チェック gatsbyjs/gatsby#23409
Hiya! This issue has gone quiet. Spooky quiet. 👻 We get a lot of issues, so we currently close issues after 30 days of inactivity. It’s been at least 20 days since the last update here. Thanks for being a part of the Gatsby community! 💪💜 |
Hey again! It’s been 30 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it. Thanks again for being part of the Gatsby community! 💪💜 |
@Strajk you ever find a solution to this? Thanks! |
Description
Remark plugins are able both to transform AST and mutate original source
Remark plugins in gatsby-plugin-mdx seem to ignore the
mutateSource
hook and only run AST transformation.(or more precisely, it ignores plugins without default export && doesn't check for
mutateSource
on plugins)• There seems to be some code prepared to handle this, but it's commented out
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-mdx/utils/gen-mdx.js#L22
(Commented out by @ChristopherBiscardi so tagging, sry if not appropriate)
• Filtering out seems to be done here
https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-mdx/utils/get-source-plugins-as-remark-plugins.js#L50
• There's an issue for this in old repo
ChristopherBiscardi/gatsby-mdx#118
The proposed workaround in the last comment is to rewrite the plugin to use AST transformation instead of
mutateSource
, so not a real solutionSteps to reproduce
https://github.com/Strajk/jungle/tree/master/gatsby-replace-md-with-md
There are two local plugins:
Project uses both
transformer-remark
&plugin-mdx
for easier reproducibility.Both are configured to use both plugins https://github.com/Strajk/jungle/blob/master/gatsby-replace-md-with-md/gatsby-config.js
There are two sample posts to test the functionality
Expected result
Both posts (md & mdx) should be transformed with both plugins.
Actual result
./plugins/remark-ast
pluginEnvironment
Gatsby 2.20.25 – Expand for all info
Tagging @mathieudutour and @vladar as I noticed they done some (maybe) similar work in #21188
(sry if not appropriate 🙏)
The text was updated successfully, but these errors were encountered: