Fixed issue where content surrounding tags are lost #1447

This commit is contained in:
Mike Farah
2022-11-27 17:29:27 +11:00
parent 43233ce62e
commit 02be2b2918
4 changed files with 77 additions and 14 deletions
+16
View File
@@ -238,6 +238,16 @@ var xmlScenarios = []formatScenario{
input: "<root>value<!-- comment--> </root>",
expected: "root: value # comment\n",
},
{
skipDoc: true,
input: "<root> <!-- comment-->value</root>",
expected: "\n# comment\nroot: value\n", //needs fix
},
{
skipDoc: true,
input: "<root>value<!-- comment-->anotherValue </root>",
expected: "root:\n # comment\n - value\n - anotherValue\n",
},
{
description: "Parse xml: simple",
subdescription: "Notice how all the values are strings, see the next example on how you can fix that.",
@@ -269,6 +279,12 @@ var xmlScenarios = []formatScenario{
input: "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<cat legs=\"4\">meow</cat>",
expected: "+p_xml: version=\"1.0\" encoding=\"UTF-8\"\ncat:\n +content: meow\n +@legs: \"4\"\n",
},
{
description: "Parse xml: content split between comments/children",
subdescription: "Multiple content texts are collected into a sequence.",
input: "<root> value <!-- comment-->anotherValue <a>frog</a> cool!</root>",
expected: "root:\n +content: # comment\n - value\n - anotherValue\n - cool!\n a: frog\n",
},
{
description: "Parse xml: custom dtd",
subdescription: "DTD entities are processed as directives.",