bennyboer ยท GitHub

Hi there again!

While testing a little bit I noticed that the parser was incorrectly trimming text nodes.

Example

<p> Hello para<b>gra</b>ph! </p>
<p> Hello para <b>gra</b> ph! </p>

for this example I would expect to get the following output:

{
  "treeType": "documentFragment",
  "children": [
    {
      "name": "p",
      "variant": "normal",
      "children": [
        " Hello para",
        {
          "name": "b",
          "variant": "normal",
          "children": [
            "gra"
          ]
        },
        "ph! "
      ]
    },
    {
      "name": "p",
      "variant": "normal",
      "children": [
        " Hello para ",
        {
          "name": "b",
          "variant": "normal",
          "children": [
            "gra"
          ]
        },
        " ph! "
      ]
    }
  ]
}

Notice the white spaces in the second paragraph nodes children.

With the current version of the HTML parser I get the following instead:

{
  "treeType": "documentFragment",
  "children": [
    {
      "name": "p",
      "variant": "normal",
      "children": [
        "Hello para",
        {
          "name": "b",
          "variant": "normal",
          "children": [
            "gra"
          ]
        },
        "ph!"
      ]
    },
    {
      "name": "p",
      "variant": "normal",
      "children": [
        "Hello para",
        {
          "name": "b",
          "variant": "normal",
          "children": [
            "gra"
          ]
        },
        "ph!"
      ]
    }
  ]
}

As you can see there is no difference between the two paragraphs with the current version of HTML Parser (0.6.3).

I will provide a PR with a possible fix ASAP! ๐Ÿ˜„

Read the original on github.com โ†—