react-showdown icon indicating copy to clipboard operation
react-showdown copied to clipboard

Parser issues with content of custom components

Open Zinggi opened this issue 3 years ago • 2 comments

Hi there :wave:

It looks like the parser for custom components gets confused when it's children are given over multiple lines. E.g. this works:

<Custom>
  foo
  bar
</Custom>

Doesn't work:

<Custom>
  foo

  bar
</Custom>

In the failing example, the custom component receives only ["↵ foo"] as children.


What's also weird is that when I insert another html tag (or custom component) as a child, the library parses that and passes it as an object to the custom component.

E.g.

<Custom>
  foo
  <p>bla</p>
  bar
</Custom>

passes: ["↵ foo↵ ", {$$typeof: Symbol(react.element), type: "p", key: "1", ref: null, props: {…}, …}, "↵ bar↵"] as children to the custom component.

I would have expected this to pass ["↵ foo↵ <p>bla</p>↵ bar↵"] instead.

Zinggi avatar Aug 10 '20 07:08 Zinggi

I join the previous speaker problem

GSoftwareDevelopment avatar Jan 04 '21 12:01 GSoftwareDevelopment

I also have a similar problem.

React component with props containing a string over multiple lines fails to be recognised.

<CustomComponent someText="Hello\n\nWorld!" />

Fails to render. One new line and it works fine.

wip-abramson avatar Feb 16 '21 19:02 wip-abramson