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

Humanizer can/should support truncating a string to a certain length whilst adding ellipsis #80

Closed
janv8000 opened this issue Feb 11, 2014 · 4 comments

Comments

@janv8000
Copy link
Contributor

What do you guys/gals think about the following:

var longPieceOfText = "This is some text that's too large to display into a column in a table (HTML), but should present nicely when truncated to a certain length";
Assert.That(longPieceOfText.TrimTo(10), Is.EqualTo("This is s…")); 

Possible variations include trimming to the last word

Assert.That(longPieceOfText.TrimTo(10,Option.RespectWords), Is.EqualTo("This is some …")); 

Trimming to the last word but respecting the length as absolute maximum

Assert.That(longPieceOfText.TrimTo(10,Option.RespectWords | ,Option.ConsiderLengthAbsolute), Is.EqualTo("This is …")); 

See also https://github.com/HubSpot/humanize#truncate

If it's desirable I might start hacking on a PR this week...

@MehdiK
Copy link
Member

MehdiK commented Feb 11, 2014

This is something I've been meaning to do for a very long time and would definitely appreciate a PR for it.

A bit unsure about the API; but that's very easy to discuss and change if needed over the PR.

@MehdiK
Copy link
Member

MehdiK commented Mar 26, 2014

Hey @janv8000,

Was just wondering if you've had a chance to make a progress on this. I am quite interested in this feature.

ErikSchierboom added a commit to ErikSchierboom/Humanizer that referenced this issue Mar 27, 2014
ErikSchierboom added a commit to ErikSchierboom/Humanizer that referenced this issue Mar 28, 2014
ErikSchierboom added a commit to ErikSchierboom/Humanizer that referenced this issue Mar 28, 2014
MehdiK added a commit that referenced this issue Mar 28, 2014
@MehdiK
Copy link
Member

MehdiK commented Mar 28, 2014

Implemented in #113

@MehdiK MehdiK closed this as completed Mar 28, 2014
@MehdiK
Copy link
Member

MehdiK commented Mar 28, 2014

This is now released to NuGet as v1.15.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants