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

Not work with russian language #13

Open
araslanov-e opened this issue Mar 5, 2015 · 5 comments
Open

Not work with russian language #13

araslanov-e opened this issue Mar 5, 2015 · 5 comments

Comments

@araslanov-e
Copy link

HTML_Truncator.truncate("<p>Русский текст.</p>", 5, length_in_chars: true) 
# => "<p>…</p>"
@nono
Copy link
Owner

nono commented Mar 5, 2015

Hello,

the current code does this:

HTML_Truncator.truncate("<p>Русский текст.</p>", 5, length_in_chars: true)
# => "<p>…</p>"
HTML_Truncator.truncate("<p>Русский текст.</p>", 7, length_in_chars: true)
# => "<p>Русский…</p>"

What were your expectations?

@araslanov-e
Copy link
Author

I expected

HTML_Truncator.truncate("<p>Русский текст.</p>", 5, length_in_chars: true)
# => "<p>Русск…</p>"

@araslanov-e
Copy link
Author

Sorry, problem not in language

HTML_Truncator.truncate("<p>Russkiy tekst.</p>", 5, length_in_chars: true)
#=> "<p>…</p>"

But, this is not true, why is not displayed part of a word?

#=> "<p>Russk...</p>"

or

#=> "<p>Ru...</p>"

@nono
Copy link
Owner

nono commented Mar 12, 2015

Yes, as explained in the README, HTML Truncator doesn't cut inside a word but goes back to the immediately preceding word boundary.

The first version of HTML Truncator was made for a website where it made more sense to cut on a number of words and not inside them. Later, someone asks me to specify the length in chars to have a more precise length, but he was still OK with not cutting words. So, I kept this behaviour. Maybe, it should be an interesting idea to cut inside words when the length is in chars.

@lustremedia
Copy link

Cutting into words would be a nice add on switch option. e.g. keep_words_intact: false

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

3 participants