awacke1 commited on
Commit
72f9332
·
verified ·
1 Parent(s): e393e33

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -142,7 +142,8 @@ def apply_emoji_font(text, emoji_font):
142
  def markdown_to_pdf_content(markdown_text, render_with_bold, auto_bold_numbers, add_space_before_numbered, headings_to_fonts):
143
  lines = markdown_text.strip().split('\n')
144
  pdf_content = []
145
- number_pattern = re.compile(r'^\d+\.\s')
 
146
  heading_pattern = re.compile(r'^(#{1,4})\s+(.+)$')
147
  first_numbered_seen = False
148
 
@@ -179,9 +180,7 @@ def markdown_to_pdf_content(markdown_text, render_with_bold, auto_bold_numbers,
179
  if not (line.startswith("<b>") and line.endswith("</b>")):
180
  if "<b>" in line and "</b>" in line:
181
  line = re.sub(r'</?b>', '', line)
182
- line = f"<b>{line}</b>"
183
- else:
184
- line = f"<b>{line}</b>"
185
  pdf_content.append(line)
186
  total_lines = len(pdf_content)
187
  return pdf_content, total_lines
@@ -245,7 +244,7 @@ def create_pdf(markdown_text, base_font_size, render_with_bold, auto_bold_number
245
  lines_per_column = total_lines / num_columns if num_columns > 0 else total_lines
246
  current_line_count = 0
247
  current_column = 0
248
- number_pattern = re.compile(r'^\d+\.\s')
249
  for item in pdf_content:
250
  if current_line_count >= lines_per_column and current_column < num_columns - 1:
251
  current_column += 1
 
142
  def markdown_to_pdf_content(markdown_text, render_with_bold, auto_bold_numbers, add_space_before_numbered, headings_to_fonts):
143
  lines = markdown_text.strip().split('\n')
144
  pdf_content = []
145
+ # Updated pattern to match both top-level (e.g., 4.) and sub-level (e.g., 4.1, 4.2) numbers
146
+ number_pattern = re.compile(r'^\d+(\.\d+)*\.\s')
147
  heading_pattern = re.compile(r'^(#{1,4})\s+(.+)$')
148
  first_numbered_seen = False
149
 
 
180
  if not (line.startswith("<b>") and line.endswith("</b>")):
181
  if "<b>" in line and "</b>" in line:
182
  line = re.sub(r'</?b>', '', line)
183
+ line = f"<b>{line}</b>"
 
 
184
  pdf_content.append(line)
185
  total_lines = len(pdf_content)
186
  return pdf_content, total_lines
 
244
  lines_per_column = total_lines / num_columns if num_columns > 0 else total_lines
245
  current_line_count = 0
246
  current_column = 0
247
+ number_pattern = re.compile(r'^\d+(\.\d+)*\.\s')
248
  for item in pdf_content:
249
  if current_line_count >= lines_per_column and current_column < num_columns - 1:
250
  current_column += 1