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

Admonitions in MDX "partials" are not rendered properly #10576

Open
6 of 7 tasks
cemerick opened this issue Oct 10, 2024 · 4 comments
Open
6 of 7 tasks

Admonitions in MDX "partials" are not rendered properly #10576

cemerick opened this issue Oct 10, 2024 · 4 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: markdown Related to Markdown parsing or syntax

Comments

@cemerick
Copy link

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

When using an MDX partial (e.g. _markdown-include.mdx) that contains an MDX admonition:

:::info[Broken admonition]

This admonition isn't rendered properly.

:::

import Admonition from '@theme/Admonition';

<Admonition type="info">
  <p>This admonition looks as expected.</p>
</Admonition>

The MDX-style admonition is not rendered properly (whereas the JSX one is).

Codesandbox URL below :-)

Reproducible demo

https://codesandbox.io/p/sandbox/cocky-jackson-ny6mjg

Steps to reproduce

  1. Put an MDX-formatted admonition in an MDX file
  2. Import that file as a "partial"
  3. Include the partial in some JSX page

Expected behavior

For the MDX-format admonition to appear with styling/icon/header as it would if the MDX file were visited directly.

Actual behavior

The body of admonition is shown plainly, and the markup usually associated with an admonition is basically missing. What does come out is an HTML transliteration of JSX admonitions:

<admonition title="..." type="..."> ...body... </admonition>

Your environment

No response

Self-service

  • I'd be willing to fix this bug myself.
@cemerick cemerick added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Oct 10, 2024
@hunxjunedo
Copy link

@slorber let me investigate and work on this, kindly assign.

@slorber
Copy link
Collaborator

slorber commented Oct 28, 2024

We don't assign issues here

If you have a solution to solve this bug, please submit a PR directly

I've checked the bug a few days ago and could reproduce. Didn't really understand why this happens, but it's definitively a bug to fix.

@slorber slorber removed the status: needs triage This issue has not been triaged by maintainers label Oct 28, 2024
@Josh-Cena
Copy link
Collaborator

The issue is that we use MDXComponents to map <admonition> to @theme/Admonition, but this mapping is absent for the fallback loader, I think.

@Josh-Cena Josh-Cena added the domain: markdown Related to Markdown parsing or syntax label Oct 28, 2024
@slorber
Copy link
Collaborator

slorber commented Oct 29, 2024

I don't think that's the problem, MDXProvider is applied at the top of the page so anything imported from it should benefit from the provider.

Also, the partial is in the pages folder so the same remark plugins should apply to both the page and the partial. The partial shouldn't use our fallback loader.

Will need to debug this to figure out what is happening exactly 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution domain: markdown Related to Markdown parsing or syntax
Projects
None yet
Development

No branches or pull requests

4 participants