Update app.py
Browse files
app.py
CHANGED
|
@@ -33,21 +33,21 @@ if uploaded_file and method != "Select a method":
|
|
| 33 |
# sections.append(current_section)
|
| 34 |
# return sections
|
| 35 |
def parse_markdown_into_boxes(text):
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
|
| 40 |
for i in range(1, len(parts), 2):
|
| 41 |
header = parts[i].strip()
|
| 42 |
content = parts[i+1].strip() if i+1 < len(parts) else ""
|
| 43 |
sections.append({"header": header, "content": content})
|
| 44 |
|
| 45 |
-
|
| 46 |
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
|
|
|
| 33 |
# sections.append(current_section)
|
| 34 |
# return sections
|
| 35 |
def parse_markdown_into_boxes(text):
|
| 36 |
+
pattern = r'(^#+ .*$)'
|
| 37 |
+
parts = re.split(pattern, text, flags=re.MULTILINE)
|
| 38 |
+
sections = []
|
| 39 |
|
| 40 |
for i in range(1, len(parts), 2):
|
| 41 |
header = parts[i].strip()
|
| 42 |
content = parts[i+1].strip() if i+1 < len(parts) else ""
|
| 43 |
sections.append({"header": header, "content": content})
|
| 44 |
|
| 45 |
+
return sections
|
| 46 |
|
| 47 |
|
| 48 |
+
st.subheader("📦 Formatted Output")
|
| 49 |
+
for section in parse_markdown_into_boxes(markdown_text):
|
| 50 |
+
with st.container(border=True):
|
| 51 |
+
if section["header"]:
|
| 52 |
+
st.markdown(f"#### {section['header']}")
|
| 53 |
+
st.markdown(section["content"])
|