Skip to content
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

In Firefox, every code block appears to end with a blank line #238

Closed
roryokane opened this issue Oct 18, 2020 · 0 comments · Fixed by #239
Closed

In Firefox, every code block appears to end with a blank line #238

roryokane opened this issue Oct 18, 2020 · 0 comments · Fixed by #239

Comments

@roryokane
Copy link
Contributor

Problem

In every blog post with code blocks I’ve seen, for example this post about ln and this post about Rust crates, the code blocks end with a blank line when I view them in Firefox 81.

Firefox example 1 – extra space

Firefox example 2 – extra space

Ideally, the blank lines should not be there, because they look weird and force unnecessary scrolling.

In Google Chrome, these blank lines do not appear:

Chrome example 1 – no extra space

Chrome example 2 – no extra space

Looking for a solution

Not an HTML problem

The problem does not appear to be your HTML. This is the generated HTML of one of your code blocks:

<pre><code class="language-go">var theDude User = abides()

ln.Log(ctx, ln.Info(&quot;created new user&quot;), theDude)
</code></pre>

I wondered if the newline before the final </code> was the culprit, but based on viewing this JS Bin in Firefox using the style pre { background: #ddd; }, Firefox seems to ignore that newline, the same as Chrome.

Apparently a CSS ::after problem

The problem appears to be your CSS rules that create an ::after pseudo-element on your code elements. If I use the developer tools to comment out these two content: rules in the served file hack.css:

.hack pre code:after,
.hack pre code:before {
  /* content: ""; */
}
.hack code:after,
.hack code:before {
  /* content: "`"; */
  display: inline;
}

then the blank lines go away.

roryokane added a commit to roryokane/Xe-site that referenced this issue Oct 18, 2020
roryokane added a commit to roryokane/Xe-site that referenced this issue Oct 18, 2020
fixes Xe#238

Disclaimer: I only tested this with the browser developer tools. I did not rebuild the site or try this CSS change on multiple pages.
@Xe Xe closed this as completed in #239 Oct 18, 2020
Xe pushed a commit that referenced this issue Oct 18, 2020
fixes #238

Disclaimer: I only tested this with the browser developer tools. I did not rebuild the site or try this CSS change on multiple pages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant