Use remark-mdx only to parse jsx syntax #2357
-
I'm using react-markdown library and I like the flexibility it gives with including your own components, I was expanding on it to create custom components using html syntax using the raw plugin, it works fine but It's a bit buggy sometimes and using objects as props is annoying, so I wanted to try and use something better and stumbled on the remark-mdx plugin. Ideally I'd want to continue using the react markdown library and just add a plugin to it but I was wondering, is it possible to use remark-mdx only to parse the syntax and props of jsx elements? I don't want imports and other things, I'll only use it for remote md and live editors. If anyone has suggestions let me know! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Welcome @Specy! 👋 TL;DR Use MDX directly, it does all the things you you describe in your question, out of the box.
Custom components are a common need there are three approaches to it:
Can you give a specific example of what you believe is a bug?
HTML does not support this
No.
MDX is a language. You can choose what you write or do not write. There is no requirement to use imports.
MDX can be both server side and client side rendered. |
Beta Was this translation helpful? Give feedback.
TL;DR if you want to support untrusted user generated content, consider using one of the first to suggestions from my initial reply:
It is a language, which mixes Markdown and JSX.
It compiles MDX down into a JavaScript file with hyperscript functions, that JavaScript output is portable across frameworks (React, Vue, Svelte, etc) and across runtimes (browser, node, deno, etc).
It also supports the
remark
,rehype
, andrecma
ecos…