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/tools/cmd/godoc: avoid line orphans #20278

Open
kevinburke opened this Issue May 8, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@kevinburke
Contributor

kevinburke commented May 8, 2017

We should be able to avoid having a single word on a line using CSS.

Here's an example of the bad (current) formatting:

Instead of having that single word we should break the line above a few words earlier.

@gopherbot gopherbot added this to the Unreleased milestone May 8, 2017

@agnivade

This comment has been minimized.

Member

agnivade commented Mar 29, 2018

AFAIK, there is nothing in css to control breaking whole words. https://stackoverflow.com/questions/27400192/css-prevent-line-in-text-to-only-contain-one-word

We generally use the word-wrap: break-word; property to break a single long word when it doesn't fit in its box. But, I don't think there is anything to control breaking of multiple words.

Think of it, you would need to detect if there is only a single word in the next line and do something to break the line before. Unless, you want to use js to tackle this, I don't see a solution.

@jimmyfrasche

This comment has been minimized.

Member

jimmyfrasche commented Mar 29, 2018

The general method I've seen is replace the last space with   to force the layout engine's hand. In the posted screenshot that would cause "for u." to be the last line. I've seen that method have just as unsatisfactory results when the last two words combined are exceptionally long, but that seems easy enough to counter with a heuristic here since the input does not contain arbitrary formatting, just text.

@agnivade

This comment has been minimized.

Member

agnivade commented Mar 29, 2018

Seems like a hacky solution for a one-off thing. But I don't have strong opinions.

@agnivade

This comment has been minimized.

Member

agnivade commented Apr 8, 2018

@kevinburke - thoughts ?

@kevinburke

This comment has been minimized.

Contributor

kevinburke commented Apr 8, 2018

Oh man. I'd hope that we can solve this problem somehow, I'm not super picky about the solution.

We could also try to get more complicated computing line lengths in Go and inserting line breaks as appropriate. There are algorithms to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment