docusaurus icon indicating copy to clipboard operation
docusaurus copied to clipboard

Admonitions in MDX "partials" are not rendered properly

Open cemerick opened this issue 4 months ago • 0 comments

Have you read the Contributing Guidelines on issues?

Prerequisites

  • [X] I'm using the latest version of Docusaurus.
  • [X] I have tried the npm run clear or yarn clear command.
  • [X] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • [X] I have tried creating a repro with https://new.docusaurus.io.
  • [X] 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 avatar Oct 10 '24 19:10 cemerick