diff --git a/post_parser.py b/post_parser.py index 1b306e3..ad1e61e 100644 --- a/post_parser.py +++ b/post_parser.py @@ -175,6 +175,23 @@ MEDIA_SOURCES: Dict[Any, Callable[[Message], Tuple[Any, Optional[str]]]] = { } +# Inline media-sizing style literals, named so the renderers below read as intent +# rather than magic numbers. Values are substituted verbatim into the style strings, +# so the emitted bytes are unchanged. +MEDIA_MAX_HEIGHT_PX = "400px" # standard image/video max-height +MEDIA_MAX_HEIGHT_SMALL_PX = "200px" # looping/sticker media max-height +MEDIA_MAX_WIDTH_PX = "400px" # audio player max-width + + +def _wrap_post_html(body: str, footer: str) -> str: + """Shared post-HTML shell: the message-body + message-footer div pair joined by a + single newline. Used by PostParser._format_html (single/debug post) and by both + branches of rss_generator._render_messages_groups (single message and merged + group), so the emitted byte structure stays identical across all three call sites.""" + return (f'
{body}
\n' + f'') + + @dataclass class RenderCtx: """Everything a renderer needs. _generate_html_media assembles it (URL signing, @@ -193,34 +210,34 @@ class RenderCtx: # byte-for-byte fidelity is the stage-5a contract. def _render_img_400(ctx: 'RenderCtx') -> List[str]: return [f''] + f'max-height:{MEDIA_MAX_HEIGHT_PX}; object-fit:contain;">'] def _render_video_400(ctx: 'RenderCtx') -> List[str]: return [f''] + f'height:auto; max-height:{MEDIA_MAX_HEIGHT_PX};">'] def _render_audio(ctx: 'RenderCtx') -> List[str]: - return [f'