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

Customisable "too long" post truncation length, based on number of lines AND number of characters #20191

Open
naught101 opened this issue Nov 9, 2022 · 9 comments
Labels
area/web interface Related to the Mastodon web interface suggestion Feature suggestion

Comments

@naught101
Copy link

Pitch

Currently some long posts truncate, due to #8205

The example posted at that MR (https://share.elouworld.org/@Exagone313/195324 - 1042 chars, one per line) is truncated to 12 lines. However, there are some long-ish posts (e.g. https://mstdn.social/@Mirella_PhD/109310858624901226, which has a 21 lines and then a long image), which do not get truncated, I guess because they are under 500 characters total.

It would be good to have a user-customisable truncation length, for example:

  • Truncate any post longer than 8 new lines.
  • Truncate any post longer than 300 characters
  • Don't show media on truncated posts

Motivation

These options would help prevent user's timelines from getting clogged up with large posts.

@naught101 naught101 added the suggestion Feature suggestion label Nov 9, 2022
@trwnh
Copy link
Member

trwnh commented Nov 9, 2022

Truncation should ideally be based on max height, not character count

@naught101
Copy link
Author

Yes, but I think that's not possible unless you assume a text width. Although I guess it would be reasonable to assume a fairly narrow text width, like 300px.

@trwnh
Copy link
Member

trwnh commented Nov 9, 2022

Not really, you can do it based on ex units or aspect ratio

@naught101
Copy link
Author

For reference, I this post:
image

is 659 characters, 116 words, and 23 lines at about 650px. So about 28 characters per line (it's ~50 characters for the full width lines)

I think my ideal truncation strategy for something like this would be

  • Estimate number of lines, maybe something like nchars / 35? This doesn't need to be too precise
  • If num lines is more than 10 (customisable), truncate to 6 lines (customisable), with a "read more" link.

@trwnh
Copy link
Member

trwnh commented Nov 9, 2022

It shouldn't be based on character count at all, because you can do things

l
i
k
e

t
h
i
s

The optimal strategy is to limit the max-height based on ex or aspect ratio

@naught101
Copy link
Author

OK, but it needs to be both, because of line wrapping. In your example, you get 9 lines with 9 characters, but I can also get 9 lines just by writing 400ish characters, and some instances allow 1000+ characters, which can easily get you up to 30+ lines with only a few line breaks.

@trwnh
Copy link
Member

trwnh commented Nov 9, 2022

Yes, so you apply a max-height using ex units or otherwise calculating an aspect ratio using Javascript. What matters is line height -- that's why I'm suggesting ex.

@ineffyble ineffyble added the ui Front-end, design label Nov 9, 2022
@idotj
Copy link

idotj commented Jan 10, 2023

Giving the user the control on line-clamp could be also a solution to manage the content height:

display: -webkit-box;
overflow: hidden;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;

@trwnh trwnh added area/web interface Related to the Mastodon web interface and removed ui Front-end, design labels Dec 30, 2023
@nielsle
Copy link

nielsle commented Feb 3, 2024

Also compare with #20188 "Option to disable external link previews".
Perhaps the collapsed version of he post could show the link without the preview.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/web interface Related to the Mastodon web interface suggestion Feature suggestion
Projects
None yet
Development

No branches or pull requests

5 participants