urlize
Converts URLs and email addresses in text into clickable links, optionally trimming long URLs and adding nofollow attributes.
def urlize(
text: string,
trim_url_limit: integer = None,
nofollow: boolean = False,
autoescape: boolean = False
) - > string
Converts URLs and email addresses in text into clickable HTML links.
Parameters
| Name | Type | Description |
|---|---|---|
| text | string | The raw text containing URLs or email addresses to be converted into links. |
| trim_url_limit | integer = None | The maximum character length for displayed link text; URLs longer than this will be truncated. |
| nofollow | boolean = False | If true, adds the 'rel="nofollow"' attribute to generated links to instruct search engines not to follow them. |
| autoescape | boolean = False | If true, escapes the input text and generated URLs to prevent XSS attacks by converting special characters to HTML entities. |
Returns
| Type | Description |
|---|---|
string | The input text with URLs and email addresses wrapped in HTML anchor tags. |