Skip to content

Plain text input is ignored #11

@denis-sokolov

Description

@denis-sokolov

Parsing a plain text node results in an empty list. Current behavior:

const lib = require("html-parse-stringify2");
const nodes = lib.parse("Hello, world!");
nodes.length === 0;

Expected behavior:

const lib = require("html-parse-stringify2");
const nodes = lib.parse("Hello, world!");
nodes.length === 1;
nodes[0].type === "text";
nodes[0].content === "Hello, world!";

The simplest workaround is to wrap in a container:

const parse = function(html){
  return lib.parse("<top>" + html + "</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