We've been working on a Markdown + JSX project, c8r/markdown where we've been blurring the lines between markdown and JSX. Then this discussion made me realize that a lot of folks are working on very similar projects that seek to also blur these lines, an MDX, if you will.
A specification
I've put a few minutes into an mdx specification.
How would it work?
Ideally, this will essentially blend the MDAST and HAST syntax trees.
Perhaps maintaining all MDAST specific nodes and introducing some new type of node.
Maybe the two trees could even be merged.
Unsurprisingly, the lion share of the work will exist on the parsing side.
Why
As rauchg mentioned in his .mdx
proposal linked above, having an AST will allow us to better handle syntax highlighting, linting and code formatting. This AST spec could also help us arrive at a community solution with the numerous projects seeking similar goals.
Not to mention, MDXAST could leverage a lot of the great tooling and utilities built around MDAST and HAST.
Other considerations
Interleaving
Where this gets quite tricky is when thinking about the interleaving of md and jsx, like the following contrived example:
I'm currently using this project and have already run into difficulties with the notion of "interleaving".
Code blocks
This would also redefine how code blocks work, as currently with remark
, block elements are predefined. This makes sense in the context of markdown, but wouldn't necessarily be the case in .mdx
.
This is a project I will begin experimenting a bit with this week, and was wondering if you and the syntax-tree/remarkjs community were interested in.
Thanks for your time and any thoughts in advance.