Update app.py
Browse files
app.py
CHANGED
|
@@ -215,7 +215,7 @@ default_markdown = """# ๐ Deities Guide: Mythology and Moral Lessons ๐
|
|
| 215 |
def markdown_to_pdf_content(markdown_text):
|
| 216 |
lines = markdown_text.strip().split('\n')
|
| 217 |
pdf_content = []
|
| 218 |
-
|
| 219 |
current_item = None
|
| 220 |
sub_items = []
|
| 221 |
|
|
@@ -225,7 +225,7 @@ def markdown_to_pdf_content(markdown_text):
|
|
| 225 |
continue
|
| 226 |
|
| 227 |
if line.startswith('# '):
|
| 228 |
-
|
| 229 |
elif line.startswith('## '):
|
| 230 |
if current_item and sub_items:
|
| 231 |
pdf_content.append([current_item, sub_items])
|
|
@@ -233,23 +233,29 @@ def markdown_to_pdf_content(markdown_text):
|
|
| 233 |
current_item = None
|
| 234 |
section = line.replace('## ', '').strip()
|
| 235 |
pdf_content.append(f"<b>{section}</b>")
|
| 236 |
-
|
| 237 |
-
elif
|
| 238 |
if current_item and sub_items:
|
| 239 |
pdf_content.append([current_item, sub_items])
|
| 240 |
sub_items = []
|
| 241 |
-
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
elif re.match(r'^\d
|
| 246 |
if current_item and sub_items:
|
| 247 |
pdf_content.append([current_item, sub_items])
|
| 248 |
sub_items = []
|
| 249 |
current_item = line.strip()
|
| 250 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 251 |
else:
|
| 252 |
-
if
|
|
|
|
|
|
|
| 253 |
pdf_content.append(line.strip())
|
| 254 |
|
| 255 |
if current_item and sub_items:
|
|
|
|
| 215 |
def markdown_to_pdf_content(markdown_text):
|
| 216 |
lines = markdown_text.strip().split('\n')
|
| 217 |
pdf_content = []
|
| 218 |
+
in_list = False
|
| 219 |
current_item = None
|
| 220 |
sub_items = []
|
| 221 |
|
|
|
|
| 225 |
continue
|
| 226 |
|
| 227 |
if line.startswith('# '):
|
| 228 |
+
continue
|
| 229 |
elif line.startswith('## '):
|
| 230 |
if current_item and sub_items:
|
| 231 |
pdf_content.append([current_item, sub_items])
|
|
|
|
| 233 |
current_item = None
|
| 234 |
section = line.replace('## ', '').strip()
|
| 235 |
pdf_content.append(f"<b>{section}</b>")
|
| 236 |
+
in_list = False
|
| 237 |
+
elif line.startswith('### '):
|
| 238 |
if current_item and sub_items:
|
| 239 |
pdf_content.append([current_item, sub_items])
|
| 240 |
sub_items = []
|
| 241 |
+
current_item = None
|
| 242 |
+
subsection = line.replace('### ', '').strip()
|
| 243 |
+
pdf_content.append(f"<b>{subsection}</b>")
|
| 244 |
+
in_list = False
|
| 245 |
+
elif re.match(r'^\d+\.', line):
|
| 246 |
if current_item and sub_items:
|
| 247 |
pdf_content.append([current_item, sub_items])
|
| 248 |
sub_items = []
|
| 249 |
current_item = line.strip()
|
| 250 |
+
in_list = True
|
| 251 |
+
elif re.match(r'^\d+\.\d+\.', line):
|
| 252 |
+
sub_items.append(line.strip())
|
| 253 |
+
elif line.startswith('*') and not in_list:
|
| 254 |
+
pdf_content.append(line.strip())
|
| 255 |
else:
|
| 256 |
+
if in_list:
|
| 257 |
+
sub_items.append(line.strip())
|
| 258 |
+
else:
|
| 259 |
pdf_content.append(line.strip())
|
| 260 |
|
| 261 |
if current_item and sub_items:
|