com3dian commited on
Commit
8deebd9
·
verified ·
1 Parent(s): 85a074f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -6
app.py CHANGED
@@ -82,8 +82,12 @@ def render_html(text):
82
  sentences = text.split('.')
83
  # Create HTML list items
84
  list_items = "".join([f"<li>{sentence.strip()}.</li>" for sentence in sentences if sentence.strip()])
 
 
 
85
  # Wrap list items in an unordered list
86
  return f"<ul>{list_items}</ul>"
 
87
 
88
  # Initialize session state for page index
89
  if 'page_index' not in st.session_state:
@@ -102,11 +106,6 @@ def turn_page(direction):
102
  st.session_state.page_index -= 1
103
  st.session_state.current_text = summ_text[st.session_state.page_index]
104
 
105
- # Function to update the current text based on text_area changes
106
- def update_text():
107
- st.session_state.current_text = st.session_state.text_area_value
108
- summ_text[st.session_state.page_index] = st.session_state.current_text
109
-
110
  # Display page turner controls
111
  col1, col2, col3 = st.columns([1, 2, 1])
112
  with col1:
@@ -117,7 +116,7 @@ with col2:
117
  st.write(f"Page {st.session_state.page_index + 1} of {len(summ_text)}")
118
 
119
  # Display editable text box
120
- text = st.text_area("Edit Text", st.session_state.current_text, height=200, key="text_area_value", on_change=update_text)
121
 
122
  # Display HTML box
123
  st.markdown(render_html(st.session_state.current_text), unsafe_allow_html=True)
 
82
  sentences = text.split('.')
83
  # Create HTML list items
84
  list_items = "".join([f"<li>{sentence.strip()}.</li>" for sentence in sentences if sentence.strip()])
85
+
86
+ summ_text[st.session_state.page_index] = text
87
+
88
  # Wrap list items in an unordered list
89
  return f"<ul>{list_items}</ul>"
90
+
91
 
92
  # Initialize session state for page index
93
  if 'page_index' not in st.session_state:
 
106
  st.session_state.page_index -= 1
107
  st.session_state.current_text = summ_text[st.session_state.page_index]
108
 
 
 
 
 
 
109
  # Display page turner controls
110
  col1, col2, col3 = st.columns([1, 2, 1])
111
  with col1:
 
116
  st.write(f"Page {st.session_state.page_index + 1} of {len(summ_text)}")
117
 
118
  # Display editable text box
119
+ text = st.text_area("Edit Text", st.session_state.current_text, height=200, key="text_area_value")
120
 
121
  # Display HTML box
122
  st.markdown(render_html(st.session_state.current_text), unsafe_allow_html=True)