awacke1 commited on
Commit
2c16adb
ยท
verified ยท
1 Parent(s): cfcefd2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -11
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
- in_list_item = False
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
- pass
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
- in_list_item = False
237
- elif re.match(r'^\d+\.', line):
238
  if current_item and sub_items:
239
  pdf_content.append([current_item, sub_items])
240
  sub_items = []
241
- current_item = line.strip()
242
- in_list_item = True
243
- elif line.startswith('- ') and in_list_item:
244
- sub_items.append(line.strip())
245
- elif re.match(r'^\d+\.\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_item = True
 
 
 
 
251
  else:
252
- if not in_list_item:
 
 
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: