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

Image breaking after switching to markdown mode and back #208

Closed
andreibasto opened this issue Jul 28, 2022 · 1 comment
Closed

Image breaking after switching to markdown mode and back #208

andreibasto opened this issue Jul 28, 2022 · 1 comment
Labels
bug Something isn't working commonmark Relates to commonmark round-tripping or syntax html Issue with html parsing or rendering

Comments

@andreibasto
Copy link

Describe the bug
If you insert an image using the rich-text editor, and then switch to markdown, and switch back to rich-text, the image breaks.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://stackoverflow.design/product/components/editor/#textarea-content-with-tables-enabled where the example is with the image
  2. Switch to markdown mode
  3. Switch directly back to rich-text mode
  4. See extra image details that weren't there before

Expected behavior
It should appear exactly as it was before.

Screenshots

Original:
Original:

After:
After

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser: Chrome
  • Version 103.0.5060.114 (Official Build) (64-bit)

Additional context
N/A

@andreibasto andreibasto added the bug Something isn't working label Jul 28, 2022
@b-kelly
Copy link
Collaborator

b-kelly commented Jul 28, 2022

Oh, this is an interesting one. I can repro the issue with the following content:

<img
  src="https://images.unsplash.com/photo-1556740758-90de374c12ad?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80"
  alt=""
/>

but not this content (note the lack of newline characters):

<img src="https://images.unsplash.com/photo-1556740758-90de374c12ad?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1000&q=80" alt="" />

What seems to be happening here is that the code that attempts to remember the html formatting of the parsed markdown (e.g. <img> vs <img /> vs <img/>) is getting tripped up by the newlines.

Thanks for the report!

@b-kelly b-kelly added commonmark Relates to commonmark round-tripping or syntax html Issue with html parsing or rendering labels Jul 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working commonmark Relates to commonmark round-tripping or syntax html Issue with html parsing or rendering
Projects
Status: Done
Development

No branches or pull requests

2 participants