-
-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MdxFlowExpression doesn't seem to preserve white space in values #150
Comments
Good to see you again @bnchi! 👋 Did this come up from doing property testing comparing the JS and rust implementations? |
Hey @ChristianMurphy ! This is taken from a round trip test in the mdx implementation here : https://github.com/syntax-tree/mdast-util-mdx-expression/blob/main/test.js#L535C25-L535C47 Shouldn't I expect the round trip to not lose information like this when I go |
Re Christian: This is different from JSX: this is expressions. Expressions often have backticked strings. In them, there needs to be some persisting of whitespace. On the other hand, people do often want to indent their expressions. Just like other things in markdown:
There is a more complex case where expressions are used in JSX:
What you are seeing is code from markdown-rs and micromark/mdast-util* being out of sync with each other. Code such as micromark/micromark-extension-mdx-expression@103af9a would need to be backported. See also the issue mdx-js/mdx#2533 and the commit micromark/micromark-extension-mdx-jsx@67f9baf! |
@wooorm does this need to be back-ported for the serialization feature you think ? For now we can just serialize the trees as they come in. |
I am not entirely sure. There is handling in different places. Parsing and serializing. Regular expressions and expressions in JSX attributes. I think it’s these 4 places. Not sure which of them are out of date with the JS version, and thus which need to be backported |
Round-trip testing will probably help us to know where the issues are as I move along since we were able to detect this one this way. I'll see if I can make a PR to close this issue before continuing to work on the serialization process. |
Ah, I think I understand better what you mean. Yes: I do think that is needed! Appreciated, thank you for working on this! |
agreed, I added some ideas in #127 (comment) |
Given this test case :
the generated markdown tree seem to be missing the white spaces between the first
\n
anda
The tree outptut from the above Rust code is :
I ran the same input on the JS version and the output is :
The text was updated successfully, but these errors were encountered: