Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -497,7 +497,6 @@ def create_new_blank_record(container):
|
|
497 |
except Exception as e:
|
498 |
st.error(f"An unexpected error occurred: {str(e)} 😱")
|
499 |
|
500 |
-
|
501 |
# Function to preprocess the pasted content
|
502 |
def preprocess_text(text):
|
503 |
# Replace CRLF and other newline variations with the JSON newline escape sequence
|
@@ -517,7 +516,8 @@ def preprocess_text(text):
|
|
517 |
text = text.strip()
|
518 |
return text
|
519 |
|
520 |
-
|
|
|
521 |
|
522 |
# 🎭 Main function - "All the world's a stage, and all the code merely players" -Shakespeare, probably
|
523 |
def main():
|
@@ -1055,6 +1055,12 @@ def main():
|
|
1055 |
if hasattr(st.session_state, 'current_file'):
|
1056 |
st.subheader(f"Editing: {st.session_state.current_file} 🛠")
|
1057 |
new_content = st.text_area("File Content ✏️:", st.session_state.file_content, height=300)
|
|
|
|
|
|
|
|
|
|
|
|
|
1058 |
if st.button("Save Changes 💾"):
|
1059 |
with open(st.session_state.current_file, 'w', encoding='utf-8') as file:
|
1060 |
file.write(new_content)
|
|
|
497 |
except Exception as e:
|
498 |
st.error(f"An unexpected error occurred: {str(e)} 😱")
|
499 |
|
|
|
500 |
# Function to preprocess the pasted content
|
501 |
def preprocess_text(text):
|
502 |
# Replace CRLF and other newline variations with the JSON newline escape sequence
|
|
|
516 |
text = text.strip()
|
517 |
return text
|
518 |
|
519 |
+
|
520 |
+
|
521 |
|
522 |
# 🎭 Main function - "All the world's a stage, and all the code merely players" -Shakespeare, probably
|
523 |
def main():
|
|
|
1055 |
if hasattr(st.session_state, 'current_file'):
|
1056 |
st.subheader(f"Editing: {st.session_state.current_file} 🛠")
|
1057 |
new_content = st.text_area("File Content ✏️:", st.session_state.file_content, height=300)
|
1058 |
+
|
1059 |
+
# Preprocess the text before loading it into JSON - Added to protect copy paste into JSON to keep format.
|
1060 |
+
cleaned_doc_str = preprocess_text(new_content)
|
1061 |
+
new_doc = json.loads(cleaned_doc_str)
|
1062 |
+
new_content = cleaned_doc_str
|
1063 |
+
|
1064 |
if st.button("Save Changes 💾"):
|
1065 |
with open(st.session_state.current_file, 'w', encoding='utf-8') as file:
|
1066 |
file.write(new_content)
|