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

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

x/tools/cmd/godoc: avoid line orphans #20278

kevinburke opened this issue May 8, 2017 · 5 comments
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@kevinburke
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Member

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
Copy link
Contributor

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

@agnivade
Copy link
Contributor

agnivade commented Apr 8, 2018

@kevinburke - thoughts ?

@kevinburke
Copy link
Contributor Author

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.

@gopherbot gopherbot added the Tools This label describes issues relating to any tools in the x/tools repository. label Sep 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

4 participants