openlibhums / janeway

A web-based platform for publishing journals, preprints, conference proceedings, and books
https://janeway.systems/
GNU Affero General Public License v3.0
168 stars 63 forks source link

Bad line breaks inside hyperlinked text #2240

Closed joemull closed 1 year ago

joemull commented 3 years ago

Describe the bug Text inside hyperlinks gets wrapped without regard to word breaks, so there are often bad line breaks in the middle of words.

Janeway version 1.3.10

To Reproduce Steps to reproduce the behavior:

  1. Go to any preview galley with hyperlinks such as https://journals.publishing.umich.edu/weaveux/plugins/typesetting/preview_galley/article/217/galley/43/
  2. Adjust the width of the browser until a piece of linked text wraps in the middle

Expected behavior Lines should break on spaces only

Screenshots Screen Shot 2021-06-04 at 1 09 43 PM

Front-end Issues

If the issue is front-end specific please add the following details:

Desktop (please complete the following information):

joemull commented 3 years ago

Oh and this journal has the material theme set.

ajrbyers commented 3 years ago

Breaking on space only could cause the text to apparat outside the reader block. Iโ€™m not sure which is worse.

joemull commented 3 years ago

Oh, you mean if the text is a URL, it might extend beyond the space visible to the user? Could you break on space if linked text does not contain a protocol like https, but otherwise break "aggressively"?

ajrbyers commented 3 years ago

I donโ€™t think CSS can differentiate between the two

joemull commented 3 years ago

Huh. But surely this is something others have run into, right? I'm looking at an NYT article that breaks hyperlinked phrases at word breaks and nowhere else. Screen Shot 2021-06-04 at 1 52 38 PM This is not an urgent issue, but surely there's a fix out there?

ajrbyers commented 3 years ago

Do they have an example of a long URL linked in the text? We do in a few places.

ajrbyers commented 3 years ago

Iโ€™m sure we can sort something @joemull ! :)

joemull commented 3 years ago

OK so this seemed to fix it for me for both hyperlinked phrases and long URLs:

Change .article-body a { word-break: break-all; }

to .article-body a { word-wrap: break-word; }

ajrbyers commented 3 years ago

๐Ÿ‘๐Ÿ‘ want to make a PR? ๐Ÿ˜€

joemull commented 3 years ago

Haha sure let me figure out how to do that!

joemull commented 3 years ago

Credit: https://css-tricks.com/snippets/css/prevent-long-urls-from-breaking-out-of-container/

joemull commented 1 year ago

Recent example of a slightly different issue on Chrome (but not Firefox) in clean theme:

Screenshot from 2022-10-18 11-03-55

mauromsl commented 1 year ago

Recent example of a slightly different issue on Chrome (but not Firefox) in clean theme:

Screenshot from 2022-10-18 11-03-55

This is what Andy had mentioned about long links before:

Do they have an example of a long URL linked in the text? We do in a few places.

And the reason why we need to {word-break: beak-all} for <a> tags

joemull commented 1 year ago

Using word-wrap: break-word; seems to be working for both scenarios using the custom styling plugin, at least for this case:

Screenshot from 2022-10-18 11-35-34

When we fix this across the board we should test it more carefully on all three themes and multiple browsers.

joemull commented 1 year ago

This was fixed by cd0fd21e173a7659f862eb4287277c9b75a9141a. Tested manually on all themes.