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

x/website: better HTML printing, don't page break inside code blocks #33933

Closed
greywolve opened this issue Aug 29, 2019 · 6 comments
Closed

x/website: better HTML printing, don't page break inside code blocks #33933

greywolve opened this issue Aug 29, 2019 · 6 comments
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@greywolve
Copy link
Contributor

I was trying to print out Effective Go and I noticed code blocks get split across pages.

This is easily fixed by amending the CSS a bit:

@media print {
  pre {
    background: #fff;
    border: 0.0625rem solid #bbb;
    white-space: pre-wrap;
    page-break-inside: avoid; // added this
  }
}

Before:
Screenshot from 2019-08-29 14-03-33

After:
Screenshot from 2019-08-29 14-05-26

@gopherbot gopherbot added this to the Unreleased milestone Aug 29, 2019
@julieqiu
Copy link
Member

/cc @dmitshur @andybons

@julieqiu julieqiu added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Aug 29, 2019
@andybons andybons added help wanted NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Aug 29, 2019
@andybons
Copy link
Member

@greywolve feel free to send a change.

@gopherbot
Copy link

Change https://golang.org/cl/192418 mentions this issue: content/static: no page breaks inside code blocks when printing

@Freeaqingme
Copy link

Freeaqingme commented Aug 29, 2019

Why is breaking a page across a code block not desirable? For one thing, it's more environmentally friendly to fill every page. Also, I remember back in the day that it wasn't unheard of of copying multiple pages of books filled with qbasic code. A page break never bothered me really.

Maybe we can only do this for small code blocks?

@greywolve
Copy link
Contributor Author

It's not desirable (to me) because it makes reading large blocks of code more difficult. Perhaps I'm just not used to reading printed out code split across pages. :) It's annoying to have to shuffle back and forth to try read a block of code, especially if you have the pages bound and can't see the other page.

Doing this for small blocks of code seems much more difficult, and perhaps not worth the effort then. You'd have to tag each small block of code throughout the entire website with a different class that you can target.

Personally this change is much more about large blocks of code than smaller blocks anyway. For me, that's the 80/20.

Would you be happy buying a technical book with code split across pages? I suspect most people wouldn't be.

@Freeaqingme
Copy link

Would you be happy buying a technical book with code split across pages? I suspect most people wouldn't be.

For larger blocks? Sure.

Anyways, feel free to fly with it. Just wanted to bring up some points that possibly hadn't been considered yet. I'm not that strongly opinionated on it.

@golang golang locked and limited conversation to collaborators Sep 19, 2020
passionSeven added a commit to passionSeven/website that referenced this issue Oct 18, 2022
Fixes golang/go#33933

Change-Id: Ia5b140f7cc452a9fd5e4eea4ab6fe2465d1444b4
Reviewed-on: https://go-review.googlesource.com/c/website/+/192418
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants