-
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
fix(gatsby-transformer-remark): fix plugin conflict causing escaped HTML in headings #20024
Conversation
packages/gatsby-transformer-remark/src/__tests__/__snapshots__/extend-node.js.snap
Outdated
Show resolved
Hide resolved
I just merged few other remark PRs that cause merge conflicts here - happy to resolve them if you want me to (don't want to push to your branch without asking first :) ) |
e811eb7
to
f305e22
Compare
I've taken feedback into account and rebased to the latest master. Feel free to squash these two commits when merging to produce a cleaner history. |
f305e22
to
618e41d
Compare
Hey - just wanted to bump this since it's close to getting off the first page of PRs and I know this is an incredibly active repo. I've made all requested changes as per code review and reduced the size of the diff. It's been freshly rebased to the latest master. |
* The `gatsby-remark-prismjs` plugin was causing HTML code to be escaped and rendered as text in TOC entries generated by `gatsby-transformer-remark`. It generated HTML nodes which the `mdast-util-toc` module flattened into text. This was fixed upstream in a major version bump. * Update the version of `mdast-util-toc` used in `gatsby-transformer-remark` to the latest version in order to fix the issue * Set `{ allowDangerousHTML: true }` on calls to `hastToHTML()` and `toHAST()` when building the TOC. This is required in order to properly render the embedded HTML nodes. * Bump `mdast-util-to-hast` to its latest version as well * Update one snapshot test that was very slightly broken as a result of this * Slight refactor of code in `on-node-create.js` to reduce nesting and clean up control flow * Add two snapshot tests to verify that the fix was successful
* This bump caused a small regression in one of the tests which was deemed unacceptable. This reverts it to its previous version and restores the original test behavior. * Revert the updated snapshot test as well * Undo refactoring changes in `extend-node-type.js` in order to produce a cleaner diff for the PR
618e41d
to
1302d3f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get this in. Thanks for research, fixes and tests!
Holy buckets, @Ameobea — we just merged your PR to Gatsby! 💪💜 Gatsby is built by awesome people like you. Let us say “thanks” in two ways:
If there’s anything we can do to help, please don’t hesitate to reach out to us: tweet at @gatsbyjs and we’ll come a-runnin’. Thanks again! |
Description
gatsby-remark-prismjs
plugin was causing HTML code to be escaped and rendered as text in TOC entries generated bygatsby-transformer-remark
. It generated HTML nodes which themdast-util-toc
module flattened into text. This was fixed upstream in a major version bump.mdast-util-toc
used ingatsby-transformer-remark
to the latest version in order to fix the issue{ allowDangerousHTML: true }
on calls tohastToHTML()
andtoHAST()
when building the TOC. This is required in order to properly render the embedded HTML nodes.mdast-util-to-hast
to its latest version as wellon-node-create.js
to reduce nesting and clean up control flowRelated Issues
Fixes #13608
Additional Info
This does not address updating the generated anchor link as mentioned here: #13608 (comment)
Ideally, another change would be applied to remove the HTML artifacts from the anchor link.