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

MDX render is printing wrapping HTML tag instead of rendering #33

Open
blue148 opened this issue Sep 2, 2022 · 8 comments
Open

MDX render is printing wrapping HTML tag instead of rendering #33

blue148 opened this issue Sep 2, 2022 · 8 comments

Comments

@blue148
Copy link

blue148 commented Sep 2, 2022

After installing the plugin and setting up the config, the output of the MDX file into HTML is "printing" the wrapping div tag as a string instead of rendering it as an HTML tag

gatsby-config.js

module.exports = {
  siteMetadata: {
    title: `Elevate Design System`,
    description: `Design System to support the Elevate Methodology`,
    author: `[Your Name]`,
    language: `en`,
  },
  plugins: [
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-styled-components`,
    `gatsby-plugin-dark-mode`,
    {
      resolve: `gatsby-plugin-mdx`,
        options:{
          gatsbyRemarkPlugins: [

          `gatsby-remark-autolink-headers`,
          {
            resolve: `gatsby-remark-table-of-contents`,
            options: {
              exclude: "Table of Contents",
              tight: true,
              ordered: false,
              fromHeading: 2,
              toHeading: 4,
              className: "table-of-contents"
            },
          },
          `gatsby-remark-prismjs`,
          ],
         
        },
        
    },
    
    {
      resolve: `gatsby-plugin-sass`,
      options: {
        implementation: require("sass"),
        additionalData: `@import "${__dirname}/src/styles/__colors.scss";`,
      },
    },
    {
      resolve: `gatsby-source-filesystem`,
      options: {
        name: `pages`,
        path: `${__dirname}/src/pages/`,
      },
    },
    {
      resolve: `gatsby-plugin-google-fonts`,
      options: {
        fonts: [
          `inter\:300, 300i,400,400i,600,600i,700` // you can also specify font weights and styles
        ],
        display: 'swap'
      }
    },
    {
      resolve: "gatsby-plugin-root-import",
      options: {
        data: path.join(__dirname, "src", "data"),
        foundations: path.join(__dirname,"src","components","foundation"),
        components: path.join(__dirname,"src","components"),
        styles: path.join(__dirname, "src","styles"),
      },
    },
  ],
};

MDX sample file

---
title: Typography
description: Typography Guidelines for an Elevate Experience
---

```toc
# This code block gets replaced with the TOC
exclude: Table of Contents
```

## Typography Usage

## Typography Fonts

## Typography Sizes

## Accessibility Considerations with Type 

Rendered Output code

<main class="Layout__StdMain-bqtKLr iqEzjp"><div tabindex="-1" id="gatsby-focus-wrapper" style="outline: none;"><h1>Typography</h1>

&lt;div className="table-of-contents"&gt;
<ul>
<li><a href="#typography-usage">Typography Usage</a></li>
<li><a href="#typography-fonts">Typography Fonts</a></li>
<li><a href="#typography-sizes">Typography Sizes</a></li>
<li><a href="#accessibility-considerations-with-type">Accessibility Considerations with Type</a></li>
</ul>
&lt;/div&gt;

<h2 id="typography-usage" style="position: relative;"><a href="#typography-usage" aria-label="typography usage permalink" class="anchor before"><div><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></div></a>Typography Usage</h2>
<h2 id="typography-fonts" style="position: relative;"><a href="#typography-fonts" aria-label="typography fonts permalink" class="anchor before"><div><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></div></a>Typography Fonts</h2>
<h2 id="typography-sizes" style="position: relative;"><a href="#typography-sizes" aria-label="typography sizes permalink" class="anchor before"><div><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></div></a>Typography Sizes</h2>
<h2 id="accessibility-considerations-with-type" style="position: relative;"><a href="#accessibility-considerations-with-type" aria-label="accessibility considerations with type permalink" class="anchor before"><div><svg aria-hidden="true" focusable="false" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></div></a>Accessibility Considerations with Type</h2></div><div id="gatsby-announcer" aria-live="assertive" aria-atomic="true" style="position: absolute; top: 0px; width: 1px; height: 1px; padding: 0px; overflow: hidden; clip: rect(0px, 0px, 0px, 0px); white-space: nowrap; border: 0px;"></div></main>

There's no way I can see to configure the type of HTML wrapper that I can see. Unsure why this would be outputting the tag as string instead of code

@angelo-martinez
Copy link

Same Issue, I started getting it when I updated to mdxv2

@christopher-besch
Copy link

I also have the same issue, after updating to gatsby-plugin-mdx v4 and mdxv2.

@lucastobrazil
Copy link

Same here

@lucastobrazil
Copy link

has anyone found any workarounds?

@angelo-martinez
Copy link

I had to build my own. Just made a custom component that I add in the markdown<TableOfContents tableOfContents={props.data.mdx.tableOfContents} /> and then I loop over the tableOfContents.items inside that component.

@lucastobrazil
Copy link

@signalwerk any thoughts on whether this is a bug or oils be addressed? Seems like basically mdx2 is not supported with the current version due to this...

@longkluong
Copy link

Having the same issue sadly.

@fgerschau
Copy link

I couldn't figure out how to fix the tests, but I published @ricale's patch as a new npm package to use in the meantime.

https://www.npmjs.com/package/gatsby-remark-table-of-contents-patch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants