Copy text and keep format from <pre> tag (ReactJS)

715 Views Asked by At

Please view my CodeSandbox here.

For the CodeSandbox, I manually select the text like so:

enter image description here

Then, I paste it into a notepad, and this is what that notepad looks like. The line breaks are maintained, and this is exactly what I need:

enter image description here

However, when I use the same code in my local environment, select the text from the localhost and paste it into a notepad, I get this. For some reason, the text is being displayed as one string, without the indenting that I'd like in the previous picture.

enter image description here

Does anyone have any suggestions to get the <pre> tag indenting to show when I copy and paste the code locally?

Goal: To be able to manually select the text in my local div, and paste into a notepad with the same formatting from the UI.

0

There are 0 best solutions below