fix(markdown): don’t generate mdast html nodes#10104
fix(markdown): don’t generate mdast html nodes#10104ematipico merged 13 commits intowithastro:mainfrom
Conversation
`html` nodes from mdast are converted to `raw` hast nodes. These nodes are then not processed by proper rehype plugins. Typically if a remark plugin generates `html` nodes, this indicates it should have actually been a rehype plugin. This changes the remark plugins that generate `html` nodes into rehype nodes. These were `remarkPrism` and `remarkShiki`. Closes withastro#9909
🦋 Changeset detectedLatest commit: 06bd1e3 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The code looks good to me, but isn't this a breaking change as the order is changed, and code is transformed differently? Or do you foresee that it shouldn't break much? |
|
I see why this can be considered a breaking change. On the other hand, it only really breaks if people rely on the bad AST that Astro produced earlier. In that case I would say it breaks people’s workarounds. I don’t expect this to break people’s code, but I’m not sure how people are using this. I do know this fixes compatibility with |
Princesseuh
left a comment
There was a problem hiding this comment.
I have the same concerns as Bjorn, but I do think it's okay!
|
As middle ground, we could release these changes as |
Fine with me! We'll mention it in the article. |
|
Don't forget about this comment: #10104 (comment). Whatever you choose is fine, just make it explicit :) |
|
Marking as minor is fine by me too 👍 Let's release it in 4.5 then. |
|
Having both before user rehype plugins I think is important otherwise great change I know rehype mermaid has been requested |
65399f1 to
e2aa2f9
Compare
e2aa2f9 to
5ab2502
Compare
|
It would be great if we could craft a good changelog explaining the possible breaking change. @remcohaszing would you mind doing that? cc @bluwy might help, he has more context on the matter. |
|
Do you mean that as part of the changeset? |
|
Yeah sorry. That's what I meant |
This also includes some hints on what users could do to upgrade of they rely on these nodes.
They aren’t used anymore, but removing would be a breaking change.
bluwy
left a comment
There was a problem hiding this comment.
Thanks for following up with the requested changes! Appreciate the refactor and cleanup.
sarah11918
left a comment
There was a problem hiding this comment.
Thank you for this contribution @remcohaszing -- seems like this will ensure some greater compatibility, and we at Astro love our code samples!
I've made some small suggestions below because this is not only a change, but potentially a breaking change, and this changeset message is a great way to call attention to that and provide the most warning, guidance and support to people who might need to make a change because of this.
See what you think and correct to be accurate if I've lost any of the particular meaning by editing! 🙌
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
sarah11918
left a comment
There was a problem hiding this comment.
Docs is approving the changeset, as long as everyone else is happy with it!
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Changes
htmlnodes from mdast are converted torawhast nodes. These nodes are then not processed by proper rehype plugins. Typically if a remark plugin generateshtmlnodes, this indicates it should have actually been a rehype plugin.This changes the remark plugins that generate
htmlnodes into rehype nodes. These wereremarkPrismandremarkShiki.Testing
pnpm build -- --force pnpm testNo tests were added, because it mostly changes internals.
Docs
This affects a user’s behaviour by adding better compatibility with some existing remark / rehype plugins. E.g.
rehype-mermaidwill work. I don’t think a docs update is needed.Closes #9909