From 1bd36b32d8918453012486a053bb8399e2817778 Mon Sep 17 00:00:00 2001 From: vvzvlad Date: Sat, 26 Apr 2025 12:51:37 +0400 Subject: [PATCH] refactor post_parser: wrap media content in a div for better HTML structure --- post_parser.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/post_parser.py b/post_parser.py index db80206..d3c3045 100644 --- a/post_parser.py +++ b/post_parser.py @@ -605,7 +605,11 @@ class PostParser: if forward_html: content_body.append(forward_html) # Forward info if reply_html: content_body.append(reply_html) # Reply info content_body.append(f'{text_html}') + + content_body.append(f'
') content_body.append(f'{self._generate_html_media(message)}') + content_body.append(f'
') + if poll_html: content_body.append(poll_html) # Poll if message.forward_origin: content_body.append(f"
--- Forwarded post end ---") # Forward info end content_body.append(f'
') @@ -630,7 +634,7 @@ class PostParser: url = f"{base_url}/media/{file}/{digest}" logger.debug(f"Collected media file: {channel_username}/{message.id}/{file_unique_id}") - content_media.append(f'
') + # Check if document is a PDF file if (message.media == MessageMediaType.DOCUMENT and @@ -679,7 +683,6 @@ class PostParser: else: content_media.append(f'Sticker {emoji}') - content_media.append('
') if webpage := getattr(message, "web_page", None): # Web page preview if webpage_html := self._format_webpage(webpage, message):