diff options
| author | Jeremy Dunck <jdunck@gmail.com> | 2007-06-25 19:33:37 +0000 |
|---|---|---|
| committer | Jeremy Dunck <jdunck@gmail.com> | 2007-06-25 19:33:37 +0000 |
| commit | fc779fe55aec84994e7e761c743716ba03484bcc (patch) | |
| tree | d139f5ce44133e630c7bb1b965baa3120ba23c99 /django/utils/html.py | |
| parent | b0a56a9919d2304fa08b71373b53fdfb5ca72de9 (diff) | |
gis: Merged revisions 5491-5539 via svnmerge from
http://code.djangoproject.com/svn/django/trunk
git-svn-id: http://code.djangoproject.com/svn/django/branches/gis@5540 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/html.py')
| -rw-r--r-- | django/utils/html.py | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/django/utils/html.py b/django/utils/html.py index 607362817b..e1860627ce 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -53,16 +53,18 @@ def fix_ampersands(value): def urlize(text, trim_url_limit=None, nofollow=False): """ - Converts any URLs in text into clickable links. Works on http://, https:// and - www. links. Links can have trailing punctuation (periods, commas, close-parens) - and leading punctuation (opening parens) and it'll still do the right thing. + Converts any URLs in text into clickable links. Works on http://, https:// + and www. links. Links can have trailing punctuation (periods, commas, + close-parens) and leading punctuation (opening parens) and it'll still do + the right thing. - If trim_url_limit is not None, the URLs in link text will be limited to - trim_url_limit characters. + If trim_url_limit is not None, the URLs in link text longer than this limit + will truncated to trim_url_limit-3 characters and appended with an elipsis. - If nofollow is True, the URLs in link text will get a rel="nofollow" attribute. + If nofollow is True, the URLs in link text will get a rel="nofollow" + attribute. """ - trim_url = lambda x, limit=trim_url_limit: limit is not None and (x[:limit] + (len(x) >=limit and '...' or '')) or x + 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 words = word_split_re.split(text) nofollow_attr = nofollow and ' rel="nofollow"' or '' for i, word in enumerate(words): |
