Update app.py
Browse files
app.py
CHANGED
|
@@ -46,13 +46,19 @@ if uploaded_file and method != "Select a method":
|
|
| 46 |
elif method == "Outline Method":
|
| 47 |
st.subheader("📝 Outline Method Output")
|
| 48 |
|
| 49 |
-
#
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
for raw_section in sections:
|
| 52 |
if not raw_section.strip():
|
| 53 |
-
continue #
|
| 54 |
|
| 55 |
-
# Extract title and bullet content
|
| 56 |
lines = raw_section.strip().splitlines()
|
| 57 |
title_line = lines[0] if lines else "Untitled Section"
|
| 58 |
content_lines = lines[1:]
|
|
@@ -60,13 +66,13 @@ if uploaded_file and method != "Select a method":
|
|
| 60 |
with st.container(border=True):
|
| 61 |
st.markdown(f"### {title_line.strip()}")
|
| 62 |
for line in content_lines:
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
st.markdown(f" 
|
| 68 |
else:
|
| 69 |
-
st.markdown(
|
| 70 |
|
| 71 |
|
| 72 |
elif method == "Cornell Method":
|
|
|
|
| 46 |
elif method == "Outline Method":
|
| 47 |
st.subheader("📝 Outline Method Output")
|
| 48 |
|
| 49 |
+
# Remove ```markdown code fences if present
|
| 50 |
+
cleaned_markdown = markdown_text.strip()
|
| 51 |
+
if cleaned_markdown.startswith("```markdown"):
|
| 52 |
+
cleaned_markdown = cleaned_markdown[len("```markdown"):].strip()
|
| 53 |
+
if cleaned_markdown.endswith("```"):
|
| 54 |
+
cleaned_markdown = cleaned_markdown[:-3].strip()
|
| 55 |
+
|
| 56 |
+
# Split into sections using '## ' headers
|
| 57 |
+
sections = cleaned_markdown.split("## ")
|
| 58 |
for raw_section in sections:
|
| 59 |
if not raw_section.strip():
|
| 60 |
+
continue # skip empty sections
|
| 61 |
|
|
|
|
| 62 |
lines = raw_section.strip().splitlines()
|
| 63 |
title_line = lines[0] if lines else "Untitled Section"
|
| 64 |
content_lines = lines[1:]
|
|
|
|
| 66 |
with st.container(border=True):
|
| 67 |
st.markdown(f"### {title_line.strip()}")
|
| 68 |
for line in content_lines:
|
| 69 |
+
stripped = line.lstrip()
|
| 70 |
+
indent_level = (len(line) - len(stripped)) // 2 # assume 2 spaces per indent
|
| 71 |
+
|
| 72 |
+
if stripped.startswith("- "):
|
| 73 |
+
st.markdown(f"{' ' * 4 * indent_level}{stripped}")
|
| 74 |
else:
|
| 75 |
+
st.markdown(stripped)
|
| 76 |
|
| 77 |
|
| 78 |
elif method == "Cornell Method":
|