forked from fb55/htmlparser2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(tests): Add test cases for misnested tags
47-misnested-formatting-tags.json demonstrates and covers Issue fb55#1075. 48-misnested-formatting-and-block-tags.json demonstrates and covers both Issue fb55#1075 and Issue fb55#1076, and their possible interaction.
- Loading branch information
1 parent
7e5941f
commit aaf85c2
Showing
2 changed files
with
252 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
{ | ||
"name": "misnested formatting tags", | ||
"input": "plain <b>bold <i>italic bold </b>italic </i>plain", | ||
"expected": [ | ||
{ | ||
"event": "text", | ||
"startIndex": 0, | ||
"endIndex": 5, | ||
"data": ["plain "] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 6, | ||
"endIndex": 8, | ||
"data": ["b"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 6, | ||
"endIndex": 8, | ||
"data": ["b", {}, false] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 9, | ||
"endIndex": 13, | ||
"data": ["bold "] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 14, | ||
"endIndex": 16, | ||
"data": ["i"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 14, | ||
"endIndex": 16, | ||
"data": ["i", {}, false] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 17, | ||
"endIndex": 28, | ||
"data": ["italic bold "] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 29, | ||
"endIndex": 32, | ||
"data": ["i", true] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 29, | ||
"endIndex": 32, | ||
"data": ["b", false] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 29, | ||
"endIndex": 32, | ||
"data": ["i"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 29, | ||
"endIndex": 32, | ||
"data": ["i", {}, true] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 33, | ||
"endIndex": 39, | ||
"data": ["italic "] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 40, | ||
"endIndex": 43, | ||
"data": ["i", false] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 44, | ||
"endIndex": 48, | ||
"data": ["plain"] | ||
} | ||
] | ||
} |
162 changes: 162 additions & 0 deletions
162
src/__fixtures__/Events/48-misnested-formatting-and-block-tags.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
{ | ||
"name": "misnested formatting and block tags", | ||
"input": "<p>plain <b>bold <p><i>italic bold <p></b> italic </i> plain", | ||
"expected": [ | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 0, | ||
"endIndex": 2, | ||
"data": ["p"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 0, | ||
"endIndex": 2, | ||
"data": ["p", {}, false] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 3, | ||
"endIndex": 8, | ||
"data": ["plain "] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 9, | ||
"endIndex": 11, | ||
"data": ["b"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 9, | ||
"endIndex": 11, | ||
"data": ["b", {}, false] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 12, | ||
"endIndex": 17, | ||
"data": ["bold "] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 18, | ||
"endIndex": 20, | ||
"data": ["b", true] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 18, | ||
"endIndex": 20, | ||
"data": ["p", true] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 18, | ||
"endIndex": 20, | ||
"data": ["p"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 18, | ||
"endIndex": 20, | ||
"data": ["p", {}, false] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 18, | ||
"endIndex": 20, | ||
"data": ["b"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 18, | ||
"endIndex": 20, | ||
"data": ["b", {}, true] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 21, | ||
"endIndex": 23, | ||
"data": ["i"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 21, | ||
"endIndex": 23, | ||
"data": ["i", {}, false] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 24, | ||
"endIndex": 35, | ||
"data": ["italic bold "] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 36, | ||
"endIndex": 38, | ||
"data": ["i", true] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 36, | ||
"endIndex": 38, | ||
"data": ["b", true] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 36, | ||
"endIndex": 38, | ||
"data": ["p", true] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 36, | ||
"endIndex": 38, | ||
"data": ["p"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 36, | ||
"endIndex": 38, | ||
"data": ["p", {}, false] | ||
}, | ||
{ | ||
"event": "opentagname", | ||
"startIndex": 36, | ||
"endIndex": 38, | ||
"data": ["i"] | ||
}, | ||
{ | ||
"event": "opentag", | ||
"startIndex": 36, | ||
"endIndex": 38, | ||
"data": ["i", {}, true] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 43, | ||
"endIndex": 50, | ||
"data": [" italic "] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 51, | ||
"endIndex": 54, | ||
"data": ["i", false] | ||
}, | ||
{ | ||
"event": "text", | ||
"startIndex": 55, | ||
"endIndex": 60, | ||
"data": [" plain"] | ||
}, | ||
{ | ||
"event": "closetag", | ||
"startIndex": 61, | ||
"endIndex": 61, | ||
"data": ["p", true] | ||
} | ||
] | ||
} |