Skip to content
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 markdoc render code block in if tag #12930

Merged
merged 2 commits into from
Jan 9, 2025
Merged

Fix markdoc render code block in if tag #12930

merged 2 commits into from
Jan 9, 2025

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Jan 8, 2025

Changes

Fix #11656

The core of the issue is that sometimes Markdoc AST may return arrays within arrays (in node.children), e.g. in if tags, content within the if tag are grouped as an array. This PR handles that and refactors the rendering code slightly.

Testing

Added tests

Docs

n/a. bug fix

Copy link

changeset-bot bot commented Jan 8, 2025

🦋 Changeset detected

Latest commit: 6200182

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

@github-actions github-actions bot added the pkg: integration Related to any renderer integration (scope) label Jan 8, 2025
Comment on lines -38 to -41
export const ComponentNode = createComponent({
factory(result: any, { treeNode }: { treeNode: TreeNode }) {
if (treeNode.type === 'text') return render`${treeNode.content}`;

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might look like I'm doing a lot of change here, but I'm only extracting the factory function here out so I can call itself for arrays. Disabling whitespace in diff should make it easier to review.

Copy link
Member

@ematipico ematipico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Happy to merge once the CI is all green

@bluwy bluwy merged commit a20a4d7 into main Jan 9, 2025
14 checks passed
@bluwy bluwy deleted the markdoc-code-if branch January 9, 2025 14:57
@astrobot-houston astrobot-houston mentioned this pull request Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: integration Related to any renderer integration (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Markdoc shiki code does not render inside an if tag
2 participants