-
-
Notifications
You must be signed in to change notification settings - Fork 579
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 nested aside title rendering issue #1703
Conversation
🦋 Changeset detectedLatest commit: a2f6925 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 latest updates on your projects. Learn more about Vercel for Git ↗︎
|
expect(labels).toMatchInlineSnapshot(` | ||
[ | ||
"Caution with a custom title", | ||
"Note", | ||
"Tip with a custom title", | ||
] | ||
`); |
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.
Even if the snapshot can be used to ensure custom titles are properly rendered, I added this small expectation to make it easier to glance at what the expected output is instead of having to read the snapshot file.
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.
Looks great! Thank you for the quick fix @HiDeoo 🙌
Let everyone go forth and populate their docs with dubious deeply nested asides!
* main: (111 commits) Fix various Expressive Code translation issues (withastro#1708) Fix nested aside title rendering issue (withastro#1703) I18n(pt-PT): Add resources pages (withastro#1678) Add SST Ion & Font Awesome to site showcase (withastro#1710) [ci] format Add SudoVanilla to showcase (withastro#1702) i18n(fr): Update `resources-showcase` (withastro#1697) [i18nIgnore] docs: update `starlight-links-validator` to version `0.7.1` (withastro#1696) [ci] format [ci] release (withastro#1688) [ci] format Update Russian translation (withastro#1616) [ci] format Adds `starlight` icon to Starlight (withastro#1698) Update Icons.ts with Farcaster Purple for SocialIcons (withastro#1622) Remove duplicate from showcase example in `contributing.md` (withastro#1692) i18n(zh-cn): Update `showcase.mdx` (withastro#1689) [ci] format i18n(zh-cn): Update configuration.mdx (withastro#1691) i18n(ko-KR): update `showcase.mdx` (withastro#1690) ...
* main: [ci] format [ci] release (withastro#1714) Fix various Expressive Code translation issues (withastro#1708) Fix nested aside title rendering issue (withastro#1703) I18n(pt-PT): Add resources pages (withastro#1678) Add SST Ion & Font Awesome to site showcase (withastro#1710)
What kind of changes does this PR include?
Description
This PR fixes an issue with nested asides using custom titles where nested custom titles would not be rendered and the outer most custom title would be the one of the inner most aside.
This behavior was caused by the assumption that
remark-directive
stores the custom title of a container in a paragraph node added to its children. To remove such node, the current code would useunist-util-remove
to remove this specific paragraph. However, this approach is incorrect asunist-util-remove
iterates recursively through all children of a node, which means that if a nested aside had a custom title, the paragraph node containing its custom title would be removed by the outer aside.The spec of
mdast-util-directive
is also a bit more precise about the structure of a container with a custom title. It states that:As the label would always be a paragraph added as the head of the content of a container, we can entirely remove the iteration step and directly remove the first child of a container if it is a paragraph with a
directiveLabel
field set totrue
.