]> gitweb.fperrin.net Git - djsite.git/blobdiff - quotes/massimport.py
Use Django's linebreaks method
[djsite.git] / quotes / massimport.py
index ade6f3899879bdbc5a76a9d10e12b0bc71ac8b02..cf63152f84e9b5a98b0c53b6fbea89904e7619ae 100644 (file)
@@ -1,5 +1,6 @@
 import re
 from django.db import DatabaseError, transaction
+from django.utils.html import linebreaks
 
 from quotes.models import QuoteTag, Quote, Work, Author
 
@@ -41,13 +42,8 @@ def add_tags_on_quote(quote, tagline, resultcontext):
         quote.tags.add(tag)
 
 def paragraphize(text):
-    paragraph = ""
-    for line in text.splitlines():
-        line = line.strip()
-        if not line: continue
-        paragraph += "<p>%s</p>" % line
-        # rest of the HTML will be bleach.clean()'d
-    return paragraph
+    text = text.strip()
+    return linebreaks(text)
         
 def create_quote(quotetext, authorname, workname, tagline, resultcontext):
     author = get_or_create_author(authorname, resultcontext)