facebook / docusaurus

Easy to maintain open source documentation websites.
https://docusaurus.io
MIT License
55.65k stars 8.34k forks source link

Admonitions with backticks elicit <mdxAdmonitionTitle /> warnings #8233

Closed SheetJSDev closed 1 year ago

SheetJSDev commented 1 year ago

Have you read the Contributing Guidelines on issues?

Prerequisites

Description

An admonition with backticks generates a warning e.g.

:::info Something `with` backticks

will elicit a warning

:::

Console warning:

Warning: The tag <mdxAdmonitionTitle> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.
    at mdxAdmonitionTitle
    at eval (webpack-internal:///./node_modules/@mdx-js/react/dist/esm.js:154:30)
    at div
    at div
...

It does display what you would expect:

docusaurus-backticks

Reproducible demo

No response

Steps to reproduce

Create a blank site (or use docusaurus.new)

Add the following to /docs/intro.md:

:::info Something `with` backticks

will elicit a warning

:::

Load the intro page

Expected behavior

No warning

Actual behavior

warning (see description)

Your environment

Affects docusaurus.new CSB site on 2022-10-20 19:52 EDT

Self-service

Djunnni commented 1 year ago

can i try this? I can't reproduce

SheetJSDev commented 1 year ago
cd /tmp
npx create-docusaurus@latest my-website classic
## create-docusaurus@2.1.0
cd my-website
cat <<EOF >> docs/intro.md

:::info Something \`with\` backticks

will elicit a warning

:::
EOF
npm start

Now open the web browser and navigate to http://localhost:3000/docs/intro . Inspecting the console reveals the warning:

docusaurus8233warning

(note: this warning does not show up when building the production site)

package.json uses the following dependencies:

{
  "@docusaurus/core": "2.1.0",
  "@docusaurus/preset-classic": "2.1.0",
  "@mdx-js/react": "^1.6.22",
  "clsx": "^1.2.1",
  "prism-react-renderer": "^1.3.5",
  "react": "^17.0.2",
  "react-dom": "^17.0.2"
}
Djunnni commented 1 year ago

thanks. i can try!

Djunnni commented 1 year ago

https://github.com/facebook/docusaurus/blob/e41133245ca4e6cee390da74ccfe305ccb2ddb25/packages/docusaurus-mdx-loader/src/remark/admonitions/index.ts#L141-L159 https://github.com/facebook/docusaurus/pull/7152#issuecomment-1145779682 Temporary workaround, because it's complex in MDX v1 to emit.

maybe they will migrate mdx 2.0 then update this later