-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Closed
Labels
🐛 type/bugThis is a problemThis is a problem👶 semver/patchThis is a backwards-compatible fixThis is a backwards-compatible fix💪 phase/solvedPost is donePost is done🗄 area/interfaceThis affects the public interfaceThis affects the public interface
Description
Subject of the issue
The issue causes parsing failure in a compiler plugin that parses the child.value strings for post processing.
Reproduce
The following:
<button>
<div>hello world</div>
//<- there is one empty space here at the start of the line
</button>
will parse as
"children": [
{
"type": "jsx",
"value": "<button>\n <div>hello world</div>\n\n</button>\n\n",
...
}
],
However, removing the one space on the empty line will parse as 3 separate elements:
<button>
<div>hello world</div>
//<- there is no empty space here
</button>
"children": [
{
"type": "jsx",
"value": "<button>\n <div>hello world</div>",
},
{
"type": "text",
"value": "\n"
},
{
"type": "jsx",
"value": "</button>",
}
],
Potential solution
The issue seems to be here:
mdx/packages/remark-mdx/block.js
Line 101 in dec55ec
| if (sequence[1].test(line)) { |
Since an empty string will always pass the test, the closing tag is missed if there is an empty line before it.
Any reasons not to change the rule to
...
if (line.length && sequence[1].test(line)) {
index = next
break
}
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🐛 type/bugThis is a problemThis is a problem👶 semver/patchThis is a backwards-compatible fixThis is a backwards-compatible fix💪 phase/solvedPost is donePost is done🗄 area/interfaceThis affects the public interfaceThis affects the public interface