Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot render tag if formatted in a certain way. #540

Closed
Khongchai opened this issue Jan 24, 2024 · 3 comments · Fixed by #557
Closed

Cannot render tag if formatted in a certain way. #540

Khongchai opened this issue Jan 24, 2024 · 3 comments · Fixed by #557
Assignees

Comments

@Khongchai
Copy link

If we do this

const string = `<p>
Item detail
<span
  style="
    color: #fddb67;
    font-size: 11px;
    font-style: normal;
    font-weight: 500;
    line-height: 18px;
    text-decoration-line: underline;
  "
  >debug item 1</span
>
</p>`;


<Markdown>{string}</Markdown>

This error would be thrown
image

But if we inline the entire string, the content is rendered correctly with no errors

const string = `<p> Item detail <span style=" color: #fddb67; font-size: 11px; font-style: normal; font-weight: 500; line-height: 18px; text-decoration-line: underline; ">debug item 1</span> </p>`;

Not sure why this happens, but we were using another library and it was rendering the first version just fine.

@janpe
Copy link

janpe commented Feb 1, 2024

I wonder if this is the same as #449.

If you put your markdown in here: https://markdown-to-jsx.quantizor.dev/

The output you get is: Item detail debug item 1</span > </p>

@janpe
Copy link

janpe commented Feb 1, 2024

@quantizor is this an issue you are aware about? Do you have any thoughts on it? For me it is currently something that prevents me from using the library which I would otherwise be very happy to use

@quantizor
Copy link
Owner

Hi, yes likely a case of some regexes not accounting for newlines properly. Will look into it

@quantizor quantizor self-assigned this Mar 13, 2024
quantizor added a commit that referenced this issue Mar 21, 2024
quantizor added a commit that referenced this issue Mar 21, 2024
* refactor: trim style keys

* fix: handle newlines inside HTML tag brackets

Closes #540
Innei pushed a commit to Innei/markdown-to-jsx that referenced this issue Mar 28, 2024
* refactor: trim style keys

* fix: handle newlines inside HTML tag brackets

Closes quantizor#540

Signed-off-by: Innei <i@innei.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants