Plain CSS. Simple. Bulletproof. Doesn't rely on js. All you need to do is set the anchor to display: inline-block;
It's also an advantage to have an extra tag in Subs.php, so you can NOT shorten the text when people put their own title inside the tags, like that. I'm already running this sort of code and it works well. Complete code for 1.1.x version on the CEMB theme is as follows. Very easy to adapt for 2.0.x/2.1/Elk/whatever.
/* Shorten url's inside posts. */
.post a.raw_url, .quote a.raw_url, .personalmessage a.raw_url {
display: inline-block;
white-space: pre;
overflow: hidden;
text-overflow: ellipsis;
max-width: 24em;
vertical-align: bottom;
}
Subs.php:
array(
'tag' => 'url',
'type' => 'unparsed_content',
'content' => '<a href="$1" class="raw_url" target="_blank">$1</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
$data = strtr($data, array(\'<br />\' => \'\'));
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
),
array(
'tag' => 'url',
'type' => 'unparsed_equals',
'before' => '<a href="$1" target="_blank">',
'after' => '</a>',
'validate' => create_function('&$tag, &$data, $disabled', '
if (strpos($data, \'http://\') !== 0 && strpos($data, \'https://\') !== 0)
$data = \'http://\' . $data;
'),
'disallow_children' => array('email', 'ftp', 'url', 'iurl'),
'disabled_after' => ' ($2)',
),
Another advantage of using CSS for it is you can also tweak it for res via media queries if you want to. Can be handy sometimes.