make links clickable in task descriptions

This commit is contained in:
2023-03-22 21:59:09 -04:00
parent 437c093adf
commit a58cc0ffcb
4 changed files with 37 additions and 6 deletions

View File

@@ -9,7 +9,17 @@
<div>
<br>
{% if task.description != None %}
<p>{{ task.description }}</p>
{% set description = task.description %}
{% set url_regex = '(https?://[^\s]+)' %}
{% set match = re.search(url_regex, description) %}
{% if match %}
{% set url = match.group(0) %}
{% set rest = description[match.end(0):] %}
<p>{{ description[:match.start(0)] }}<a href="{{ url }}">{{ url }}</a>{{ rest }}</p>
{% else %}
<p>{{ description }}</p>
{% endif %}
{% endif %}
</div>
<div>