Commit c223fa0b by Zia Fazal

Removed linkify of text when it is in response textarea

parent 81d6ab51
{% load tz %}
{% load i18n %}
{% load oa_extras %}
{% spaceless %}
{% block list_item %}
<li class="openassessment__steps__step step--response is--in-progress is--showing ui-slidable__container"
......@@ -104,7 +103,7 @@
aria-describedby="submission__answer__tip__{{ xblock_id }}"
placeholder="{% trans "Enter your response to the prompt above." %}"
maxlength="100000"
>{{ part.text|escape|link_and_linebreak }}</textarea>
>{{ part.text }}</textarea>
</div>
{% with forloop.counter|stringformat:"s" as submission_num %}
{% include "openassessmentblock/oa_latex_preview.html" with id="submission__"|add:xblock_id|add:submission_num elem="div" preview_name="submission__"|add:submission_num %}
......
......@@ -9,12 +9,16 @@ import bleach
register = template.Library()
@register.filter(needs_autoescape=True)
@register.filter()
@stringfilter
def link_and_linebreak(text, autoescape=True):
if text and len(text) > 0:
the_text = conditional_escape(text)
return mark_safe(linebreaks(bleach.linkify(the_text, callbacks=[callbacks.target_blank])))
else:
return text
def link_and_linebreak(text):
"""
Converts URLs in text into clickable links with their target attribute set to `_blank`.
It wraps givent tags into <p> tags and converts line breaks(\n) to <br> tags.
Args:
text: (str) Text having URLs to be converted
Returns: (str) Text with URLs convert to links
"""
if text:
escaped_text = conditional_escape(text)
return mark_safe(linebreaks(bleach.linkify(escaped_text, callbacks=[callbacks.target_blank])))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment