I am implementing a code editor in python using codemirror 6 as shown in the image below.
To run the code, I want to read it from the editor and store it in a backend file for execution. However, when I am trying to get the contents of the editor I am losing indentations which is an important part of python syntax.
I want file contents to be like this -
print("hello")
for i in range(10):
print(i+1)
But I am currently getting this -
print("hello") for i in range(10): print(i+1)
Is there a way to get the code from the codemirror editor without losing the line breaks and indentations?