Ticket #4657: urlize_trunc.patch
File urlize_trunc.patch, 1.5 KB (added by , 17 years ago) |
---|
-
django/utils/html.py
57 57 www. links. Links can have trailing punctuation (periods, commas, close-parens) 58 58 and leading punctuation (opening parens) and it'll still do the right thing. 59 59 60 If trim_url_limit is not None, the URLs in link text will be limited to61 trim_url_limit characters.60 If trim_url_limit is not None, the URLs in link text longer than this limit 61 will truncated to trim_url_limit-3 characters and appended with an elipsis. 62 62 63 63 If nofollow is True, the URLs in link text will get a rel="nofollow" attribute. 64 64 """ 65 trim_url = lambda x, limit=trim_url_limit: limit is not None and (x[:limit] + (len(x) >=limit and '...' or ''))or x65 trim_url = lambda x, limit=trim_url_limit: limit is not None and len(x) > limit and ('%s...' % x[:max(0, limit-3)]) or x 66 66 words = word_split_re.split(text) 67 67 nofollow_attr = nofollow and ' rel="nofollow"' or '' 68 68 for i, word in enumerate(words): -
docs/templates.txt
1266 1266 urlizetrunc 1267 1267 ~~~~~~~~~~~ 1268 1268 1269 Converts URLs into clickable links, truncating URLs to the given character limit. 1269 Converts URLs into clickable links, truncating URLs longer than the given 1270 character limit. 1270 1271 1271 1272 **Argument:** Length to truncate URLs to 1272 1273