Attempt to reintroduce commonmark behavior #11
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Initial checklist
Description of changes
This is a proof of concept to reintroduce CommonMark-style HTML blocks to MDX. I would like to request comments on these changes.
Currently, MDX parses
as
The content within the tags is parsed as a paragraph, but this is often not wanted. CommonMark specifies this behavior to only occur if there is a blank line after the tag, as such:
but this is needlessly restrictive when you want markdown syntax within flow elements.
This change introduces a configuration option to parse content within flow elements as inline markdown. Paragraph wrapping can be restored by adding a blank line, as in CommonMark.
Examples:
Configuration is done by setting
preferInline
(bad name, please advise) when creating the extension:mdxJsx({ acorn, acornOptions, addResult: true, preferInline: true })
.I am currently writing tests for this feature and will update the PR when I have good coverage.
I intend to maintain this patch set into the future because I am currently working on a project which wants this feature. I am opening this PR for the primary purpose of gathering feedback. If this feature is not wanted, please close this PR.
Finally, I would like to offer my sincere gratitude for the authors of
micromark
and related packages. Markdown truly is horrible to parse, andmicromark
makes everything so much easier.Things that need fixing
This does not work because expressions are not handled:fixed hopefullyThis does not work: