Update app.py
Browse files
app.py
CHANGED
|
@@ -4,7 +4,7 @@ import re
|
|
| 4 |
st.set_page_config(page_title="π¦ Markdown Formatter", layout="centered")
|
| 5 |
st.title("π Markdown Formatter App")
|
| 6 |
|
| 7 |
-
method = st.selectbox("Choose a formatting method:", ["Select a method", "Boxing Method","Outline Method", "Raw Markdown","Flashcard"])
|
| 8 |
uploaded_file = st.file_uploader("Upload a Markdown (.md) file", type=["md"])
|
| 9 |
|
| 10 |
if uploaded_file and method != "Select a method":
|
|
@@ -44,6 +44,37 @@ if uploaded_file and method != "Select a method":
|
|
| 44 |
st.markdown(f"**{title}**")
|
| 45 |
st.markdown(content)
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
elif method == "Flashcard":
|
| 49 |
st.subheader("π Flashcards")
|
|
|
|
| 4 |
st.set_page_config(page_title="π¦ Markdown Formatter", layout="centered")
|
| 5 |
st.title("π Markdown Formatter App")
|
| 6 |
|
| 7 |
+
method = st.selectbox("Choose a formatting method:", ["Select a method", "Boxing Method","Outline Method", "Raw Markdown","Flashcard", "Cornell Method"])
|
| 8 |
uploaded_file = st.file_uploader("Upload a Markdown (.md) file", type=["md"])
|
| 9 |
|
| 10 |
if uploaded_file and method != "Select a method":
|
|
|
|
| 44 |
st.markdown(f"**{title}**")
|
| 45 |
st.markdown(content)
|
| 46 |
|
| 47 |
+
elif method == "Cornell Method":
|
| 48 |
+
st.subheader("π Cornell Notes Formatted")
|
| 49 |
+
|
| 50 |
+
def parse_markdown_sections(text):
|
| 51 |
+
sections = {}
|
| 52 |
+
current_section = None
|
| 53 |
+
for line in text.splitlines():
|
| 54 |
+
if line.strip().startswith("## "):
|
| 55 |
+
current_section = line.replace("##", "").strip()
|
| 56 |
+
sections[current_section] = ""
|
| 57 |
+
elif current_section:
|
| 58 |
+
sections[current_section] += line + "\n"
|
| 59 |
+
return sections
|
| 60 |
+
|
| 61 |
+
sections = parse_markdown_sections(final_text)
|
| 62 |
+
cue_column = sections.get("Cues", "Cues Column not found.")
|
| 63 |
+
notes_section = sections.get("Notes", "Notes Section not found.")
|
| 64 |
+
summary = sections.get("Summary", "Summary not found.")
|
| 65 |
+
|
| 66 |
+
col1, col2 = st.columns([1, 2])
|
| 67 |
+
with col1:
|
| 68 |
+
st.markdown("### Cue Column")
|
| 69 |
+
st.markdown(cue_column)
|
| 70 |
+
with col2:
|
| 71 |
+
st.markdown("### Notes Section")
|
| 72 |
+
st.markdown(notes_section)
|
| 73 |
+
|
| 74 |
+
st.markdown("---")
|
| 75 |
+
st.markdown("### Summary")
|
| 76 |
+
st.markdown(summary)
|
| 77 |
+
|
| 78 |
|
| 79 |
elif method == "Flashcard":
|
| 80 |
st.subheader("π Flashcards")
|