specification icon indicating copy to clipboard operation
specification copied to clipboard

Introduce evaluated code block for JSX

Open johno opened this issue 7 years ago • 5 comments

Considering the fact that most tooling doesn't support MDX syntax, perhaps it makes sense to introduce an official way to introduce JSX blocks that render nicely with existing MD tools.

@jamiebuilds brings up a great point about how we can make a small, optional change to MDX in order to have JSX blocks work more seamlessly.

I like the idea of something along the lines of what Jamie proposes, using metadata to indicate the code block should be evaluated. This is something we discussed in the original spec, but decided to punt on for the initial release.

Language

  • /jsx?/

Metadata

  • render=true
  • eval=true
```js render=true

johno avatar Aug 29 '18 15:08 johno

I believe we want this to land for code block infostring parsing -- https://github.com/remarkjs/remark/pull/345

ChristopherBiscardi avatar Aug 29 '18 15:08 ChristopherBiscardi

@ChristopherBiscardi The info string is already supported, just not split on that one space. I’m sure we could work around it already! But anyway, probably going to land in a couple days, waiting on a couple more things first!

wooorm avatar Aug 29 '18 19:08 wooorm

Dope! my mistake :) I'll look further into how it currently works

ChristopherBiscardi avatar Aug 30 '18 08:08 ChristopherBiscardi

I completely agree with this assessment, though I wonder if this should be done under the name of MDX or as a separate initiative since MDX has started gaining dev market share on a number of fronts and this would presumably be a large, breaking change that would not be backwards-compatible with existing projects.

transitive-bullshit avatar Sep 27 '18 01:09 transitive-bullshit

I believe that those code blocks are easier for type checking

```ts
<Component >
```

We can strip out those blocks and feed it to type checker. Related https://github.com/mdx-js/specification/issues/16

stereobooster avatar Nov 30 '18 15:11 stereobooster