diff --git a/ckan/lib/helpers.py b/ckan/lib/helpers.py index fecc4d093aa..92c7a2aa2bd 100644 --- a/ckan/lib/helpers.py +++ b/ckan/lib/helpers.py @@ -559,10 +559,15 @@ def group_name_to_title(name): def markdown_extract(text, extract_length=190): + ''' return the plain text representation of markdown encoded text. That + is the texted without any html tags. If extract_length is 0 then it + will not be truncated.''' if (text is None) or (text.strip() == ''): return '' plain = re.sub(r'<.*?>', '', markdown(text)) - return literal(unicode(truncate(plain, length=extract_length, indicator='...', whole_word=True))) + if not extract_length or len(plain) < extract_length: + return plain + return truncate(plain, length=extract_length, indicator='...', whole_word=True) def icon_url(name):