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

Comments

@greywolve
Copy link
Contributor

@greywolve greywolve commented Aug 29, 2019

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
Contributor

@julieqiu julieqiu commented Aug 29, 2019

@andybons
Copy link
Member

@andybons andybons commented Aug 29, 2019

@greywolve feel free to send a change.

@gopherbot
Copy link

@gopherbot gopherbot commented Aug 29, 2019

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

@Freeaqingme
Copy link

@Freeaqingme 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

@greywolve greywolve commented Sep 3, 2019

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

@Freeaqingme Freeaqingme commented Sep 3, 2019

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.