[PR #156] [MERGED] [renderer] Fix rendered post look: title, numbering, escaping, clean markup #160

Closed
opened 2026-10-13 19:48:09 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Glitchy-Sheep/boosty-downloader/pull/156
Author: @Glitchy-Sheep
Created: 8/16/2026
Status: ✅ Merged
Merged: 8/16/2026
Merged by: @Glitchy-Sheep

Base: main ← Head: fix/html-render-cleanup


📝 Commits (5)

  • ac138ad fix: Clean up and escape the rendered HTML
  • 9721525 fix: Use the post title as the browser tab title
  • 6aad2e1 fix: Keep the author's list numbering in rendered posts
  • 861d224 fix: Clean up list and text template markup
  • 2573f41 fix: Polish rendered post output and changelog the render fixes

📊 Changes

15 files changed (+218 additions, -473 deletions)

View changed files

📝 CHANGELOG.md (+5 -0)
📝 boosty_downloader/src/application/mappers/html_converter.py (+5 -2)
📝 boosty_downloader/src/application/mappers/list.py (+10 -1)
📝 boosty_downloader/src/application/use_cases/download_single_post.py (+7 -1)
📝 boosty_downloader/src/domain/post_data_chunks.py (+3 -2)
📝 boosty_downloader/src/infrastructure/html_generator/renderer.py (+37 -10)
📝 boosty_downloader/src/infrastructure/html_generator/templates/audio.html (+1 -1)
📝 boosty_downloader/src/infrastructure/html_generator/templates/base.html (+1 -1)
➕ boosty_downloader/src/infrastructure/html_generator/templates/file.html (+1 -0)
📝 boosty_downloader/src/infrastructure/html_generator/templates/list.html (+18 -34)
📝 boosty_downloader/src/infrastructure/html_generator/templates/text.html (+12 -24)
📝 boosty_downloader/src/infrastructure/html_generator/templates/video.html (+2 -2)
📝 test/fixtures/rendered_post.html (+36 -388)
📝 test/unit/html_generator/html_templates_test.py (+25 -7)
➕ test/unit/mappers/list_style_test.py (+55 -0)

📄 Description

[renderer] Fix rendered post look: title, numbering, escaping, clean markup

Summary

Six renderer problems fixed in one pass (stacked on #155, merge order: #153 -> #154 -> #155 -> this). Every fix is visible as a golden-file diff - the goldens from #155 were added for exactly this purpose.

Problem

  • post.html was ~600 lines of mostly blank lines and stray indentation: Jinja control lines leaked their whitespace, templates carried decorative indentation that broke on recursion (stair-stepped <li> / </li>)
  • Every saved post showed "HTML Report" in the browser tab
  • Numbered lists rendered as bullet lists: the API style was parsed but dropped on the way to HTML, the <ol> template branch was dead
  • A file name with markup broke the page: file links were built with an f-string, bypassing autoescape
  • Every video got a hardcoded type="video/mp4" - external downloads can be webm/mkv
  • The renderer mutated chunk urls in place

Fix

  • trim_blocks/lstrip_blocks on the Jinja environment, re-flowed text.html and list.html: inline styles render as one line, nested lists indent classically (content at +4, close tags aligned), empty chunks leave no blank lines
  • render_html takes a required page_title; the use case passes the post title (folder name for empty titles)
  • The list style now travels the whole chain: API DTO -> domain field -> converter -> template; unknown styles fall back to bullets
  • File links render through a template: names and urls are escaped
  • Video MIME type comes from the file extension; unknown ones omit the attribute so the browser sniffs
  • Windows path slashes are normalized in a local helper instead of mutating the chunk

Verification

  • task ci green: checks, 155 unit tests + 1 strict xfail, build; live integration tests 6/6 (one transient network timeout on first run, curl failed at the same moment, retry passed in 2s)
  • Live download of a real post: the tab shows the post title, the content section has zero blank lines, image paths stay relative
  • Golden diffs reviewed stage by stage: escaped file name, conditional MIME, live <ol>, clean indentation

Notes

  • Already downloaded posts keep their old HTML (the cache skips them) - the new rendering applies to new and updated posts; a full re-render belongs to the manifests design
  • Changelog updated (4 entries under Fixed)

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Glitchy-Sheep/boosty-downloader/pull/156 **Author:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Created:** 8/16/2026 **Status:** ✅ Merged **Merged:** 8/16/2026 **Merged by:** [@Glitchy-Sheep](https://github.com/Glitchy-Sheep) **Base:** `main` ← **Head:** `fix/html-render-cleanup` --- ### 📝 Commits (5) - [`ac138ad`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/ac138ade983e22ab993dbb2092b27b6dbe463322) fix: Clean up and escape the rendered HTML - [`9721525`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/97215252cb1032386ad2efb76d4c87f4528a608d) fix: Use the post title as the browser tab title - [`6aad2e1`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/6aad2e1692d1c3dc75e91174f4deaa332957334b) fix: Keep the author's list numbering in rendered posts - [`861d224`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/861d224db4c750ad94d2434f6da4e109906d8158) fix: Clean up list and text template markup - [`2573f41`](https://github.com/Glitchy-Sheep/boosty-downloader/commit/2573f41e34e4b289bb70a2debd94061398aa09ea) fix: Polish rendered post output and changelog the render fixes ### 📊 Changes **15 files changed** (+218 additions, -473 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+5 -0) 📝 `boosty_downloader/src/application/mappers/html_converter.py` (+5 -2) 📝 `boosty_downloader/src/application/mappers/list.py` (+10 -1) 📝 `boosty_downloader/src/application/use_cases/download_single_post.py` (+7 -1) 📝 `boosty_downloader/src/domain/post_data_chunks.py` (+3 -2) 📝 `boosty_downloader/src/infrastructure/html_generator/renderer.py` (+37 -10) 📝 `boosty_downloader/src/infrastructure/html_generator/templates/audio.html` (+1 -1) 📝 `boosty_downloader/src/infrastructure/html_generator/templates/base.html` (+1 -1) ➕ `boosty_downloader/src/infrastructure/html_generator/templates/file.html` (+1 -0) 📝 `boosty_downloader/src/infrastructure/html_generator/templates/list.html` (+18 -34) 📝 `boosty_downloader/src/infrastructure/html_generator/templates/text.html` (+12 -24) 📝 `boosty_downloader/src/infrastructure/html_generator/templates/video.html` (+2 -2) 📝 `test/fixtures/rendered_post.html` (+36 -388) 📝 `test/unit/html_generator/html_templates_test.py` (+25 -7) ➕ `test/unit/mappers/list_style_test.py` (+55 -0) </details> ### 📄 Description # [renderer] Fix rendered post look: title, numbering, escaping, clean markup ## Summary Six renderer problems fixed in one pass (stacked on #155, merge order: #153 -> #154 -> #155 -> this). Every fix is visible as a golden-file diff - the goldens from #155 were added for exactly this purpose. ## Problem - post.html was ~600 lines of mostly blank lines and stray indentation: Jinja control lines leaked their whitespace, templates carried decorative indentation that broke on recursion (stair-stepped `<li>` / `</li>`) - Every saved post showed "HTML Report" in the browser tab - Numbered lists rendered as bullet lists: the API style was parsed but dropped on the way to HTML, the `<ol>` template branch was dead - A file name with markup broke the page: file links were built with an f-string, bypassing autoescape - Every video got a hardcoded `type="video/mp4"` - external downloads can be webm/mkv - The renderer mutated chunk urls in place ## Fix - `trim_blocks`/`lstrip_blocks` on the Jinja environment, re-flowed `text.html` and `list.html`: inline styles render as one line, nested lists indent classically (content at +4, close tags aligned), empty chunks leave no blank lines - `render_html` takes a required `page_title`; the use case passes the post title (folder name for empty titles) - The list style now travels the whole chain: API DTO -> domain field -> converter -> template; unknown styles fall back to bullets - File links render through a template: names and urls are escaped - Video MIME type comes from the file extension; unknown ones omit the attribute so the browser sniffs - Windows path slashes are normalized in a local helper instead of mutating the chunk ## Verification - `task ci` green: checks, 155 unit tests + 1 strict xfail, build; live integration tests 6/6 (one transient network timeout on first run, curl failed at the same moment, retry passed in 2s) - Live download of a real post: the tab shows the post title, the content section has zero blank lines, image paths stay relative - Golden diffs reviewed stage by stage: escaped file name, conditional MIME, live `<ol>`, clean indentation ## Notes - Already downloaded posts keep their old HTML (the cache skips them) - the new rendering applies to new and updated posts; a full re-render belongs to the manifests design - Changelog updated (4 entries under Fixed) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-13 19:48:09 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Glitchy-Sheep/boosty-downloader#160
No description provided.