Think twitter where you paste a link next to some plain text and when your tweet is rendered, that url is now a clickable link.
Do I:
-
replace jinja’s autoescape with my own by scanning the text for html tags and replacing them with the html entity code
-
use a regular expression to detect a url contained in the text and replace it within an a href=
- what would this expression look like to detect any # of .tld’s, http/https, www/any subdomain?
-
and render this all as ¦safe in the template?
Or is there a python/flask/jinja ‘feature’ that can better handle this kind of thing?
Jinja has a filter built-in called
urlizethat should do exactly what you want.