Browse Source

fixed bug in template tag short_markdown when post is other language than English

Signed-off-by: Henry Chen <chen_hanli@163.com>
Henry Chen 9 years ago
parent
commit
811cb84223
1 changed files with 4 additions and 3 deletions
  1. 4 3
      misago/templatetags/md.py

+ 4 - 3
misago/templatetags/md.py

@@ -26,8 +26,9 @@ def short_markdown(value, length=300):
     value = ' '.join(value.splitlines())
     value = ' '.join(value.splitlines())
     value = value[0:length]
     value = value[0:length]
 
 
-    while value[-1] != ' ':
-        value = value[0:-1]
+    if ' ' in value:
+        while value[-1] != ' ':
+            value = value[0:-1]
 
 
     value = value.strip()
     value = value.strip()
     if value[-3:3] != '...':
     if value[-3:3] != '...':
@@ -38,4 +39,4 @@ def short_markdown(value, length=300):
 
 
 @register.filter(name='markdown_final')
 @register.filter(name='markdown_final')
 def finalize_markdown(value):
 def finalize_markdown(value):
-    return misago.markdown.finalize_markdown(value)
+    return misago.markdown.finalize_markdown(value)