Skip to content

preact-parser swallows newlines #7

Description

@hannobraun

Hey!

I'm using preact-parser 1.3.7 from NPM, and it seems to swallow newlines.

Test case (I've extracted this from my Deno app, hence the npm: thingy in the import):

import parser from "npm:preact-parser";

const contentHtml = "<p>a\nb</p>";
const contentJsx = parser.parse(contentHtml);

console.log(contentHtml);
console.log("---");
console.log(contentJsx.props.children[0].props.children);

Output:

<p>a
b</p>
---
[ "ab" ]

As you can see, the newline does not show up in the output. I don't know what the correct behavior should be. For my use case, it would be perfectly fine to have a space there instead of a newline. But completely swallowing whitespace seems wrong.

I'm about to submit a pull request with a suggested fix.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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