0.0
No commit activity in last 3 years
No release in over 3 years
Ever wanted to truncate some text till the Ntn character only to find a word or sentence was cut in half? SmartTruncate fixes that.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 0
 Project Readme

SmartTruncate

smart_truncate is a simple Rails gem that truncates text like a human. Ever wanted to truncate some text till the Ntn character only to find a word or sentence was cut in half? SmartTruncate fixes that."

INSTALL

gem install smart_truncate

BASIC smart_truncate USE

# truncate by characters and it will end in a meaningful word
SmartTruncate.by_chars("I am a nice sentance… Previous sentence is not with a proper multicolon ending.",26,'!')
# => "I am a nice sentance… Previous!"

# truncate by sentence
SmartTruncate.by_sentences("I am a nice sentance ... Previous sentence is not with a proper multicolon ending.",1)
# => "I am a nice sentance ..."

# truncate mixed by both sentence and characters/words
SmartTruncate.by_mixed("I am a nice sentance. Previous sentence is with a proper multicolon ending.",2,10)
# => "I am a nice."
SmartTruncate.by_mixed("I am a nice sentance. Previous sentence is with a proper multicolon ending.",1,100)
# => "I am a nice sentance."

LICENSE

This project uses MIT-LICENSE.