For as long as I can remember, truncate_utf8()
has claimed that it has an option to add an ellipsis to a truncated string…
However, that is not what it does. Instead, it will add three dots (and in Drupal 6, even prefix them with a space, the horror).
There are many different conventions as to how to print an ellipsis with the characters on a normal keyboard, but since Drupal supports Unicode, we have the option of using the dedicated Unicode character for ellipsis, namely U+2026 or “…”.
The benefits is that … is much easier on the eyes than ..., it takes up less characters, carries a semantic meaning instead of just being a multiple of dots and it pleases those of us that are typographically inclined.
I’ve added a patch for this issue, and since it changes the output of truncate_utf8()
, I’ve adjusted the tests accordingly.
Comment | File | Size | Author |
---|---|---|---|
#27 | ellipsis-847608-27.patch | 5.7 KB | mikl |
#23 | ellipsis-847608-23.patch | 5.44 KB | mikl |
#21 | ellipsis-847608-21.patch | 5.6 KB | mikl |
#7 | 2010-07-30-ellipsis.patch | 6.38 KB | mikl |
2010-07-07-ellipsis.patch | 5.14 KB | mikl | |
Comments
Comment #1
mikl CreditAttribution: mikl commentedOh yes, please test.
Comment #2
moshe weitzman CreditAttribution: moshe weitzman commentedWe should make sure that our HTML => Plain Text converter does the right thing when it encounters this char.
Comment #3
mikl CreditAttribution: mikl commented#2: I’m not quite sure what this entails? More tests for check_plain(), filter_xss(), and drupal_validate_utf8()?
Comment #4
moshe weitzman CreditAttribution: moshe weitzman commentedhttp://api.drupal.org/api/function/drupal_html_to_text
Comment #5
royerd CreditAttribution: royerd commentedIndeed, this kind of drives me nuts. I'm in D6. Is there a way I can make this happen to my D6 install?
Comment #6
mikl CreditAttribution: mikl commented#5: No, there’s no way of changing it, short of hacking core… :-(
Comment #7
mikl CreditAttribution: mikl commentedI’ve added some tests for drupal_html_to_text() that includes the ellipsis character. There were no pre-existing tests, so I’ve added a couple. I suppose there should be more thorough testing of that function, but that is beyond the scope of this ticket.
Comment #8
moshe weitzman CreditAttribution: moshe weitzman commentedExcellent. Thanks for adding the tests.
Comment #9
Dries CreditAttribution: Dries commentedI'm going to postpone it to Drupal 8.
Comment #10
mikl CreditAttribution: mikl commented@Dries: Aww :(
Can we convince you to change your mind? The semantics of
truncate_utf8()
has been bugging me for ages…Comment #11
royerd CreditAttribution: royerd commentedComment #12
TR CreditAttribution: TR commentedStill applies in Drupal 8.x. Let's see what the test bot has to say about it.
Comment #13
TR CreditAttribution: TR commented#7: 2010-07-30-ellipsis.patch queued for re-testing.
Comment #14
catchWe should consider this for backport, should be entirely backwards compatible.
Comment #15
webchickSorry, I don't find this compelling enough to break translations in D7, considering how long this has been broken. Dries also explicitly moved this to D8 a year ago.
However, an easy workaround for this issue for D6/D7 sites would be the http://drupal.org/project/stringoverrides module.
Comment #16
Dries CreditAttribution: Dries commented2010-07-07-ellipsis.patch queued for re-testing.
Comment #17
Dries CreditAttribution: Dries commentedThe tests passed in 2010 so I'm asking for a re-test.
Comment #18
Dries CreditAttribution: Dries commentedComment #19
catch#7: 2010-07-30-ellipsis.patch queued for re-testing.
Comment #21
mikl CreditAttribution: mikl commentedRerolled patch for the new core/* structure in D8. No code changes.
Comment #23
mikl CreditAttribution: mikl commentedRe-roll.
Comment #24
webchickcan we make that one just one ellipsis, and not an ellipsis and a period?
I can't commit this to D7, since it's a string change, but +1 from me. :)
Comment #25
webchickComment #26
mikl CreditAttribution: mikl commented#24:
Yeah, that should be a definite improvement. Here's a stab at that :)
Comment #27
mikl CreditAttribution: mikl commentedAh, forgot the patch.
Comment #28
yoroy CreditAttribution: yoroy commentedI felt so awesome the day I found out about this character…
Comment #29
catchThanks! Committed/pushed to 8.x.