Unterminated template when parsing template literals with multiple newlines (regression from v1)
See original GitHub issueInitial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Affected packages and versions
Link to runnable example
https://stackblitz.com/edit/github-rumgbj?file=index.js
Steps to reproduce
Add an extra \n
between .foo
and .bar
styles in the linked stackblitz example
Expected behavior
It should compile successfully. We are using this pattern in Storybook’s starter template:
Actual behavior
It will crash with
Could not parse expression with acorn: Unterminated template
Or perhaps this is an intentional breaking change in MDXv2?
Runtime
No response
Package manager
No response
OS
No response
Build and bundle tools
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
SyntaxError: unterminated string literal - JavaScript | MDN
The JavaScript error "unterminated string literal" occurs when there is an unterminated ... Instead, use the + operator, a backslash, or template literals....
Read more >javascript - "Unterminated template literal" syntax error when ...
I'm using ES6 template literals to construct some HTML in strings, and so far it has been working fine. However, as soon as...
Read more >CoffeeScript
''' and """ strings are now output as more readable JavaScript template literals, or backtick ( ` ) strings, with actual newlines rather...
Read more >How to Create Multi-Line String with Template Literals
It's super easy now to create multi-line strings with Template Literals in JavaScript. ... I mean the output of the string is spanning...
Read more >Template literals (Template strings) - JavaScript
To escape a backtick in a template literal, put a backslash ( \ ) before the backtick. `\`` === '`' // --> true....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @wooorm thanks so much for getting back to me.
I updated the example to make it a little more readable and realized it was not exactly what I wanted to convey (though the behavior is the same).
Original (broken)
The “original” version worked with MDXv1 and we shipped it to tens of thousands of users as part of the example template in Storybook Docs. Now in MDXv2 it’s broken. It feels like a regression to me, but if that’s the expected behavior I’m totally fine with it – I realize that’s what major versions are for.
Updated1 (works)
Updated2 (also works)
Discussion
Both updated versions work. I could update our template accordingly, and provide migration instructions or potentially even ship a codemod to update users’ code accordingly.
Before I do that, however, I want to confirm:
Updated1
andUpdated2
? (I’m guessingUpdated2
is more idiomatic MDX, but not entirely sure)Thanks again for your help! And congratulations on the v2 release–super excited to get this into users’ hands!!! 🎉
@brendonco you’re probably better off asking questions about storybook betas in storybook repos