Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Empty text #4

@noreiller

Description

@noreiller

Brief bug description

When I want to parse an HTML string like this one <p>one <strong>two</strong></p>, the first TextNode child (#text) of the P tag does not contain the value one .

The issue comes from the text node which is serialized with parse5 while parse5 computes the text value from the childNodes, which a TextNode has not.

If you replace the parentNode instead of adding it to the childNodes, it works better:
https://github.com/kontent-ai/kontent-delivery-node-parser/blob/master/lib/parser/implementation/shared.ts#L160

-        text: striptags(serialize(node)),
+        text:  tagName === "#text" ? node.value : striptags(serialize(node)),

Test environment

  • Node

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions