Fix missing margins for certain posts

https://vt.social/@a1ba@suya.place/110552480243348878#m
vt.social/@lina?max_id=111463476293964258
This commit is contained in:
blankie 2023-11-29 15:20:00 +11:00
parent 5d74e1124d
commit 6130e92114
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
2 changed files with 11 additions and 2 deletions

View File

@ -22,9 +22,11 @@ static const constexpr char css[] = R"EOF(
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
p, details { /* .quote-inline and display: block: workaround for vt.social/@lina?max_id=111463476293964258 */
p, details, .quote-inline {
margin-top: 1em; margin-top: 1em;
margin-bottom: 1em; margin-bottom: 1em;
display: block;
} }
ul, ol { ul, ol {
margin: revert; margin: revert;

View File

@ -387,7 +387,14 @@ static Element serialize_post(const httplib::Request& req, const std::string& se
: "Created: "s + full_time(post.created_at) + "\nEdited: " + full_time(post.edited_at); : "Created: "s + full_time(post.created_at) + "\nEdited: " + full_time(post.edited_at);
const char* time_badge = post.edited_at < 0 ? "" : " (edited)"; const char* time_badge = post.edited_at < 0 ? "" : " (edited)";
Element contents("div", {{"class", "post-contents"}}, {preprocess_html(req, server, post.emojis, post.content)}); blankie::html::HTMLString preprocessed_html = preprocess_html(req, server, post.emojis, post.content);
// Workaround for https://vt.social/@a1ba@suya.place/110552480243348878#m
if (preprocessed_html.str.find("<p>") == std::string::npos) {
preprocessed_html.str.reserve(preprocessed_html.str.size() + 3 + 4);
preprocessed_html.str.insert(0, "<p>");
preprocessed_html.str.append("</p>");
}
Element contents("div", {{"class", "post-contents"}}, {std::move(preprocessed_html)});
Element post_attachments("div", {{"class", "post-attachments"}}, {}); Element post_attachments("div", {{"class", "post-attachments"}}, {});
post_attachments.nodes.reserve(post.media_attachments.size()); post_attachments.nodes.reserve(post.media_attachments.size());