Skip to content

In case "plain text + tags", text is ignored #25

@maxsimych

Description

@maxsimych

Thank you for this helpful package!

Almost the same problem as #11 still remain:
Parsing a plain text node + tags results in an list without plain text. Current behavior:

const lib = require("html-parse-stringify2");
const nodes = lib.parse("Hello, <b>world!</b>");
nodes.length === 1;

Expected behavior:

const lib = require("html-parse-stringify2");
const nodes = lib.parse("Hello, <b>world!</b>")
nodes.length === 2;
nodes[0].type === "text";
nodes[0].content === "Hello, ";
nodes[0].type === "tag";
nodes[0].name === "b";

And the same workaround works:

const parse = function(htmlAndText){
  return lib.parse("<top>" + htmlAndText + "</top>")[0].children;
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions