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

Improved string shortening for CJK languages. #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jameswilson
Copy link

When you are trying to trim a string that contains CJK characters or even a string of western characters that don't have any spaces, then the entire string is stripped.

This pull request adds two bits of functionality:

  1. Break words using spaces, dashes, zero-width space characters, and other standard word-break characters that work in most modern browsers.

  2. If no word-break is found in the string, fall back to letter removal.

There are a few other minor js lint cleanups (trailing whitespace, empty line at end of file) that my editor cleaned up automatically and included in this commit as well.

Here are two fiddles that demonstrate the issue, and the fix: and the second with the patched code.

jquery.autoellipsis version 1.0.10 without the patch
http://jsfiddle.net/jwilson3/XKN9R/1/

jquery.autoellipsis with the patch applied in commit 0298b42
http://jsfiddle.net/jwilson3/XKN9R/3/

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

Successfully merging this pull request may close these issues.

1 participant