Update backup11.app.py
Browse files- backup11.app.py +9 -10
backup11.app.py
CHANGED
@@ -98,7 +98,7 @@ def apply_emoji_font(text, emoji_font):
|
|
98 |
segments = tag_pattern.split(text)
|
99 |
result = []
|
100 |
|
101 |
-
# Apply emoji font only to
|
102 |
emoji_pattern = re.compile(
|
103 |
r"([\U0001F300-\U0001F5FF"
|
104 |
r"\U0001F600-\U0001F64F"
|
@@ -124,7 +124,7 @@ def apply_emoji_font(text, emoji_font):
|
|
124 |
# Keep tags unchanged
|
125 |
result.append(segment)
|
126 |
else:
|
127 |
-
# Apply
|
128 |
parts = []
|
129 |
last_pos = 0
|
130 |
for match in emoji_pattern.finditer(segment):
|
@@ -170,10 +170,9 @@ def markdown_to_pdf_content(markdown_text, render_with_bold, auto_bold_numbers,
|
|
170 |
|
171 |
line = detect_and_convert_links(line)
|
172 |
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
line = re.sub(r'\*([^*]+?)\*', r'<b>\1</b>', line)
|
177 |
|
178 |
if auto_bold_numbers and is_numbered_line:
|
179 |
if not (line.startswith("<b>") and line.endswith("</b>")):
|
@@ -195,7 +194,7 @@ def create_pdf(markdown_text, base_font_size, render_with_bold, auto_bold_number
|
|
195 |
rightMargin=36,
|
196 |
topMargin=36,
|
197 |
bottomMargin=36,
|
198 |
-
title=doc_title
|
199 |
)
|
200 |
styles = getSampleStyleSheet()
|
201 |
spacer_height = 10
|
@@ -285,9 +284,9 @@ def create_pdf(markdown_text, base_font_size, render_with_bold, auto_bold_number
|
|
285 |
else:
|
286 |
column_cells[col_idx].append(Paragraph(apply_emoji_font(content, "NotoEmoji-Bold"), section_style))
|
287 |
else:
|
288 |
-
column_cells[col_idx].append(Paragraph(apply_emoji_font(item, "
|
289 |
else:
|
290 |
-
column_cells[col_idx].append(Paragraph(apply_emoji_font(str(item), "
|
291 |
max_cells = max(len(cells) for cells in column_cells) if column_cells else 0
|
292 |
for cells in column_cells:
|
293 |
cells.extend([Paragraph("", item_style)] * (max_cells - len(cells)))
|
@@ -400,7 +399,7 @@ def create_crossfile_pdfs(source_pdf="TestSource.pdf", target_pdf="TestTarget.pd
|
|
400 |
create_base_pdf(source_pdf)
|
401 |
create_base_pdf(target_pdf)
|
402 |
add_bookmark_to_seven(target_pdf)
|
403 |
-
modify_source_pdf(
|
404 |
add_internal_link(source_pdf)
|
405 |
add_internal_link(target_pdf)
|
406 |
return source_pdf, target_pdf
|
|
|
98 |
segments = tag_pattern.split(text)
|
99 |
result = []
|
100 |
|
101 |
+
# Apply emoji font only to emojis, use DejaVuSans for other text
|
102 |
emoji_pattern = re.compile(
|
103 |
r"([\U0001F300-\U0001F5FF"
|
104 |
r"\U0001F600-\U0001F64F"
|
|
|
124 |
# Keep tags unchanged
|
125 |
result.append(segment)
|
126 |
else:
|
127 |
+
# Apply DejaVuSans to non-emoji text, emoji_font to emojis
|
128 |
parts = []
|
129 |
last_pos = 0
|
130 |
for match in emoji_pattern.finditer(segment):
|
|
|
170 |
|
171 |
line = detect_and_convert_links(line)
|
172 |
|
173 |
+
# Preserve bold and emphasis formatting
|
174 |
+
line = re.sub(r'\*\*(.+?)\*\*', r'<b>\1</b>', line)
|
175 |
+
line = re.sub(r'\*([^*]+?)\*', r'<b>\1</b>', line)
|
|
|
176 |
|
177 |
if auto_bold_numbers and is_numbered_line:
|
178 |
if not (line.startswith("<b>") and line.endswith("</b>")):
|
|
|
194 |
rightMargin=36,
|
195 |
topMargin=36,
|
196 |
bottomMargin=36,
|
197 |
+
title=doc_title
|
198 |
)
|
199 |
styles = getSampleStyleSheet()
|
200 |
spacer_height = 10
|
|
|
284 |
else:
|
285 |
column_cells[col_idx].append(Paragraph(apply_emoji_font(content, "NotoEmoji-Bold"), section_style))
|
286 |
else:
|
287 |
+
column_cells[col_idx].append(Paragraph(apply_emoji_font(item, "NotoEmoji-Bold"), item_style))
|
288 |
else:
|
289 |
+
column_cells[col_idx].append(Paragraph(apply_emoji_font(str(item), "NotoEmoji-Bold"), item_style))
|
290 |
max_cells = max(len(cells) for cells in column_cells) if column_cells else 0
|
291 |
for cells in column_cells:
|
292 |
cells.extend([Paragraph("", item_style)] * (max_cells - len(cells)))
|
|
|
399 |
create_base_pdf(source_pdf)
|
400 |
create_base_pdf(target_pdf)
|
401 |
add_bookmark_to_seven(target_pdf)
|
402 |
+
modify_source_pdf(source, target)
|
403 |
add_internal_link(source_pdf)
|
404 |
add_internal_link(target_pdf)
|
405 |
return source_pdf, target_pdf
|