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

Extra space is added after word #18

Closed
alecrobertson1 opened this issue Jan 11, 2022 · 3 comments
Closed

Extra space is added after word #18

alecrobertson1 opened this issue Jan 11, 2022 · 3 comments

Comments

@alecrobertson1
Copy link

Screenshot 2022-01-11 at 16 40 53

This is with HTML set to true, I am finding that a space is added after the word, is it possible to change the output such that the space after the word is not added?

@janis-veinbergs
Copy link

Just do this:

(clip("achievements before we won", 24, { indicator: "" }).trim() + "…"

The other question is if whitespace should be automatically trimmed - if it would be implemented in default behavior, it could break someone's code who would expect trimmed text to be exactly maxLength characters long. Otherwise it could be a nice non-default option.

@arendjr
Copy link
Owner

arendjr commented Jan 24, 2022

Hey, sorry for the late response. I think what @janis-veinbergs provides is a somewhat workable work-around, but I also agree with the original report. Ideally, the space wouldn't be there, and if I remember correctly, the only reason it's still there is because it was somewhat tricky to remove it consistently. Note that the default behavior is already to break at word boundaries, so it's already acceptable to return strings less than maxLength characters.

That said, I might indeed want to do a major version bump when I fix this, just in case. Not sure exactly when I have time to pick this up, so if you want to work on this, please let me know. PRs are welcome :)

@arendjr
Copy link
Owner

arendjr commented Jul 10, 2024

Better late than never, this is implemented :)

@arendjr arendjr closed this as completed Jul 10, 2024
thewilkybarkid added a commit to PREreview/prereview.org that referenced this issue Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants