Skip to content

Fix element margins inside posts and comments #413

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1112,6 +1112,10 @@ pub fn rewrite_urls(input_text: &str) -> String {
// Remove (html-encoded) "\" from URLs.
text1 = text1.replace("%5C", "").replace("\\_", "_");

/* Remove paragraphs that only contain zero width spaces.
Reddit ignores these in their formatting so we want to remove them so they don't mess with ours. */
text1 = text1.replace("<p>&#8203;</p>", "").replace("<p>&#x200B;</p>", "");

// Rewrite external media previews to Redlib
loop {
if REDDIT_PREVIEW_REGEX.find(&text1).is_none() {
Expand Down
19 changes: 10 additions & 9 deletions static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1210,7 +1210,6 @@ a.search_subreddit:hover {
.post_body pre {
background: var(--background);
overflow-x: auto;
margin: 10px 0;
padding: 10px;
}

Expand Down Expand Up @@ -1748,17 +1747,16 @@ input[type="submit"] {
width: 100%;
}

.md > p:not(:first-child) {
margin-top: 20px;
.md > :first-child {
margin-top: 0;
}

.md > figure:first-of-type {
margin-top: 5px;
margin-bottom: 0px;
.md > :last-child {
margin-bottom: 0;
}

.md > figure:not(:first-of-type) {
margin-top: 10px;
.md > * {
margin-bottom: 1.25rem;
}

.md h1 {
Expand All @@ -1780,6 +1778,10 @@ input[type="submit"] {
font-size: 12px;
}

.md h1, h2, h3, h4, h5, h6 {
margin: 1.25rem 0 .75rem;
}

.md blockquote {
padding: 10px;
margin: 4px 0 4px 5px;
Expand Down Expand Up @@ -1818,7 +1820,6 @@ input[type="submit"] {
.md pre {
background: var(--outside);
padding: 20px;
margin-top: 10px;
border-radius: 5px;
box-shadow: var(--shadow);
overflow: auto;
Expand Down