Skip to content

Include unravel transformation into remark-mdx #2649

@fuma-nama

Description

@fuma-nama

Initial checklist

Problem

Since @mdx-js/mdx is more high-level, I usually use remark-mdx for unit tests for my own remark mdx plugins.

I noticed an inconsistency when parsing MDX inline content, like:

<Comp>Text</Comp>

<Comp>

Text

</Comp>

In remark-mdx, the former one is a flow text element, while latter one is a JSX flow element.

But when using @mdx-jd/mdx, where my remark plugins run, they became both JSX flow element.

I would have expected it's a parse-level behaviour as it's about how JSX syntax being handled, but after checking, the work is done by an internal remark plugin to unravel JSX text elements.

Current solutions

Copy the remark unravel plugin from this repository, or using another existing plugins.

But they're not parser, which causes processor.parse to handle syntax like:

<Comp>Text</Comp>

as inline elements, and created inconsistency when I use remark().use(remarkMdx) instead.

The result is a bit unintuitive because it's enabled by default by MDX.js, and cannot be disabled at all.

Proposed solutions

An option to remarkMdx to specify how to handle those JSX syntax. (or consider enabling it by default)

Metadata

Metadata

Assignees

No one assigned

    Labels

    🤞 phase/openPost is being triaged manually

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions