What causes two leading spaces to be removed from template strings? #2588
-
Using the MDX playground, I entered: <pre><code>{`01234
abcd`}</code></pre> Looking at the compiled code, I see: function _createMdxContent(props) {
return <pre><code>{`01234
abcd`}</code></pre>;
} Notably, the template literal string now has only two spaces before I'm working around this for now by replacing my spaces with non-breaking spaces, which aren't removed. Zooming out a bit, I have a custom component for the ```my-language additional-argument="1"
cool
stuff here
``` Instead I've been calling the component directly using a template string to get newlines:
Is there any syntax I've missed to pass additional arguments to the fenced code block? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi! Markdown is a whitespace sensitive language. We must take that into account. And so do you. This example illustrates things:
So, you indent things in MD(X):
For your practical example, you can write it as: <MyFormatting
additional-argument="1"
language="my-language"
>
{
`cool
stuff here`
}
</MyFormatting> Though, because you probably do not allow markup as children, I would write: <MyFormatting
additional-argument="1"
language="my-language"
value={
`cool
stuff here`
}
/> |
Beta Was this translation helpful? Give feedback.
Expressions is the part of “markdown” that does that.
MDX, the language, extends markdown.
Expressions are one extension.
When you type
{
, an expression is opened, and that expression extensions allows an indent, of 2 spaces.