fix(mdx): handle inline html correctly (#5704)

master
Ika 2019-01-03 10:46:11 +08:00 committed by GitHub
parent 1ca473186a
commit 63999c74eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 1 deletions

View File

@ -55,7 +55,9 @@ function htmlToJsx() {
node.type !== "html" ||
/^<!--[\s\S]*-->$/.test(node.value) ||
// inline html
parent.type === "paragraph"
(parent.type === "paragraph" ||
parent.type === "tableCell" ||
parent.type === "heading")
) {
return node;
}

View File

@ -188,6 +188,12 @@ printWidth: 80
test <World /> test
</Hello>
---
| Column 1 | Column 2 |
|---|---|
| Text | <Hello>Text</Hello> |
=====================================output=====================================
<Heading hi="there">Hello, world!</Heading>
@ -197,6 +203,12 @@ printWidth: 80
test <World /> test
</Hello>
---
| Column 1 | Column 2 |
| -------- | ------------------- |
| Text | <Hello>Text</Hello> |
================================================================================
`;
@ -216,6 +228,12 @@ semi: false
test <World /> test
</Hello>
---
| Column 1 | Column 2 |
|---|---|
| Text | <Hello>Text</Hello> |
=====================================output=====================================
<Heading hi="there">Hello, world!</Heading>
@ -225,6 +243,12 @@ semi: false
test <World /> test
</Hello>
---
| Column 1 | Column 2 |
| -------- | ------------------- |
| Text | <Hello>Text</Hello> |
================================================================================
`;

View File

@ -6,3 +6,9 @@
<Hello>
test <World /> test
</Hello>
---
| Column 1 | Column 2 |
|---|---|
| Text | <Hello>Text</Hello> |