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

template literals #218

Closed
geddski opened this issue Aug 10, 2018 · 5 comments
Closed

template literals #218

geddski opened this issue Aug 10, 2018 · 5 comments
Labels
🐛 type/bug This is a problem

Comments

@geddski
Copy link

geddski commented Aug 10, 2018

MDX appears to be trying to parse template literals into MDX Tags, rather than pass the value through.

# Testing template literals

<TemplateLiteralTest 
  test={`
    thing1 {
      background: blue;
    }

    thing2 {
      background: blue;
    }
  `}
/>

MDX is transforming that into this:

<TemplateLiteralTest
  test={`
    thing1 {
      background: blue;
    }
<MDXTag name="pre" components={components}><MDXTag name="code" components={components} parentName="pre">{`thing2 {
  background: blue;
}
`}</MDXTag></MDXTag>
<MDXTag name="p" components={components}>{`  \`}
/>`}</MDXTag></MDXTag>

which leads to this error:

SyntaxError: unknown: Unexpected token, expected "}" (23:106)
    21 |       background: blue;
    22 |     }
  > 23 | <MDXTag name="pre" components={components}><MDXTag name="code" components={components} parentName="pre">{`thing2 {
       |                                                                                                           ^
    24 |   background: blue;
    25 | }
    26 | `}</MDXTag></MDXTag>

I'd expect MDX to interpolate and pass the template literal value through to the component.

@johno johno added the 🐛 type/bug This is a problem label Aug 10, 2018
@johno
Copy link
Member

johno commented Aug 10, 2018

Thanks for filing an issue!

This is a known bug with empty lines within JSX blocks (a problem with the remark parser). We're currently working on implementing a new custom parser to better handle JSX parsing.

@geddski
Copy link
Author

geddski commented Aug 10, 2018

@johno oh cool. Is there an issue I can sub to follow that?

@johno
Copy link
Member

johno commented Aug 10, 2018

#195 is what I'm currently referencing, but we can keep this open as well in case folks stumble upon it. Hoping to get a fix implemented in the next week.

@geddski
Copy link
Author

geddski commented Aug 10, 2018

awesome

@johno
Copy link
Member

johno commented Feb 15, 2019

Going to close this since we can track progress in #195. Thanks for opening up the issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 type/bug This is a problem
Development

No branches or pull requests

2 participants