kentcdodds / mdx-bundler

🦤 Give me MDX/TSX strings and I'll give you back a component you can render. Supports imports!
MIT License
1.78k stars 75 forks source link

Do not convert code-blocks inside a `<pre>` tag #148

Open AnweshGangula opened 2 years ago

AnweshGangula commented 2 years ago

What you did:

Created a basic mdx-bundler code to convert a md or mdx file to a web-page

What happened:

Code-block inside a <pre> tag is converted to HTML

Reproduction repository: https://stackblitz.com/edit/nextjs-2n34zo?file=package.json

Problem description:

When I have code-blocks inside a <pre /> tag, I expect them to be displayed as plain text - without converting the code-block into a <pre> tag with a <code> tag inside. Below is an example of a code-block inside a <pre> tag and its expected behavior (how GitHub renders it). But if you look at the output in the following stackblitz demo, you can use that this doesn't happen in that - even if we use remark-gfm

Example code-block inside <pre> tag:

  ```
  abc
  ```
Current Output Expected Output
Current Output of pre tag Expected output of pre tag
AnweshGangula commented 2 years ago

Note: I've also noticed the same issue in the MDXjs Playground, but the same issue was not seen with mdxjs v1.6.21 playgroung. So i'm guessing this is an issue with the updated version of MDXjs.

I have added the same question in stack overflow, but didn't get any response.