syntax-tree/mdast-util-mdx-jsx

Extraneous indent for mdxJsxTextElements during stringify

tonywu6 opened this issue · 3 comments

Initial checklist

Affected packages and versions

mdast-util-mdx-jsx@2.1.3, remark-mdx@2.3.0, remark-parse@10.0.2, remark-stringify@10.0.3

Link to runnable example

https://codesandbox.io/p/sandbox/nostalgic-cloud-fdvyzk

Steps to reproduce

Maybe introduced here?

const depth = inferDepth(context)

With default options, parse and then stringify a MDX document containing a mdxJsxTextElement nested inside a mdxJsxFlowElement, for example:

<div>
    Lorem ipsum <span>dolor</span> sit amet
</div>

Expected behavior

Input and output should be the same

Actual behavior

Inline elements have extra whitespace in front of them

<div>
    Lorem ipsum   <span>dolor</span> sit amet
</div>

Affected runtime and version

node@16.20

Affected package manager and version

pnpm@8.5.0

Affected OS and version

macOS Ventura 13.1

Build and bundle tools

No response

inferDepth only handles flow elements, not texts:

if (x === 'mdxJsxFlowElement') {
.

Can repro in this project, thanks!

Thanks for the report, released!