syntax-tree/mdast-util-mdx-jsx

Cannot close `mdxJsxTextTag` a different token `paragraph` is open

ChristianMurphy opened this issue · 2 comments

Initial checklist

Affected packages and versions

1.1.2

Link to runnable example

https://stackblitz.com/edit/node-4jipvc?file=index.js

Steps to reproduce

run

import * as acorn from 'acorn';
import { fromMarkdown } from 'mdast-util-from-markdown';
import { mdxJsx } from 'micromark-extension-mdx-jsx';
import { mdxJsxFromMarkdown } from 'mdast-util-mdx-jsx';

const content = `<b>
  example
</b> example`;

const tree = fromMarkdown(content, {
  extensions: [mdxJsx({ acorn: acorn, addResult: true })],
  mdastExtensions: [mdxJsxFromMarkdown],
});

console.log(tree);

Expected behavior

A paragraph, mdxJsxFlowElement and text node.

or

a clearer error message.

Actual behavior

Error: Cannot close `mdxJsxTextTag` (3:1-3:5): a different token (`paragraph`, 2:3-3:13) is open
    at async ModuleJob.run (https://node-4jipvc.w.staticblitz.com/blitz.5a55fa0dbb2eb8daf8e20eb3b6ad27ffc8ae4a6b.js:6:734565)
    at async Loader.import (https://node-4jipvc.w.staticblitz.com/blitz.5a55fa0dbb2eb8daf8e20eb3b6ad27ffc8ae4a6b.js:6:865940)
    at async Object.r.loadESM (https://node-4jipvc.w.staticblitz.com/blitz.5a55fa0dbb2eb8daf8e20eb3b6ad27ffc8ae4a6b.js:6:249892)

Runtime

Node v16

Package manager

npm v7

OS

Linux

Build and bundle tools

No response

The version tested includes e6661a6, this error does not appear to be covered by those changes.

The error added earlier was for a *b <c> d* </c> (so “markdown” closes while a JSX tag is open).
Added an another error for <a> *b </a> c* d (JSX closes while markdown is open)